Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
mvladic committed Nov 28, 2020
1 parent e367f81 commit 2413013
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 42 deletions.
1 change: 1 addition & 0 deletions src/eez/gui/data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ bool compare_NONE_value(const Value &a, const Value &b) {
}

void NONE_value_to_text(const Value &value, char *text, int count) {
*text = 0;
}

bool compare_INT_value(const Value &a, const Value &b) {
Expand Down
12 changes: 4 additions & 8 deletions src/eez/modules/psu/dlog_record.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -495,15 +495,14 @@ static void log(uint32_t tickCount) {
) {
writeFloat(NAN);
} else if (dlogItem.resourceType >= DLOG_RESOURCE_TYPE_DIN0 && dlogItem.resourceType <= DLOG_RESOURCE_TYPE_DIN7) {
writeUint8(0);
writeFloat(NAN);
}
}

++g_recording.size;
}

// write sample
dlog_view::DlogItem *prevDlogItem = nullptr;
for (int i = 0; i < g_recording.parameters.numDlogItems; i++) {
auto &dlogItem = g_recording.parameters.dlogItems[i];
if (dlogItem.resourceType == DLOG_RESOURCE_TYPE_U) {
Expand All @@ -516,13 +515,10 @@ static void log(uint32_t tickCount) {
channel_dispatcher::getIMonLast(dlogItem.slotIndex, dlogItem.subchannelIndex)
);
} else if (dlogItem.resourceType >= DLOG_RESOURCE_TYPE_DIN0 && dlogItem.resourceType <= DLOG_RESOURCE_TYPE_DIN7) {
if (prevDlogItem == nullptr || prevDlogItem->slotIndex != dlogItem.slotIndex || prevDlogItem->subchannelIndex != dlogItem.subchannelIndex) {
uint8_t data;
channel_dispatcher::getDigitalInputData(dlogItem.slotIndex, dlogItem.subchannelIndex, data, nullptr);
writeUint8(data);
}
uint8_t data;
channel_dispatcher::getDigitalInputData(dlogItem.slotIndex, dlogItem.subchannelIndex, data, nullptr);
writeFloat(data * 1.0f);
}
prevDlogItem = &dlogItem;
}

++g_recording.size;
Expand Down
4 changes: 2 additions & 2 deletions src/eez/modules/psu/dlog_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -538,10 +538,10 @@ void initAxis(Recording &recording) {
yAxis.channelIndex = dlogItem.subchannelIndex;
}
} else if (dlogItem.resourceType >= DLOG_RESOURCE_TYPE_DIN0 && dlogItem.resourceType <= DLOG_RESOURCE_TYPE_DIN7) {
yAxis.unit = UNIT_NONE;
yAxis.unit = UNIT_UNKNOWN;
yAxis.range.min = 0;
yAxis.range.max = 1;
yAxis.channelIndex = dlogItem.resourceType - DLOG_RESOURCE_TYPE_DIN0;
yAxis.channelIndex = -1;
}
strcpy(yAxis.label, g_slots[dlogItem.slotIndex]->getDlogResourceLabel(dlogItem.subchannelIndex, dlogItem.resourceIndex));
}
Expand Down
47 changes: 16 additions & 31 deletions src/eez/modules/psu/gui/data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1227,17 +1227,15 @@ void data_channel_output_state(DataOperationEnum operation, Cursor cursor, Value
void data_channel_is_cc(DataOperationEnum operation, Cursor cursor, Value &value) {
if (operation == DATA_OPERATION_GET) {
int iChannel = cursor >= 0 ? cursor : (g_channel ? g_channel->channelIndex : 0);
if (iChannel < CH_NUM) {
Channel &channel = Channel::get(iChannel);
value = channel.getMode() == CHANNEL_MODE_CC;
}
Channel &channel = Channel::get(iChannel);
value = channel.getMode() == CHANNEL_MODE_CC;
}
}

void data_channel_is_cv(DataOperationEnum operation, Cursor cursor, Value &value) {
if (operation == DATA_OPERATION_GET) {
int iChannel = cursor >= 0 ? cursor : (g_channel ? g_channel->channelIndex : -1);
if (iChannel >= 0 && iChannel < CH_NUM) {
if (iChannel != -1) {
Channel &channel = Channel::get(iChannel);
value = channel.getMode() == CHANNEL_MODE_CV;
} else {
Expand Down Expand Up @@ -1627,8 +1625,7 @@ void data_no_channel_index(int slotIndex, DataOperationEnum operation, Cursor cu
}

void data_slot_channel_index(int slotIndex, Channel *channel, DataOperationEnum operation, Cursor cursor, Value &value) {
auto testResult = g_slots[slotIndex]->getTestResult();
if (channel && (testResult == TEST_OK || testResult == TEST_SKIPPED)) {
if (channel) {
data_channel_index(*channel, operation, cursor, value);
} else {
data_no_channel_index(slotIndex, operation, cursor, value);
Expand Down Expand Up @@ -2711,10 +2708,8 @@ void data_channel_rsense_installed(DataOperationEnum operation, Cursor cursor, V
void data_channel_rsense_status(DataOperationEnum operation, Cursor cursor, Value &value) {
if (operation == DATA_OPERATION_GET) {
int iChannel = cursor >= 0 ? cursor : (g_channel ? g_channel->channelIndex : 0);
if (iChannel < CH_NUM) {
Channel &channel = Channel::get(iChannel);
value = channel.isRemoteSensingEnabled();
}
Channel &channel = Channel::get(iChannel);
value = channel.isRemoteSensingEnabled();
}
}

Expand All @@ -2727,10 +2722,8 @@ void data_channel_rprog_installed(DataOperationEnum operation, Cursor cursor, Va
void data_channel_rprog_status(DataOperationEnum operation, Cursor cursor, Value &value) {
if (operation == DATA_OPERATION_GET) {
int iChannel = cursor >= 0 ? cursor : (g_channel ? g_channel->channelIndex : 0);
if (iChannel < CH_NUM) {
Channel &channel = Channel::get(iChannel);
value = (int)channel.flags.rprogEnabled;
}
Channel &channel = Channel::get(iChannel);
value = (int)channel.flags.rprogEnabled;
}
}

Expand Down Expand Up @@ -4482,37 +4475,29 @@ void data_sys_display_background_luminosity_step(DataOperationEnum operation, Cu

void data_simulator_load_state(DataOperationEnum operation, Cursor cursor, Value &value) {
if (operation == DATA_OPERATION_GET) {
if (cursor < CH_NUM) {
Channel &channel = Channel::get(cursor);
value = channel.simulator.getLoadEnabled() ? 1 : 0;
}
Channel &channel = Channel::get(cursor);
value = channel.simulator.getLoadEnabled() ? 1 : 0;
}
}

void data_simulator_load(DataOperationEnum operation, Cursor cursor, Value &value) {
if (operation == DATA_OPERATION_GET) {
if (cursor < CH_NUM) {
Channel &channel = Channel::get(cursor);
value = MakeValue(channel.simulator.getLoad(), UNIT_OHM);
}
Channel &channel = Channel::get(cursor);
value = MakeValue(channel.simulator.getLoad(), UNIT_OHM);
}
}

void data_simulator_load_state2(DataOperationEnum operation, Cursor cursor, Value &value) {
if (operation == DATA_OPERATION_GET) {
if (cursor < CH_NUM) {
Channel &channel = Channel::get(cursor + 1);
value = channel.simulator.getLoadEnabled() ? 1 : 0;
}
Channel &channel = Channel::get(cursor + 1);
value = channel.simulator.getLoadEnabled() ? 1 : 0;
}
}

void data_simulator_load2(DataOperationEnum operation, Cursor cursor, Value &value) {
if (operation == DATA_OPERATION_GET) {
if (cursor < CH_NUM) {
Channel &channel = Channel::get(cursor + 1);
value = MakeValue(channel.simulator.getLoad(), UNIT_OHM);
}
Channel &channel = Channel::get(cursor + 1);
value = MakeValue(channel.simulator.getLoad(), UNIT_OHM);
}
}

Expand Down
1 change: 0 additions & 1 deletion src/eez/unit.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ namespace eez {

// order of units should not be changed since it is used in DLOG files
enum Unit {
UNIT_NONE = -1,
UNIT_UNKNOWN,
UNIT_VOLT,
UNIT_MILLI_VOLT,
Expand Down

0 comments on commit 2413013

Please sign in to comment.