UniWidgets  1.0.0
SwitchRTVLogic.h
00001 #ifndef _SWITCHRTVLOGIC_H
00002 #define _SWITCHRTVLOGIC_H
00003 // -------------------------------------------------------------------------
00004 #include <objects/AbstractLogic.h>
00005 #include <UniSetTypes.h>
00006 #include <global_macros.h>
00007 #include <uniwidgets/USignals.h>
00008 // -------------------------------------------------------------------------
00009 namespace UniWidgets
00010 {
00011 enum ControlMode
00012 {
00013     Local  = 0,
00014     Remote = 1
00015 };
00016 class IButton;
00030 class SwitchRTVLogic : public AbstractLogic
00031 {
00032 public:
00033     SwitchRTVLogic();
00034     explicit SwitchRTVLogic(Gtk::EventBox::BaseObjectType* gobject);
00035     virtual ~SwitchRTVLogic();
00036 
00037     /* Public methods */
00038     bool set_state( const long object, const long mode);                
00039     bool get_state(const long object);                      
00040     bool get_control();                             
00041     void handler_message( const long object, const long mode, const long type); 
00042     inline bool is_controlled(){return controlled;}                 
00043     inline bool is_initialized(){return initialized;}               
00044     virtual void set_confirm_handler(UMessages::MessageId id);
00045     virtual void set_message_handler();
00046     virtual void set_sensor_handler();
00047     void set_control_sensor_handler();                      
00048     virtual void confirm_handler(UMessages::MessageId id, time_t sec);
00049     virtual void message_handler(UMessages::MessageId id, Glib::ustring msg);
00050     virtual void sensor_handler(UniSetTypes::ObjectId sensor, UniSetTypes::ObjectId node, long value, long object);
00052     void localcontrol_sensor_handler(UniSetTypes::ObjectId sensor, UniSetTypes::ObjectId node, long value);
00054     void remotecontrol_sensor_handler(UniSetTypes::ObjectId sensor, UniSetTypes::ObjectId node, long value);
00055     virtual void connect();
00056 //  virtual long get_state_obj();
00057 
00058 protected:
00059     /* Methods */
00060     virtual void on_init();                 
00062 private:
00063      /* Variables */
00064     std::map<long, IButton *> switches_;            
00065     long sensitive;
00066     long confirm;
00067     long confirm_mode;
00068     bool connection_timeout_;               
00069     bool current_state_;                    
00070     bool remote_command;                    
00071     bool controlled;                    
00072     bool initialized;                   
00074     /* Methods */
00075     void constructor();
00076     virtual void init_states();
00080     bool on_timeout(const long object, const long mode, const UniSetTypes::ObjectId sensor_cmd, const UniSetTypes::ObjectId sensor, const UniSetTypes::ObjectId node);
00081     virtual void set_current_state();
00082 
00083     DISALLOW_COPY_AND_ASSIGN(SwitchRTVLogic);
00084     ADD_PROPERTY( errvalue_ai, UniSetTypes::ObjectId )          
00085     ADD_PROPERTY( remotecontrol_di, UniSetTypes::ObjectId )         
00086     ADD_PROPERTY( localcontrol_di, UniSetTypes::ObjectId )          
00087     ADD_PROPERTY( timeout, long )                       
00088     ADD_PROPERTY( node, UniSetTypes::ObjectId )             
00089 };
00090 
00091 }
00092 #endif