|
1 | 1 | #include <QDebug> |
2 | 2 | #include "modbusdataunitmap.h" |
3 | 3 |
|
| 4 | +/// |
| 5 | +/// \brief getDataValue |
| 6 | +/// \param modbusMap |
| 7 | +/// \param pointType |
| 8 | +/// \param pointAddress |
| 9 | +/// \return |
| 10 | +/// |
| 11 | +quint16 getDataValue(const QModbusDataUnitMap& modbusMap, QModbusDataUnit::RegisterType pointType, quint16 pointAddress) |
| 12 | +{ |
| 13 | + const auto length = modbusMap[pointType].valueCount(); |
| 14 | + const auto startAddress = modbusMap[pointType].startAddress(); |
| 15 | + if(pointAddress < startAddress || pointAddress > startAddress + length) |
| 16 | + return 0; |
| 17 | + else |
| 18 | + return modbusMap[pointType].value(pointAddress - startAddress); |
| 19 | +} |
| 20 | + |
| 21 | +/// |
| 22 | +/// \brief setDataValue |
| 23 | +/// \param modbusMap |
| 24 | +/// \param pointType |
| 25 | +/// \param pointAddress |
| 26 | +/// \param value |
| 27 | +/// |
| 28 | +void setDataValue(QModbusDataUnitMap& modbusMap, QModbusDataUnit::RegisterType pointType, quint16 pointAddress, quint16 value) |
| 29 | +{ |
| 30 | + const auto startAddress = modbusMap[pointType].startAddress(); |
| 31 | + const auto idx = pointAddress - startAddress; |
| 32 | + if(idx >= 0) modbusMap[pointType].setValue(idx, value); |
| 33 | +} |
| 34 | + |
4 | 35 | /// |
5 | 36 | /// \brief ModbusDataUnitMap::addUnitMap |
6 | 37 | /// \param id |
@@ -42,37 +73,6 @@ QModbusDataUnitMap::Iterator ModbusDataUnitMap::end() |
42 | 73 | return _modbusDataUnitMap.end(); |
43 | 74 | } |
44 | 75 |
|
45 | | -/// |
46 | | -/// \brief getDataValue |
47 | | -/// \param modbusMap |
48 | | -/// \param pointType |
49 | | -/// \param pointAddress |
50 | | -/// \return |
51 | | -/// |
52 | | -quint16 getDataValue(const QModbusDataUnitMap& modbusMap, QModbusDataUnit::RegisterType pointType, quint16 pointAddress) |
53 | | -{ |
54 | | - const auto length = modbusMap[pointType].valueCount(); |
55 | | - const auto startAddress = modbusMap[pointType].startAddress(); |
56 | | - if(pointAddress < startAddress || pointAddress > startAddress + length) |
57 | | - return 0; |
58 | | - else |
59 | | - return modbusMap[pointType].value(pointAddress - startAddress); |
60 | | -} |
61 | | - |
62 | | -/// |
63 | | -/// \brief setDataValue |
64 | | -/// \param modbusMap |
65 | | -/// \param pointType |
66 | | -/// \param pointAddress |
67 | | -/// \param value |
68 | | -/// |
69 | | -void setDataValue(QModbusDataUnitMap& modbusMap, QModbusDataUnit::RegisterType pointType, quint16 pointAddress, quint16 value) |
70 | | -{ |
71 | | - const auto startAddress = modbusMap[pointType].startAddress(); |
72 | | - const auto idx = pointAddress - startAddress; |
73 | | - if(idx >= 0) modbusMap[pointType].setValue(idx, value); |
74 | | -} |
75 | | - |
76 | 76 | /// |
77 | 77 | /// \brief ModbusDataUnitMap::setData |
78 | 78 | /// \param data |
|
0 commit comments