Skip to content

Commit

Permalink
#53
Browse files Browse the repository at this point in the history
  • Loading branch information
mvladic committed Sep 11, 2020
1 parent 1af06c1 commit c18fc8c
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/eez/modules/psu/gui/page.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ enum ToastType {
};

class ToastMessagePage : public InternalPage {
friend class PsuAppContext;

static ToastMessagePage *findFreePage();

public:
Expand Down
28 changes: 28 additions & 0 deletions src/eez/modules/psu/gui/psu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
#include <eez/hmi.h>
#include <eez/keyboard.h>

#include <eez/scpi/regs.h>

#include <eez/modules/psu/psu.h>
#include <eez/modules/psu/calibration.h>
#include <eez/modules/psu/channel_dispatcher.h>
Expand Down Expand Up @@ -317,6 +319,32 @@ void PsuAppContext::stateManagment() {
m_asyncOperationInProgressParams.checkStatus();
}
}

//
if (getActivePageId() == INTERNAL_PAGE_ID_TOAST_MESSAGE) {
ToastMessagePage *page = (ToastMessagePage *)getActivePage();
if (page->messageValue.getType() == VALUE_TYPE_EVENT_MESSAGE) {

int16_t eventId = page->messageValue.getFirstInt16();
int channelIndex = page->messageValue.getSecondInt16();

bool dismissPage = false;

if (eventId == event_queue::EVENT_ERROR_CH_OVP_TRIPPED) {
dismissPage = !eez::scpi::is_ques_bit_enabled(channelIndex, QUES_ISUM_OVP);
} else if (eventId == event_queue::EVENT_ERROR_CH_OCP_TRIPPED) {
dismissPage = !eez::scpi::is_ques_bit_enabled(channelIndex, QUES_ISUM_OCP);
} else if (eventId == event_queue::EVENT_ERROR_CH_OPP_TRIPPED) {
dismissPage = !eez::scpi::is_ques_bit_enabled(channelIndex, QUES_ISUM_OPP);
} else if (eventId == event_queue::EVENT_ERROR_CH_REMOTE_SENSE_REVERSE_POLARITY_DETECTED) {
dismissPage = !eez::scpi::is_ques_bit_enabled(channelIndex, QUES_ISUM_RPOL);
}

if (dismissPage) {
popPage();
}
}
}
}

bool PsuAppContext::isActiveWidget(const WidgetCursor &widgetCursor) {
Expand Down
19 changes: 19 additions & 0 deletions src/eez/scpi/regs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,25 @@ void reg_set_ques_isum_bit(int iChannel, int bit_mask, bool on) {
#endif
}

bool is_ques_bit_enabled(int channelIndex, int bit_mask) {
if (serial::g_testResult == TEST_OK) {
scpi_reg_val_t val = reg_get(&serial::g_scpiContext, (scpi_psu_reg_name_t)(SCPI_PSU_CH_REG_QUES_INST_ISUM_EVENT1 + channelIndex));
if (!(val & bit_mask)) {
return false;
}
}
#if OPTION_ETHERNET
if (ethernet::g_testResult == TEST_OK) {
scpi_reg_val_t val = reg_get(&ethernet::g_scpiContext, (scpi_psu_reg_name_t)(SCPI_PSU_CH_REG_QUES_INST_ISUM_EVENT1 + channelIndex));
if (!(val & bit_mask)) {
return false;
}
}
#endif

return true;
}

void reg_set_oper_bit(scpi_t *context, int bit_mask, bool on) {
scpi_reg_val_t val = reg_get(context, SCPI_PSU_REG_OPER_COND);
if (on) {
Expand Down
1 change: 1 addition & 0 deletions src/eez/scpi/regs.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ void reg_set_esr_bits(int bit_mask);

void reg_set_ques_bit(int bit_mask, bool on);
void reg_set_ques_isum_bit(int iChannel /* zero based */, int bit_mask, bool on);
bool is_ques_bit_enabled(int channelIndex, int bit_mask);

void reg_set_oper_bit(int bit_mask, bool on);

Expand Down

0 comments on commit c18fc8c

Please sign in to comment.