Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
mvladic committed Jan 28, 2021
1 parent 2bf032d commit 58197f4
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 14 deletions.
17 changes: 16 additions & 1 deletion src/eez/modules/psu/channel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -790,16 +790,31 @@ void Channel::updateAllChannels() {
}
}

bool initiateTrigger = false;

for (int i = 0; i < CH_NUM; ++i) {
Channel &channel = Channel::get(i);
if (channel.isOk()) {
bool triggerModeEnabled = channel.flags.outputEnabled &&
(channel_dispatcher::getVoltageTriggerMode(channel) != TRIGGER_MODE_FIXED ||
channel_dispatcher::getCurrentTriggerMode(channel) != TRIGGER_MODE_FIXED) && !channel.isRemoteProgrammingEnabled();

if (triggerModeEnabled && trigger::g_triggerSource == trigger::SOURCE_IMMEDIATE) {
initiateTrigger = true;
}

channel.flags.outputEnabledValueOnNextSync = channel.flags.outputEnabled;
channel.flags.outputEnabled = !channel.flags.outputEnabled;
channel.flags.doOutputEnableOnNextSync = 1;
}
}

Channel::syncOutputEnable();
if (initiateTrigger) {
// trigger will call syncOutputEnable
trigger::initiate();
} else {
Channel::syncOutputEnable();
}

for (int i = 0; i < CH_NUM; ++i) {
Channel &channel = Channel::get(i);
Expand Down
19 changes: 8 additions & 11 deletions src/eez/modules/psu/gui/psu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1924,17 +1924,6 @@ void channelReinitiateTrigger() {
channelInitiateTrigger();
}

// void clearTrip(int channelIndex) {
// Channel &channel = Channel::get(channelIndex);
// channel_dispatcher::clearProtection(channel);

// if (temperature::sensors[temp_sensor::AUX].isTripped()) {
// temperature::sensors[temp_sensor::AUX].clearProtection();
// }

// channelToggleOutput();
// }

void doChannelToggleOutput() {
Channel &channel = *g_channel;
bool triggerModeEnabled =
Expand Down Expand Up @@ -1977,6 +1966,14 @@ void channelToggleOutput() {
Channel &channel = *g_channel;
int channelIndex;
if (channel_dispatcher::isTripped(channel, channelIndex)) {
// auto clearTrip = [] (int channelIndex) {
// Channel &channel = Channel::get(channelIndex);
// channel_dispatcher::clearProtection(channel);
// if (temperature::sensors[temp_sensor::AUX].isTripped()) {
// temperature::sensors[temp_sensor::AUX].clearProtection();
// }
// channelToggleOutput();
// };
if (temperature::sensors[temp_sensor::AUX].isTripped()) {
// errorMessageWithAction("AUX temp. sensor is tripped!", clearTrip, "Clear", channelIndex);
errorMessage("AUX temp. sensor is tripped!");
Expand Down
4 changes: 2 additions & 2 deletions src/eez/modules/psu/profile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -849,12 +849,12 @@ static bool recallState(Parameters &profile, List *lists, int recallOptions, int
}
}

Channel::updateAllChannels();

trigger::g_triggerContinuousInitializationEnabled = profile.flags.triggerContinuousInitializationEnabled;
trigger::g_triggerSource = (trigger::Source)profile.triggerSource;
trigger::g_triggerDelay = profile.triggerDelay;

Channel::updateAllChannels();

memcpy(io_pins::g_ioPins, profile.ioPins, sizeof(profile.ioPins));
memcpy(io_pins::g_pwmFrequency, profile.ioPinsPwmFrequency, sizeof(profile.ioPinsPwmFrequency));
memcpy(io_pins::g_pwmDuty, profile.ioPinsPwmDuty, sizeof(profile.ioPinsPwmDuty));
Expand Down

0 comments on commit 58197f4

Please sign in to comment.