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