Skip to content

Commit c18fc8c

Browse files
committed
1 parent 1af06c1 commit c18fc8c

File tree

4 files changed

+50
-0
lines changed

4 files changed

+50
-0
lines changed

src/eez/modules/psu/gui/page.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ enum ToastType {
3636
};
3737

3838
class ToastMessagePage : public InternalPage {
39+
friend class PsuAppContext;
40+
3941
static ToastMessagePage *findFreePage();
4042

4143
public:

src/eez/modules/psu/gui/psu.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
#include <eez/hmi.h>
3131
#include <eez/keyboard.h>
3232

33+
#include <eez/scpi/regs.h>
34+
3335
#include <eez/modules/psu/psu.h>
3436
#include <eez/modules/psu/calibration.h>
3537
#include <eez/modules/psu/channel_dispatcher.h>
@@ -317,6 +319,32 @@ void PsuAppContext::stateManagment() {
317319
m_asyncOperationInProgressParams.checkStatus();
318320
}
319321
}
322+
323+
//
324+
if (getActivePageId() == INTERNAL_PAGE_ID_TOAST_MESSAGE) {
325+
ToastMessagePage *page = (ToastMessagePage *)getActivePage();
326+
if (page->messageValue.getType() == VALUE_TYPE_EVENT_MESSAGE) {
327+
328+
int16_t eventId = page->messageValue.getFirstInt16();
329+
int channelIndex = page->messageValue.getSecondInt16();
330+
331+
bool dismissPage = false;
332+
333+
if (eventId == event_queue::EVENT_ERROR_CH_OVP_TRIPPED) {
334+
dismissPage = !eez::scpi::is_ques_bit_enabled(channelIndex, QUES_ISUM_OVP);
335+
} else if (eventId == event_queue::EVENT_ERROR_CH_OCP_TRIPPED) {
336+
dismissPage = !eez::scpi::is_ques_bit_enabled(channelIndex, QUES_ISUM_OCP);
337+
} else if (eventId == event_queue::EVENT_ERROR_CH_OPP_TRIPPED) {
338+
dismissPage = !eez::scpi::is_ques_bit_enabled(channelIndex, QUES_ISUM_OPP);
339+
} else if (eventId == event_queue::EVENT_ERROR_CH_REMOTE_SENSE_REVERSE_POLARITY_DETECTED) {
340+
dismissPage = !eez::scpi::is_ques_bit_enabled(channelIndex, QUES_ISUM_RPOL);
341+
}
342+
343+
if (dismissPage) {
344+
popPage();
345+
}
346+
}
347+
}
320348
}
321349

322350
bool PsuAppContext::isActiveWidget(const WidgetCursor &widgetCursor) {

src/eez/scpi/regs.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,25 @@ void reg_set_ques_isum_bit(int iChannel, int bit_mask, bool on) {
280280
#endif
281281
}
282282

283+
bool is_ques_bit_enabled(int channelIndex, int bit_mask) {
284+
if (serial::g_testResult == TEST_OK) {
285+
scpi_reg_val_t val = reg_get(&serial::g_scpiContext, (scpi_psu_reg_name_t)(SCPI_PSU_CH_REG_QUES_INST_ISUM_EVENT1 + channelIndex));
286+
if (!(val & bit_mask)) {
287+
return false;
288+
}
289+
}
290+
#if OPTION_ETHERNET
291+
if (ethernet::g_testResult == TEST_OK) {
292+
scpi_reg_val_t val = reg_get(&ethernet::g_scpiContext, (scpi_psu_reg_name_t)(SCPI_PSU_CH_REG_QUES_INST_ISUM_EVENT1 + channelIndex));
293+
if (!(val & bit_mask)) {
294+
return false;
295+
}
296+
}
297+
#endif
298+
299+
return true;
300+
}
301+
283302
void reg_set_oper_bit(scpi_t *context, int bit_mask, bool on) {
284303
scpi_reg_val_t val = reg_get(context, SCPI_PSU_REG_OPER_COND);
285304
if (on) {

src/eez/scpi/regs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ void reg_set_esr_bits(int bit_mask);
116116

117117
void reg_set_ques_bit(int bit_mask, bool on);
118118
void reg_set_ques_isum_bit(int iChannel /* zero based */, int bit_mask, bool on);
119+
bool is_ques_bit_enabled(int channelIndex, int bit_mask);
119120

120121
void reg_set_oper_bit(int bit_mask, bool on);
121122

0 commit comments

Comments
 (0)