Core Base Classes for the Light Endpoints

Dependencies:   BufferedSerial

Dependents:   mbed_mqtt_endpoint_ublox_ethernet mbed_mqtt_endpoint_ublox_cellular mbed_nsp_endpoint_ublox_cellular mbed_nsp_endpoint_ublox_ethernet ... more

Committer:
ansond
Date:
Thu Mar 13 17:25:18 2014 +0000
Revision:
91:8732d54328ae
Parent:
87:e9d77e9f9eae
Child:
92:330746c526b7
updates

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ansond 0:4c9bfcb3e759 1 /* Copyright C2013 Doug Anson, MIT License
ansond 0:4c9bfcb3e759 2 *
ansond 0:4c9bfcb3e759 3 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
ansond 0:4c9bfcb3e759 4 * and associated documentation files the "Software", to deal in the Software without restriction,
ansond 0:4c9bfcb3e759 5 * including without limitation the rights to use, copy, modify, merge, publish, distribute,
ansond 0:4c9bfcb3e759 6 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
ansond 0:4c9bfcb3e759 7 * furnished to do so, subject to the following conditions:
ansond 0:4c9bfcb3e759 8 *
ansond 0:4c9bfcb3e759 9 * The above copyright notice and this permission notice shall be included in all copies or
ansond 0:4c9bfcb3e759 10 * substantial portions of the Software.
ansond 0:4c9bfcb3e759 11 *
ansond 0:4c9bfcb3e759 12 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
ansond 0:4c9bfcb3e759 13 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
ansond 0:4c9bfcb3e759 14 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
ansond 0:4c9bfcb3e759 15 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
ansond 0:4c9bfcb3e759 16 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
ansond 0:4c9bfcb3e759 17 */
ansond 0:4c9bfcb3e759 18
ansond 0:4c9bfcb3e759 19 #ifndef _LIGHT_H_
ansond 0:4c9bfcb3e759 20 #define _LIGHT_H_
ansond 0:4c9bfcb3e759 21
ansond 0:4c9bfcb3e759 22 // Transport support
ansond 0:4c9bfcb3e759 23 #include "Transport.h"
ansond 0:4c9bfcb3e759 24
ansond 1:5d332fa199ce 25 // ResourceFactory
ansond 1:5d332fa199ce 26 #include "ResourceFactory.h"
ansond 1:5d332fa199ce 27
ansond 29:9a99f076129a 28 // Philips Light Support
ansond 29:9a99f076129a 29 #include "PhilipsLight.h"
ansond 29:9a99f076129a 30
ansond 0:4c9bfcb3e759 31 class Light {
ansond 0:4c9bfcb3e759 32 private:
ansond 9:90fadae5489a 33 ErrorHandler *m_error_handler;
ansond 9:90fadae5489a 34 ResourceFactory *m_resources;
ansond 9:90fadae5489a 35 void *m_endpoint;
ansond 9:90fadae5489a 36 Transport *m_transports[NUM_TRANSPORTS];
ansond 16:fda7dbb8b47a 37 char m_name[LIGHT_NAME_LEN+1];
ansond 9:90fadae5489a 38
ansond 9:90fadae5489a 39 void *m_dimmer_action;
ansond 9:90fadae5489a 40 void *m_switch_action;
ansond 28:52b7ca6aacd6 41
ansond 28:52b7ca6aacd6 42 int m_ioc_id;
ansond 29:9a99f076129a 43 PhilipsLight *m_pl;
ansond 91:8732d54328ae 44
ansond 91:8732d54328ae 45 Thread *m_blinking_thread;
ansond 91:8732d54328ae 46 int m_current_state;
ansond 91:8732d54328ae 47 int m_last_state;
ansond 91:8732d54328ae 48 bool m_is_blinking;
ansond 91:8732d54328ae 49
ansond 0:4c9bfcb3e759 50 public:
ansond 0:4c9bfcb3e759 51 Light(ErrorHandler *error_handler,Transport *transports[NUM_TRANSPORTS],int instance,void *endpoint);
ansond 0:4c9bfcb3e759 52 virtual ~Light();
ansond 0:4c9bfcb3e759 53
ansond 9:90fadae5489a 54 Transport *getTransport(int index);
ansond 9:90fadae5489a 55 char *getName();
ansond 21:cfdaee0a2b50 56 ResourceFactory *getResourceFactory();
ansond 1:5d332fa199ce 57
ansond 9:90fadae5489a 58 ErrorHandler *logger();
ansond 9:90fadae5489a 59 ResourceFactory *resources();
ansond 9:90fadae5489a 60
ansond 9:90fadae5489a 61 void setDimmerAction(void *dimmer_action);
ansond 9:90fadae5489a 62 void setSwitchAction(void *switch_action);
ansond 9:90fadae5489a 63
ansond 9:90fadae5489a 64 virtual void on();
ansond 9:90fadae5489a 65 virtual void off();
ansond 91:8732d54328ae 66 void blink();
ansond 9:90fadae5489a 67 virtual void dim(int value);
ansond 9:90fadae5489a 68
ansond 28:52b7ca6aacd6 69 void setIOCID(int id);
ansond 28:52b7ca6aacd6 70 int getIOCID();
ansond 28:52b7ca6aacd6 71
ansond 91:8732d54328ae 72 void blinkLight();
ansond 91:8732d54328ae 73
ansond 9:90fadae5489a 74 protected:
ansond 9:90fadae5489a 75 void *getDimmerAction();
ansond 29:9a99f076129a 76 void *getSwitchAction();
ansond 29:9a99f076129a 77
ansond 29:9a99f076129a 78 private:
ansond 29:9a99f076129a 79 PhilipsLight *pl();
ansond 91:8732d54328ae 80 void startBlinking();
ansond 91:8732d54328ae 81 void stopBlinking();
ansond 91:8732d54328ae 82 void manageBlinkingThread();
ansond 91:8732d54328ae 83 void startBlinkingThread();
ansond 91:8732d54328ae 84 void stopBlinkingThread();
ansond 91:8732d54328ae 85
ansond 0:4c9bfcb3e759 86 };
ansond 0:4c9bfcb3e759 87
ansond 0:4c9bfcb3e759 88 #endif // _LIGHT_H_