uniset-algorithms  0.2
APSControl.h
00001 #ifndef APSControl_H_
00002 #define APSControl_H_
00003 // ------------------------------------------------------------------------------------------
00004 #include <map>
00005 #include <list>
00006 #include <UniSetObject_LT.h>
00007 #include <MessageType.h>
00008 #include <PassiveTimer.h>
00009 #include <Trigger.h>
00010 #include <extensions/SMInterface.h>
00011 // ------------------------------------------------------------------------------------------
00036 class APSControl:
00037     public  UniSetObject_LT 
00038 {
00039     public:
00040     
00041         APSControl( UniSetTypes::ObjectId id, const std::string name="APSControl" );
00042         ~APSControl();
00043 
00044         static DebugStream dlog;
00045         static void init_dlog( DebugStream& dlog );
00046 
00047     protected:
00048     
00052         void processingMessage(UniSetTypes::VoidMessage *msg);
00053         
00057         void askSensors(UniversalIO::UIOCommand cmd);
00058         
00062         void sysCommand(UniSetTypes::SystemMessage *sm);
00063         
00067         void sensorInfo(UniSetTypes::SensorMessage *sm);
00068         
00072         void timerInfo(UniSetTypes::TimerMessage *tm);
00073         
00078         void makeAPS(UniSetTypes::ObjectId id, bool state); 
00079         
00084         void makeAPSLamp( bool newAPS, bool isAnyAPS );
00085 
00087         void makeNewAPSSensor( bool newAPS );
00088 
00089     //  string getShortName(const string& fullName, char brk = ':');
00090     
00092         struct APSSensorInfo
00093         {
00094             UniSetTypes::ObjectId id;       
00095             UniSetTypes::ObjectId apsId;    
00096             UniSetTypes::ObjectId blockerId;
00099             bool state;                     
00100             bool no_apslamp;        
00102             APSSensorInfo():
00103                 id(UniSetTypes::DefaultObjectId),
00104                 apsId(UniSetTypes::DefaultObjectId),
00105                 blockerId(UniSetTypes::DefaultObjectId),
00106                 state(false),
00107                 no_apslamp(false)
00108             {};
00109         };
00110         
00111         std::map<UniSetTypes::ObjectId,APSSensorInfo> sensorToAPS;              // <sensorId,APSSsensorInfo>
00112         std::map<UniSetTypes::ObjectId,UniSetTypes::ObjectId>blockedSensors;    // <sensorId,blockSensorId>
00113 
00115         struct APSGroupInfo
00116         {
00117             UniSetTypes::ObjectId apsId; 
00118             bool apsState;
00119             std::list<UniSetTypes::ObjectId> sensIdList; 
00120             APSGroupInfo():apsId(UniSetTypes::DefaultObjectId),
00121             apsState( false )
00122             {};
00123         };
00124         
00125         typedef std::map<UniSetTypes::ObjectId,APSGroupInfo> APSGroupList;
00126         APSGroupList apsGroupsInfo;
00127 
00128         bool initAPS(xmlNode*cnode);
00129 
00130         SMInterface* smi;
00131         UniSetTypes::ObjectId testSensor;
00132         UniSetTypes::ObjectId nodeTestSensor;
00133         bool in_testSensor;
00134         bool in_nodeTestSensor;
00135         
00136         UniSetTypes::ObjectId sidHeartBeat;
00137         int maxHeartBeat;
00138         timeout_t heartbeatTime;
00139 
00140         UniSetTypes::ObjectId newaps_s; 
00141         UniSetTypes::ObjectId confirm_s; 
00142         bool confirmMode;               /*< режим нажатия кнопки квитирования ("1" - нажата "0" - отжата)*/
00143         UniSetTypes::ObjectId apsLamp_c; 
00145         enum Timers
00146         {
00147             ptHeartBeat
00148         };
00149         
00150         timeout_t smReadyTimeout;
00151         
00152         virtual void sigterm( int signo );
00153         void offOutputs( bool all );
00154         bool TermOffAps;
00155         bool checkTestMode();
00156         
00157         std::string f_field;
00158         std::string f_value;
00159         
00160         timeout_t apsMakePause; 
00161     private:
00162         timeout_t askTimeout;   
00163         timeout_t askPause;     
00164         Trigger trTestMode;
00165 };
00166 
00167 #endif // APSControl_H_