IModbusAdapter.h
1.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/****************************************************************************
* Copyright (c) 2022 Priva b.v.
****************************************************************************/
#pragma once
// std
#include <string>
#include <variant>
#include <vector>
using modbusData = std::vector<std::variant<uint8_t, uint16_t>>;
// Forward Declaration
class ConnectionConfig;
/*!
* \brief The IModbusAdapter class
*/
class IModbusAdapter
{
public:
virtual ~IModbusAdapter() {}
virtual void ModbusConnect( const ConnectionConfig &conncfg ) = 0;
/*!
* \brief ModbusDisconnect
*/
virtual void ModbusDisconnect() = 0;
/*!
* \brief ModbusReadData
* \param slaveId
* \param startAddress
* \param noOfItems
*/
virtual modbusData ModbusReadData( int slaveId, int startAddress, int noOfItems ) = 0;
/*!
* \brief ModbusReadHoldReg
* \param slaveId
* \param startAddress
* \param noOfItems
* \return
*/
virtual modbusData ModbusReadHoldReg( int slaveId, int startAddress, int noOfItems ) = 0;
/*!
* \brief ModBusWriteData
* \param slaveId
* \param funtionCode
* \param startAddress
* \param noOfItems
* \param values
*/
virtual void ModBusWriteData( int slaveId, int funtionCode, int startAddress, int noOfItems, std::vector<int>values ) = 0;
/*!
* \brief isConnected
* \return
*/
virtual bool isConnected() const = 0;
/*!
* \brief ErrorString
* \param errnum
* \return
*/
virtual std::string ErrorString( int errnum ) const = 0;
};