Skip to content

Commit 9dca770

Browse files
committed
ModeIndicatorWidget: Params textfield labels now changes its texts depending on choosen command
1 parent 1f76180 commit 9dca770

3 files changed

Lines changed: 107 additions & 7 deletions

File tree

src/FirmwarePlugin/ChargingStation/ChargingStationFirmwarePlugin.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ QStringList ChargingStationFirmwarePlugin::flightModes(Vehicle* vehicle)
3131
Q_UNUSED(vehicle);
3232

3333
QStringList flightModes;
34-
flightModes << tr("Open") << tr("Closed") << tr("Load drone") << tr("Unload drone") << tr("Get from user") << tr("Unload to user") << tr("Change battery") << tr("Reset") << tr("Service");
34+
flightModes << tr("Stop") << tr("Open") << tr("Closed") << tr("Load drone") << tr("Unload drone") << tr("Get from user") << tr("Unload to user") << tr("Change battery") << tr("Reset") << tr("Service");
3535
return flightModes;
3636
}
3737

@@ -57,6 +57,8 @@ bool ChargingStationFirmwarePlugin::setFlightMode(const QString& flightMode, uin
5757
*custom_mode = CUSTOM_MODE_RESET;
5858
} else if (flightMode.compare(tr("Service"), Qt::CaseInsensitive) == 0) {
5959
*custom_mode = CUSTOM_MODE_SERVICE;
60+
} else if (flightMode.compare(tr("Stop"), Qt::CaseInsensitive) == 0) {
61+
*custom_mode = CUSTOM_MODE_STOP;
6062
} else {
6163
return false;
6264
}

src/FirmwarePlugin/ChargingStation/ChargingStationFirmwarePlugin.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#define CUSTOM_MODE_RESET 11
1818
#define CUSTOM_MODE_STANDBY 12
1919
#define CUSTOM_MODE_ERROR 13
20+
#define CUSTOM_MODE_STOP 14
2021

2122

2223
class ChargingStationFactGroup : public FactGroup

src/ui/toolbar/ModeIndicator.qml

Lines changed: 103 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,15 @@ Item {
5353
Rectangle {
5454
id: testRect
5555
width: 200
56-
height: 300
56+
height: contentColumn.height * 1.1
5757
radius: ScreenTools.defaultFontPixelHeight * 0.5
5858
color: qgcPal.window
5959
border.color: qgcPal.text
6060
Column{
61+
id: contentColumn
6162
width: parent.width * 0.9
6263
anchors.horizontalCenter: parent.horizontalCenter
64+
anchors.topMargin: height*0.1
6365
ComboBox {
6466
id: cbFlightMode
6567
currentIndex: -1
@@ -77,20 +79,111 @@ Item {
7779
}
7880
currentIndex = find(activeVehicle.flightMode)
7981
}
82+
onCurrentIndexChanged: {
83+
// Default labels
84+
p1Label.text = "Param1: "
85+
p2Label.text = "Param2: "
86+
p3Label.text = "Param3: "
87+
p4Label.text = "Param4: "
88+
p5Label.text = "Param5: "
89+
90+
if (cbFlightModeModel.get(currentIndex).mode == "Load drone"
91+
|| cbFlightModeModel.get(currentIndex).mode == "Unload drone")
92+
{
93+
p1Label.text = "Payload cell: "
94+
p2Label.text = "Charging cell: "
95+
}
96+
else if (cbFlightModeModel.get(currentIndex).mode == "Get from user")
97+
{
98+
p1Label.text = "Payload cell: "
99+
}
100+
else if (cbFlightModeModel.get(currentIndex).mode == "Unload to user")
101+
{
102+
p1Label.text = "Payload cell: "
103+
}
104+
else if (cbFlightModeModel.get(currentIndex).mode == "Change battery")
105+
{
106+
p1Label.text = "Empty cell: "
107+
p2Label.text = "Charged cell: "
108+
}
109+
else if (cbFlightModeModel.get(currentIndex).mode == "Service")
110+
{
111+
p1Label.text = "Command id: "
112+
}
80113
}
114+
}
115+
ComboBox {
116+
id: commandSelector
117+
currentIndex: -1
118+
displayText: currentIndex === -1 ? "Choose command..." : currentText
119+
visible: cbFlightMode.currentIndex == 9
120+
model: ListModel {
121+
id: commandSelectorModel
122+
ListElement { command: "LOCK_RELEASE" }
123+
ListElement { command: "LOCK_LOCK" }
124+
ListElement { command: "LOCK_STOP" }
125+
ListElement { command: "OPEN_TOP_HATCH" }
126+
ListElement { command: "CLOSE_TOP_HATCH" }
127+
ListElement { command: "GOTO_CELL" }
128+
ListElement { command: "LOAD_CHARGING_CELL" }
129+
ListElement { command: "UNLOAD_CHARGING_CELL" }
130+
ListElement { command: "LOAD_PAYLOAD_CELL" }
131+
ListElement { command: "UNLOAD_PAYLOAD_CELL" }
132+
ListElement { command: "GET_FROM_USER" }
133+
ListElement { command: "UNLOAD_TO_USER" }
134+
ListElement { command: "STOP" }
135+
ListElement { command: "GET_PAYLOAD_FROM_DRONE" }
136+
ListElement { command: "INSERT_PAYLOAD_INTO_DRONE" }
137+
ListElement { command: "LOCK_PAYLOAD" }
138+
ListElement { command: "RELEASE_PAYLOAD" }
139+
ListElement { command: "LOCK_CHARGING_CELL_LOCK" }
140+
ListElement { command: "RELEASE_CHARGING_CELL_LOCK" }
141+
ListElement { command: "LOCK_TOP_HATCH_LOCK" }
142+
ListElement { command: "RELEASE_TOP_HATCH_LOCK" }
143+
ListElement { command: "OPEN_BOTTOM_HATCH" }
144+
ListElement { command: "CLOSE_BOTTOM_HATCH" }
145+
ListElement { command: "LOCK_USER_CELL_LOCK" }
146+
ListElement { command: "RELEASE_USER_CELL_LOCK" }
147+
ListElement { command: "GOTO_CHARGING_CELL" }
148+
}
149+
width: parent.width
150+
anchors.horizontalCenter: parent.horizontalCenter
151+
onCurrentIndexChanged: {
152+
param1Box.text = currentIndex
153+
p2Label.text = "Param2: "
154+
p3Label.text = "Param3: "
155+
p4Label.text = "Param4: "
156+
p5Label.text = "Param5: "
157+
if (commandSelectorModel.get(currentIndex).command == "GOTO_CELL")
158+
{
159+
p2Label.text = "X: "
160+
p3Label.text = "Y: "
161+
p4Label.text = "Z: "
162+
}
163+
else if (commandSelectorModel.get(currentIndex).command == "GOTO_CHARGING_CELL")
164+
{
165+
p2Label.text = "Xkr: "
166+
p3Label.text = "Y: "
167+
p4Label.text = "Z: "
168+
}
169+
}
170+
171+
}
81172
Row {
82173
width: parent.width
83174
QGCLabel {
175+
id: p1Label
84176
text: qsTr("Param1: ")
85177
}
86178
TextField {
87179
id: param1Box
88180
text: modeParam1
89181
width: parent.width * 0.5
90182
anchors.verticalCenter: parent.verticalCenter
183+
91184
inputMethodHints: Qt.ImhDigitsOnly
92185
validator: IntValidator {
93-
bottom: -32768
186+
bottom: 0
94187
top: 32768
95188
}
96189
onAccepted: {
@@ -101,6 +194,7 @@ Item {
101194
Row {
102195
width: parent.width
103196
QGCLabel {
197+
id: p2Label
104198
text: qsTr("Param2: ")
105199
}
106200
TextField {
@@ -110,7 +204,7 @@ Item {
110204
anchors.verticalCenter: parent.verticalCenter
111205
inputMethodHints: Qt.ImhDigitsOnly
112206
validator: IntValidator {
113-
bottom: -32768
207+
bottom: 0
114208
top: 32768
115209
}
116210
onAccepted: {
@@ -121,6 +215,7 @@ Item {
121215
Row {
122216
width: parent.width
123217
QGCLabel {
218+
id: p3Label
124219
text: qsTr("Param3: ")
125220
}
126221
TextField {
@@ -130,7 +225,7 @@ Item {
130225
anchors.verticalCenter: parent.verticalCenter
131226
inputMethodHints: Qt.ImhDigitsOnly
132227
validator: IntValidator {
133-
bottom: -32768
228+
bottom: 0
134229
top: 32768
135230
}
136231
onAccepted: {
@@ -141,6 +236,7 @@ Item {
141236
Row {
142237
width: parent.width
143238
QGCLabel {
239+
id: p4Label
144240
text: qsTr("Param4: ")
145241
}
146242
TextField {
@@ -150,7 +246,7 @@ Item {
150246
anchors.verticalCenter: parent.verticalCenter
151247
inputMethodHints: Qt.ImhDigitsOnly
152248
validator: IntValidator {
153-
bottom: -32768
249+
bottom: 0
154250
top: 32768
155251
}
156252
onAccepted: {
@@ -161,6 +257,7 @@ Item {
161257
Row {
162258
width: parent.width
163259
QGCLabel {
260+
id: p5Label
164261
text: qsTr("Param5: ")
165262
}
166263
TextField {
@@ -170,7 +267,7 @@ Item {
170267
anchors.verticalCenter: parent.verticalCenter
171268
inputMethodHints: Qt.ImhDigitsOnly
172269
validator: IntValidator {
173-
bottom: -32768
270+
bottom: 0
174271
top: 32768
175272
}
176273
onAccepted: {

0 commit comments

Comments
 (0)