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 26, 2024
1 parent c53a528 commit c66b595
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 14 deletions.
3 changes: 3 additions & 0 deletions components/CommonWords.qml
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,9 @@ QtObject {
//% "Overall history"
readonly property string overall_history: qsTrId("common_words_overall_history")

//% "Pending"
readonly property string pending: qsTrId("common_words_pending")

//% "Password"
readonly property string password: qsTrId("common_words_password")

Expand Down
11 changes: 11 additions & 0 deletions data/common/Battery.qml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ 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 string numberOfBmses: _numberOfBmses.isValid ? _numberOfBmses.value : "" // eg. "1/2"
readonly property bool isParallelBms: _numberOfBmses.isValid
readonly property int state: _state.isValid ? _state.value : NaN

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

property VeQuickItem _numberOfBmses: VeQuickItem {
uid: battery.serviceUid + "/NumberOfBmses"
}

property VeQuickItem _state: VeQuickItem {
uid: battery.serviceUid + "/State"
}
}
16 changes: 11 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)
? [
CommonWords.pending,
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
32 changes: 23 additions & 9 deletions pages/settings/devicelist/battery/PageBattery.qml
Original file line number Diff line number Diff line change
Expand Up @@ -42,33 +42,35 @@ 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:
return CommonWords.pending
default:
return ""
}
Expand Down Expand Up @@ -128,6 +130,18 @@ Page {
unit: VenusOS.Units_AmpHour
}

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

//% "System voltage"
text: qsTrId("devicelist_battery_system_voltage")
dataItem.uid: BackendConnection.serviceUidForType("battery.lynxparallel") + _n2kDeviceInstance.value + "/Dc/0/Voltage"
allowed: defaultAllowed && _n2kDeviceInstance.isValid && 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 c66b595

Please sign in to comment.