|
UniSet
2.6.0
|
00001 00002 // -------------------------------------------------------------------------- 00003 /* 00004 DO NOT EDIT THIS FILE. IT IS AUTOGENERATED FILE. 00005 ALL YOUR CHANGES WILL BE LOST. 00006 00007 НЕ РЕДАКТИРУЙТЕ ЭТОТ ФАЙЛ. ЭТОТ ФАЙЛ СОЗДАН АВТОМАТИЧЕСКИ. 00008 ВСЕ ВАШИ ИЗМЕНЕНИЯ БУДУТ ПОТЕРЯНЫ. 00009 */ 00010 // -------------------------------------------------------------------------- 00011 // generate timestamp: 2016-12-09 00012 // ----------------------------------------------------------------------------- 00013 #ifndef LostTestProc_SK_H_ 00014 #define LostTestProc_SK_H_ 00015 // ----------------------------------------------------------------------------- 00016 #include <memory> 00017 #include <string> 00018 #include <unordered_map> 00019 #include <sstream> 00020 #include "UniSetObject.h" 00021 #include "UniXML.h" 00022 #include "Trigger.h" 00023 #include "DebugStream.h" 00024 #include "LogServer.h" 00025 #include "LogAgregator.h" 00026 #include "VMonitor.h" 00027 // ----------------------------------------------------------------------------- 00028 class LostTestProc_SK: 00029 public uniset::UniSetObject 00030 { 00031 public: 00032 LostTestProc_SK( uniset::ObjectId id, xmlNode* node=uniset::uniset_conf()->getNode("LostTestProc"), const std::string& argprefix="" ); 00033 LostTestProc_SK(); 00034 virtual ~LostTestProc_SK(); 00035 00036 00037 long getValue( uniset::ObjectId sid ); 00038 void setValue( uniset::ObjectId sid, long value ); 00039 void askSensor( uniset::ObjectId sid, UniversalIO::UIOCommand, uniset::ObjectId node = uniset::uniset_conf()->getLocalNode() ); 00040 void updateValues(); 00041 00042 virtual uniset::SimpleInfo* getInfo( const char* userparam ) override; 00043 00044 virtual bool setMsg( uniset::ObjectId code, bool state = true ) noexcept; 00045 00046 inline std::shared_ptr<DebugStream> log() noexcept { return mylog; } 00047 inline std::shared_ptr<uniset::LogAgregator> logAgregator() noexcept { return loga; } 00048 00049 void init_dlog( std::shared_ptr<DebugStream> d ) noexcept; 00050 00051 // "синтаксический сахар"..для логов 00052 #ifndef myinfo 00053 #define myinfo if( log()->debugging(Debug::INFO) ) log()->info() 00054 #endif 00055 #ifndef mywarn 00056 #define mywarn if( log()->debugging(Debug::WARN) ) log()->warn() 00057 #endif 00058 #ifndef mycrit 00059 #define mycrit if( log()->debugging(Debug::CRIT) ) log()->crit() 00060 #endif 00061 #ifndef mylog1 00062 #define mylog1 if( log()->debugging(Debug::LEVEL1) ) log()->level1() 00063 #endif 00064 #ifndef mylog2 00065 #define mylog2 if( log()->debugging(Debug::LEVEL2) ) log()->level2() 00066 #endif 00067 #ifndef mylog3 00068 #define mylog3 if( log()->debugging(Debug::LEVEL3) ) log()->level3() 00069 #endif 00070 #ifndef mylog4 00071 #define mylog4 if( log()->debugging(Debug::LEVEL4) ) log()->level4() 00072 #endif 00073 #ifndef mylog5 00074 #define mylog5 if( log()->debugging(Debug::LEVEL5) ) log()->level5() 00075 #endif 00076 #ifndef mylog6 00077 #define mylog6 if( log()->debugging(Debug::LEVEL6) ) log()->level6() 00078 #endif 00079 #ifndef mylog7 00080 #define mylog7 if( log()->debugging(Debug::LEVEL7) ) log()->level7() 00081 #endif 00082 #ifndef mylog8 00083 #define mylog8 if( log()->debugging(Debug::LEVEL8) ) log()->level8() 00084 #endif 00085 #ifndef mylog9 00086 #define mylog9 if( log()->debugging(Debug::LEVEL9) ) log()->level9() 00087 #endif 00088 #ifndef mylogany 00089 #define mylogany log()->any() 00090 #endif 00091 #ifndef vmonit 00092 #define vmonit( var ) vmon.add( #var, var ) 00093 #endif 00094 00095 // Вспомогательные функции для удобства логирования 00096 // ------------------------------------------------------------ 00104 std::string dumpIO(); 00105 00110 std::string str( uniset::ObjectId id, bool showLinkName=true ) const; 00111 00116 std::string strval( uniset::ObjectId id, bool showLinkName=true ) const; 00117 00119 inline std::string dumpVars(){ return std::move(vmon.pretty_str()); } 00120 // ------------------------------------------------------------ 00121 std::string help() noexcept; 00122 00123 00124 #ifndef DISABLE_REST_API 00125 // HTTP API 00126 virtual Poco::JSON::Object::Ptr httpGet( const Poco::URI::QueryParameters& p ) override; 00127 virtual Poco::JSON::Object::Ptr httpRequest( const std::string& req, const Poco::URI::QueryParameters& p ) override; 00128 virtual Poco::JSON::Object::Ptr httpHelp( const Poco::URI::QueryParameters& p ) override; 00129 #endif 00130 00131 00132 // Используемые идентификаторы 00133 00134 00135 // Используемые идентификаторы сообщений 00136 00137 00138 // Текущее значение 00139 00140 00141 // --- public variables --- 00142 00143 const int checkTime; 00145 // --- end of public variables --- 00146 00147 protected: 00148 // --- protected variables --- 00149 00150 00151 // ---- end of protected variables ---- 00152 00153 00154 virtual void callback() noexcept override; 00155 virtual void processingMessage( const uniset::VoidMessage* msg ) override; 00156 virtual void sysCommand( const uniset::SystemMessage* sm ){}; 00157 virtual void askSensors( UniversalIO::UIOCommand cmd ){} 00158 virtual void sensorInfo( const uniset::SensorMessage* sm ) override{} 00159 virtual void timerInfo( const uniset::TimerMessage* tm ) override{} 00160 virtual void sigterm( int signo ) override; 00161 virtual bool activateObject() override; 00162 virtual std::string getMonitInfo(){ return ""; } 00164 #ifndef DISABLE_REST_API 00165 virtual void httpGetUserData( Poco::JSON::Object::Ptr& jdata ){} 00166 virtual Poco::JSON::Object::Ptr httpDumpIO(); 00167 virtual Poco::JSON::Object::Ptr httpRequestLog( const Poco::URI::QueryParameters& p ); 00168 #endif 00169 00170 // Выполнение очередного шага программы 00171 virtual void step(){} 00172 00173 void preAskSensors( UniversalIO::UIOCommand cmd ); 00174 void preSysCommand( const uniset::SystemMessage* sm ); 00175 00176 virtual void testMode( bool state ); 00177 void updateOutputs( bool force ); 00178 00179 void waitSM( int wait_msec, uniset::ObjectId testID = uniset::DefaultObjectId ); 00180 uniset::ObjectId getSMTestID(); 00181 00182 void resetMsg(); 00183 uniset::Trigger trResetMsg; 00184 uniset::PassiveTimer ptResetMsg; 00185 int resetMsgTime; 00186 00187 int sleep_msec; 00188 bool active; 00189 00190 const std::string argprefix; 00191 uniset::ObjectId smTestID; 00193 // управление датчиком "сердцебиения" 00194 uniset::PassiveTimer ptHeartBeat; 00195 uniset::ObjectId idHeartBeat; 00196 long maxHeartBeat; 00198 xmlNode* confnode; 00200 int getIntProp(const std::string& name) { return uniset::uniset_conf()->getIntProp(confnode, name); } 00202 inline const std::string getProp(const std::string& name) { return uniset::uniset_conf()->getProp(confnode, name); } 00203 00204 uniset::timeout_t smReadyTimeout; 00205 std::atomic_bool activated; 00206 uniset::timeout_t activateTimeout; 00207 uniset::PassiveTimer ptStartUpTimeout; 00208 int askPause; 00210 IOController_i::SensorInfo si; 00211 bool forceOut; 00213 std::shared_ptr<uniset::LogAgregator> loga; 00214 std::shared_ptr<DebugStream> mylog; 00215 std::shared_ptr<uniset::LogServer> logserv; 00216 std::string logserv_host = {""}; 00217 int logserv_port = {0}; 00218 00219 uniset::VMonitor vmon; 00220 00221 00222 00223 private: 00224 00225 // --- private variables --- 00226 // --- end of private variables --- 00227 00228 // предыдущее значение (для работы UpdateValue()) 00229 00230 00231 // Текущее значение (rw-переменные) 00232 00233 00234 // Используемые идентификаторы сообщений 00235 00236 // ------------ private функции --------------- 00237 void updatePreviousValues() noexcept; 00238 void preSensorInfo( const uniset::SensorMessage* sm ); 00239 void preTimerInfo( const uniset::TimerMessage* tm ); 00240 void initFromSM(); 00241 void checkSensors(); 00242 // -------------------------------------------- 00243 00244 class StatHashFn 00245 { 00246 public: 00247 size_t operator() (const uniset::ObjectId& key) const 00248 { 00249 return std::hash<long>()(key); 00250 } 00251 }; 00252 00253 std::unordered_map<const uniset::ObjectId,size_t, StatHashFn> smStat; 00254 size_t processingMessageCatchCount = { 0 }; 00257 bool end_private; // вспомогательное поле (для внутреннего использования при генерировании кода) 00258 }; 00259 00260 // ----------------------------------------------------------------------------- 00261 #endif // LostTestProc_SK_H_
1.7.6.1