-
Notifications
You must be signed in to change notification settings - Fork 0
/
Fan.qml
236 lines (211 loc) · 7.64 KB
/
Fan.qml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
import QtQuick 2.13
import QtQuick.Controls 2.13
import QtQuick.Layouts 1.13
import BackEnd 1.0
Item {
property int lblTopMargin: 8
property string title
property int fanNo
property var fan
Layout.fillWidth: true
height: 135
Connections {
target: backEnd
onConfigDownloaded: function() {
populateSourceOptions();
}
}
function populateSourceOptions() {
let idx = fieldSource.currentIndex,
mdl = fieldSource.model,
record = mdl.get(idx),
firstVal = null,
selVal = record ? record.val : BackEnd.WaterSupplyTemp, // uses initial ListElements
cur = 0;
idx = 0;
function appendElement(obj) {
if (firstVal === null)
firstVal = obj.val;
mdl.append({ val: obj.val, text: obj.text });
if (obj.val === selVal)
idx = cur;
cur++;
}
mdl.clear();
if (backEnd.sensor1.pin)
appendElement({ val: BackEnd.WaterSupplyTemp, text: qsTr("Water Supply Temp") });
if (backEnd.sensor2.pin)
appendElement({ val: BackEnd.WaterReturnTemp, text: qsTr("Water Return Temp") });
if (backEnd.sensor3.pin)
appendElement({ val: BackEnd.CaseTemp, text: qsTr("Case Temp") });
if (backEnd.sensor4.pin)
appendElement({ val: BackEnd.Aux1Temp, text: qsTr("Aux1 Temp") });
if (backEnd.sensor5.pin)
appendElement({ val: BackEnd.Aux2Temp, text: qsTr("Aux2 Temp") });
if (backEnd.sensor1.pin && backEnd.sensor2.pin)
appendElement({ val: BackEnd.VirtualDeltaT, text: qsTr("DeltaT (Return - Supply Temp)") });
fieldSource.currentIndex = idx;
fieldSource.val = (idx !== 0 ? selVal : firstVal) || BackEnd.WaterSupplyTemp;
fan.source = fieldSource.val // make sure config is up to date
}
function showFanPID(source, fanNo) {
let valid = true,
pid, pidTitle;
switch (source) {
case BackEnd.WaterSupplyTemp:
pidTitle = "Supply Temp PID"
pid = backEnd.pid1
break;
case BackEnd.CaseTemp:
pidTitle = "Case Temp PID"
pid = backEnd.pid2
break;
case BackEnd.Aux1Temp:
pidTitle = "Aux1 Temp PID"
pid = backEnd.pid3
break;
case BackEnd.Aux2Temp:
pidTitle = "Aux2 Temp PID"
pid = backEnd.pid4
break;
default:
pidTitle = "INVALID TEMP SOURCE"
pid = undefined
valid = false
break;
}
stackView.push("fan_pid.qml", {
fanTitle: qsTr("Fan " + fanNo),
pidTitle: qsTr(pidTitle),
pid: pid
})
}
function showFanTbl(fan, fanNo) {
let tblTitle;
switch (fan.source) {
case BackEnd.WaterSupplyTemp:
tblTitle = "Supply Temp - % Table"
break;
case BackEnd.WaterReturnTemp:
tblTitle = "Return Temp - % Table"
break;
case BackEnd.CaseTemp:
tblTitle = "Case Temp - % Table"
break;
case BackEnd.Aux1Temp:
tblTitle = "Aux1 Temp - % Table"
break;
case BackEnd.Aux2Temp:
tblTitle = "Aux2 Temp - % Table"
break;
case BackEnd.VirtualDeltaT:
tblTitle = "DeltaT - % Table"
break;
}
stackView.push("fan_tbl.qml", {
fanTitle: qsTr("Fan " + fanNo),
tblTitle: qsTr(tblTitle),
fan: fan
})
stackView.currentItem.load()
}
Label {
id: titleText
text: title
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
anchors.topMargin: lblTopMargin
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
font.bold: true
}
GridLayout {
anchors.top: titleText.bottom
anchors.left: parent.left
anchors.right: parent.right
anchors.bottom: parent.bottom
anchors.topMargin: 4
columns: 1
RowLayout {
ComboBox {
id: fieldMode
Layout.minimumWidth: 115
Layout.maximumWidth: 255
Layout.fillWidth: true
currentIndex: fan.mode
model: ListModel {
ListElement { text: qsTr("Temp-% Table") }
ListElement { text: "PID" }
ListElement { text: qsTr("Fixed") }
ListElement { text: qsTr("Off") }
}
onActivated: {
fan.mode = fieldMode.currentIndex
}
}
ComboBox {
property int val: BackEnd.WaterSupplyTemp
id: fieldSource
visible: fan.mode === BackEnd.ControlMode.Tbl || fan.mode === BackEnd.ControlMode.PID
Layout.minimumWidth: 175
Layout.fillWidth: true
textRole: "text"
currentIndex: fan.source
model: ListModel {
ListElement { val: BackEnd.WaterSupplyTemp; text: qsTr("Water Supply Temp") }
ListElement { val: BackEnd.WaterReturnTemp; text: qsTr("Water Return Temp") }
ListElement { val: BackEnd.CaseTemp; text: qsTr("Case Temp") }
ListElement { val: BackEnd.Aux1Temp; text: qsTr("Aux1 Temp") }
ListElement { val: BackEnd.Aux2Temp; text: qsTr("Aux2 Temp") }
ListElement { val: BackEnd.VirtualDeltaT; text: qsTr("DeltaT (Return - Supply Temp)") }
}
onActivated: {
let rec = fieldSource.model.get(index);
if (rec)
fieldSource.val = rec.val;
fan.source = fieldSource.val;
}
Component.onCompleted: {
populateSourceOptions();
}
}
}
RowLayout {
ToolButton {
id: editTblButton
visible: fan.mode === BackEnd.ControlMode.Tbl
text: qsTr("Edit Table")
Layout.margins: 4
onClicked: {
showFanTbl(fan, fanNo)
}
}
ToolButton {
id: editPIDButton
visible: fan.mode === BackEnd.ControlMode.PID
text: qsTr("Edit PID Settings")
Layout.margins: 4
onClicked: {
showFanPID(fan.source, fanNo)
}
}
Item {
Layout.fillWidth: true
visible: fan.mode !== BackEnd.ControlMode.Fixed
}
TextFieldExt {
id: fieldRatio
visible: fan.mode === BackEnd.ControlMode.PID || fan.mode === BackEnd.ControlMode.Fixed
horizontalAlignment: Qt.AlignHRight
Layout.minimumWidth: 95
Layout.maximumWidth: 95
label: qsTr("Ratio")
tooltip: qsTr("Fan Ratio: set a value less than 1 to reduce this fan's speed, set a value greater than 1 to increase this fan's speed. Note: fan ratio is applied after PID and %-table calculations.")
text: fan.ratio
target: fan
property: "ratio"
}
}
}
}