|
UniSet
2.0.0
|
00001 #ifndef _MBTCPMaster_H_ 00002 #define _MBTCPMaster_H_ 00003 // ----------------------------------------------------------------------------- 00004 #include <ostream> 00005 #include <string> 00006 #include <map> 00007 #include <vector> 00008 #include <memory> 00009 #include "MBExchange.h" 00010 #include "modbus/ModbusTCPMaster.h" 00011 // ----------------------------------------------------------------------------- 00182 // ----------------------------------------------------------------------------- 00192 class MBTCPMaster: 00193 public MBExchange 00194 { 00195 public: 00196 MBTCPMaster( UniSetTypes::ObjectId objId, UniSetTypes::ObjectId shmID, SharedMemory* ic=0, 00197 const std::string& prefix="mbtcp" ); 00198 virtual ~MBTCPMaster(); 00199 00201 static MBTCPMaster* init_mbmaster( int argc, const char* const* argv, 00202 UniSetTypes::ObjectId shmID, SharedMemory* ic=0, 00203 const std::string& prefix="mbtcp" ); 00204 00206 static void help_print( int argc, const char* const* argv ); 00207 00208 protected: 00209 virtual void sysCommand( const UniSetTypes::SystemMessage *sm ) override; 00210 virtual std::shared_ptr<ModbusClient> initMB( bool reopen=false ) override; 00211 virtual void sigterm( int signo ) override; 00212 00213 UniSetTypes::uniset_rwmutex mbMutex; 00214 std::string iaddr; 00215 int port; 00216 00217 void poll_thread(); 00218 bool force_disconnect; 00219 00220 private: 00221 MBTCPMaster(); 00222 00223 std::shared_ptr<ModbusTCPMaster> mbtcp; 00224 00225 // т.к. TCP может "зависнуть" на подключении к недоступному узлу 00226 // делаем опрос в отдельном потоке 00227 ThreadCreator<MBTCPMaster>* pollThread; 00228 UniSetTypes::uniset_rwmutex tcpMutex; 00229 }; 00230 // ----------------------------------------------------------------------------- 00231 #endif // _MBTCPMaster_H_ 00232 // -----------------------------------------------------------------------------
1.7.6.1