|
UniSet
2.2.1
|
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 // ----------------------------------------------------------------------------- 00189 // ----------------------------------------------------------------------------- 00199 class MBTCPMaster: 00200 public MBExchange 00201 { 00202 public: 00203 MBTCPMaster( UniSetTypes::ObjectId objId, UniSetTypes::ObjectId shmID, const std::shared_ptr<SharedMemory>& ic = nullptr, 00204 const std::string& prefix = "mbtcp" ); 00205 virtual ~MBTCPMaster(); 00206 00208 static std::shared_ptr<MBTCPMaster> init_mbmaster( int argc, const char* const* argv, 00209 UniSetTypes::ObjectId shmID, const std::shared_ptr<SharedMemory>& ic = nullptr, 00210 const std::string& prefix = "mbtcp" ); 00211 00213 static void help_print( int argc, const char* const* argv ); 00214 00215 virtual UniSetTypes::SimpleInfo* getInfo( CORBA::Long userparam = 0 ) override; 00216 00217 protected: 00218 virtual void sysCommand( const UniSetTypes::SystemMessage* sm ) override; 00219 virtual std::shared_ptr<ModbusClient> initMB( bool reopen = false ) override; 00220 virtual void sigterm( int signo ) override; 00221 00222 UniSetTypes::uniset_rwmutex mbMutex; 00223 std::string iaddr; 00224 int port; 00225 00226 void poll_thread(); 00227 void final_thread(); 00228 bool force_disconnect; 00229 00230 private: 00231 MBTCPMaster(); 00232 00233 std::shared_ptr<ModbusTCPMaster> mbtcp; 00234 00235 // т.к. TCP может "зависнуть" на подключении к недоступному узлу 00236 // делаем опрос в отдельном потоке 00237 std::shared_ptr<ThreadCreator<MBTCPMaster>> pollThread; 00238 }; 00239 // ----------------------------------------------------------------------------- 00240 #endif // _MBTCPMaster_H_ 00241 // -----------------------------------------------------------------------------
1.7.6.1