Skip to content

Commit 5017711

Browse files
author
Maxime Rochat
committed
Made readonly valved and updated range or solenoid inputs
1 parent d936323 commit 5017711

9 files changed

Lines changed: 75 additions & 91 deletions

File tree

GUI/include/ValveControlView.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ typedef struct {
2828
GUI_FIELD f;
2929
Position p;
3030
ValveButton::Orientation o;
31+
bool read_only;
3132
} ValveInfo;
3233

3334
typedef struct {
@@ -49,7 +50,7 @@ class ValveControlView : public QFrame {
4950

5051
private:
5152
void setSvgBackground(const QString& filePath);
52-
void addButtonIcon(GUI_FIELD field,float x, float y, ValveButton::Orientation orientation = ValveButton::Orientation::Vertical);
53+
void addButtonIcon(GUI_FIELD field,float x, float y, ValveButton::Orientation orientation = ValveButton::Orientation::Vertical, bool read_only = 0);
5354
void addDataLabel(const GUI_FIELD field, float x, float y);
5455
void placeValves();
5556
void placeDataLabels();

GUI/include/components/ValveButton.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class ValveButton : public QLabel {
1919
enum Orientation { Horizontal = 0, Vertical };
2020

2121
explicit ValveButton(GUI_FIELD field, Orientation orientation = Horizontal,
22-
QWidget *parent = nullptr);
22+
QWidget *parent = nullptr, bool read_only = 0);
2323
~ValveButton() override;
2424
void resetStyle();
2525
State getState();
@@ -42,6 +42,7 @@ class ValveButton : public QLabel {
4242
Orientation orientation;
4343
QSize iconSize;
4444
GUI_FIELD m_field;
45+
bool m_readOnly = false;
4546
ModuleLog _logger = ModuleLog("ValveButton", LOG_FILE_PATH);
4647
QMessageBox::StandardButton showConfirmDialog(QWidget *parent,
4748
const QString &title,

GUI/res/images/prop_icarus_disconnect.svg

Lines changed: 1 addition & 1 deletion
Loading
25 Bytes
Binary file not shown.

GUI/src/Setup.h

Lines changed: 52 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -62,29 +62,40 @@ inline QMap<std::string, QList<std::vector<GUI_FIELD>>> controlMap{
6262

6363
inline std::vector<ValveInfo> valves = {{GUI_FIELD::GSE_VENT,
6464
{0.234569, 0.668},
65-
ValveButton::Orientation::Vertical},
65+
ValveButton::Orientation::Vertical,
66+
false},
6667
{GUI_FIELD::GSE_FILLING_N2O,
6768
{0.23, 0.45},
68-
ValveButton::Orientation::Horizontal},
69+
ValveButton::Orientation::Horizontal, false},
6970

7071
{GUI_FIELD::HOPPER_N2O_VENT,
7172
{0.50665, 0.318},
72-
ValveButton::Orientation::Horizontal},
73+
ValveButton::Orientation::Horizontal, false},
7374
{GUI_FIELD::HOPPER_ETH_VENT,
7475
{0.785838, 0.318},
75-
ValveButton::Orientation::Horizontal},
76+
ValveButton::Orientation::Horizontal, false},
7677
{GUI_FIELD::HOPPER_N2_SOL,
7778
{0.645736, 0.124315},
78-
ValveButton::Orientation::Horizontal},
79+
ValveButton::Orientation::Horizontal, false},
80+
7981
{GUI_FIELD::HOPPER_N2O_SOL,
8082
{0.585838, 0.638},
81-
ValveButton::Orientation::Vertical},
83+
ValveButton::Orientation::Vertical, false},
84+
{GUI_FIELD::HOPPER_N2O_MAIN,
85+
{0.585838, 0.57},
86+
ValveButton::Orientation::Vertical, true},
87+
88+
8289
{GUI_FIELD::HOPPER_ETH_SOL,
8390
{0.703604, 0.638},
84-
ValveButton::Orientation::Vertical},
91+
ValveButton::Orientation::Vertical, false},
92+
{GUI_FIELD::HOPPER_ETH_MAIN,
93+
{0.703604, 0.57},
94+
ValveButton::Orientation::Vertical, true},
95+
8596
{GUI_FIELD::HOPPER_IGNITER,
8697
{0.5, 0.85},
87-
ValveButton::Orientation::Vertical}};
98+
ValveButton::Orientation::Vertical, false}};
8899

89100
inline QList<std::vector<GUI_FIELD>> gseValvesMap{
90101
{GUI_FIELD::GSE_GQN_NC1, GUI_FIELD::GSE_GQN_NC2, GSE_GQN_NC5, GSE_GPN_NC,
@@ -113,28 +124,28 @@ inline std::vector<ValveInfo> gseValves = {
113124
// LOX quadrant
114125
{GUI_FIELD::GSE_GFO_NCC,
115126
{0.186, 0.35},
116-
ValveButton::Orientation::Horizontal},
127+
ValveButton::Orientation::Horizontal,false},
117128
{GUI_FIELD::GSE_GDO_NCC,
118129
{0.186, 0.247},
119-
ValveButton::Orientation::Horizontal},
130+
ValveButton::Orientation::Horizontal,false},
120131

121132
// Ethanol quadrant
122-
{GUI_FIELD::GSE_GFE_NC, {0.7, 0.382}, ValveButton::Orientation::Horizontal},
123-
{GUI_FIELD::GSE_PUMP, {0.575, 0.382}, ValveButton::Orientation::Horizontal},
133+
{GUI_FIELD::GSE_GFE_NC, {0.7, 0.382}, ValveButton::Orientation::Horizontal,false},
134+
{GUI_FIELD::GSE_PUMP, {0.575, 0.382}, ValveButton::Orientation::Horizontal,false},
124135

125136
// N2 quadrant
126-
{GUI_FIELD::GSE_GPN_NC, {0.15, 0.58}, ValveButton::Orientation::Horizontal},
127-
{GUI_FIELD::GSE_GPA_NC, {0.15, 0.7}, ValveButton::Orientation::Horizontal},
128-
{GUI_FIELD::GSE_GVN_NC, {0.7, 0.565}, ValveButton::Orientation::Horizontal},
137+
{GUI_FIELD::GSE_GPN_NC, {0.15, 0.58}, ValveButton::Orientation::Horizontal,false},
138+
{GUI_FIELD::GSE_GPA_NC, {0.15, 0.7}, ValveButton::Orientation::Horizontal,false},
139+
{GUI_FIELD::GSE_GVN_NC, {0.7, 0.565}, ValveButton::Orientation::Horizontal,false},
129140

130141
// Air valves
131142

132-
{GUI_FIELD::GSE_GQN_NC1, {0.515, 0.08}, ValveButton::Orientation::Vertical},
133-
{GUI_FIELD::GSE_GQN_NC2, {0.585, 0.08}, ValveButton::Orientation::Vertical},
134-
{GUI_FIELD::GSE_GQN_NC3, {0.655, 0.08}, ValveButton::Orientation::Vertical},
135-
{GUI_FIELD::GSE_GQN_NC4, {0.725, 0.08}, ValveButton::Orientation::Vertical},
136-
{GUI_FIELD::GSE_GQN_NC5, {0.78, 0.08}, ValveButton::Orientation::Vertical},
137-
{GUI_FIELD::GSE_GQN_NC5, {0.78, 0.08}, ValveButton::Orientation::Vertical},
143+
{GUI_FIELD::GSE_GQN_NC1, {0.515, 0.08}, ValveButton::Orientation::Vertical,false},
144+
{GUI_FIELD::GSE_GQN_NC2, {0.585, 0.08}, ValveButton::Orientation::Vertical,false},
145+
{GUI_FIELD::GSE_GQN_NC3, {0.655, 0.08}, ValveButton::Orientation::Vertical,false},
146+
{GUI_FIELD::GSE_GQN_NC4, {0.725, 0.08}, ValveButton::Orientation::Vertical,false},
147+
{GUI_FIELD::GSE_GQN_NC5, {0.78, 0.08}, ValveButton::Orientation::Vertical,false},
148+
{GUI_FIELD::GSE_GQN_NC5, {0.78, 0.08}, ValveButton::Orientation::Vertical,false},
138149

139150
};
140151

@@ -243,19 +254,19 @@ inline QMap<std::string, QList<std::vector<GUI_FIELD>>> gseControlMap{
243254
inline std::vector<ValveInfo> valves = {
244255
/*{GUI_FIELD::GSE_VENT, {0.24, 0.668},
245256
ValveButton::Orientation::Horizontal},*/
246-
{GUI_FIELD::VENT_N2, {0.55, -0.005}, ValveButton::Orientation::Horizontal},
247-
{GUI_FIELD::MAIN_LOX, {0.487, 0.75}, ValveButton::Orientation::Vertical},
248-
{GUI_FIELD::MAIN_FUEL, {0.4, 0.78}, ValveButton::Orientation::Vertical},
257+
{GUI_FIELD::VENT_N2, {0.55, -0.005}, ValveButton::Orientation::Horizontal, false},
258+
{GUI_FIELD::MAIN_LOX, {0.487, 0.75}, ValveButton::Orientation::Vertical, false},
259+
{GUI_FIELD::MAIN_FUEL, {0.4, 0.78}, ValveButton::Orientation::Vertical, false},
249260
{GUI_FIELD::VENT_FUEL,
250261
{0.386, 0.249},
251-
ValveButton::Orientation::Horizontal},
252-
{GUI_FIELD::VENT_LOX, {0.625, 0.498}, ValveButton::Orientation::Horizontal},
262+
ValveButton::Orientation::Horizontal, false},
263+
{GUI_FIELD::VENT_LOX, {0.625, 0.498}, ValveButton::Orientation::Horizontal, false},
253264
{GUI_FIELD::PRESSURE_VALVE_FUEL,
254265
{0.513, 0.225},
255-
ValveButton::Orientation::Vertical},
266+
ValveButton::Orientation::Vertical, false},
256267
{GUI_FIELD::PRESSURE_VALVE_LOX,
257268
{0.572, 0.33},
258-
ValveButton::Orientation::Vertical},
269+
ValveButton::Orientation::Vertical, false},
259270
};
260271

261272
inline std::vector<LabelInfo> labels = {
@@ -286,28 +297,28 @@ inline std::vector<ValveInfo> gseValves = {
286297
// LOX quadrant
287298
{GUI_FIELD::GSE_GFO_NCC,
288299
{0.186, 0.35},
289-
ValveButton::Orientation::Horizontal},
300+
ValveButton::Orientation::Horizontal,false},
290301
{GUI_FIELD::GSE_GDO_NCC,
291302
{0.186, 0.247},
292-
ValveButton::Orientation::Horizontal},
303+
ValveButton::Orientation::Horizontal,false},
293304

294305
// Ethanol quadrant
295-
{GUI_FIELD::GSE_GFE_NC, {0.7, 0.382}, ValveButton::Orientation::Horizontal},
296-
{GUI_FIELD::GSE_PUMP, {0.575, 0.382}, ValveButton::Orientation::Horizontal},
306+
{GUI_FIELD::GSE_GFE_NC, {0.7, 0.382}, ValveButton::Orientation::Horizontal,false},
307+
{GUI_FIELD::GSE_PUMP, {0.575, 0.382}, ValveButton::Orientation::Horizontal,false},
297308

298309
// N2 quadrant
299-
{GUI_FIELD::GSE_GPN_NC, {0.15, 0.58}, ValveButton::Orientation::Horizontal},
300-
{GUI_FIELD::GSE_GPA_NC, {0.15, 0.7}, ValveButton::Orientation::Horizontal},
301-
{GUI_FIELD::GSE_GVN_NC, {0.7, 0.565}, ValveButton::Orientation::Horizontal},
310+
{GUI_FIELD::GSE_GPN_NC, {0.15, 0.58}, ValveButton::Orientation::Horizontal,false},
311+
{GUI_FIELD::GSE_GPA_NC, {0.15, 0.7}, ValveButton::Orientation::Horizontal,false},
312+
{GUI_FIELD::GSE_GVN_NC, {0.7, 0.565}, ValveButton::Orientation::Horizontal,false},
302313

303314
// Air valves
304315

305-
{GUI_FIELD::GSE_GQN_NC1, {0.515, 0.08}, ValveButton::Orientation::Vertical},
306-
{GUI_FIELD::GSE_GQN_NC2, {0.585, 0.08}, ValveButton::Orientation::Vertical},
307-
{GUI_FIELD::GSE_GQN_NC3, {0.655, 0.08}, ValveButton::Orientation::Vertical},
308-
{GUI_FIELD::GSE_GQN_NC4, {0.725, 0.08}, ValveButton::Orientation::Vertical},
309-
{GUI_FIELD::GSE_GQN_NC5, {0.78, 0.08}, ValveButton::Orientation::Vertical},
310-
{GUI_FIELD::GSE_GQN_NC5, {0.78, 0.08}, ValveButton::Orientation::Vertical},
316+
{GUI_FIELD::GSE_GQN_NC1, {0.515, 0.08}, ValveButton::Orientation::Vertical,false},
317+
{GUI_FIELD::GSE_GQN_NC2, {0.585, 0.08}, ValveButton::Orientation::Vertical,false},
318+
{GUI_FIELD::GSE_GQN_NC3, {0.655, 0.08}, ValveButton::Orientation::Vertical,false},
319+
{GUI_FIELD::GSE_GQN_NC4, {0.725, 0.08}, ValveButton::Orientation::Vertical,false},
320+
{GUI_FIELD::GSE_GQN_NC5, {0.78, 0.08}, ValveButton::Orientation::Vertical,false},
321+
{GUI_FIELD::GSE_GQN_NC5, {0.78, 0.08}, ValveButton::Orientation::Vertical,false},
311322

312323
};
313324

GUI/src/components/IcarusCommandsView.cpp

Lines changed: 1 addition & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -33,47 +33,6 @@ IcarusCommandsView::IcarusCommandsView(QWidget *parent)
3333
QLayout* configSection = setupIDConfigSection();
3434
QLayout *gimbalSection = setupGimbalSection();
3535
QLayout *valvesSection = setupValvesSection();
36-
/*QScrollArea *scrollArea = new QScrollArea(this);*/
37-
/*QWidget* mainWidget = new QWidget();*/
38-
/*mainWidget->setObjectName("IcarusCommandsViewInternalWidget");*/
39-
/*mainWidget->setStyleSheet(col::defaultCardStyle("IcarusCommandsViewInternalWidget"));*/
40-
/*mainWidget->setLayout(mainLayout);*/
41-
/*scrollArea->setWidget(mainWidget);*/
42-
/*scrollArea->setWidgetResizable(true);*/
43-
/*// Optionally hide the horizontal scroll bar if you only need vertical*/
44-
/*// scrolling:*/
45-
/*scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);*/
46-
/*scrollArea->verticalScrollBar()->setAttribute(Qt::WA_TranslucentBackground,*/
47-
/* true);*/
48-
/**/
49-
/*scrollArea->verticalScrollBar()->setStyleSheet(*/
50-
/* "QScrollBar {"*/
51-
/* " border: none;"*/
52-
/* "}"*/
53-
/* "QScrollBar:vertical {"*/
54-
/* " background: #2e2e2e;"*/
55-
/* " width: 15px;"*/
56-
/* " margin: 15px 3px 15px 3px;"*/
57-
/* "}"*/
58-
/* "QScrollBar::handle:vertical {"*/
59-
/* " background: #b0b0b0;"*/
60-
/* " min-height: 20px;"*/
61-
/* " border: 2px solid transparent;" // transparent border to trigger*/
62-
/* // border-radius*/
63-
/* " border-radius: 7px;"*/
64-
/* " background-clip: padding;" // ensure the background respects the*/
65-
/* // border-radius*/
66-
/* "}"*/
67-
/* "QScrollBar::handle:vertical:hover {"*/
68-
/* " background: #a0a0a0;"*/
69-
/* "}"*/
70-
/* "QScrollBar::add-line:vertical, QScrollBar::sub-line:vertical {"*/
71-
/* " background: none;"*/
72-
/* " height: 15px;"*/
73-
/* "}"*/
74-
/* "QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical {"*/
75-
/* " background: none;"*/
76-
/* "}");*/
7736

7837
mainLayout->addLayout(configSection);
7938
mainLayout->addWidget(line);
@@ -305,7 +264,7 @@ void IcarusCommandsView::onValvesCommandButtonClicked()
305264
bool okX, okY;
306265
int n2oValue = m_mainOLineEdit->text().toInt(&okX);
307266
int fuelValue = m_mainELineEdit->text().toInt(&okY);
308-
if (n2oValue < 0 || n2oValue > 100 || fuelValue < 0 || fuelValue > 100) {
267+
if (n2oValue < -10 || n2oValue > 100 || fuelValue < -10 || fuelValue > 100) {
309268
_logger.error("Invalid Command Value", QString(R"(The value valve_MAIN_N2O=%1, valve_MAIN_FUEL=%2, contain an invalid value, they should be between 0 and 100)").arg(n2oValue).arg(fuelValue).toStdString());
310269
return;
311270
}

GUI/src/components/ValveButton.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
#include "components/ValveButton.h"
1919

2020
ValveButton::ValveButton(GUI_FIELD field, Orientation orientation,
21-
QWidget *parent)
22-
: QLabel(parent), currentState(Unknown), iconSize(52, 52), m_field(field) {
21+
QWidget *parent, bool read_only)
22+
: QLabel(parent), currentState(Unknown), iconSize(52, 52), m_field(field), m_readOnly(read_only) {
2323
// Set initial state and update button icon
2424
// Change this to set the initial state as needed
2525
this->orientation = orientation;
@@ -79,6 +79,10 @@ ValveButton::ValveButton(GUI_FIELD field, Orientation orientation,
7979
}
8080
});
8181

82+
if (m_readOnly) {
83+
setAttribute(Qt::WA_TransparentForMouseEvents, true);
84+
}
85+
8286
setFixedSize(sizeHint());
8387
}
8488

@@ -183,6 +187,8 @@ void ValveButton::updateButtonIcon() {
183187
ValveButton::State ValveButton::getState() { return currentState; }
184188

185189
void ValveButton::mousePressEvent(QMouseEvent *event) {
190+
if (m_readOnly) return;
191+
186192
if (event->button() == Qt::LeftButton)
187193
emit clicked();
188194

@@ -201,6 +207,10 @@ void ValveButton::mousePressEvent(QMouseEvent *event) {
201207
}
202208

203209
void ValveButton::resetStyle() {
210+
if (m_readOnly) {
211+
setStyleSheet("background: transparent;");
212+
return;
213+
}
204214
setStyleSheet(QString(R"(
205215
#valveButton {
206216
background:transparent;

GUI/src/views/ValveControlView.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ ValveControlView::ValveControlView(std::vector<ValveInfo> valves,
5151

5252
void ValveControlView::placeValves() {
5353
for (auto valveInfo : _valves) {
54-
addButtonIcon(valveInfo.f, valveInfo.p.x, valveInfo.p.y, valveInfo.o);
54+
addButtonIcon(valveInfo.f, valveInfo.p.x, valveInfo.p.y, valveInfo.o, valveInfo.read_only);
5555
}
5656
}
5757

@@ -114,7 +114,7 @@ void ValveControlView::setSvgBackground(const QString &filePath) {
114114
}
115115

116116
void ValveControlView::addButtonIcon(GUI_FIELD field, float x, float y,
117-
ValveButton::Orientation orientation) {
117+
ValveButton::Orientation orientation, bool read_only) {
118118
/*ValveButton *button = new ValveButton(orientation, this);*/
119119

120120
// Create a container widget
@@ -129,7 +129,7 @@ void ValveControlView::addButtonIcon(GUI_FIELD field, float x, float y,
129129

130130
// Create the valve button
131131
ValveButton *button =
132-
new ValveButton(field, orientation, valveWithTitle);
132+
new ValveButton(field, orientation, valveWithTitle, read_only);
133133
button->setAlignment(Qt::AlignCenter);
134134

135135
// Add them to the layout

Server/src/server.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,8 @@ void Server::simulateJsonData() {
543543
packet.gnss_lat = distCoord(gen);
544544
packet.baro = distAlt(gen);
545545
packet.N2_solenoid = static_cast<int8_t>(distState(gen));
546+
packet.N2O_sol = static_cast<int8_t>(distState(gen));
547+
packet.ETH_sol = static_cast<int8_t>(distState(gen));
546548
packet.N2O_main = distPressure(gen);
547549
packet.N2O_vent = distPressure(gen);
548550
packet.N2O_temp = distPressure(gen);

0 commit comments

Comments
 (0)