58 private USingleProcess,
64 const std::string& prefix =
"mb" );
65 virtual ~MBExchange();
68 static void help_print(
int argc,
const char*
const* argv );
78 inline std::shared_ptr<LogAgregator> getLogAggregator()
82 inline std::shared_ptr<DebugStream> log()
89 bool reload(
const std::string& confile );
91 static uint8_t firstBit( uint16_t mask );
94 static uint16_t getBits( uint16_t value, uint16_t mask, uint8_t offset );
96 static uint16_t setBits( uint16_t value, uint16_t set, uint16_t mask, uint8_t offset );
98 static uint16_t forceSetBits( uint16_t value, uint16_t set, uint16_t mask, uint8_t offset );
105 virtual void askSensors( UniversalIO::UIOCommand cmd );
106 virtual void initOutput();
109 virtual void initIterators();
110 virtual void initValues();
111 virtual bool reconfigure(
const std::shared_ptr<uniset::UniXML>& xml,
const std::shared_ptr<uniset::MBConfig>& mbconf );
112#ifndef DISABLE_REST_API
114 virtual Poco::JSON::Object::Ptr httpHelp(
const Poco::URI::QueryParameters& p )
override;
115 virtual Poco::JSON::Object::Ptr httpRequest(
const std::string& req,
const Poco::URI::QueryParameters& p )
override;
118 Poco::JSON::Object::Ptr httpModeGet(
const Poco::URI::QueryParameters& p );
119 Poco::JSON::Object::Ptr httpModeSet(
const Poco::URI::QueryParameters& p );
120 Poco::JSON::Object::Ptr httpModeSupported(
const Poco::URI::QueryParameters&);
121 Poco::JSON::Object::Ptr httpMode(
const Poco::URI::QueryParameters& p );
122 Poco::JSON::Object::Ptr httpReload(
const Poco::URI::QueryParameters& p );
123 virtual Poco::JSON::Object::Ptr httpGetParam(
const Poco::URI::QueryParameters& p );
124 virtual Poco::JSON::Object::Ptr httpSetParam(
const Poco::URI::QueryParameters& p );
125 virtual Poco::JSON::Object::Ptr httpStatus();
127 bool httpEnabledSetParams = {
false };
129 void firstInitRegisters();
130 bool preInitRead( MBConfig::InitList::iterator& p );
134 virtual std::shared_ptr<ModbusClient> initMB(
bool reopen =
false ) = 0;
137 bool pollRTU( std::shared_ptr<MBConfig::RTUDevice>& dev, MBConfig::RegMap::iterator& it );
143 void updateRTU(MBConfig::RegMap::iterator& it);
144 void updateMTR(MBConfig::RegMap::iterator& it);
145 void updateRTU188(MBConfig::RegMap::iterator& it);
147 virtual void updateRespondSensors();
149 bool isUpdateSM(
bool wrFunc,
long devMode )
const noexcept;
150 bool isPollEnabled(
bool wrFunc )
const noexcept;
151 bool isSafeMode( std::shared_ptr<MBConfig::RTUDevice>& dev )
const noexcept;
153 bool isProcActive()
const;
154 void setProcActive(
bool st );
157 bool readItem(
const std::shared_ptr<UniXML>& xml, UniXML::iterator& it, xmlNode* sec );
158 bool initItem( UniXML::iterator& it );
159 void initOffsetList();
160 std::string initPropPrefix(
const std::string& def_prop_prefix );
162 xmlNode* cnode = { 0 };
163 std::shared_ptr<SMInterface> shm;
165 timeout_t initPause = { 3000 };
173 long maxHeartBeat = { 10 };
174 IOController::IOStateList::iterator itHeartBeat;
178 IOController::IOStateList::iterator itExchangeMode;
181 std::atomic_bool activated = {
false };
182 std::atomic_bool canceled = {
false };
183 timeout_t activateTimeout = { 20000 };
184 bool notUseExchangeTimer = {
false };
187 size_t poll_count = { 0 };
189 std::string statInfo = {
"" };
191 std::shared_ptr<ModbusClient> mb;
198 std::shared_ptr<LogAgregator> loga;
199 std::shared_ptr<DebugStream> mblog;
200 std::shared_ptr<LogServer> logserv;
201 std::string logserv_host = {
""};
202 int logserv_port = {0};
203 const std::shared_ptr<SharedMemory> ic;
209 std::shared_ptr<uniset::MBConfig> mbconf;