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;
195 #endif // _MBExchange_H_ Пассивный таймер
Definition: PassiveTimer.h:92
size_t ncycle
Definition: MBExchange.h:183
Definition: MBExchange.h:56
PassiveTimer ptReopen
Definition: MBExchange.h:169
Definition: CommonEventLoop.h:14
Definition: MBConfig.h:53
uniset::ObjectId sidExchangeMode
Definition: MBExchange.h:153
long exchangeMode
Definition: MBExchange.h:155
Definition: MessageType.h:170
Definition: UniSetObject.h:73
const ObjectId DefaultObjectId
Definition: UniSetTypes.h:69
virtual bool activateObject() override
Активизация объекта (переопределяется для необходимых действий после активизации)
Definition: MBExchange.cc:1966
PassiveTimer ptInitChannel
Definition: MBExchange.h:172
void updateRSProperty(MBConfig::RSProperty *p, bool write_only=false)
Definition: MBExchange.cc:1110
bool force
Definition: MBExchange.h:144
Definition: MessageType.h:126
bool force_out
Definition: MBExchange.h:145
timeout_t stat_time
Definition: MBExchange.h:162
Definition: MBConfig.h:87
Definition: MessageType.h:213
static void help_print(int argc, const char *const *argv)
Definition: MBExchange.cc:216
Definition: UniSetTypes_i.idl:64
void updateMTR(MBConfig::RegMap::iterator &it)
Definition: MBExchange.cc:1562
virtual bool deactivateObject() override
Деактивация объекта (переопределяется для необходимых действий при завершении работы)
Definition: MBExchange.cc:322
PassiveTimer ptStatistic
Definition: MBExchange.h:164
long ObjectId
Definition: UniSetTypes_i.idl:30