115 lines
2.9 KiB
QML
115 lines
2.9 KiB
QML
|
import QtQuick 1.1
|
||
|
import "utils.js" as Utils
|
||
|
|
||
|
MbSubMenu {
|
||
|
id: root
|
||
|
property string bindPrefix: "com.victronenergy.settings/Settings/Controller/ScheduledCharge"
|
||
|
property int scheduleNumber: 4
|
||
|
property VBusItem schedule1: VBusItem { bind: Utils.path(bindPrefix, "0/Day") }
|
||
|
property VBusItem schedule2: VBusItem { bind: Utils.path(bindPrefix, "1/Day") }
|
||
|
property VBusItem schedule3: VBusItem { bind: Utils.path(bindPrefix, "2/Day") }
|
||
|
property VBusItem schedule4: VBusItem { bind: Utils.path(bindPrefix, "3/Day") }
|
||
|
|
||
|
|
||
|
description: qsTr("Calibration charge scheduling")
|
||
|
userHasWriteAccess: true
|
||
|
item {
|
||
|
text: getItemText()
|
||
|
}
|
||
|
|
||
|
// Negative values means disabled. We preserve the day by just flipping the sign.
|
||
|
function toggleDay(v)
|
||
|
{
|
||
|
// Sunday (0) is special since -0 is equal, map it to -10 and vice versa.
|
||
|
if (v === -10)
|
||
|
return 0;
|
||
|
if (v === 0)
|
||
|
return -10;
|
||
|
return -v
|
||
|
}
|
||
|
|
||
|
function getItemText()
|
||
|
{
|
||
|
if (itemDay.valid && itemDay.value >= 0) {
|
||
|
var day = itemDay.text
|
||
|
var start = startTime.item.text
|
||
|
var durationSecs = Utils.secondsToString(duration.item.value)
|
||
|
// This is stupid, but QString.arg apparently can't handle an
|
||
|
// integer mixed in with some strings.
|
||
|
return qsTr("%1 %2").arg(day).arg(start)
|
||
|
}
|
||
|
|
||
|
return qsTr("Disabled")
|
||
|
}
|
||
|
|
||
|
subpage: MbPage {
|
||
|
title: root.description
|
||
|
model: VisualItemModel {
|
||
|
MbSwitch {
|
||
|
id: itemEnabled
|
||
|
name: qsTr("Enabled")
|
||
|
enabled: true
|
||
|
bind: Utils.path(bindPrefix, "Enabled")
|
||
|
}
|
||
|
|
||
|
MbItemOptions {
|
||
|
id: itemDay
|
||
|
description: qsTr("Day")
|
||
|
bind: Utils.path(bindPrefix, "Day")
|
||
|
show: itemEnabled.checked
|
||
|
unknownOptionText: "--"
|
||
|
possibleValues: [
|
||
|
MbOption { description: qsTr("Monday"); value: 1 },
|
||
|
MbOption { description: qsTr("Tuesday"); value: 2 },
|
||
|
MbOption { description: qsTr("Wednesday"); value: 3 },
|
||
|
MbOption { description: qsTr("Thursday"); value: 4 },
|
||
|
MbOption { description: qsTr("Friday"); value: 5 },
|
||
|
MbOption { description: qsTr("Saturday"); value: 6 },
|
||
|
MbOption { description: qsTr("Sunday"); value: 0 }
|
||
|
]
|
||
|
}
|
||
|
|
||
|
MbEditBoxTime {
|
||
|
id: startTime
|
||
|
description: qsTr("Start time")
|
||
|
item.bind: Utils.path(bindPrefix, "StartTime")
|
||
|
show: itemEnabled.checked
|
||
|
}
|
||
|
|
||
|
MbEditBoxTime {
|
||
|
id: duration
|
||
|
description: qsTr("Duration (hh:mm)")
|
||
|
item.bind: Utils.path(bindPrefix, scheduleNumber, "/Duration")
|
||
|
show: false
|
||
|
}
|
||
|
|
||
|
MbSwitch {
|
||
|
id: socLimitEnabled
|
||
|
name: qsTr("Stop on SOC")
|
||
|
enabled: true
|
||
|
show: false
|
||
|
checked: socLimit.value < 100
|
||
|
onCheckedChanged: {
|
||
|
if (checked && socLimit.value > 100)
|
||
|
socLimit.item.setValue(100)
|
||
|
else if (!checked && socLimit.value <= 100)
|
||
|
socLimit.item.setValue(100)
|
||
|
}
|
||
|
}
|
||
|
|
||
|
MbSpinBox {
|
||
|
id: socLimit
|
||
|
description: qsTr("SOC limit")
|
||
|
bind: Utils.path(bindPrefix, scheduleNumber, "/Soc")
|
||
|
show: false
|
||
|
numOfDecimals: 0
|
||
|
unit: "%"
|
||
|
min: 5
|
||
|
max: 100
|
||
|
stepSize: 5
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|