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