17 #ifndef _MBExchange_H_
18 #define _MBExchange_H_
23 #include <unordered_map>
25 #include "IONotifyController.h"
26 #include "UniSetObject.h"
27 #include "PassiveTimer.h"
28 #include "DelayTimer.h"
31 #include "Calibration.h"
32 #include "SMInterface.h"
33 #include "SharedMemory.h"
34 #include "ThreadCreator.h"
38 #include "RTUStorage.h"
39 #include "modbus/ModbusClient.h"
40 #include "LogAgregator.h"
41 #include "LogServer.h"
42 #include "LogAgregator.h"
47 #define vmonit( var ) vmon.add( #var, var )
61 const std::string& prefix =
"mb" );
65 static void help_print(
int argc,
const char*
const* argv );
75 inline std::shared_ptr<LogAgregator> getLogAggregator()
79 inline std::shared_ptr<DebugStream> log()
86 bool reload(
const std::string& confile );
93 virtual void askSensors( UniversalIO::UIOCommand cmd );
94 virtual void initOutput();
97 virtual void initIterators();
98 virtual void initValues();
99 virtual bool reconfigure(
const std::shared_ptr<uniset::UniXML>& xml,
const std::shared_ptr<uniset::MBConfig>& mbconf );
100 #ifndef DISABLE_REST_API
102 virtual Poco::JSON::Object::Ptr httpHelp(
const Poco::URI::QueryParameters& p )
override;
103 virtual Poco::JSON::Object::Ptr httpRequest(
const std::string& req,
const Poco::URI::QueryParameters& p )
override;
105 void firstInitRegisters();
106 bool preInitRead( MBConfig::InitList::iterator& p );
110 virtual std::shared_ptr<ModbusClient> initMB(
bool reopen =
false ) = 0;
113 bool pollRTU( std::shared_ptr<MBConfig::RTUDevice>& dev, MBConfig::RegMap::iterator& it );
119 void updateRTU(MBConfig::RegMap::iterator& it);
120 void updateMTR(MBConfig::RegMap::iterator& it);
121 void updateRTU188(MBConfig::RegMap::iterator& it);
123 virtual void updateRespondSensors();
125 bool isUpdateSM(
bool wrFunc,
long devMode )
const noexcept;
126 bool isPollEnabled(
bool wrFunc )
const noexcept;
127 bool isSafeMode( std::shared_ptr<MBConfig::RTUDevice>& dev )
const noexcept;
129 bool isProcActive()
const;
130 void setProcActive(
bool st );
133 bool readItem(
const std::shared_ptr<UniXML>& xml,
UniXML::iterator& it, xmlNode* sec );
135 void initOffsetList();
136 std::string initPropPrefix(
const std::string& s_filed,
const std::string& def_prop_prefix );
138 xmlNode* cnode = { 0 };
139 std::shared_ptr<SMInterface> shm;
141 timeout_t initPause = { 3000 };
149 long maxHeartBeat = { 10 };
150 IOController::IOStateList::iterator itHeartBeat;
154 IOController::IOStateList::iterator itExchangeMode;
157 std::atomic_bool activated = {
false };
158 std::atomic_bool canceled = {
false };
159 timeout_t activateTimeout = { 20000 };
160 bool notUseExchangeTimer = {
false };
163 size_t poll_count = { 0 };
165 std::string statInfo = {
"" };
167 std::shared_ptr<ModbusClient> mb;
174 std::shared_ptr<LogAgregator> loga;
175 std::shared_ptr<DebugStream> mblog;
176 std::shared_ptr<LogServer> logserv;
177 std::string logserv_host = {
""};
178 int logserv_port = {0};
179 const std::shared_ptr<SharedMemory> ic;
185 std::shared_ptr<uniset::MBConfig> mbconf;
@ emNone
Definition: MBConfig.h:53
Definition: MBExchange.h:58
size_t ncycle
Definition: MBExchange.h:183
uniset::ObjectId sidExchangeMode
Definition: MBExchange.h:153
PassiveTimer ptReopen
Definition: MBExchange.h:169
long exchangeMode
Definition: MBExchange.h:155
bool force_out
Definition: MBExchange.h:145
PassiveTimer ptInitChannel
Definition: MBExchange.h:172
virtual bool deactivateObject() override
Деактивация объекта (переопределяется для необходимых действий при завершении работы)
Definition: MBExchange.cc:323
void updateRSProperty(MBConfig::RSProperty *p, bool write_only=false)
Definition: MBExchange.cc:1111
void updateMTR(MBConfig::RegMap::iterator &it)
Definition: MBExchange.cc:1563
static void help_print(int argc, const char *const *argv)
Definition: MBExchange.cc:217
timeout_t stat_time
Definition: MBExchange.h:162
PassiveTimer ptStatistic
Definition: MBExchange.h:164
bool force
Definition: MBExchange.h:144
virtual bool activateObject() override
Активизация объекта (переопределяется для необходимых действий после активизации)
Definition: MBExchange.cc:1967
Пассивный таймер
Definition: PassiveTimer.h:94
Definition: MessageType.h:127
Definition: MessageType.h:171
Definition: MessageType.h:214
Definition: UniSetObject.h:80
Definition: CommonEventLoop.h:15
const ObjectId DefaultObjectId
Definition: UniSetTypes.h:70
long ObjectId
Definition: UniSetTypes_i.idl:30
Definition: MBConfig.h:89
Definition: UniSetTypes_i.idl:65