|
uniset-algorithms
0.2
|
00001 #ifndef APSLamp_H_ 00002 #define APSLamp_H_ 00003 // ----------------------------------------------------------------------------- 00004 #include <Trigger.h> 00005 #include <UniSetTypes.h> 00006 #include <PassiveTimer.h> 00007 #include <UniversalInterface.h> 00008 // ----------------------------------------------------------------------------- 00029 class APSLamp 00030 { 00031 public: 00032 APSLamp( UniSetTypes::ObjectId apsid, UniSetTypes::ObjectId lampid, UniversalInterface* shm, 00033 UniSetTypes::ObjectId idBlock=UniSetTypes::DefaultObjectId ); 00034 virtual ~APSLamp(); 00035 00036 inline void setRemoteReset( bool set ){ remoteReset = set; } 00037 inline void setOffTime( timeout_t msec ){ offTime = msec; } 00038 inline void setNoConfirm( bool set ){ noConfirm = set; } 00039 inline bool getNoConfirm(){ return noConfirm; } 00040 inline void setBlink( bool set ){ blink = set; } 00041 inline bool getAlwaysAlarm(){ return alwaysAlarm; } 00042 inline void setAlwaysAlarm( bool s ){ alwaysAlarm = s; } 00043 00044 inline bool getNoHorn(){ return noHorn; } 00045 inline void setNoHorn( bool s ){ noHorn = s; } 00046 00047 inline bool getOnHorn(){ return onHorn; } 00048 inline void setOnHorn( bool s ){ onHorn = s; } 00049 00050 inline bool getNoFlash(){ return noFlash; } 00051 inline void setNoFlash( bool s ){ noFlash = s; } 00052 00053 inline bool getOnFlash(){ return onFlash; } 00054 inline void setOnFlash( bool s ){ onFlash = s; } 00055 00056 virtual void confirm( bool state ); 00057 virtual void remoteConfirm( bool state ){} 00058 virtual void remoteLamp( long val ); 00059 virtual void testLamp( bool state ); 00060 virtual void setControl( bool state ); 00061 00062 void setJarDelay( timeout_t msec ); 00063 void setOnDelay( timeout_t msec ); 00064 void setOffDelay( timeout_t msec ); 00065 00066 inline UniSetTypes::LampCommand get() 00067 { 00068 return lmpState; 00069 } 00070 00071 virtual void step(); 00072 virtual void updateOutputs(); 00073 00074 // сменилось ли состояние... 00075 // Особенность: lmpState не ДИСКРЕТНЫЙ 00076 // поэтому тригер не сработает, если состояние изменится 00077 // с lmpON на lmpBLINK или наоборот. НО нам так и надо... 00078 inline bool change(){ return trChange.change( (lmpState==UniSetTypes::lmpOFF) ); } 00079 00080 inline bool changeState(){ return trChangeState.change(apsState); } 00081 inline bool stateAPS(){ return apsState; } 00082 00083 inline UniSetTypes::ObjectId getLampID(){ return lampid; } 00084 00085 #ifdef ASKMODE 00086 virtual void askSensors( UniversalIO::UIOCommand cmd ); 00087 virtual void sensorInfo( UniSetTypes::SensorMessage* sm ); 00088 #endif 00089 protected: 00090 virtual UniSetTypes::LampCommand check(); 00091 00092 Trigger trOn; 00093 Trigger trChange; 00094 Trigger trChangeState; 00095 UniSetTypes::LampCommand lmpState; 00096 00097 bool apsState; 00098 bool apsBlocked; 00099 long remoteLampState; 00100 UniSetTypes::ObjectId apsid; 00101 UniSetTypes::ObjectId lampid; 00102 UniSetTypes::ObjectId blockid; 00103 UniversalInterface* shm; 00104 bool remoteReset; // сбрасывать лампочу, если произошло удалённое квитирование 00105 bool isTestLamp; 00106 bool ctlON; 00107 00108 timeout_t offTime; 00109 PassiveTimer ptOff; 00110 Trigger trOffTimer; 00111 00112 Trigger trAPSChange; 00113 00114 bool apsRealState; 00115 bool noConfirm; 00116 bool noFlash; 00117 bool onFlash; 00118 bool noHorn; 00119 bool onHorn; 00120 bool blink; 00121 bool alwaysAlarm; 00123 PassiveTimer ptJar; 00124 Trigger trJar; 00125 bool jar_wait; 00126 bool jar_state; 00127 00128 bool check_jar( bool newval ); 00129 00130 PassiveTimer ptOnDelay; 00131 Trigger trOnDelay; 00132 bool ondelay_wait; 00133 bool ondelay_state; 00134 00135 bool check_ondelay( bool newval ); 00136 00137 PassiveTimer ptOffDelay; 00138 Trigger trOffDelay; 00139 bool offdelay_wait; 00140 bool offdelay_state; 00141 00142 bool check_offdelay( bool newval ); 00143 00144 private: 00145 }; 00146 // ----------------------------------------------------------------------------- 00161 class APSLampDelay: 00162 public APSLamp 00163 { 00164 public: 00165 APSLampDelay( UniSetTypes::ObjectId apsid, UniSetTypes::ObjectId lampid, 00166 UniversalInterface* shm, int delay, 00167 UniSetTypes::ObjectId idBlock=UniSetTypes::DefaultObjectId ); 00168 virtual ~APSLampDelay(); 00169 00170 virtual void remoteConfirm( bool state ); 00171 00172 protected: 00173 virtual UniSetTypes::LampCommand check(); 00174 virtual UniSetTypes::LampCommand simpleCheck(); 00175 00176 Trigger trAPS; 00177 Trigger trTimeout; 00178 PassiveTimer ptDelay; 00179 int delay; 00180 bool waitRemoteConfirm; 00181 bool confirmTimeout; 00182 00183 private: 00184 }; 00185 // ----------------------------------------------------------------------------- 00186 #endif // APSLamp_H_ 00187 // -----------------------------------------------------------------------------
1.7.6.1