UniSet 2.44.3
MQPerfTest/TestProc_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: 2026-02-10
12// -----------------------------------------------------------------------------
13#ifndef TestProc_SK_H_
14#define TestProc_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// -----------------------------------------------------------------------------
28class TestProc_SK:
30{
31 public:
32 TestProc_SK( uniset::ObjectId id, xmlNode* node=uniset::uniset_conf()->getNode("TestProc"), const std::string& argprefix="", xmlNode* globalConfNode=nullptr );
33 TestProc_SK();
34 virtual ~TestProc_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
41 void updateValues();
42 virtual bool setMsg( uniset::ObjectId code, bool state = true ) noexcept;
43
44 virtual uniset::SimpleInfo* getInfo( const char* userparam ) override;
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();
109 std::string str( uniset::ObjectId id, bool showLinkName=true ) const;
110
115 std::string strval( uniset::ObjectId id, bool showLinkName=true ) const;
116
121 std::string msgstr( uniset::ObjectId id, bool showLinkName=true ) const;
122
123
125 inline std::string dumpVars(){ return vmon.pretty_str(); }
126 // ------------------------------------------------------------
127 std::string help() const noexcept;
128
129
130#ifndef DISABLE_REST_API
131 // HTTP API
132 virtual Poco::JSON::Object::Ptr httpRequest( const uniset::UHttp::HttpRequestContext& ctx ) override;
133 virtual Poco::JSON::Object::Ptr httpHelp( const Poco::URI::QueryParameters& p ) override;
134#endif
135
136 // Используемые идентификаторы
137
138
139 // Используемые идентификаторы сообщений
140
141
142 // Текущее значение
143
144
145 // --- public variables ---
146
147
148 // --- end of public variables ---
149
150 protected:
151
152 // --- protected variables ---
153
154
155 // ---- end of protected variables ----
156
157 virtual void callback() noexcept override;
158 virtual void processingMessage( const uniset::VoidMessage* msg ) override;
159 virtual void sysCommand( const uniset::SystemMessage* sm ) override {}
160 virtual void askSensors( UniversalIO::UIOCommand cmd ) {}
161 virtual void sensorInfo( const uniset::SensorMessage* sm ) override {}
162 virtual void timerInfo( const uniset::TimerMessage* tm ) override {}
163 virtual bool activateObject() override;
164 virtual bool deactivateObject() override;
165 virtual std::string getMonitInfo() const { return ""; }
166 virtual std::string getTypeOfMessage( int t ) const { return uniset::strTypeOfMessage(t); }
167
168#ifndef DISABLE_REST_API
169 virtual void httpGetUserData( Poco::JSON::Object::Ptr& jdata ){}
170 virtual Poco::JSON::Object::Ptr httpDumpIO();
171 virtual Poco::JSON::Object::Ptr httpRequestLog( const Poco::URI::QueryParameters& p );
172 virtual Poco::JSON::Object::Ptr request_params_set( const std::string& req, const Poco::URI::QueryParameters& p ) override;
173 virtual Poco::JSON::Object::Ptr request_params_get( const std::string& req, const Poco::URI::QueryParameters& p ) override;
174#endif
175
176 void preAskSensors( UniversalIO::UIOCommand cmd );
177 void preSysCommand( const uniset::SystemMessage* sm );
178
179
180 bool waitSM( int wait_msec, uniset::ObjectId testID = uniset::DefaultObjectId );
181 uniset::ObjectId getSMTestID() const;
182
183 // Выполнение очередного шага программы
184 virtual void step(){}
185
186 void updateOutputs( bool force );
187 void resetMsg();
188 uniset::Trigger trResetMsg;
189 uniset::PassiveTimer ptResetMsg;
190 int resetMsgTime;
191
192 int sleep_msec;
193 bool forceOut = { false };
194
195
196 bool active;
197
198 const std::string argprefix;
200
201 // управление датчиком "сердцебиения"
202 uniset::PassiveTimer ptHeartBeat;
204 long maxHeartBeat;
205
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 canceled = { false };
215 uniset::timeout_t activateTimeout;
216 uniset::PassiveTimer ptStartUpTimeout;
217 int askPause;
218
219 IOController_i::SensorInfo si;
220
221 std::shared_ptr<uniset::LogAgregator> loga;
222 std::shared_ptr<DebugStream> mylog;
223 std::shared_ptr<uniset::LogServer> logserv;
224 std::string logserv_host = {""};
225 int logserv_port = {0};
226
227 uniset::VMonitor vmon;
228
229
230
231 private:
232
233 // --- private variables ---
234 // --- end of private variables ---
235
236 // предыдущее значение (для работы UpdateValue())
237
238
239 // Текущее значение (rw-переменные)
240
241
242 // Используемые идентификаторы сообщений
243
244 // ------------ private функции ---------------
245
246 void updatePreviousValues() noexcept;
247 void checkSensors();
248 void initFromSM();
249
250 void preSensorInfo( const uniset::SensorMessage* sm );
251 void preTimerInfo( const uniset::TimerMessage* tm );
252 // --------------------------------------------
253
254 class StatHashFn
255 {
256 public:
257 size_t operator() (const uniset::ObjectId& key) const
258 {
259 return std::hash<long>()(key);
260 }
261 };
262
263 std::unordered_map<const uniset::ObjectId,size_t, StatHashFn> smStat;
264 size_t processingMessageCatchCount = { 0 };
265
266 std::unordered_map<long,size_t> msgTypeStat;
267
268 std::string ostate = { "" };
269
270
271 bool end_private; // вспомогательное поле (для внутреннего использования при генерировании кода)
272};
273
274// -----------------------------------------------------------------------------
275#endif // TestProc_SK_H_
Определения MBSlaveTest/TestProc_SK.h:30
std::string dumpIO()
long maxHeartBeat
Определения MBSlaveTest/TestProc_SK.h:263
virtual bool activateObject() override
Активизация объекта (переопределяется для необходимых действий после активизации).
uniset::PassiveTimer ptStartUpTimeout
Определения MBSlaveTest/TestProc_SK.h:275
virtual void callback() noexcept override
virtual void processingMessage(const uniset::VoidMessage *msg) override
int sleep_msec
Определения MBSlaveTest/TestProc_SK.h:251
virtual void httpGetUserData(Poco::JSON::Object::Ptr &jdata)
Определения MQPerfTest/TestProc_SK.h:169
std::string msgstr(uniset::ObjectId id, bool showLinkName=true) const
uniset::timeout_t smReadyTimeout
Определения MBSlaveTest/TestProc_SK.h:271
virtual std::string getTypeOfMessage(int t) const
Определения MQPerfTest/TestProc_SK.h:166
int getIntProp(const std::string &name)
Определения MQPerfTest/TestProc_SK.h:208
virtual bool deactivateObject() override
Деактивация объекта (переопределяется для необходимых действий при завершении работы).
std::string strval(uniset::ObjectId id, bool showLinkName=true) const
uniset::timeout_t activateTimeout
Определения MBSlaveTest/TestProc_SK.h:274
const std::string getProp(const std::string &name)
Определения MQPerfTest/TestProc_SK.h:210
bool forceOut
Определения MBSlaveTest/TestProc_SK.h:252
uniset::ObjectId idHeartBeat
Определения MBSlaveTest/TestProc_SK.h:262
uniset::ObjectId smTestID
Определения MBSlaveTest/TestProc_SK.h:258
int askPause
Определения MBSlaveTest/TestProc_SK.h:276
std::string str(uniset::ObjectId id, bool showLinkName=true) const
virtual std::string getMonitInfo() const
Определения MQPerfTest/TestProc_SK.h:165
xmlNode * confnode
Определения MBSlaveTest/TestProc_SK.h:265
std::string dumpVars()
Определения MQPerfTest/TestProc_SK.h:125
Определения MessageType.h:171
Определения UniSetObject.h:80
Определения Calibration.h:27
KeyType key(const uniset::ObjectId id, const uniset::ObjectId node)
Определения UniSetTypes.cc:1048
const ObjectId DefaultObjectId
Определения UniSetTypes.h:71
std::shared_ptr< Configuration > uniset_conf() noexcept
Определения Configuration.cc:106
long ObjectId
Определения UniSetTypes_i.idl:30
Определения UHttpRequestHandler.h:87