2#ifndef ModbusTCPSession_H_
3#define ModbusTCPSession_H_
7#include <unordered_map>
9#include "ModbusServerSlot.h"
10#include "ModbusServer.h"
11#include "PassiveTimer.h"
13#include "UTCPStream.h"
39 ModbusTCPSession(
const Poco::Net::StreamSocket& s,
const std::unordered_set<ModbusRTU::ModbusAddr>& vmbaddr, timeout_t timeout );
42 void cleanInputStream();
44 virtual void cleanupChannel()
override;
45 virtual void terminate()
override;
47 typedef sigc::slot<void, const ModbusTCPSession*> FinalSlot;
49 void connectFinalSession( FinalSlot sl );
51 std::string getClientAddress()
const;
53 void setSessionTimeout(
double t );
56 void run( ev::loop_ref& loop );
58 virtual bool isActive()
const override;
62 virtual void iowait( timeout_t msec )
override;
64 virtual ModbusRTU::mbErrCode
realReceive(
const std::unordered_set<ModbusRTU::ModbusAddr>& vmbaddr, timeout_t msecTimeout )
override;
66 void callback( ev::io& watcher,
int revents );
67 void onTimeout( ev::timer& watcher,
int revents );
68 virtual void readEvent( ev::io& watcher );
69 virtual void writeEvent( ev::io& watcher );
72 virtual size_t getNextData(
unsigned char* buf,
int len )
override;
74 virtual ModbusRTU::mbErrCode sendData(
unsigned char* buf,
int len )
override;
122 std::queue<unsigned char> qrecv;
123 std::unordered_set<ModbusRTU::ModbusAddr> vaddr;
126 timeout_t timeout = { 0 };
132 std::shared_ptr<UTCPStream> sock;
133 std::queue<UTCPCore::Buffer*> qsend;
134 double sessTimeout = { 10.0 };
136 bool ignoreAddr = {
false };
137 std::string peername = {
"" };
139 std::string caddr = {
"" };
143 std::atomic_bool cancelled = {
false };
Definition ModbusServer.h:33
Definition ModbusServerSlot.h:14
The ModbusTCPSession class Класс рассчитан на совместную работу с ModbusTCPServer,...
Definition ModbusTCPSession.h:36
virtual ModbusRTU::mbErrCode writeOutputSingleRegister(ModbusRTU::WriteSingleOutputMessage &query, ModbusRTU::WriteSingleOutputRetMessage &reply) override
Definition ModbusTCPSession.cc:534
virtual ModbusRTU::mbErrCode fileTransfer(ModbusRTU::FileTransferMessage &query, ModbusRTU::FileTransferRetMessage &reply) override
Definition ModbusTCPSession.cc:571
virtual ModbusRTU::mbErrCode readInputRegisters(ModbusRTU::ReadInputMessage &query, ModbusRTU::ReadInputRetMessage &reply) override
Definition ModbusTCPSession.cc:475
virtual ModbusRTU::mbErrCode writeOutputRegisters(ModbusRTU::WriteOutputMessage &query, ModbusRTU::WriteOutputRetMessage &reply) override
Definition ModbusTCPSession.cc:496
virtual ModbusRTU::mbErrCode realReceive(const std::unordered_set< ModbusRTU::ModbusAddr > &vmbaddr, timeout_t msecTimeout) override
Definition ModbusTCPSession.cc:211
virtual ModbusRTU::mbErrCode journalCommand(ModbusRTU::JournalCommandMessage &query, ModbusRTU::JournalCommandRetMessage &reply) override
Definition ModbusTCPSession.cc:544
virtual ModbusRTU::mbErrCode read4314(ModbusRTU::MEIMessageRDI &query, ModbusRTU::MEIMessageRetRDI &reply) override
Definition ModbusTCPSession.cc:515
virtual ModbusRTU::mbErrCode readCoilStatus(ModbusRTU::ReadCoilMessage &query, ModbusRTU::ReadCoilRetMessage &reply) override
Definition ModbusTCPSession.cc:444
virtual ModbusRTU::mbErrCode diagnostics(ModbusRTU::DiagnosticMessage &query, ModbusRTU::DiagnosticRetMessage &reply) override
Definition ModbusTCPSession.cc:506
virtual size_t getNextData(unsigned char *buf, int len) override
Definition ModbusTCPSession.cc:299
virtual ModbusRTU::mbErrCode forceMultipleCoils(ModbusRTU::ForceCoilsMessage &query, ModbusRTU::ForceCoilsRetMessage &reply) override
Definition ModbusTCPSession.cc:485
virtual ModbusRTU::mbErrCode readOutputRegisters(ModbusRTU::ReadOutputMessage &query, ModbusRTU::ReadOutputRetMessage &reply) override
Definition ModbusTCPSession.cc:465
virtual void setChannelTimeout(timeout_t msec) override
Definition ModbusTCPSession.cc:580
virtual ModbusRTU::mbErrCode readInputStatus(ModbusRTU::ReadInputStatusMessage &query, ModbusRTU::ReadInputStatusRetMessage &reply) override
Definition ModbusTCPSession.cc:454
virtual ModbusRTU::mbErrCode remoteService(ModbusRTU::RemoteServiceMessage &query, ModbusRTU::RemoteServiceRetMessage &reply) override
Definition ModbusTCPSession.cc:562
virtual ModbusRTU::mbErrCode setDateTime(ModbusRTU::SetDateTimeMessage &query, ModbusRTU::SetDateTimeRetMessage &reply) override
Definition ModbusTCPSession.cc:553
virtual ModbusRTU::mbErrCode forceSingleCoil(ModbusRTU::ForceSingleCoilMessage &query, ModbusRTU::ForceSingleCoilRetMessage &reply) override
Definition ModbusTCPSession.cc:524
Пассивный таймер
Definition PassiveTimer.h:94
Definition Calibration.h:27
Definition ModbusTypes.h:1118
Definition ModbusTypes.h:1176
Definition ModbusTypes.h:1575
Definition ModbusTypes.h:1603
Definition ModbusTypes.h:727
Definition ModbusTypes.h:804
Definition ModbusTypes.h:937
Definition ModbusTypes.h:988
Definition ModbusTypes.h:1310
Definition ModbusTypes.h:1333
Definition ModbusTypes.h:1188
Definition ModbusTypes.h:1243
Definition ModbusTypes.h:211
Definition ModbusTypes.h:347
Definition ModbusTypes.h:378
Definition ModbusTypes.h:548
Definition ModbusTypes.h:577
Definition ModbusTypes.h:1456
Definition ModbusTypes.h:1489
Definition ModbusTypes.h:1398
Definition ModbusTypes.h:1436
Definition ModbusTypes.h:844
Definition ModbusTypes.h:898
Definition ModbusTypes.h:1033
Definition ModbusTypes.h:1079