UniSet  2.2.1
UObject_SK.h
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: 2015-12-19+03:00
00012 // -----------------------------------------------------------------------------
00013 #ifndef UObject_SK_H_
00014 #define UObject_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 UObject_SK:
00029     public UniSetObject
00030 {
00031     public:
00032         UObject_SK( UniSetTypes::ObjectId id, xmlNode* node=UniSetTypes::uniset_conf()->getNode("UObject"), const std::string& argprefix="" );
00033         UObject_SK();
00034         virtual ~UObject_SK();
00035 
00036         
00037         long getValue( UniSetTypes::ObjectId sid );
00038         void setValue( UniSetTypes::ObjectId sid, long value );
00039         void askSensor( UniSetTypes::ObjectId sid, UniversalIO::UIOCommand, UniSetTypes::ObjectId node = UniSetTypes::uniset_conf()->getLocalNode() );
00040         void updateValues();
00041 
00042         virtual UniSetTypes::SimpleInfo* getInfo( CORBA::Long userparam = 0 ) override;
00043 
00044         virtual bool setMsg( UniSetTypes::ObjectId code, bool state = true );
00045 
00046         inline std::shared_ptr<DebugStream> log(){ return mylog; }
00047         inline std::shared_ptr<LogAgregator> logAgregator(){ return loga; }
00048 
00049         void init_dlog( std::shared_ptr<DebugStream> d );
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( UniSetTypes::ObjectId id, bool showLinkName=true );
00111         
00116         std::string strval( UniSetTypes::ObjectId id, bool showLinkName=true );        
00117         
00119         inline std::string dumpVars(){ return std::move(vmon.pretty_str()); }
00120         // ------------------------------------------------------------
00121         std::string help();
00122         
00123 
00124 
00125         // Используемые идентификаторы
00126         
00127 
00128         // Используемые идентификаторы сообщений
00129         
00130 
00131         // Текущее значение
00132         
00133 
00134         // --- public variables ---
00135         
00136         
00137         // --- end of public variables ---
00138 
00139     protected:
00140         // --- protected variables ---
00141         
00142         
00143         // ---- end of protected variables ----
00144 
00145         
00146         virtual void callback() override;
00147         virtual void processingMessage( UniSetTypes::VoidMessage* msg ) override;
00148         virtual void sysCommand( const UniSetTypes::SystemMessage* sm ){};
00149         virtual void askSensors( UniversalIO::UIOCommand cmd ){}
00150         virtual void sensorInfo( const UniSetTypes::SensorMessage* sm ) override{}
00151         virtual void timerInfo( const UniSetTypes::TimerMessage* tm ) override{}
00152         virtual void sigterm( int signo ) override;
00153         virtual bool activateObject() override;
00154         virtual std::string getMonitInfo(){ return ""; } 
00156         virtual void testMode( bool state );
00157         void updatePreviousValues();
00158         void checkSensors();
00159         void updateOutputs( bool force );
00160 
00161         void preAskSensors( UniversalIO::UIOCommand cmd );
00162         void preSensorInfo( const UniSetTypes::SensorMessage* sm );
00163         void preTimerInfo( const UniSetTypes::TimerMessage* tm );
00164         void preSysCommand( const UniSetTypes::SystemMessage* sm );
00165         void waitSM( int wait_msec, UniSetTypes::ObjectId testID = UniSetTypes::DefaultObjectId );
00166         void initFromSM();
00167 
00168         void resetMsg();
00169         Trigger trResetMsg;
00170         PassiveTimer ptResetMsg;
00171         int resetMsgTime;
00172 
00173         // Выполнение очередного шага программы
00174         virtual void step(){}
00175 
00176         int sleep_msec; 
00177         bool active;
00178 
00179         const std::string argprefix;
00180         UniSetTypes::ObjectId smTestID; 
00182         // управление датчиком "сердцебиения"
00183         PassiveTimer ptHeartBeat;               
00184         UniSetTypes::ObjectId idHeartBeat;      
00185         int maxHeartBeat;                       
00187         xmlNode* confnode;
00189         int getIntProp(const std::string& name) { return UniSetTypes::uniset_conf()->getIntProp(confnode, name); }
00191         inline const std::string getProp(const std::string& name) { return UniSetTypes::uniset_conf()->getProp(confnode, name); }
00192 
00193         timeout_t smReadyTimeout;   
00194         std::atomic_bool activated;
00195         timeout_t activateTimeout;  
00196         PassiveTimer ptStartUpTimeout;  
00197         int askPause; 
00199         IOController_i::SensorInfo si;
00200         bool forceOut; 
00202         std::shared_ptr<LogAgregator> loga;
00203         std::shared_ptr<DebugStream> mylog;
00204         std::shared_ptr<LogServer> logserv;
00205         std::string logserv_host = {""};
00206         int logserv_port = {0};
00207 
00208         // snap
00209         bool no_snap = {false};
00210         
00211         VMonitor vmon;
00212 
00213         
00214 
00215     private:
00216         
00217         // --- private variables ---
00218         // --- end of private variables ---
00219 
00220         // предыдущее значение (для работы UpdateValue())
00221         
00222 
00223         // Используемые идентификаторы сообщений
00224         
00225 
00226         bool end_private; // вспомогательное поле (для внутреннего использования при генерировании кода)
00227 };
00228 
00229 // -----------------------------------------------------------------------------
00230 #endif // UObject_SK_H_