-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for DC gensets #1435
Conversation
ae56c39
to
b5ecad9
Compare
b5ecad9
to
a81fdcd
Compare
I haven't been able to test the dc-generator-specific changes with mqtt / wasm, only with dbus via the latest venus-docker simulations 'gdf' and 'gdh'. |
components/PageGensetModel.qml
Outdated
@@ -32,7 +33,9 @@ ObjectModel { | |||
} | |||
} | |||
|
|||
readonly property var nrOfPhases: VeQuickItem { | |||
readonly property bool dcGenset: serviceType === "dcgenset" | |||
readonly property int nrOfPhases: phases.valid ? phases.value : dcGenset ? 0 : 3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style nit: would prefer this to be broken over 3 lines, e.g.:
readonly property int nrOfPhases: phases.valid ? phases.value
: dcGenset ? 0
: 3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be phases.isValid
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes it should be, thanks Bea.
Style nit fixed also
} else { | ||
summary = [ gensetPowerText ] | ||
} | ||
break; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style nit: for consistency, put an empty whitespace line after the break
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@@ -0,0 +1,59 @@ | |||
/* | |||
** Copyright (C) 2023 Victron Energy B.V. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
components/PageGensetModel.qml
Outdated
text: qsTrId("genset_bms_control") | ||
secondaryText: CommonWords.press_to_reset | ||
visible: defaultAllowed && bmsControlled.dataItem.value === 1 | ||
// TODO: gui-v1 has "cornerMark: true" for this button. What does this mean? Does gui-v2 support this? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like it's just an icon in the bottom-right hand corner of the button, which will change colour if the list item to which it belongs is the currently selected list item. It looks like it's mostly set to true for items which are editable, or activatable (e.g. slider). I suspect it's just to visualise the fact that the item is interactable in some way.
I don't think we need it, as in gui-v2 we have blue borders for interactable things, generally, and we (hopefully) visualize disabled items with grey instead.
components/PageGensetModel.qml
Outdated
} | ||
|
||
ListSpinBox { | ||
text: CommonWords.charge_current |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I would have assumed the string to be "Charge current limit" rather than "Charge current" (i.e. the maximum current which should be generated by the genset when charging the battery) but perhaps I am misunderstanding?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated as suggested. It is "Charge current" in gui-v1, but I think you are right
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have made some initial comments; I'll try to test against the gui-v1 version to check that as well.
components/PageGensetModel.qml
Outdated
@@ -32,7 +33,9 @@ ObjectModel { | |||
} | |||
} | |||
|
|||
readonly property var nrOfPhases: VeQuickItem { | |||
readonly property bool dcGenset: serviceType === "dcgenset" | |||
readonly property int nrOfPhases: phases.valid ? phases.value : dcGenset ? 0 : 3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be phases.isValid
?
components/PageGensetModel.qml
Outdated
readonly property var nrOfPhases: VeQuickItem { | ||
readonly property bool dcGenset: serviceType === "dcgenset" | ||
readonly property int nrOfPhases: phases.valid ? phases.value : dcGenset ? 0 : 3 | ||
readonly property var phases: VeQuickItem { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this need to be a property
or can it just be a child item?
If it needs to be a property then it can be strongly typed as a VeQuickItem
type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to be a property, changed type to VeQuickItem for strong typing
components/PageGensetModel.qml
Outdated
//% "BMS Controlled" | ||
text: qsTrId("genset_bms_controlled") | ||
dataItem.uid: root.bindPrefix + "/Settings/BmsPresent" | ||
enabled: false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can just make this a ListTextItem
if it's not actually clickable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
components/PageGensetModel.qml
Outdated
allowed: defaultAllowed && dataItem.isValid | ||
} | ||
|
||
ListTextItem { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this could be a ListLabel instead, and placed as a caption within the bmsControlled
component (using bottomContent
) since it's only visible when that is enabled.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
components/PageGensetModel.qml
Outdated
dataItem.uid: root.bindPrefix + "/Settings/ChargeVoltage" | ||
decimals: 1 | ||
stepSize: 0.1 | ||
suffix: "V" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can fetch from units.cpp instead of hardcoding, e.g. Units.defaultUnitString(VenusOS.Units_Volt)
Similarly for other suffix values elsewhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
components/PageGensetModel.qml
Outdated
@@ -91,7 +94,7 @@ ObjectModel { | |||
text: qsTrId("ac-in-genset_error") | |||
dataItem.uid: root.bindPrefix + "/ErrorCode" | |||
allowed: defaultAllowed && dataItem.isValid | |||
nrOfPhases: root.nrOfPhases.value || 3 | |||
nrOfPhases: root.nrOfPhases |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed this part of #1377 hasn't been done yet: port "Refactored MbItemFpGensetError to MbItemGensetError" to gui-v2
The main thing there is to rewrite ListFpGensetErrorItem
so that it fetches the error description from GensetError
instead of having a massive switch statement for the secondaryText
. Note that GensetError
will need to be registered as a QML type, similar to what's done for ChargerError
and WakespeedError
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ListFpGensetErrorItem has been deleted in main, so I guess this goes away until we need to translate a generator error code
Did some more checking via venus-docker instead. The pages all seem fine, I noticed various warnings like these:
Which I think is just due to a lack of checks on whether |
a81fdcd
to
815f04a
Compare
815f04a
to
fef8e19
Compare
1ead03b
to
f4eb315
Compare
I can't reproduce this, I think it may have been fixed. Would you mind checking again? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, modulo those invalid uid part warnings which Bea mentioned - @blammit could you double check whether those are fixed?
readonly property bool dcGenset: serviceType === "dcgenset" | ||
readonly property int nrOfPhases: phases.valid ? phases.value | ||
: dcGenset ? 0 | ||
: 3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
valid
-> isValid
Also could we just have readonly property int nrOfPhases: phases.isValid ? phases.value : (dcGenset ? 0 : 3)
to avoid the odd indentation?
[Edit: I see that @chriadam suggested this change to go over multiple lines ... hm. I wish this could be done without such massive indentation]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After changing this to isValid
, I get this error:
<Unknown File>: Can't create role for unsupported data type
Any ideas?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a ListModel involved somewhere? I think it can serve ListElement entries or JS objects which have only QML basic type properties, and not more complex JavaScript types (including arrays).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Long shot, but does explicitly qualifying to root.phases
make any difference? It shouldn't, of course.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's something to do with GensetErrorModel
, I'll figure it out
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed, ListModel was complaining about setting an element's value to undefined
@DanielMcInnes I can't reproduce those anymore, but when running with the 'gdh' simulation, if I click "Hatz Genset" in the Device List and then "Settings", there is a warning:
... hang on, this is only when running via MQTT. Let me see, I think this is related to the GensetService check in PageGensetModel. [Edit: I will add a comment to |
@@ -12,6 +12,7 @@ ObjectModel { | |||
property string bindPrefix | |||
property string settingsBindPrefix: Global.systemSettings.serviceUid + "/Settings/Generator1" | |||
property string startStopBindPrefix: startStop1Uid | |||
readonly property string serviceType: BackendConnection.serviceTypeFromUid(bindPrefix) | |||
|
|||
// On D-Bus, the startstop1 generator is at com.victronenergy.generator.startstop1. | |||
// On MQTT, the startstop1 generator is the one with GensetService=com.victronenergy.genset.* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This part needs to be updated to check for the "dcgenset" service as well, for MQTT backends. Basically, on MQTT we need to find a generator with a matching GensetService
, because we don't have a straightforward way to find the startstop1 service there, unlike on a D-Bus backend. Here is a patch that seems to fix this, from testing via MQTT with the gdh
simulation:
diff --git a/components/PageGensetModel.qml b/components/PageGensetModel.qml
index b386ae1e..66aeb72e 100644
--- a/components/PageGensetModel.qml
+++ b/components/PageGensetModel.qml
@@ -16,6 +16,7 @@ ObjectModel {
// On D-Bus, the startstop1 generator is at com.victronenergy.generator.startstop1.
// On MQTT, the startstop1 generator is the one with GensetService=com.victronenergy.genset.*
+ // (or GensetService=com.victronenergy.dcgenset.* if this is a dcgenset)
readonly property string startStop1Uid: BackendConnection.type === BackendConnection.MqttSource
? generatorWithGensetService
: BackendConnection.uidPrefix() + "/com.victronenergy.generator.startstop1"
@@ -26,7 +27,8 @@ ObjectModel {
delegate: VeQuickItem {
uid: model.device.serviceUid + "/GensetService"
onValueChanged: {
- if (value !== undefined && value.startsWith("com.victronenergy.genset.")) {
+ if ( (isValid && root.dcGenset && value.startsWith("com.victronenergy.dcgenset."))
+ || (isValid && !root.dcGenset && value.startsWith("com.victronenergy.genset.")) ) {
root.generatorWithGensetService = model.device.serviceUid
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks Bea, updated as suggested.
53576e7
to
ba4194f
Compare
As per gui-v1 commit b20574be6c3be329e5452928ee03e521c1c0e94d
ba4194f
to
18e31de
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, lgtm :)
Fixes #1377