00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef Automat_SK_H_
00014 #define Automat_SK_H_
00015
00016 #include <string>
00017 #include "UniSetObject.h"
00018 #include "LT_Object.h"
00019 #include "UniXML.h"
00020 #include "Trigger.h"
00021 #include "DebugStream.h"
00022
00023 class Automat_SK:
00024 public UniSetObject,
00025 public LT_Object
00026 {
00027 public:
00028 Automat_SK( UniSetTypes::ObjectId id, xmlNode* node=UniSetTypes::conf->getNode("Automat"), const std::string& argprefix="" );
00029 Automat_SK();
00030 virtual ~Automat_SK();
00031
00032
00033
00034 bool alarm( UniSetTypes::ObjectId sid, bool state );
00035 bool getState( UniSetTypes::ObjectId sid );
00036 long getValue( UniSetTypes::ObjectId sid );
00037 void setValue( UniSetTypes::ObjectId sid, long value );
00038 void setState( UniSetTypes::ObjectId sid, bool state );
00039 void askState( UniSetTypes::ObjectId sid, UniversalIO::UIOCommand, UniSetTypes::ObjectId node = UniSetTypes::conf->getLocalNode() );
00040 void askValue( UniSetTypes::ObjectId sid, UniversalIO::UIOCommand, UniSetTypes::ObjectId node = UniSetTypes::conf->getLocalNode() );
00041 void updateValues();
00042 void setMsg( UniSetTypes::ObjectId code, bool state );
00043
00044
00045 DebugStream dlog;
00046 void init_dlog(DebugStream& dlog);
00047
00048
00049
00050 const UniSetTypes::ObjectId State_On_s;
00051 UniSetTypes::ObjectId node_State_On_s;
00052 const UniSetTypes::ObjectId State_Off_s;
00053 UniSetTypes::ObjectId node_State_Off_s;
00054 const UniSetTypes::ObjectId Protection_s;
00055 UniSetTypes::ObjectId node_Protection_s;
00056 const UniSetTypes::ObjectId On_c;
00057 UniSetTypes::ObjectId node_On_c;
00058 const UniSetTypes::ObjectId Off_c;
00059 UniSetTypes::ObjectId node_Off_c;
00060 const UniSetTypes::ObjectId Automat_NA_s;
00061 UniSetTypes::ObjectId node_Automat_NA_s;
00062 const UniSetTypes::ObjectId state_as;
00063 UniSetTypes::ObjectId node_state_as;
00064
00065
00066
00067
00068 const UniSetTypes::ObjectId mid_HandOn;
00069 UniSetTypes::ObjectId node_mid_HandOn;
00070 bool m_mid_HandOn;
00071 bool prev_m_mid_HandOn;
00073 const UniSetTypes::ObjectId mid_HandOff;
00074 UniSetTypes::ObjectId node_mid_HandOff;
00075 bool m_mid_HandOff;
00076 bool prev_m_mid_HandOff;
00078 const UniSetTypes::ObjectId mid_NotOn;
00079 UniSetTypes::ObjectId node_mid_NotOn;
00080 bool m_mid_NotOn;
00081 bool prev_m_mid_NotOn;
00083 const UniSetTypes::ObjectId mid_NotOff;
00084 UniSetTypes::ObjectId node_mid_NotOff;
00085 bool m_mid_NotOff;
00086 bool prev_m_mid_NotOff;
00088 const UniSetTypes::ObjectId mid_NotResetProtection;
00089 UniSetTypes::ObjectId node_mid_NotResetProtection;
00090 bool m_mid_NotResetProtection;
00091 bool prev_m_mid_NotResetProtection;
00093 const UniSetTypes::ObjectId mid_CurrentProtection_Att;
00094 UniSetTypes::ObjectId node_mid_CurrentProtection_Att;
00095 bool m_mid_CurrentProtection_Att;
00096 bool prev_m_mid_CurrentProtection_Att;
00098 const UniSetTypes::ObjectId mid_NA_Att;
00099 UniSetTypes::ObjectId node_mid_NA_Att;
00100 bool m_mid_NA_Att;
00101 bool prev_m_mid_NA_Att;
00104
00105 bool in_State_On_s;
00106 bool prev_in_State_On_s;
00107 bool in_State_Off_s;
00108 bool prev_in_State_Off_s;
00109 bool in_Protection_s;
00110 bool prev_in_Protection_s;
00111 bool out_On_c;
00112 bool prev_out_On_c;
00113 bool out_Off_c;
00114 bool prev_out_Off_c;
00115 bool out_Automat_NA_s;
00116 bool prev_out_Automat_NA_s;
00117 long out_state_as;
00118 long prev_out_state_as;
00119
00120
00121
00122
00123 const bool autoResetProtection;
00124 const int OnTime;
00125 const int OffTime;
00126 const int stateTimeOut;
00127 const int CommandTime;
00128 const int minWaitingTime;
00129 const int offPause;
00130 const int CheckStateTime;
00131 const int naTime;
00133
00134
00135 protected:
00136
00137
00138
00139
00140
00141
00142 virtual void callback();
00143 virtual void processingMessage( UniSetTypes::VoidMessage* msg );
00144 virtual void sysCommand( UniSetTypes::SystemMessage* sm );
00145 virtual void askSensors( UniversalIO::UIOCommand cmd ){}
00146 virtual void sensorInfo( UniSetTypes::SensorMessage* sm ){}
00147 virtual void timerInfo( UniSetTypes::TimerMessage* tm ){}
00148 virtual void sigterm( int signo );
00149 virtual bool activateObject();
00150 virtual void testMode( bool state );
00151 void updatePreviousValues();
00152 void checkSensors();
00153 void updateOutputs( bool force );
00154
00155 void preAskSensors( UniversalIO::UIOCommand cmd );
00156 void preSensorInfo( UniSetTypes::SensorMessage* sm );
00157 void preTimerInfo( UniSetTypes::TimerMessage* tm );
00158 void waitSM( int wait_msec, UniSetTypes::ObjectId testID = UniSetTypes::DefaultObjectId );
00159
00160 void resetMsg();
00161 Trigger trResetMsg;
00162 PassiveTimer ptResetMsg;
00163 int resetMsgTime;
00164
00165
00166 virtual void step()=0;
00167
00168 int sleep_msec;
00169 bool active;
00170
00171 UniSetTypes::ObjectId smTestID;
00173
00174 PassiveTimer ptHeartBeat;
00175 UniSetTypes::ObjectId idHeartBeat;
00176 int maxHeartBeat;
00178 xmlNode* confnode;
00180 int getIntProp(const std::string& name) { return UniSetTypes::conf->getIntProp(confnode, name); }
00182 inline const std::string getProp(const std::string& name) { return UniSetTypes::conf->getProp(confnode, name); }
00183
00184 int smReadyTimeout;
00185 bool activated;
00186 int activateTimeout;
00187 PassiveTimer ptStartUpTimeout;
00188 int askPause;
00190 IOController_i::SensorInfo si;
00191
00192
00193 private:
00194
00195
00196
00197
00198
00199
00200 bool end_private;
00201 };
00202
00203
00204 #endif // Automat_SK_H_