Warning, /sdk/cutehmi/extensions/CuteHMI/Examples/Modbus/Requests.3/DiagnosticsControl.qml is written in an unsupported language. File is not indexed.

0001 import QtQml.Models 2.12
0002 import QtQuick 2
0003 import QtQuick.Controls 2.0
0004 import QtQuick.Layouts 1.0
0005 
0006 import CuteHMI.Modbus 4.0
0007 
0008 RowLayout {
0009         property AbstractDevice device
0010 
0011         property int diagnosticsData
0012 
0013         Button {
0014                 text: "Diagnostics"
0015                 onClicked: device.requestDiagnostics(subfunctionBox.value, parent.diagnosticsData)
0016         }
0017 
0018         Label {
0019                 text: qsTr("Subfunction:")
0020         }
0021 
0022         ComboBox {
0023                 id: subfunctionBox
0024 
0025                 implicitWidth: 250
0026                 textRole: "key"
0027                 model: ListModel {
0028                         ListElement { key: qsTr("Return query data"); value: AbstractDevice.DIAGNOSTICS_RETURN_QUERY_DATA }
0029                         ListElement { key: qsTr("Restart communications option"); value: AbstractDevice.DIAGNOSTICS_RESTART_COMM_OPTION }
0030                         ListElement { key: qsTr("Return diagnostics register"); value: AbstractDevice.DIAGNOSTICS_RETURN_DIAGNOSTICS_REGISTER }
0031                         ListElement { key: qsTr("Change ASCII input delimiter"); value: AbstractDevice.DIAGNOSTICS_CHANGE_ASCII_INPUT_DELIMITER }
0032                         ListElement { key: qsTr("Force listen only mode"); value: AbstractDevice.DIAGNOSTICS_FORCE_LISTEN_ONLY_MODE }
0033                         ListElement { key: qsTr("Clear counters and diagnostic register"); value: AbstractDevice.DIAGNOSTICS_CLEAR_COUNTERS_AND_DIAGNOSTICS_REGISTER }
0034                         ListElement { key: qsTr("Return bus message count"); value: AbstractDevice.DIAGNOSTICS_RETURN_BUS_MESSAGE_COUNT }
0035                         ListElement { key: qsTr("Return bus communication error count"); value: AbstractDevice.DIAGNOSTICS_RETURN_BUS_COMM_ERROR_COUNT }
0036                         ListElement { key: qsTr("Return bus exception error count"); value: AbstractDevice.DIAGNOSTICS_RETURN_BUS_EXCEPTION_ERROR_COUNT }
0037                         ListElement { key: qsTr("Return slave message count"); value: AbstractDevice.DIAGNOSTICS_RETURN_SLAVE_MESSAGE_COUNT }
0038                         ListElement { key: qsTr("Return slave no response count"); value: AbstractDevice.DIAGNOSTICS_RETURN_SLAVE_NO_RESPONSE_COUNT }
0039                         ListElement { key: qsTr("Return slave NAK count"); value: AbstractDevice.DIAGNOSTICS_RETURN_SLAVE_NAK_COUNT }
0040                         ListElement { key: qsTr("Return slave busy count"); value: AbstractDevice.DIAGNOSTICS_RETURN_SLAVE_BUSY_COUNT }
0041                         ListElement { key: qsTr("Return bus character overrun count"); value: AbstractDevice.DIAGNOSTICS_RETURN_BUS_CHARACTER_OVERRUN_COUNT }
0042                         ListElement { key: qsTr("Return IOP overrun count"); value: AbstractDevice.DIAGNOSTICS_RETURN_IOP_OVERRUN_COUNT }
0043                         ListElement { key: qsTr("Clear overrun counter and flag"); value: AbstractDevice.DIAGNOSTICS_CLEAR_OVERRUN_COUNTER_AND_FLAG }
0044                         ListElement { key: qsTr("Get/Clear modbus plus statistics"); value: AbstractDevice.DIAGNOSTICS_GET_CLEAR_MODBUS_PLUS_STATISTICS }
0045                 }
0046 
0047                 property int value: model.get(currentIndex).value
0048 
0049                 onActivated: value = model.get(index).value
0050         }
0051 
0052         Label {
0053                 text: qsTr("Data:")
0054         }
0055 
0056         TextField {
0057                 text: parent.diagnosticsData
0058                 validator: IntValidator {
0059                         bottom: 0
0060                         top: 65535
0061                 }
0062 
0063                 onAccepted: parent.diagnosticsData = Number.fromLocaleString(locale, text)
0064         }
0065 
0066         Label {
0067                 text: qsTr("Data (hex):")
0068         }
0069 
0070         TextField {
0071                 text: "0x" + parent.diagnosticsData.toString(16)
0072                 validator: RegularExpressionValidator {
0073                         regularExpression: /0x[0-9A-Fa-f]{1,4}/
0074                 }
0075 
0076                 onAccepted: parent.diagnosticsData = parseInt(text)
0077         }
0078 }
0079 
0080 //(c)C: Copyright © 2022-2024, Michał Policht <michal@policht.pl>. All rights reserved.
0081 //(c)C: SPDX-License-Identifier: LGPL-3.0-or-later OR MIT
0082 //(c)C: This file is a part of CuteHMI.
0083 //(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
0084 //(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
0085 //(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI.  If not, see <https://www.gnu.org/licenses/>.
0086 //(c)C: Additionally, this file is licensed under terms of MIT license as expressed below.
0087 //(c)C: Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
0088 //(c)C: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
0089 //(c)C: THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.