Blame view

src/IModbusAdapter.h 1.59 KB
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
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
  
      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;
32017af3   Peter M. Groen   Setting up workin...
72
  };