UniSet  2.6.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: 2017-03-02+03:00
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="" );
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 
119  inline std::string dumpVars(){ return vmon.pretty_str(); }
120  // ------------------------------------------------------------
121  std::string help() noexcept;
122 
123 
124 
125  // Используемые идентификаторы
126 
127 
128  // Используемые идентификаторы сообщений
129 
130 
131  // Текущее значение
132 
133 
134  // --- public variables ---
135 
136  const int checkTime;
138  // --- end of public variables ---
139 
140  protected:
141  // --- protected variables ---
142 
143 
144  // ---- end of protected variables ----
145 
146 
147  virtual void callback() noexcept override;
148  virtual void processingMessage( const uniset::VoidMessage* msg ) override;
149  virtual void sysCommand( const uniset::SystemMessage* sm ){};
150  virtual void askSensors( UniversalIO::UIOCommand cmd ){}
151  virtual void sensorInfo( const uniset::SensorMessage* sm ) override{}
152  virtual void timerInfo( const uniset::TimerMessage* tm ) override{}
153  virtual void sigterm( int signo ) override;
154  virtual bool activateObject() override;
155  virtual std::string getMonitInfo(){ return ""; }
157  // Выполнение очередного шага программы
158  virtual void step(){}
159 
160  void preAskSensors( UniversalIO::UIOCommand cmd );
161  void preSysCommand( const uniset::SystemMessage* sm );
162 
163  virtual void testMode( bool state );
164  void updateOutputs( bool force );
165 
166  void waitSM( int wait_msec, uniset::ObjectId testID = uniset::DefaultObjectId );
167  uniset::ObjectId getSMTestID();
168 
169  void resetMsg();
170  uniset::Trigger trResetMsg;
171  uniset::PassiveTimer ptResetMsg;
172  int resetMsgTime;
173 
175  bool active;
176 
177  const std::string argprefix;
180  // управление датчиком "сердцебиения"
181  uniset::PassiveTimer ptHeartBeat;
185  xmlNode* confnode;
187  int getIntProp(const std::string& name) { return uniset::uniset_conf()->getIntProp(confnode, name); }
189  inline const std::string getProp(const std::string& name) { return uniset::uniset_conf()->getProp(confnode, name); }
190 
191  uniset::timeout_t smReadyTimeout;
192  std::atomic_bool activated;
193  uniset::timeout_t activateTimeout;
195  int askPause;
198  bool forceOut;
200  std::shared_ptr<uniset::LogAgregator> loga;
201  std::shared_ptr<DebugStream> mylog;
202  std::shared_ptr<uniset::LogServer> logserv;
203  std::string logserv_host = {""};
204  int logserv_port = {0};
205 
206  uniset::VMonitor vmon;
207 
208 
209 
210  private:
211 
212  // --- private variables ---
213  // --- end of private variables ---
214 
215  // предыдущее значение (для работы UpdateValue())
216 
217 
218  // Текущее значение (rw-переменные)
219 
220 
221  // Используемые идентификаторы сообщений
222 
223  // ------------ private функции ---------------
224  void updatePreviousValues() noexcept;
225  void preSensorInfo( const uniset::SensorMessage* sm );
226  void preTimerInfo( const uniset::TimerMessage* tm );
227  void initFromSM();
228  void checkSensors();
229  // --------------------------------------------
230 
231  class StatHashFn
232  {
233  public:
234  size_t operator() (const uniset::ObjectId& key) const
235  {
236  return std::hash<long>()(key);
237  }
238  };
239 
240  std::unordered_map<const uniset::ObjectId,size_t, StatHashFn> smStat;
241  size_t processingMessageCatchCount = { 0 };
243  std::string ostate = { "" };
246  bool end_private; // вспомогательное поле (для внутреннего использования при генерировании кода)
247 };
248 
249 // -----------------------------------------------------------------------------
250 #endif // LostTestProc_SK_H_
Пассивный таймер
Definition: PassiveTimer.h:90
virtual void callback() noexceptoverride
Definition: CallbackTimer.h:29
int askPause
Definition: LostTestProc_SK.h:195
uniset::timeout_t smReadyTimeout
Definition: LostTestProc_SK.h:191
long maxHeartBeat
Definition: LostTestProc_SK.h:183
std::string dumpIO()
Definition: MessageType.h:166
std::string dumpVars()
Definition: LostTestProc_SK.h:119
uniset::timeout_t activateTimeout
Definition: LostTestProc_SK.h:193
Definition: UniSetObject.h:73
Definition: VMonitor.h:116
std::shared_ptr< Configuration > uniset_conf() noexcept
Definition: Configuration.cc:89
std::string pretty_str(int namewidth=NameWidth, int colnum=ColCount)
Definition: VMonitor.cc:187
virtual void sigterm(int signo) override
const ObjectId DefaultObjectId
Definition: UniSetTypes.h:56
bool forceOut
Definition: LostTestProc_SK.h:198
int getIntProp(const std::string &name)
Definition: LostTestProc_SK.h:187
virtual std::string getMonitInfo()
Definition: LostTestProc_SK.h:155
Definition: Trigger.h:29
virtual bool activateObject() override
Активизация объекта (переопределяется для необходимых действий после активизации) ...
const int checkTime
Definition: LostTestProc_SK.h:136
xmlNode * confnode
Definition: LostTestProc_SK.h:185
Definition: MessageType.h:122
std::string strval(uniset::ObjectId id, bool showLinkName=true) const
Definition: LostTestProc_SK.h:28
int sleep_msec
Definition: LostTestProc_SK.h:174
uniset::ObjectId idHeartBeat
Definition: LostTestProc_SK.h:182
Definition: MessageType.h:209
virtual void processingMessage(const uniset::VoidMessage *msg) override
uniset::PassiveTimer ptStartUpTimeout
Definition: LostTestProc_SK.h:194
Definition: IOController_i.idl:56
const std::string getProp(const std::string &name)
Definition: LostTestProc_SK.h:189
Definition: UniSetTypes_i.idl:64
std::string str(uniset::ObjectId id, bool showLinkName=true) const
long ObjectId
Definition: UniSetTypes_i.idl:30
uniset::ObjectId smTestID
Definition: LostTestProc_SK.h:178