Added fault state popup

This commit is contained in:
Yury Shuvakin
2023-03-26 23:45:49 +03:00
parent 960dd6ba88
commit 649c9ed2a0
19 changed files with 715 additions and 85 deletions

12
qml/Icons/error-state.svg Normal file
View File

@@ -0,0 +1,12 @@
<svg width="24" height="25" viewBox="0 0 24 25" fill="none" xmlns="http://www.w3.org/2000/svg">
<g clip-path="url(#clip0_1401_2121)">
<circle cx="12" cy="12.5" r="11" stroke="#CF3200" stroke-width="2"/>
<path d="M12 6.5L12 14.5" stroke="#CF3200" stroke-width="2"/>
<path d="M12 16L12 18" stroke="#CF3200" stroke-width="2" stroke-linejoin="round"/>
</g>
<defs>
<clipPath id="clip0_1401_2121">
<rect width="24" height="24" fill="white" transform="translate(0 0.5)"/>
</clipPath>
</defs>
</svg>

After

Width:  |  Height:  |  Size: 492 B

12
qml/Icons/good-state.svg Normal file
View File

@@ -0,0 +1,12 @@
<svg width="24" height="25" viewBox="0 0 24 25" fill="none" xmlns="http://www.w3.org/2000/svg">
<g clip-path="url(#clip0_1401_2104)">
<path d="M6 12.95L9.85714 17L18 8" stroke="#009352" stroke-width="2" stroke-linejoin="round"/>
<circle cx="12" cy="12.5" r="11" stroke="#009352" stroke-width="2"/>
</g>
<defs>
<clipPath id="clip0_1401_2104">
<rect width="24" height="24" fill="white" transform="translate(0 0.5)"/>
</clipPath>
</defs>
</svg>

After

Width:  |  Height:  |  Size: 443 B

12
qml/Icons/info-state.svg Normal file
View File

@@ -0,0 +1,12 @@
<svg width="24" height="25" viewBox="0 0 24 25" fill="none" xmlns="http://www.w3.org/2000/svg">
<g clip-path="url(#clip0_1401_2130)">
<path d="M12 23.5V24.5V23.5ZM12 1.5V0.5V1.5ZM1 12.5H0H1ZM2.65602 18.3044L3.60879 18.6081C3.69622 18.3338 3.66119 18.0351 3.51265 17.7885L2.65602 18.3044ZM1 23.5L0.0472261 23.1963C-0.0638084 23.5447 0.0241315 23.9259 0.276556 24.1904C0.52898 24.4549 0.905642 24.5606 1.25881 24.4659L1 23.5ZM6.5 22.0263L6.99158 21.1555C6.76354 21.0268 6.49412 20.9926 6.24119 21.0604L6.5 22.0263ZM2.5 18.0453L1.63627 18.5495L1.64336 18.5612L2.5 18.0453ZM6.68517 22.1308L6.19357 23.0017L6.20203 23.0064L6.68517 22.1308ZM12 24.5C15.1826 24.5 18.2348 23.2357 20.4853 20.9853L19.0711 19.5711C17.1957 21.4464 14.6522 22.5 12 22.5V24.5ZM20.4853 20.9853C22.7357 18.7348 24 15.6826 24 12.5H22C22 15.1522 20.9464 17.6957 19.0711 19.5711L20.4853 20.9853ZM24 12.5C24 9.3174 22.7357 6.26516 20.4853 4.01472L19.0711 5.42893C20.9464 7.3043 22 9.84783 22 12.5H24ZM20.4853 4.01472C18.2348 1.76428 15.1826 0.5 12 0.5V2.5C14.6522 2.5 17.1957 3.55357 19.0711 5.42893L20.4853 4.01472ZM12 0.5C8.8174 0.5 5.76516 1.76428 3.51472 4.01472L4.92893 5.42893C6.8043 3.55357 9.34784 2.5 12 2.5V0.5ZM3.51472 4.01472C1.26428 6.26516 0 9.3174 0 12.5H2C2 9.84784 3.05357 7.3043 4.92893 5.42893L3.51472 4.01472ZM1.70324 18.0007L0.0472261 23.1963L1.95277 23.8037L3.60879 18.6081L1.70324 18.0007ZM1.25881 24.4659L6.75881 22.9922L6.24119 21.0604L0.741187 22.5341L1.25881 24.4659ZM0 12.5C0 14.6441 0.573832 16.729 1.63635 18.5494L3.36365 17.5412C2.47814 16.0241 2 14.2867 2 12.5H0ZM6.20203 23.0064C7.96181 23.9775 9.95397 24.5 12 24.5V22.5C10.295 22.5 8.63494 22.0646 7.16831 21.2553L6.20203 23.0064ZM1.64336 18.5612L1.79938 18.8203L3.51265 17.7885L3.35664 17.5294L1.64336 18.5612ZM6.00842 22.8971L6.19359 23.0017L7.17675 21.26L6.99158 21.1555L6.00842 22.8971Z" fill="#0A72BA"/>
<path d="M7.25 10.75H16.75" stroke="#0A72BA" stroke-width="2" stroke-linejoin="round"/>
<path d="M7.25 14.25H13.75" stroke="#0A72BA" stroke-width="2" stroke-linejoin="round"/>
</g>
<defs>
<clipPath id="clip0_1401_2130">
<rect width="24" height="24" fill="white" transform="translate(0 0.5)"/>
</clipPath>
</defs>
</svg>

After

Width:  |  Height:  |  Size: 2.1 KiB

View File

@@ -0,0 +1,12 @@
<svg width="24" height="25" viewBox="0 0 24 25" fill="none" xmlns="http://www.w3.org/2000/svg">
<g clip-path="url(#clip0_1401_2140)">
<circle cx="12" cy="12.5" r="11" stroke="#838D97" stroke-width="2"/>
<path d="M12 18L12 10" stroke="#838D97" stroke-width="2"/>
<path d="M12 8.5L12 6.5" stroke="#838D97" stroke-width="2" stroke-linejoin="round"/>
</g>
<defs>
<clipPath id="clip0_1401_2140">
<rect width="24" height="24" fill="white" transform="translate(0 0.5)"/>
</clipPath>
</defs>
</svg>

After

Width:  |  Height:  |  Size: 491 B

View File

@@ -0,0 +1,12 @@
<svg width="24" height="25" viewBox="0 0 24 25" fill="none" xmlns="http://www.w3.org/2000/svg">
<g clip-path="url(#clip0_1401_2112)">
<path d="M12 23.5V24.5V23.5ZM12 1.5V0.5V1.5ZM1 12.5H0H1ZM2.65602 18.3044L3.60879 18.6081C3.69622 18.3338 3.66119 18.0351 3.51265 17.7885L2.65602 18.3044ZM1 23.5L0.0472261 23.1963C-0.0638084 23.5447 0.0241315 23.9259 0.276556 24.1904C0.52898 24.4549 0.905642 24.5606 1.25881 24.4659L1 23.5ZM6.5 22.0263L6.99158 21.1555C6.76354 21.0268 6.49412 20.9926 6.24119 21.0604L6.5 22.0263ZM2.5 18.0453L1.63627 18.5495L1.64336 18.5612L2.5 18.0453ZM6.68517 22.1308L6.19357 23.0017L6.20203 23.0064L6.68517 22.1308ZM12 24.5C15.1826 24.5 18.2348 23.2357 20.4853 20.9853L19.0711 19.5711C17.1957 21.4464 14.6522 22.5 12 22.5V24.5ZM20.4853 20.9853C22.7357 18.7348 24 15.6826 24 12.5H22C22 15.1522 20.9464 17.6957 19.0711 19.5711L20.4853 20.9853ZM24 12.5C24 9.3174 22.7357 6.26516 20.4853 4.01472L19.0711 5.42893C20.9464 7.3043 22 9.84783 22 12.5H24ZM20.4853 4.01472C18.2348 1.76428 15.1826 0.5 12 0.5V2.5C14.6522 2.5 17.1957 3.55357 19.0711 5.42893L20.4853 4.01472ZM12 0.5C8.8174 0.5 5.76516 1.76428 3.51472 4.01472L4.92893 5.42893C6.8043 3.55357 9.34784 2.5 12 2.5V0.5ZM3.51472 4.01472C1.26428 6.26516 0 9.3174 0 12.5H2C2 9.84784 3.05357 7.3043 4.92893 5.42893L3.51472 4.01472ZM1.70324 18.0007L0.0472261 23.1963L1.95277 23.8037L3.60879 18.6081L1.70324 18.0007ZM1.25881 24.4659L6.75881 22.9922L6.24119 21.0604L0.741187 22.5341L1.25881 24.4659ZM0 12.5C0 14.6441 0.573832 16.729 1.63635 18.5494L3.36365 17.5412C2.47814 16.0241 2 14.2867 2 12.5H0ZM6.20203 23.0064C7.96181 23.9775 9.95397 24.5 12 24.5V22.5C10.295 22.5 8.63494 22.0646 7.16831 21.2553L6.20203 23.0064ZM1.64336 18.5612L1.79938 18.8203L3.51265 17.7885L3.35664 17.5294L1.64336 18.5612ZM6.00842 22.8971L6.19359 23.0017L7.17675 21.26L6.99158 21.1555L6.00842 22.8971Z" fill="#E6C207"/>
<path d="M12 6.5L12 14.5" stroke="#E6C207" stroke-width="2"/>
<path d="M12 16L12 18" stroke="#E6C207" stroke-width="2" stroke-linejoin="round"/>
</g>
<defs>
<clipPath id="clip0_1401_2112">
<rect width="24" height="24" fill="white" transform="translate(0 0.5)"/>
</clipPath>
</defs>
</svg>

After

Width:  |  Height:  |  Size: 2.1 KiB

View File

@@ -353,11 +353,16 @@ ApplicationWindow {
onPortConnectedChanged: {
connectionStatusLabel.text = Qt.binding(function(){ return BmsInterface.isPortConnected() ? qsTr("Connected") : qsTr("Disconnected") })
connectionStatusIndicator.enabled = BmsInterface.isPortConnected()
faultStateTimer.running = BmsInterface.isPortConnected()
if (BmsInterface.isPortConnected()) {
BmsInterface.commands().getBMSconf()
BmsInterface.commands().getFaultState()
} else {
serialLabel.text = "-"
firmwareLabel.text = "-"
statusPopup.queue = []
faultStatePopup.lastState = ""
}
}
@@ -419,6 +424,17 @@ ApplicationWindow {
onFwVersionReceived: {
firmwareLabel.text = major + "." + minor
}
onFaultStateReceived: {
if (faultStatePopup.lastState != faultString) {
faultStatePopup.close()
faultStatePopup.lastState = faultString
faultStatePopup.text = faultString
faultStatePopup.type = faultType
faultStatePopup.open()
Qt.callLater(debugScreen.printMessage, faultString, faultStatePopup.color)
}
}
}
Screens.ConnectionDialog {
@@ -457,12 +473,12 @@ ApplicationWindow {
onOpened: {
hideStatusTimer.start()
}
}
Timer {
id: hideStatusTimer
interval: 3000
onTriggered: statusPopup.close()
Timer {
id: hideStatusTimer
interval: 3000
onTriggered: statusPopup.close()
}
}
Popup {
@@ -505,6 +521,12 @@ ApplicationWindow {
onOpened: hideBusyTimer.start()
onClosed: hideBusyTimer.stop()
Timer {
id: hideBusyTimer
interval: 30000
onTriggered: busyPopup.close()
}
}
Popup {
@@ -549,10 +571,29 @@ ApplicationWindow {
}
}
Timer {
id: hideBusyTimer
interval: 30000
onTriggered: busyPopup.close()
Screens.StatePopup {
id: faultStatePopup
x: parent.width - width - 45
y: 18
property var lastState: ""
onOpened: {
hideStateTimer.start()
}
Timer {
id: hideStateTimer
interval: 3000
onTriggered: faultStatePopup.close()
}
Timer {
id: faultStateTimer
interval: 50000
repeat: true
onTriggered: BmsInterface.commands().getFaultState()
}
}
background: Rectangle {
@@ -561,6 +602,6 @@ ApplicationWindow {
Component.onCompleted: {
connectionDialog.open()
Qt.callLater(debugScreen.printMessage, qsTr("Tool started"), true)
Qt.callLater(debugScreen.printMessage, qsTr("Tool started"))
}
}

View File

@@ -37,23 +37,15 @@ ColumnLayout {
Connections {
target: BmsInterface
onStatusMessage: printMessage(msg, isGood)
onPortConnectedChanged: printMessage(BmsInterface.getConnectedPortName(), true)
onStatusMessage: printMessage(msg, isGood ? Palette.textColor : Palette.invalidColor)
onPortConnectedChanged: printMessage(BmsInterface.getConnectedPortName())
}
function printMessage(msg, isGood) {
var message = ""
if (!isGood) {
message += "<font color=\"" + Palette.invalidColor + "\">"
}
function printMessage(msg, color = Palette.textColor) {
var message = "<font color=\"" + color + "\">"
message += new Date().toLocaleString(Qt.locale("en-US"), "dd.MM.yyyy hh:mm:ss") + ": " + msg
if (!isGood) {
message += "</font>"
}
message += "</font>"
message += "<br>"
outputArea.insert(outputArea.length, message)

View File

@@ -0,0 +1,97 @@
import QtQuick 2.12
import QtQuick.Controls 2.12
import QtQuick.Layouts 1.12
import Controls 1.0 as Controls
import Cubo 1.0
import Utils 1.0
Popup {
id: root
closePolicy: Popup.NoAutoClose
property string text: ""
property var type: DataTypes.StateType.Info
property color color: switch (type) {
case DataTypes.StateType.Info:
return "#0A72BA"
case DataTypes.StateType.Good:
return "#009352"
case DataTypes.StateType.Warning:
return "#E5C207"
case DataTypes.StateType.Error:
return "#CF3200"
case DataTypes.StateType.Neutral:
default:
return "#838D97"
}
property var icon: switch (type) {
case DataTypes.StateType.Info:
return "qrc:/Icons/info-state.svg"
case DataTypes.StateType.Good:
return "qrc:/Icons/good-state.svg"
case DataTypes.StateType.Warning:
return "qrc:/Icons/warning-state.svg"
case DataTypes.StateType.Error:
return "qrc:/Icons/error-state.svg"
case DataTypes.StateType.Neutral:
default:
return "qrc:/Icons/neutral-state.svg"
}
RowLayout {
spacing: 15
Image {
source: root.icon
Layout.leftMargin: 5
}
Controls.SubtitleLabel {
id: label
text: root.text
maximumLineCount: 10
wrapMode: Text.Wrap
}
}
background: Rectangle {
radius: 6
color: "#F7F8FC"
Rectangle {
radius: 6
anchors.fill: parent
color: Qt.rgba(root.color.r, root.color.g, root.color.b, 0.1)
}
Rectangle {
radius: 6
width: 4
height: parent.height
anchors.left: parent.left
color: root.color
}
}
enter: Transition {
NumberAnimation {
property: "opacity"
from: 0.0
to: 1.0
duration: 300
}
}
exit: Transition {
NumberAnimation {
property: "opacity"
from: 1.0
to: 0.0
duration: 2500
}
}
}

View File

@@ -14,3 +14,4 @@ NetworkSettingsScreen 1.0 NetworkSettingsScreen.qml
TimeSettingsScreen 1.0 TimeSettingsScreen.qml
CanSettingsScreen 1.0 CanSettingsScreen.qml
TemperatureMonitorScreen 1.0 TemperatureMonitorScreen.qml
StatePopup 1.0 StatePopup.qml

View File

@@ -19,5 +19,10 @@
<file>Icons/russian-flag.svg</file>
<file>Icons/refresh.svg</file>
<file>Icons/temperature.svg</file>
<file>Icons/error-state.svg</file>
<file>Icons/good-state.svg</file>
<file>Icons/info-state.svg</file>
<file>Icons/neutral-state.svg</file>
<file>Icons/warning-state.svg</file>
</qresource>
</RCC>

View File

@@ -49,5 +49,6 @@
<file>Controls/RadioButton.qml</file>
<file>Screens/TemperatureMonitorScreen.qml</file>
<file>Screens/CanSettingsScreen.qml</file>
<file>Screens/StatePopup.qml</file>
</qresource>
</RCC>