UniSet 2.32.1
UObject_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: 2023-03-07+03:00
12// -----------------------------------------------------------------------------
13#ifndef UObject_SK_H_
14#define UObject_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 UObject_SK( uniset::ObjectId id, xmlNode* node=uniset::uniset_conf()->getNode("UObject"), const std::string& argprefix="", xmlNode* globalConfNode=nullptr );
33 UObject_SK();
34 virtual ~UObject_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 virtual uniset::SimpleInfo* getInfo( const char* userparam ) override;
42
43 inline std::shared_ptr<DebugStream> log() noexcept { return mylog; }
44 inline std::shared_ptr<uniset::LogAgregator> logAgregator() noexcept { return loga; }
45
46 void init_dlog( std::shared_ptr<DebugStream> d ) noexcept;
47
48 // "синтаксический сахар"..для логов
49 #ifndef myinfo
50 #define myinfo if( log()->debugging(Debug::INFO) ) log()->info()
51 #endif
52 #ifndef mywarn
53 #define mywarn if( log()->debugging(Debug::WARN) ) log()->warn()
54 #endif
55 #ifndef mycrit
56 #define mycrit if( log()->debugging(Debug::CRIT) ) log()->crit()
57 #endif
58 #ifndef mylog1
59 #define mylog1 if( log()->debugging(Debug::LEVEL1) ) log()->level1()
60 #endif
61 #ifndef mylog2
62 #define mylog2 if( log()->debugging(Debug::LEVEL2) ) log()->level2()
63 #endif
64 #ifndef mylog3
65 #define mylog3 if( log()->debugging(Debug::LEVEL3) ) log()->level3()
66 #endif
67 #ifndef mylog4
68 #define mylog4 if( log()->debugging(Debug::LEVEL4) ) log()->level4()
69 #endif
70 #ifndef mylog5
71 #define mylog5 if( log()->debugging(Debug::LEVEL5) ) log()->level5()
72 #endif
73 #ifndef mylog6
74 #define mylog6 if( log()->debugging(Debug::LEVEL6) ) log()->level6()
75 #endif
76 #ifndef mylog7
77 #define mylog7 if( log()->debugging(Debug::LEVEL7) ) log()->level7()
78 #endif
79 #ifndef mylog8
80 #define mylog8 if( log()->debugging(Debug::LEVEL8) ) log()->level8()
81 #endif
82 #ifndef mylog9
83 #define mylog9 if( log()->debugging(Debug::LEVEL9) ) log()->level9()
84 #endif
85 #ifndef mylogany
86 #define mylogany log()->any()
87 #endif
88 #ifndef vmonit
89 #define vmonit( var ) vmon.add( #var, var )
90 #endif
91
93 inline std::string dumpVars(){ return vmon.pretty_str(); }
94 // ------------------------------------------------------------
95 std::string help() const noexcept;
96
97
98#ifndef DISABLE_REST_API
99 // HTTP API
100 virtual Poco::JSON::Object::Ptr httpGet( const Poco::URI::QueryParameters& p ) override;
101 virtual Poco::JSON::Object::Ptr httpRequest( const std::string& req, const Poco::URI::QueryParameters& p ) override;
102 virtual Poco::JSON::Object::Ptr httpHelp( const Poco::URI::QueryParameters& p ) override;
103#endif
104
105 protected:
106
107 virtual void callback() noexcept override;
108 virtual void processingMessage( const uniset::VoidMessage* msg ) override;
109 virtual void sysCommand( const uniset::SystemMessage* sm ) override {}
110 virtual void askSensors( UniversalIO::UIOCommand cmd ) {}
111 virtual void sensorInfo( const uniset::SensorMessage* sm ) override {}
112 virtual void timerInfo( const uniset::TimerMessage* tm ) override {}
113 virtual bool activateObject() override;
114 virtual bool deactivateObject() override;
115 virtual std::string getMonitInfo() const { return ""; }
116 virtual std::string getTypeOfMessage( int t ) const { return uniset::strTypeOfMessage(t); }
118#ifndef DISABLE_REST_API
119 virtual void httpGetUserData( Poco::JSON::Object::Ptr& jdata ){}
120 virtual Poco::JSON::Object::Ptr httpDumpIO();
121 virtual Poco::JSON::Object::Ptr httpRequestLog( const Poco::URI::QueryParameters& p );
122 virtual Poco::JSON::Object::Ptr request_params_set( const std::string& req, const Poco::URI::QueryParameters& p ) override;
123 virtual Poco::JSON::Object::Ptr request_params_get( const std::string& req, const Poco::URI::QueryParameters& p ) override;
124#endif
125
126 void preAskSensors( UniversalIO::UIOCommand cmd );
127 void preSysCommand( const uniset::SystemMessage* sm );
128
129
130 bool waitSM( int wait_msec, uniset::ObjectId testID = uniset::DefaultObjectId );
131 uniset::ObjectId getSMTestID() const;
132
133
134 bool active;
135
136 const std::string argprefix;
139 // управление датчиком "сердцебиения"
140 uniset::PassiveTimer ptHeartBeat;
144 xmlNode* confnode;
146 int getIntProp(const std::string& name) { return uniset::uniset_conf()->getIntProp(confnode, name); }
148 inline const std::string getProp(const std::string& name) { return uniset::uniset_conf()->getProp(confnode, name); }
149
150 uniset::timeout_t smReadyTimeout;
151 std::atomic_bool activated = { false };
152 std::atomic_bool canceled = { false };
153 uniset::timeout_t activateTimeout;
158
159 std::shared_ptr<uniset::LogAgregator> loga;
160 std::shared_ptr<DebugStream> mylog;
161 std::shared_ptr<uniset::LogServer> logserv;
162 std::string logserv_host = {""};
163 int logserv_port = {0};
164
165 uniset::VMonitor vmon;
166
167
168
169 private:
170
171 // ------------ private функции ---------------
172
173 void preSensorInfo( const uniset::SensorMessage* sm );
174 void preTimerInfo( const uniset::TimerMessage* tm );
175 // --------------------------------------------
176
177 class StatHashFn
178 {
179 public:
180 size_t operator() (const uniset::ObjectId& key) const
181 {
182 return std::hash<long>()(key);
183 }
184 };
185
186 std::unordered_map<const uniset::ObjectId,size_t, StatHashFn> smStat;
187 size_t processingMessageCatchCount = { 0 };
189 std::unordered_map<long,size_t> msgTypeStat;
191 std::string ostate = { "" };
194 bool end_private; // вспомогательное поле (для внутреннего использования при генерировании кода)
195};
196
197// -----------------------------------------------------------------------------
198#endif // UObject_SK_H_
Definition UObject_SK.h:30
virtual void processingMessage(const uniset::VoidMessage *msg) override
virtual void httpGetUserData(Poco::JSON::Object::Ptr &jdata)
Definition UObject_SK.h:119
int askPause
Definition UObject_SK.h:155
uniset::timeout_t smReadyTimeout
Definition UObject_SK.h:150
virtual void callback() noexcept override
virtual bool deactivateObject() override
Деактивация объекта (переопределяется для необходимых действий при завершении работы)
xmlNode * confnode
Definition UObject_SK.h:144
virtual std::string getTypeOfMessage(int t) const
Definition UObject_SK.h:116
int getIntProp(const std::string &name)
Definition UObject_SK.h:146
uniset::timeout_t activateTimeout
Definition UObject_SK.h:153
const std::string getProp(const std::string &name)
Definition UObject_SK.h:148
uniset::PassiveTimer ptStartUpTimeout
Definition UObject_SK.h:154
virtual std::string getMonitInfo() const
Definition UObject_SK.h:115
std::string dumpVars()
Definition UObject_SK.h:93
long maxHeartBeat
Definition UObject_SK.h:142
uniset::ObjectId smTestID
Definition UObject_SK.h:137
uniset::ObjectId idHeartBeat
Definition UObject_SK.h:141
virtual bool activateObject() override
Активизация объекта (переопределяется для необходимых действий после активизации)
Пассивный таймер
Definition PassiveTimer.h:94
Definition MessageType.h:127
Definition MessageType.h:171
Definition MessageType.h:214
Definition UniSetObject.h:80
Definition VMonitor.h:117
std::string pretty_str(int namewidth=NameWidth, int colnum=ColCount) const
Definition VMonitor.cc:186
Definition Calibration.h:27
KeyType key(const uniset::ObjectId id, const uniset::ObjectId node)
Definition UniSetTypes.cc:980
const ObjectId DefaultObjectId
Definition UniSetTypes.h:71
std::shared_ptr< Configuration > uniset_conf() noexcept
Definition Configuration.cc:90
long ObjectId
Definition UniSetTypes_i.idl:30
Definition IOController_i.idl:58
Definition UniSetTypes_i.idl:65