41 bool run(
const std::unordered_set<ModbusRTU::ModbusAddr>& vmbaddr );
46 bool async_run(
const std::unordered_set<ModbusRTU::ModbusAddr>& vmbaddr );
51 virtual bool isActive()
const override;
53 void setMaxSessions(
size_t num );
54 size_t getMaxSessions()
const noexcept;
58 timeout_t getSessionTimeout()
const noexcept;
66 SessionInfo(
const std::string& a,
size_t ask ): iaddr(a), askCount(ask) {}
72 typedef std::list<SessionInfo> Sessions;
74 void getSessions( Sessions& lst );
76 std::string getInetAddress() const noexcept;
77 int getInetPort() const noexcept;
80 size_t getConnectionCount() const noexcept;
89 typedef sigc::signal<
void> TimerSignal;
90 TimerSignal signal_timer();
92 void setTimer( timeout_t msec );
93 timeout_t getTimer() const noexcept;
98 void setSocketTimeout( timeout_t msec );
99 timeout_t getSocketTimeout() const noexcept;
104 virtual
void iowait( timeout_t msec ) override;
107 virtual ModbusRTU::mbErrCode
realReceive( const
std::unordered_set<ModbusRTU::ModbusAddr>& vaddr, timeout_t msecTimeout ) override;
109 virtual
void evprepare() override;
110 virtual
void evfinish() override;
112 virtual
void ioAccept(ev::io& watcher,
int revents);
113 void onTimer( ev::timer& t,
int revents );
114 void onSocketTimeout( ev::timer& t,
int revents );
115 void onSocketResetTimeout( ev::async& watcher,
int revents ) noexcept;
119 virtual
size_t getNextData(
unsigned char* buf,
int len )
override
124 virtual ModbusRTU::mbErrCode sendData(
unsigned char* buf,
int len )
override
126 return ModbusRTU::erHardwareError;
135 std::queue<unsigned char> qrecv;
136 ModbusRTU::MBAPHeader curQueryHeader;
139 typedef std::list<std::shared_ptr<ModbusTCPSession>> SessionList;
142 bool ignoreAddr = {
false };
144 size_t maxSessions = { 100 };
145 size_t sessCount = { 0 };
148 size_t connCount = { 0 };
150 timeout_t sessTimeout = { 10000 };
154 std::shared_ptr<UTCPSocket> sock;
156 ev::timer sockTimeout;
158 double tmSockTimeout = { 0.0 };
159 ev::async asyncResetSockTimeout;
161 std::unordered_set<ModbusRTU::ModbusAddr> vmbaddr;
162 TimerSignal m_timer_signal;
165 double tmTime = { 0.0 };
173 void postReceiveEvent( ModbusRTU::mbErrCode res );
174 ModbusRTU::mbErrCode preReceiveEvent(
const std::unordered_set<ModbusRTU::ModbusAddr> vaddr, timeout_t tout );