UniSet 2.41.2
JSProxy_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: 2025-11-10
12// -----------------------------------------------------------------------------
13#ifndef JSProxy_SK_H_
14#define JSProxy_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 JSProxy_SK:
30{
31 public:
32 JSProxy_SK( uniset::ObjectId id, xmlNode* node=uniset::uniset_conf()->getNode("JSProxy"), const std::string& argprefix="", xmlNode* globalConfNode=nullptr );
33 JSProxy_SK();
34 virtual ~JSProxy_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 httpGet( const Poco::URI::QueryParameters& p ) override;
133 virtual Poco::JSON::Object::Ptr httpRequest( const std::string& req, const Poco::URI::QueryParameters& p ) override;
134 virtual Poco::JSON::Object::Ptr httpHelp( const Poco::URI::QueryParameters& p ) override;
135#endif
136
137 // Используемые идентификаторы
138
139
140 // Используемые идентификаторы сообщений
141
142
143 // Текущее значение
144
145
146 // --- public variables ---
147
148
149 // --- end of public variables ---
150
151 protected:
152
153 // --- protected variables ---
154
155 const std::string file;
156 const int loopCount;
157 const int httpLoopCount;
158 const int httpMaxQueueSize;
159 const int httpResponseTimeout_msec;
160 const int httpQueueWaitTimeout_msec;
161 const int httpMaxThreads;
162 const int httpMaxRequestQueue;
163 const bool esmModuleMode;
164
165 // ---- end of protected variables ----
166
167 virtual void callback() noexcept override;
168 virtual void processingMessage( const uniset::VoidMessage* msg ) override;
169 virtual void sysCommand( const uniset::SystemMessage* sm ) override {}
170 virtual void askSensors( UniversalIO::UIOCommand cmd ) {}
171 virtual void sensorInfo( const uniset::SensorMessage* sm ) override {}
172 virtual void timerInfo( const uniset::TimerMessage* tm ) override {}
173 virtual bool activateObject() override;
174 virtual bool deactivateObject() override;
175 virtual std::string getMonitInfo() const { return ""; }
176 virtual std::string getTypeOfMessage( int t ) const { return uniset::strTypeOfMessage(t); }
177
178#ifndef DISABLE_REST_API
179 virtual void httpGetUserData( Poco::JSON::Object::Ptr& jdata ){}
180 virtual Poco::JSON::Object::Ptr httpDumpIO();
181 virtual Poco::JSON::Object::Ptr httpRequestLog( const Poco::URI::QueryParameters& p );
182 virtual Poco::JSON::Object::Ptr request_params_set( const std::string& req, const Poco::URI::QueryParameters& p ) override;
183 virtual Poco::JSON::Object::Ptr request_params_get( const std::string& req, const Poco::URI::QueryParameters& p ) override;
184#endif
185
186 void preAskSensors( UniversalIO::UIOCommand cmd );
187 void preSysCommand( const uniset::SystemMessage* sm );
188
189
190 bool waitSM( int wait_msec, uniset::ObjectId testID = uniset::DefaultObjectId );
191 uniset::ObjectId getSMTestID() const;
192
193 // Выполнение очередного шага программы
194 virtual void step(){}
195
196 void updateOutputs( bool force );
197 void resetMsg();
198 uniset::Trigger trResetMsg;
199 uniset::PassiveTimer ptResetMsg;
200 int resetMsgTime;
201
203 bool forceOut = { false };
204
205
206 bool active;
207
208 const std::string argprefix;
210
211 // управление датчиком "сердцебиения"
212 uniset::PassiveTimer ptHeartBeat;
215
216 xmlNode* confnode;
218 int getIntProp(const std::string& name) { return uniset::uniset_conf()->getIntProp(confnode, name); }
220 inline const std::string getProp(const std::string& name) { return uniset::uniset_conf()->getProp(confnode, name); }
221
222 uniset::timeout_t smReadyTimeout;
223 std::atomic_bool activated = { false };
224 std::atomic_bool canceled = { false };
225 uniset::timeout_t activateTimeout;
228
230
231 std::shared_ptr<uniset::LogAgregator> loga;
232 std::shared_ptr<DebugStream> mylog;
233 std::shared_ptr<uniset::LogServer> logserv;
234 std::string logserv_host = {""};
235 int logserv_port = {0};
236
237 uniset::VMonitor vmon;
238
239
240
241 private:
242
243 // --- private variables ---
244 // --- end of private variables ---
245
246 // предыдущее значение (для работы UpdateValue())
247
248
249 // Текущее значение (rw-переменные)
250
251
252 // Используемые идентификаторы сообщений
253
254 // ------------ private функции ---------------
255
256 void updatePreviousValues() noexcept;
257 void checkSensors();
258 void initFromSM();
259
260 void preSensorInfo( const uniset::SensorMessage* sm );
261 void preTimerInfo( const uniset::TimerMessage* tm );
262 // --------------------------------------------
263
264 class StatHashFn
265 {
266 public:
267 size_t operator() (const uniset::ObjectId& key) const
268 {
269 return std::hash<long>()(key);
270 }
271 };
272
273 std::unordered_map<const uniset::ObjectId,size_t, StatHashFn> smStat;
274 size_t processingMessageCatchCount = { 0 };
275
276 std::unordered_map<long,size_t> msgTypeStat;
277
278 std::string ostate = { "" };
279
280
281 bool end_private; // вспомогательное поле (для внутреннего использования при генерировании кода)
282};
283
284// -----------------------------------------------------------------------------
285#endif // JSProxy_SK_H_
uniset::ObjectId smTestID
Определения JSProxy_SK.h:209
std::string strval(uniset::ObjectId id, bool showLinkName=true) const
int askPause
Определения JSProxy_SK.h:227
virtual bool deactivateObject() override
Деактивация объекта (переопределяется для необходимых действий при завершении работы).
virtual void httpGetUserData(Poco::JSON::Object::Ptr &jdata)
Определения JSProxy_SK.h:179
std::string dumpVars()
Определения JSProxy_SK.h:125
uniset::timeout_t smReadyTimeout
Определения JSProxy_SK.h:222
virtual std::string getMonitInfo() const
Определения JSProxy_SK.h:175
bool forceOut
Определения JSProxy_SK.h:203
virtual std::string getTypeOfMessage(int t) const
Определения JSProxy_SK.h:176
virtual bool activateObject() override
Активизация объекта (переопределяется для необходимых действий после активизации).
uniset::timeout_t activateTimeout
Определения JSProxy_SK.h:225
uniset::ObjectId idHeartBeat
Определения JSProxy_SK.h:213
std::string dumpIO()
const std::string getProp(const std::string &name)
Определения JSProxy_SK.h:220
int sleep_msec
Определения JSProxy_SK.h:202
int getIntProp(const std::string &name)
Определения JSProxy_SK.h:218
xmlNode * confnode
Определения JSProxy_SK.h:216
long maxHeartBeat
Определения JSProxy_SK.h:214
uniset::PassiveTimer ptStartUpTimeout
Определения JSProxy_SK.h:226
std::string str(uniset::ObjectId id, bool showLinkName=true) const
virtual void callback() noexcept override
virtual void processingMessage(const uniset::VoidMessage *msg) override
std::string msgstr(uniset::ObjectId id, bool showLinkName=true) const
Пассивный таймер
Определения PassiveTimer.h:94
Определения MessageType.h:171
Определения UniSetObject.h:80
Определения Calibration.h:27
KeyType key(const uniset::ObjectId id, const uniset::ObjectId node)
Определения UniSetTypes.cc:990
const ObjectId DefaultObjectId
Определения UniSetTypes.h:71
std::shared_ptr< Configuration > uniset_conf() noexcept
Определения Configuration.cc:90
long ObjectId
Определения UniSetTypes_i.idl:30
Определения IOController_i.idl:64
Определения UniSetTypes_i.idl:65