@@ -450,7 +450,7 @@ void FormModSim::print(QPrinter* printer)
450450ModbusSimulationMap FormModSim::simulationMap () const
451451{
452452 const auto dd = displayDefinition ();
453- const auto startAddr = dd.PointAddress - 1 ;
453+ const auto startAddr = dd.PointAddress - (dd. ZeroBasedAddress ? 0 : 1 ) ;
454454 const auto endAddr = startAddr + dd.Length ;
455455
456456 ModbusSimulationMap result;
@@ -467,25 +467,26 @@ ModbusSimulationMap FormModSim::simulationMap() const
467467 return result;
468468}
469469
470-
471- QModbusDataUnit FormModSim::serializeModbusDataUnit (QModbusDataUnit::RegisterType type,
472- quint16 startAddress,
473- quint16 length) const
470+ // /
471+ // / \brief FormModSim::serializeModbusDataUnit
472+ // / \param type
473+ // / \param startAddress
474+ // / \param length
475+ // / \return
476+ // /
477+ QModbusDataUnit FormModSim::serializeModbusDataUnit (QModbusDataUnit::RegisterType type, quint16 startAddress, quint16 length) const
474478{
475479 QModbusDataUnit dataUnit;
476-
477480 const auto serverData = _mbMultiServer.data (type, startAddress, length);
478481
479- const auto & unit = serverData;
480-
481- if (startAddress >= unit.startAddress () &&
482- (startAddress + length) <= (unit.startAddress () + unit.valueCount ())) {
482+ if (startAddress >= serverData.startAddress () &&
483+ (startAddress + length) <= (serverData.startAddress () + serverData.valueCount ())) {
483484
484- int offset = startAddress - unit .startAddress ();
485+ const int offset = startAddress - serverData .startAddress ();
485486
486487 QVector<quint16> values;
487488 for (int i = 0 ; i < length; ++i) {
488- values.append (unit .value (offset + i));
489+ values.append (serverData .value (offset + i));
489490 }
490491
491492 dataUnit.setValues (values);
@@ -506,9 +507,13 @@ void FormModSim::startSimulation(QModbusDataUnit::RegisterType type, quint16 add
506507 _dataSimulator->startSimulation (dataDisplayMode (), type, addr, params);
507508}
508509
509- void FormModSim::configureModbusDataUnit (QModbusDataUnit::RegisterType type,
510- quint16 startAddress,
511- const QVector<quint16>& values) const
510+ // /
511+ // / \brief FormModSim::configureModbusDataUnit
512+ // / \param type
513+ // / \param startAddress
514+ // / \param values
515+ // /
516+ void FormModSim::configureModbusDataUnit (QModbusDataUnit::RegisterType type, quint16 startAddress, const QVector<quint16>& values) const
512517{
513518 QModbusDataUnit unit;
514519 unit.setRegisterType (type);
0 commit comments