Skip to content

Commit

Permalink
add motor drive
Browse files Browse the repository at this point in the history
  • Loading branch information
kwindrem committed Oct 29, 2022
1 parent f13b257 commit 6ffb71f
Show file tree
Hide file tree
Showing 12 changed files with 401 additions and 28 deletions.
13 changes: 11 additions & 2 deletions FileSets/DcSystemRow.qml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ Row {
property bool showRpm: false
property bool showVoltage: false
property bool showCurrent: false
property string speedParam: "/Speed"
property string temperatureParam: "/Dc/0/Temperature"


Component.onCompleted:
{
Expand All @@ -43,6 +46,12 @@ Row {
useMonitorMode = true
positivePowerIsConsuming = true
}
else if (serviceType == DBusService.DBUS_SERVICE_MOTOR_DRIVE)
{
positivePowerIsConsuming = true
speedParam = "/Motor/RPM"
temperatureParam = "/Motor/Temperature"
}
}

// uses the same sizes as DetailsDcSystem page
Expand All @@ -58,8 +67,8 @@ Row {
VBusItem { id: dbusVoltageItem; bind: Utils.path (serviceName, "/Dc/0/Voltage") }
VBusItem { id: dbusCurrentItem; bind: Utils.path (serviceName, "/Dc/0/Current") }
VBusItem { id: dbusTemperatureItem; bind: Utils.path (serviceName, "/Dc/0/Temperature") }
VBusItem { id: stateItem; bind: Utils.path (serviceName, "/State") }
VBusItem { id: rpmItem; bind: Utils.path (serviceName, "/Speed") }
VBusItem { id: stateItem; bind: Utils.path (serviceName, temperatureParam) }
VBusItem { id: rpmItem; bind: Utils.path (serviceName, speedParam) }

// use system temperature scale if it exists (v2.90 onward) - otherwise use the GuiMods version
property VBusItem systemScaleItem: VBusItem { bind: "com.victronenergy.settings/Settings/System/Units/Temperature" }
Expand Down
147 changes: 147 additions & 0 deletions FileSets/DetailMotorDrive.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
////// detail page for displaying Motor Drive details
////// pushed from Flow overview

import QtQuick 1.1
import "utils.js" as Utils
import com.victron.velib 1.0
import "enhancedFormat.js" as EnhFmt

MbPage
{
id: root

title: "Motor Drive detail"

property variant sys: theSystem
property string systemPrefix: "com.victronenergy.system"
property color backgroundColor: "#b3b3b3"

property int rowTitleWidth: 130
property int tableColumnWidth: 100
property int totalDataWidth: tableColumnWidth * 3

VBusItem { id: motorDrivePowerItem; bind: Utils.path(systemPrefix, "/Dc/MotorDrive/Power") }

Component.onCompleted: discoverServices()

// background
Rectangle
{
anchors
{
fill: parent
}
color: root.backgroundColor
}

Row
{
spacing: 5
anchors.horizontalCenter: parent.horizontalCenter
anchors.top: parent.top; anchors.topMargin: + 10
Column
{
spacing: 2
Row
{
anchors.horizontalCenter: parent.horizontalCenter
Text { id: totalLabel; font.pixelSize: 12; font.bold: true; color: "black"
horizontalAlignment: Text.AlignRight
text: qsTr("Total Power") }
Text { font.pixelSize: 12; font.bold: true; color: "black"
width: tableColumnWidth; horizontalAlignment: Text.AlignHCenter
text: EnhFmt.formatVBusItem (motorDrivePowerItem, " W")
}
PowerGauge
{
id: gauge
width: (root.width * 0.8) - totalLabel.paintedWidth - tableColumnWidth
height: 15
connection: motorDrivePowerItem
maxForwardPowerParameter: "com.victronenergy.settings/Settings/GuiMods/GaugeLimits/MaxMotorDriveLoad"
maxReversePowerParameter: "com.victronenergy.settings/Settings/GuiMods/GaugeLimits/MaxMotorDriveCharge"
}
}
// vertical spacer
Row { Text { font.pixelSize: 12; width: rowTitleWidth; text: "" } }
Row
{
id: tableHeaderRow
anchors.horizontalCenter: parent.horizontalCenter
Text { font.pixelSize: 12; font.bold: true; color: "black"
width: rowTitleWidth; horizontalAlignment: Text.AlignHCenter
text: qsTr("Name") }
Text { font.pixelSize: 12; font.bold: true; color: "black"
width: tableColumnWidth; horizontalAlignment: Text.AlignHCenter
text: qsTr("Power") }
Text { font.pixelSize: 12; font.bold: true; color: "black"
width: tableColumnWidth; horizontalAlignment: Text.AlignHCenter
text: qsTr("Temperature") }
Text { font.pixelSize: 12; font.bold: true; color: "black"
width: tableColumnWidth; horizontalAlignment: Text.AlignHCenter
text: qsTr("RPM") }
}
}
}

// table of available alternators
ListView
{
id: theTable

anchors
{
top: root.top; topMargin: 60
horizontalCenter: root.horizontalCenter
}
width: tableHeaderRow.width
height: root.height - 60
interactive: true

model: dcModel
delegate: DcSystemRow
{
tableColumnWidth: root.tableColumnWidth
rowTitleWidth: root.rowTitleWidth
width: theTable.width
showTemperature: true
showRpm: true
Connections
{
target: scrollTimer
onTriggered: doScroll()
}
}
}

ListModel { id: dcModel }

// Synchronise name text scroll start
Timer
{
id: scrollTimer
interval: 5000
repeat: true
running: root.active
}

function addService(service)
{
switch (service.type)
{
case DBusService.DBUS_SERVICE_ALTERNATOR:
dcModel.append ( {serviceName: service.name, serviceType: service.type } )
break;;
}
}

// Detect available services of interest
function discoverServices()
{
dcModel.clear()
for (var i = 0; i < DBusServices.count; i++)
{
addService(DBusServices.at(i))
}
}
}
26 changes: 26 additions & 0 deletions FileSets/PageSettingsGuiModsGauges.qml
Original file line number Diff line number Diff line change
Expand Up @@ -240,5 +240,31 @@ MbPage {
show: showGauges.checked
writeAccessLevel: User.AccessInstaller
}
MbEditBox
{
description: qsTr ("Max Motor Drive load power")
maximumLength: 6
item.bind: Utils.path (bindPrefixGuiMods, "/GaugeLimits/MaxMotorDriveLoad")
matchString: "0123456789"
numericOnlyLayout: true
overwriteMode: false
unit: "W"
enableSpaceBar: true
show: showGauges.checked
writeAccessLevel: User.AccessInstaller
}
MbEditBox
{
description: qsTr ("Max Motor Drive charge power")
maximumLength: 6
item.bind: Utils.path (bindPrefixGuiMods, "/GaugeLimits/MaxMotorDriveCharge")
matchString: "0123456789"
numericOnlyLayout: true
overwriteMode: false
unit: "W"
enableSpaceBar: true
show: showGauges.checked
writeAccessLevel: User.AccessInstaller
}
}
}
62 changes: 55 additions & 7 deletions FileSets/v2.66/OverviewFlowComplex.qml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ OverviewPage {
property bool hasAcCharger: sys.acCharger != undefined && sys.acCharger.power.valid
property bool showAcCharger: (dcCoupled || !hasPvOnInput) && hasAcCharger

VBusItem { id: motorDrivePowerItem; bind: Utils.path(systemPrefix, "/Dc/MotorDrive/Power") }
property bool showMotorDrive: (dcCoupled || !hasLoadsOnInput) && ! showAlternator && motorDrivePowerItem.valid

property int bottomOffset: showTanksTemps ? 45 : 5
property int topOffset: showTanksTemps ? 1 : 5
property string settingsBindPreffix: "com.victronenergy.settings"
Expand Down Expand Up @@ -104,6 +107,7 @@ OverviewPage {
property double pvChargerFlow: showPvCharger ? noNoise (sys.pvCharger.power) : 0
property double dcSystemFlow: showDcSystem ? -noNoise (sys.dcSystem.power) : 0
property double alternatorFlow: showAlternator ? noNoise (sys.alternator.power) : 0
property double motorDriveFlow: showMotorDrive ? noNoise (motorDrivePowerItem) : 0
property double inverterDcFlow: showInverter ? noNoise (sys.vebusDc.power) : 0
property double batteryFlow: noNoise (sys.battery.power)
property double windGenFlow: noNoise (sys.windGenerator.power)
Expand Down Expand Up @@ -610,6 +614,50 @@ OverviewPage {
DetailTarget { id: alternatorTarget; detailsPage: "DetailAlternator.qml" }
}

OverviewBox
{
id: motorDriveBox
title: qsTr ("Motor Drive")
color: "#157894"
titleColor: "#419FB9"
height: inOutTileHeight
width: inOutTileWidth
opacity: showMotorDrive ? 1 : disabledTileOpacity
visible: showMotorDrive
anchors
{
left: root.left; leftMargin: 5
bottom: dcSystemBox.top; bottomMargin: 5
}
values: TileText {
text: EnhFmt.formatVBusItem (motorDrivePowerItem)
font.pixelSize: 17
visible: showMotorDrive
anchors
{
bottom: parent.bottom; bottomMargin: 0
horizontalCenter: parent.horizontalCenter
}
}
PowerGauge
{
id: motorDriveGauge
width: parent.width
height: 10
anchors
{
top: parent.top; topMargin: 20
horizontalCenter: parent.horizontalCenter
}
connection: motorDrivePowerItem
maxForwardPowerParameter: "com.victronenergy.settings/Settings/GuiMods/GaugeLimits/MaxMotorDriveLoad"
maxReversePowerParameter: "com.victronenergy.settings/Settings/GuiMods/GaugeLimits/MaxMotorDriveCharge"
show: showGauges && showMotorDrive
showLabels: true
}
DetailTarget { id: motorDriveTarget; detailsPage: "DetailMotorDrive.qml" }
}

VBusItem { id: dcSystemNameItem; bind: Utils.path(settingsPrefix, "/Settings/GuiMods/CustomDcSystemName") }

OverviewBox {
Expand Down Expand Up @@ -994,8 +1042,8 @@ OverviewPage {
id: dcBus1
ballCount: 1
path: straight
active: root.active && ((showAlternator || showDcSystem) || (dcCoupled && showInactiveFlow))
value: -Utils.sign (alternatorFlow + dcSystemFlow)
active: root.active && ((showAlternator || showMotorDrive || showDcSystem) || (dcCoupled && showInactiveFlow))
value: -Utils.sign (alternatorFlow + motorDriveFlow + dcSystemFlow)
startPointVisible: false
endPointVisible: false

Expand All @@ -1010,8 +1058,8 @@ OverviewPage {
id: dcBus2
ballCount: 1
path: straight
active: root.active && ((showAlternator || showAcCharger || showDcSystem) || (dcCoupled && showInactiveFlow))
value: Utils.sign (alternatorFlow + dcSystemFlow + acChargerFlow)
active: root.active && ((showAlternator || showMotorDrive || showAcCharger || showDcSystem) || (dcCoupled && showInactiveFlow))
value: Utils.sign (alternatorFlow + motorDriveFlow + dcSystemFlow + acChargerFlow)
startPointVisible: false
endPointVisible: false

Expand Down Expand Up @@ -1126,8 +1174,8 @@ OverviewPage {
id: alternatorConnection
ballCount: 1
path: straight
active: root.active && (showAlternator || (dcCoupled && showInactiveFlow))
value: Utils.sign (alternatorFlow)
active: root.active && (showAlternator || showMotorDrive || (dcCoupled && showInactiveFlow))
value: Utils.sign (alternatorFlow + motorDriveFlow)
startPointVisible: true
endPointVisible: false
anchors
Expand Down Expand Up @@ -1418,7 +1466,7 @@ OverviewPage {
property variant targetList:
[
acInputTarget, pvOnInputTarget, acLoadsOnInputTarget,
acChargerTarget, alternatorTarget, dcSystemTarget,
acChargerTarget, alternatorTarget, motorDriveTarget, dcSystemTarget,
multiTarget, batteryTarget,
acLoadsOnOutputTarget, pvOnOutputTarget, fuelCellTarget, windGenTarget, pvChargerTarget
]
Expand Down
Loading

0 comments on commit 6ffb71f

Please sign in to comment.