* @brief Get current Modbus configuration */
| 625 | * @brief Get current Modbus configuration |
| 626 | */ |
| 627 | API::CommandResponse API::Handlers::ModbusHandler::getConfiguration(const QString& id, |
| 628 | const QJsonObject& params) |
| 629 | { |
| 630 | Q_UNUSED(params) |
| 631 | |
| 632 | auto* modbus = IO::ConnectionManager::instance().modbus(); |
| 633 | |
| 634 | QJsonObject result; |
| 635 | |
| 636 | result[QStringLiteral("protocolIndex")] = modbus->protocolIndex(); |
| 637 | const auto& protocolList = modbus->protocolList(); |
| 638 | if (modbus->protocolIndex() < protocolList.count()) |
| 639 | result[QStringLiteral("protocolName")] = protocolList.at(modbus->protocolIndex()); |
| 640 | |
| 641 | result[QStringLiteral("slaveAddress")] = modbus->slaveAddress(); |
| 642 | result[QStringLiteral("pollInterval")] = modbus->pollInterval(); |
| 643 | |
| 644 | result[QStringLiteral("host")] = modbus->host(); |
| 645 | result[QStringLiteral("port")] = modbus->port(); |
| 646 | |
| 647 | result[QStringLiteral("serialPortIndex")] = modbus->serialPortIndex(); |
| 648 | const auto& portList = modbus->serialPortList(); |
| 649 | if (modbus->serialPortIndex() < portList.count()) |
| 650 | result[QStringLiteral("serialPortName")] = portList.at(modbus->serialPortIndex()); |
| 651 | |
| 652 | result[QStringLiteral("baudRate")] = modbus->baudRate(); |
| 653 | |
| 654 | result[QStringLiteral("parityIndex")] = modbus->parityIndex(); |
| 655 | const auto& parityList = modbus->parityList(); |
| 656 | if (modbus->parityIndex() < parityList.count()) |
| 657 | result[QStringLiteral("parityName")] = parityList.at(modbus->parityIndex()); |
| 658 | |
| 659 | result[QStringLiteral("dataBitsIndex")] = modbus->dataBitsIndex(); |
| 660 | const auto& dataBitsList = modbus->dataBitsList(); |
| 661 | if (modbus->dataBitsIndex() < dataBitsList.count()) |
| 662 | result[QStringLiteral("dataBitsValue")] = dataBitsList.at(modbus->dataBitsIndex()); |
| 663 | |
| 664 | result[QStringLiteral("stopBitsIndex")] = modbus->stopBitsIndex(); |
| 665 | const auto& stopBitsList = modbus->stopBitsList(); |
| 666 | if (modbus->stopBitsIndex() < stopBitsList.count()) |
| 667 | result[QStringLiteral("stopBitsValue")] = stopBitsList.at(modbus->stopBitsIndex()); |
| 668 | |
| 669 | result[QStringLiteral("isOpen")] = modbus->isOpen(); |
| 670 | result[QStringLiteral("configurationOk")] = modbus->configurationOk(); |
| 671 | |
| 672 | result[QStringLiteral("registerGroupCount")] = modbus->registerGroupCount(); |
| 673 | |
| 674 | return CommandResponse::makeSuccess(id, result); |
| 675 | } |
| 676 | |
| 677 | /** |
| 678 | * @brief Get list of supported protocols |
nothing calls this directly
no test coverage detected