Skip to content

Commit

Permalink
Show that Lynx BMS is waiting to connect to a parallel system
Browse files Browse the repository at this point in the history
 Fixes #1283
  • Loading branch information
DanielMcInnes committed Jul 5, 2024
1 parent ed8b5df commit b334476
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 14 deletions.
18 changes: 18 additions & 0 deletions data/common/Battery.qml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ Device {
readonly property real timeToGo: _timeToGo.value === undefined ? NaN : _timeToGo.value // in seconds
readonly property string icon: !!Global.batteries ? Global.batteries.batteryIcon(battery) : ""
readonly property int mode: !!Global.batteries ? Global.batteries.batteryMode(battery) : -1
readonly property int n2kDeviceInstance: _n2kDeviceInstance.isValid ? _n2kDeviceInstance.value : NaN
readonly property int numberOfBmses: _numberOfBmses.isValid ? _numberOfBmses.value : NaN
readonly property bool isParallelBms: _numberOfBmses.isValid
readonly property bool state: _state.isValid ? _state.value : NaN

readonly property VeQuickItem _stateOfCharge: VeQuickItem {
uid: battery.serviceUid + "/Soc"
Expand All @@ -41,4 +45,18 @@ Device {
readonly property VeQuickItem _timeToGo: VeQuickItem {
uid: battery.serviceUid + "/TimeToGo"
}

readonly property VeQuickItem _n2kDeviceInstance: VeQuickItem {
uid: battery.serviceUid + "/N2kDeviceInstance"
}

property VeQuickItem _numberOfBmses: VeQuickItem {
uid: battery.serviceUid + "/NumberOfBmses"
onValueChanged: console.log("*********************", uid, value)
}

property VeQuickItem _state: VeQuickItem {
uid: battery.serviceUid + "/State"
onValueChanged: console.log("*********************", uid, value)
}
}
18 changes: 13 additions & 5 deletions pages/settings/devicelist/DeviceListPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,17 @@ Page {
case "battery":
url = "/pages/settings/devicelist/battery/PageBattery.qml"
params = { "battery" : device }
summary = [
Units.getCombinedDisplayText(VenusOS.Units_Percentage, device.stateOfCharge),
Units.getCombinedDisplayText(VenusOS.Units_Volt_DC, device.voltage),
Units.getCombinedDisplayText(VenusOS.Units_Amp, device.current),
]
summary = (!device.isParallelBms && device.state === VenusOS.Battery_State_Pending)
? [
"Pending", // intentionally not translated to prevent overlap with the BMS name in case of long translations
Units.getCombinedDisplayText(VenusOS.Units_Volt_DC, device.voltage),
Units.getCombinedDisplayText(VenusOS.Units_Percentage, device.stateOfCharge)
]
: [
Units.getCombinedDisplayText(VenusOS.Units_Percentage, device.stateOfCharge),
Units.getCombinedDisplayText(VenusOS.Units_Volt_DC, device.voltage),
Units.getCombinedDisplayText(VenusOS.Units_Amp, device.current),
]
break;

case "solarcharger":
Expand Down Expand Up @@ -228,7 +234,9 @@ Page {
: null

text: model.cachedDeviceDescription
onTextChanged: console.log("********************* text:", text, "model.device.serviceUid:", model.device.serviceUid)
textModel: model.connected && _displayInfo ? _displayInfo.summary || [] : [ CommonWords.not_connected ]
onTextModelChanged: console.log("********************* textModel:", textModel)
down: deviceMouseArea.containsPress
allowed: _displayInfo !== null

Expand Down
30 changes: 21 additions & 9 deletions pages/settings/devicelist/battery/PageBattery.qml
Original file line number Diff line number Diff line change
Expand Up @@ -41,33 +41,37 @@ Page {
return qsTrId("devicelist_battery_initializing")
}
switch (dataItem.value) {
case 9:
case VenusOS.Battery_State_Running:
return CommonWords.running_status
case 10:
case VenusOS.Battery_State_Error:
return CommonWords.error
// case 11 (Unknown) is omitted
case 12:
// case Battery_State_Unknown is omitted
case VenusOS.Battery_State_Shutdown:
//: Status is 'Shutdown'
//% "Shutdown"
return qsTrId("devicelist_battery_shutdown")
case 13:
case VenusOS.Battery_State_Updating:
//: Status is 'Updating'
//% "Updating"
return qsTrId("devicelist_battery_updating")
case 14:
case VenusOS.Battery_State_Standby:
return CommonWords.standby
case 15:
case VenusOS.Battery_State_GoingToRun:
//: Status is 'Going to run'
//% "Going to run"
return qsTrId("devicelist_battery_going_to_run")
case 16:
case VenusOS.Battery_State_Precharging:
//: Status is 'Pre-Charging'
//% "Pre-Charging"
return qsTrId("devicelist_battery_pre_charging")
case 17:
case VenusOS.Battery_State_ContactorCheck:
//: Status is 'Contactor check'
//% "Contactor check"
return qsTrId("devicelist_battery_contactor_check")
case VenusOS.Battery_State_Pending:
//: Status is 'Pending'
//% "Pending"
return qsTrId("devicelist_battery_pending")
default:
return ""
}
Expand Down Expand Up @@ -127,6 +131,14 @@ Page {
unit: VenusOS.Units_AmpHour
}

ListQuantityItem {
//% "System voltage"
text: qsTrId("devicelist_battery_system_voltage")
dataItem.uid: root.battery.serviceUid + "/Dc/0/Voltage"
allowed: defaultAllowed && root.battery.state === VenusOS.Battery_State_Pending
unit: VenusOS.Units_Volt_DC
}

ListTextItem {
id: numberOfBms
//% "Number of BMSes"
Expand Down
14 changes: 14 additions & 0 deletions src/enums.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,20 @@ class Enums : public QObject
};
Q_ENUM(Battery_Mode)

enum Battery_State {
Battery_State_Running = 9,
Battery_State_Error = 10,
Battery_State_Unknown = 11,
Battery_State_Shutdown = 12,
Battery_State_Updating = 13,
Battery_State_Standby = 14,
Battery_State_GoingToRun = 15,
Battery_State_Precharging = 16,
Battery_State_ContactorCheck = 17,
Battery_State_Pending = 18
};
Q_ENUM(Battery_State)

enum Battery_TimeToGo_Format {
Battery_TimeToGo_ShortFormat,
Battery_TimeToGo_LongFormat
Expand Down

0 comments on commit b334476

Please sign in to comment.