UniSet  2.8.0
LostTestProc_SK.h
1 
2 // --------------------------------------------------------------------------
3 /*
4  DO NOT EDIT THIS FILE. IT IS AUTOGENERATED FILE.
5  ALL YOUR CHANGES WILL BE LOST.
6 
7  НЕ РЕДАКТИРУЙТЕ ЭТОТ ФАЙЛ. ЭТОТ ФАЙЛ СОЗДАН АВТОМАТИЧЕСКИ.
8  ВСЕ ВАШИ ИЗМЕНЕНИЯ БУДУТ ПОТЕРЯНЫ.
9 */
10 // --------------------------------------------------------------------------
11 // generate timestamp: 2019-09-20
12 // -----------------------------------------------------------------------------
13 #ifndef LostTestProc_SK_H_
14 #define LostTestProc_SK_H_
15 // -----------------------------------------------------------------------------
16 #include <memory>
17 #include <string>
18 #include <unordered_map>
19 #include <sstream>
20 #include "UniSetObject.h"
21 #include "UniXML.h"
22 #include "Trigger.h"
23 #include "DebugStream.h"
24 #include "LogServer.h"
25 #include "LogAgregator.h"
26 #include "VMonitor.h"
27 // -----------------------------------------------------------------------------
30 {
31  public:
32  LostTestProc_SK( uniset::ObjectId id, xmlNode* node=uniset::uniset_conf()->getNode("LostTestProc"), const std::string& argprefix="", xmlNode* globalConfNode=nullptr );
34  virtual ~LostTestProc_SK();
35 
36 
37  long getValue( uniset::ObjectId sid );
38  void setValue( uniset::ObjectId sid, long value );
39  void askSensor( uniset::ObjectId sid, UniversalIO::UIOCommand, uniset::ObjectId node = uniset::uniset_conf()->getLocalNode() );
40  void updateValues();
41 
42  virtual uniset::SimpleInfo* getInfo( const char* userparam ) override;
43 
44  virtual bool setMsg( uniset::ObjectId code, bool state = true ) noexcept;
45 
46  inline std::shared_ptr<DebugStream> log() noexcept { return mylog; }
47  inline std::shared_ptr<uniset::LogAgregator> logAgregator() noexcept { return loga; }
48 
49  void init_dlog( std::shared_ptr<DebugStream> d ) noexcept;
50 
51  // "синтаксический сахар"..для логов
52  #ifndef myinfo
53  #define myinfo if( log()->debugging(Debug::INFO) ) log()->info()
54  #endif
55  #ifndef mywarn
56  #define mywarn if( log()->debugging(Debug::WARN) ) log()->warn()
57  #endif
58  #ifndef mycrit
59  #define mycrit if( log()->debugging(Debug::CRIT) ) log()->crit()
60  #endif
61  #ifndef mylog1
62  #define mylog1 if( log()->debugging(Debug::LEVEL1) ) log()->level1()
63  #endif
64  #ifndef mylog2
65  #define mylog2 if( log()->debugging(Debug::LEVEL2) ) log()->level2()
66  #endif
67  #ifndef mylog3
68  #define mylog3 if( log()->debugging(Debug::LEVEL3) ) log()->level3()
69  #endif
70  #ifndef mylog4
71  #define mylog4 if( log()->debugging(Debug::LEVEL4) ) log()->level4()
72  #endif
73  #ifndef mylog5
74  #define mylog5 if( log()->debugging(Debug::LEVEL5) ) log()->level5()
75  #endif
76  #ifndef mylog6
77  #define mylog6 if( log()->debugging(Debug::LEVEL6) ) log()->level6()
78  #endif
79  #ifndef mylog7
80  #define mylog7 if( log()->debugging(Debug::LEVEL7) ) log()->level7()
81  #endif
82  #ifndef mylog8
83  #define mylog8 if( log()->debugging(Debug::LEVEL8) ) log()->level8()
84  #endif
85  #ifndef mylog9
86  #define mylog9 if( log()->debugging(Debug::LEVEL9) ) log()->level9()
87  #endif
88  #ifndef mylogany
89  #define mylogany log()->any()
90  #endif
91  #ifndef vmonit
92  #define vmonit( var ) vmon.add( #var, var )
93  #endif
94 
95  // Вспомогательные функции для удобства логирования
96  // ------------------------------------------------------------
104  std::string dumpIO();
105 
110  std::string str( uniset::ObjectId id, bool showLinkName=true ) const;
111 
116  std::string strval( uniset::ObjectId id, bool showLinkName=true ) const;
117 
122  std::string msgstr( uniset::ObjectId id, bool showLinkName=true ) const;
123 
124 
126  inline std::string dumpVars(){ return vmon.pretty_str(); }
127  // ------------------------------------------------------------
128  std::string help() const noexcept;
129 
130 
131 #ifndef DISABLE_REST_API
132  // HTTP API
133  virtual Poco::JSON::Object::Ptr httpGet( const Poco::URI::QueryParameters& p ) override;
134  virtual Poco::JSON::Object::Ptr httpRequest( const std::string& req, const Poco::URI::QueryParameters& p ) override;
135  virtual Poco::JSON::Object::Ptr httpHelp( const Poco::URI::QueryParameters& p ) override;
136 #endif
137 
138 
139  // Используемые идентификаторы
140 
141 
142  // Используемые идентификаторы сообщений
143 
144 
145  // Текущее значение
146 
147 
148  // --- public variables ---
149 
150  const int checkTime;
152  // --- end of public variables ---
153 
154  protected:
155  // --- protected variables ---
156 
157 
158  // ---- end of protected variables ----
159 
160 
161  virtual void callback() noexcept override;
162  virtual void processingMessage( const uniset::VoidMessage* msg ) override;
163  virtual void sysCommand( const uniset::SystemMessage* sm ) override {}
164  virtual void askSensors( UniversalIO::UIOCommand cmd ) {}
165  virtual void sensorInfo( const uniset::SensorMessage* sm ) override {}
166  virtual void timerInfo( const uniset::TimerMessage* tm ) override {}
167  virtual bool activateObject() override;
168  virtual bool deactivateObject() override;
169  virtual std::string getMonitInfo() const { return ""; }
170  virtual std::string getTypeOfMessage( int t ) const { return uniset::strTypeOfMessage(t); }
172 #ifndef DISABLE_REST_API
173  virtual void httpGetUserData( Poco::JSON::Object::Ptr& jdata ){}
174  virtual Poco::JSON::Object::Ptr httpDumpIO();
175  virtual Poco::JSON::Object::Ptr httpRequestLog( const Poco::URI::QueryParameters& p );
176 #endif
177 
178  // Выполнение очередного шага программы
179  virtual void step(){}
180 
181  void preAskSensors( UniversalIO::UIOCommand cmd );
182  void preSysCommand( const uniset::SystemMessage* sm );
183 
184  virtual void testMode( bool state );
185  void updateOutputs( bool force );
186 
187  bool waitSM( int wait_msec, uniset::ObjectId testID = uniset::DefaultObjectId );
188  uniset::ObjectId getSMTestID() const;
189 
190  void resetMsg();
191  uniset::Trigger trResetMsg;
192  uniset::PassiveTimer ptResetMsg;
193  int resetMsgTime;
194 
196  bool active;
197 
198  const std::string argprefix;
201  // управление датчиком "сердцебиения"
202  uniset::PassiveTimer ptHeartBeat;
206  xmlNode* confnode;
208  int getIntProp(const std::string& name) { return uniset::uniset_conf()->getIntProp(confnode, name); }
210  inline const std::string getProp(const std::string& name) { return uniset::uniset_conf()->getProp(confnode, name); }
211 
212  uniset::timeout_t smReadyTimeout;
213  std::atomic_bool activated = { false };
214  std::atomic_bool cancelled = { false };
215  uniset::timeout_t activateTimeout;
217  int askPause;
220  bool forceOut;
222  std::shared_ptr<uniset::LogAgregator> loga;
223  std::shared_ptr<DebugStream> mylog;
224  std::shared_ptr<uniset::LogServer> logserv;
225  std::string logserv_host = {""};
226  int logserv_port = {0};
227 
228  uniset::VMonitor vmon;
229 
230 
231 
232  private:
233 
234  // --- private variables ---
235  // --- end of private variables ---
236 
237  // предыдущее значение (для работы UpdateValue())
238 
239 
240  // Текущее значение (rw-переменные)
241 
242 
243  // Используемые идентификаторы сообщений
244 
245  // ------------ private функции ---------------
246  void updatePreviousValues() noexcept;
247  void preSensorInfo( const uniset::SensorMessage* sm );
248  void preTimerInfo( const uniset::TimerMessage* tm );
249  void initFromSM();
250  void checkSensors();
251  // --------------------------------------------
252 
253  class StatHashFn
254  {
255  public:
256  size_t operator() (const uniset::ObjectId& key) const
257  {
258  return std::hash<long>()(key);
259  }
260  };
261 
262  std::unordered_map<const uniset::ObjectId,size_t, StatHashFn> smStat;
263  size_t processingMessageCatchCount = { 0 };
265  std::unordered_map<long,size_t> msgTypeStat;
267  std::string ostate = { "" };
270  bool end_private; // вспомогательное поле (для внутреннего использования при генерировании кода)
271 };
272 
273 // -----------------------------------------------------------------------------
274 #endif // LostTestProc_SK_H_
Пассивный таймер
Definition: PassiveTimer.h:92
virtual std::string getMonitInfo() const
Definition: LostTestProc_SK.h:169
Definition: CommonEventLoop.h:14
virtual bool deactivateObject() override
Деактивация объекта (переопределяется для необходимых действий при завершении работы)
virtual void callback() noexcept override
int askPause
Definition: LostTestProc_SK.h:217
uniset::timeout_t smReadyTimeout
Definition: LostTestProc_SK.h:212
long maxHeartBeat
Definition: LostTestProc_SK.h:204
std::string dumpIO()
Definition: MessageType.h:170
std::string dumpVars()
Definition: LostTestProc_SK.h:126
uniset::timeout_t activateTimeout
Definition: LostTestProc_SK.h:215
Definition: UniSetObject.h:73
std::string strval(uniset::ObjectId id, bool showLinkName=true) const
Definition: VMonitor.h:116
std::shared_ptr< Configuration > uniset_conf() noexcept
Definition: Configuration.cc:91
std::string msgstr(uniset::ObjectId id, bool showLinkName=true) const
const ObjectId DefaultObjectId
Definition: UniSetTypes.h:69
bool forceOut
Definition: LostTestProc_SK.h:220
std::string pretty_str(int namewidth=NameWidth, int colnum=ColCount) const
Definition: VMonitor.cc:186
int getIntProp(const std::string &name)
Definition: LostTestProc_SK.h:208
Definition: Trigger.h:29
virtual bool activateObject() override
Активизация объекта (переопределяется для необходимых действий после активизации)
const int checkTime
Definition: LostTestProc_SK.h:150
KeyType key(const uniset::ObjectId id, const uniset::ObjectId node)
Definition: UniSetTypes.cc:718
xmlNode * confnode
Definition: LostTestProc_SK.h:206
Definition: MessageType.h:126
Definition: LostTestProc_SK.h:28
int sleep_msec
Definition: LostTestProc_SK.h:195
std::string str(uniset::ObjectId id, bool showLinkName=true) const
uniset::ObjectId idHeartBeat
Definition: LostTestProc_SK.h:203
Definition: MessageType.h:213
virtual void processingMessage(const uniset::VoidMessage *msg) override
uniset::PassiveTimer ptStartUpTimeout
Definition: LostTestProc_SK.h:216
virtual std::string getTypeOfMessage(int t) const
Definition: LostTestProc_SK.h:170
Definition: IOController_i.idl:57
const std::string getProp(const std::string &name)
Definition: LostTestProc_SK.h:210
Definition: UniSetTypes_i.idl:64
long ObjectId
Definition: UniSetTypes_i.idl:30
uniset::ObjectId smTestID
Definition: LostTestProc_SK.h:199
virtual void httpGetUserData(Poco::JSON::Object::Ptr &jdata)
Definition: LostTestProc_SK.h:173