Skip to content

Commit df8e1ac

Browse files
committed
disp:dialog fixes
1 parent 2566217 commit df8e1ac

File tree

9 files changed

+66
-39
lines changed

9 files changed

+66
-39
lines changed

modular-psu-firmware.eez-project

+33-17
Original file line numberDiff line numberDiff line change
@@ -2945,16 +2945,16 @@
29452945
"image": "images\\bb3_front_panel.png",
29462946
"extensionName": "eez_bb3",
29472947
"idn": "Envox,EEZ BB3 (STM32)",
2948-
"idfName": "EEZ BB3 R1B6",
2949-
"idfShortName": "BB3-R1B6",
2948+
"idfName": "EEZ BB3 R2B4",
2949+
"idfShortName": "BB3-R2B4",
29502950
"idfFirmwareVersion": "1.0",
29512951
"idfGuid": "687b6dee-2093-4c36-afb7-cfc7ea2bf262",
29522952
"idfRevisionNumber": "1.0.3",
29532953
"idfDescription": "EEZ Bench box 3-module T&M chassis",
2954-
"idfSupportedModels": "BB3 R1B6",
2954+
"idfSupportedModels": "BB3 R2B4",
29552955
"idfRevisionComments": "Initial version",
29562956
"idfAuthor": "Envox",
2957-
"sdlFriendlyName": "EEZ BB3 R1B6"
2957+
"sdlFriendlyName": "EEZ BB3 R2B4"
29582958
},
29592959
{
29602960
"name": "EEZ Bench Box 3 Simulator",
@@ -2971,7 +2971,7 @@
29712971
"idfGuid": "7cab6860-e593-4ba2-ee68-57fe84460fa4",
29722972
"idfRevisionNumber": "1.0.3",
29732973
"idfDescription": "EEZ Bench box 3-module T&M chassis firmware simulator",
2974-
"idfSupportedModels": "BB3 R1B6",
2974+
"idfSupportedModels": "BB3 R2B4",
29752975
"idfRevisionComments": "Initial version",
29762976
"idfAuthor": "Envox",
29772977
"sdlFriendlyName": "EEZ BB3 Simulator"
@@ -532397,7 +532397,7 @@
532397532397
"response": {}
532398532398
},
532399532399
{
532400-
"name": "DISPlay[:WINdow]:INPUt?",
532400+
"name": "DISPlay[:WINdow]:INPut?",
532401532401
"helpLink": "EEZ BB3 SCPI reference 5.4 - DISPlay.html#disp_text",
532402532402
"parameters": [
532403532403
{
@@ -533130,7 +533130,7 @@
533130533130
"parameters": [],
533131533131
"response": {
533132533132
"type": "boolean",
533133-
"enumeration": "State1"
533133+
"enumeration": "Switch"
533134533134
}
533135533135
}
533136533136
]
@@ -533546,7 +533546,7 @@
533546533546
"type": [
533547533547
{
533548533548
"type": "discrete",
533549-
"enumeration": "DprogState"
533549+
"enumeration": "Switch"
533550533550
}
533551533551
],
533552533552
"isOptional": false
@@ -533560,7 +533560,7 @@
533560533560
"parameters": [],
533561533561
"response": {
533562533562
"type": "discrete",
533563-
"enumeration": "DprogState"
533563+
"enumeration": "Switch"
533564533564
}
533565533565
},
533566533566
{
@@ -533632,8 +533632,11 @@
533632533632
"helpLink": "EEZ BB3 SCPI reference 5.12 - OUTPut.html#outp_trac",
533633533633
"parameters": [
533634533634
{
533635-
"name": "bool",
533635+
"name": "chanlist",
533636533636
"type": [
533637+
{
533638+
"type": "channel-list"
533639+
},
533637533640
{
533638533641
"type": "boolean"
533639533642
}
@@ -536233,7 +536236,7 @@
536233536236
"type": [
536234536237
{
536235536238
"type": "discrete",
536236-
"enumeration": "State1"
536239+
"enumeration": "Switch"
536237536240
}
536238536241
],
536239536242
"isOptional": false
@@ -537711,7 +537714,7 @@
537711537714
}
537712537715
},
537713537716
{
537714-
"name": "SYSTem:SERial?",
537717+
"name": "SYSTem:CPU:SNO?",
537715537718
"parameters": [],
537716537719
"response": {
537717537720
"type": "numeric"
@@ -538110,7 +538113,7 @@
538110538113
]
538111538114
},
538112538115
{
538113-
"name": "State1",
538116+
"name": "Switch",
538114538117
"members": [
538115538118
{
538116538119
"name": "ON",
@@ -538354,11 +538357,11 @@
538354538357
"name": "DataType",
538355538358
"members": [
538356538359
{
538357-
"name": "INTEger",
538360+
"name": "INTeger",
538358538361
"value": "1"
538359538362
},
538360538363
{
538361-
"name": "FLOAt",
538364+
"name": "FLOat",
538362538365
"value": "2"
538363538366
},
538364538367
{
@@ -538401,8 +538404,8 @@
538401538404
"id": "bbe8f05b-cb07-4142-efe6-840a8f2f9163",
538402538405
"name": "Tracking mode ON",
538403538406
"action": {
538404-
"type": "scpi-commands",
538405-
"data": "OUTP:TRAC ON"
538407+
"type": "javascript",
538408+
"data": "connection.acquire();\n\nvar numChannels = parseInt(await connection.query(\"SYSTem:CHANnel?\"));\n\n\nif (numChannels === 0) {\n connection.release();\n notify.error(\"There is no channel installed!\");\n return;\n}\n\nvar defaultValues = storage.getItem(\"EezTrackingModeOn\", {\n ch1: false,\n ch2: false,\n ch3: false,\n ch4: false,\n ch5: false,\n ch6: false\n});\n\nvar fields = [];\n\nfor (let i = 1; i <= numChannels; i++) {\n fields.push({ \n name: `ch${i}`,\n displayName: `Channel ${i}`,\n type: \"boolean\"\n });\n}\n\nvar values = defaultValues;\nvar channelList;\nvar numTracChannels;\nvar error;\n\nwhile (true) {\n values = await input({\n title: \"Select channels to operate in the track mode\",\n fields,\n error\n }, values);\n if (!values) {\n connection.release();\n session.deleteScriptLogEntry();\n return;\n }\n\n channelList = \"(@\";\n var numTracChannels = 0;\n for (let i = 1; i <= numChannels; i++) {\n if (values[`ch${i}`]) {\n if (numTracChannels > 0) {\n channelList +=\",\";\n }\n channelList += i.toString();\n numTracChannels++;\n }\n }\n channelList += \")\";\n \n if (numTracChannels >= 2) {\n break;\n }\n \n error = \"Select at least 2 channels.\"\n}\n\nstorage.setItem(\"EezTrackingModeOn\", values);\n\nsession.scriptParameters = channelList;\n\nconnection.command(`OUTP:TRAC ${channelList}`);\n\nconnection.release();\n"
538406538409
},
538407538410
"keybinding": "f3",
538408538411
"showInToolbar": true,
@@ -538565,6 +538568,19 @@
538565538568
"toolbarButtonPosition": 14,
538566538569
"toolbarButtonColor": "#727b84",
538567538570
"requiresConfirmation": false
538571+
},
538572+
{
538573+
"id": "755fe7e0-ca38-4391-d50c-b9cf141ed0b1",
538574+
"name": "Screenshot",
538575+
"action": {
538576+
"type": "scpi-commands",
538577+
"data": "DISP:DATA?"
538578+
},
538579+
"keybinding": "f2",
538580+
"showInToolbar": true,
538581+
"toolbarButtonPosition": 1,
538582+
"toolbarButtonColor": "#7BC3D4",
538583+
"requiresConfirmation": false
538568538584
}
538569538585
]
538570538586
}

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

+3-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,9 @@ ToastMessagePage *ToastMessagePage::create(ToastType type, const char *message,
6464
ToastMessagePage *page = ToastMessagePage::findFreePage();
6565

6666
page->type = type;
67-
page->message = message;
67+
strncpy(page->messageBuffer, message, MAX_MESSAGE_LENGTH);
68+
page->messageBuffer[ToastMessagePage::MAX_MESSAGE_LENGTH] = 0;
69+
page->message = page->messageBuffer;
6870
page->messageValue = Value();
6971
page->actionLabel = type == ERROR_TOAST && !autoDismiss ? "Close" : nullptr;
7072
page->actionWidgetIsActive = false;

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

+2
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ class ToastMessagePage : public InternalPage {
6666
private:
6767
ToastType type;
6868

69+
static const size_t MAX_MESSAGE_LENGTH = 200;
70+
char messageBuffer[MAX_MESSAGE_LENGTH + 1];
6971
const char *message;
7072
Value messageValue;
7173
const char *actionLabel;

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

+15-5
Original file line numberDiff line numberDiff line change
@@ -798,17 +798,25 @@ void PsuAppContext::doShowNumberInput() {
798798
NumericKeypad::start(this, m_inputLabel, Value(m_numberInputParams.m_input, m_numberInputParams.m_options.editValueUnit), m_numberInputParams.m_options, m_numberInputParams.onSet, nullptr, m_numberInputParams.onCancel);
799799
}
800800

801-
void PsuAppContext::dialogOpen() {
801+
bool PsuAppContext::dialogOpen(int *err) {
802802
if (osThreadGetId() == g_guiTaskHandle) {
803803
if (getActivePageId() != getExternalAssetsFirstPageId()) {
804804
dialogResetDataItemValues();
805805
pushPage(getExternalAssetsFirstPageId());
806806
}
807807
g_dialogOpening = false;
808808
} else {
809-
g_dialogOpening = true;
810-
osMessagePut(g_guiMessageQueueId, GUI_QUEUE_MESSAGE(GUI_QUEUE_MESSAGE_TYPE_DIALOG_OPEN, 0), osWaitForever);
809+
if (!g_dialogOpening && getActivePageId() != getExternalAssetsFirstPageId()) {
810+
g_dialogOpening = true;
811+
osMessagePut(g_guiMessageQueueId, GUI_QUEUE_MESSAGE(GUI_QUEUE_MESSAGE_TYPE_DIALOG_OPEN, 0), osWaitForever);
812+
} else {
813+
if (err) {
814+
*err = SCPI_ERROR_EXECUTION_ERROR;
815+
}
816+
return false;
817+
}
811818
}
819+
return true;
812820
}
813821

814822
DialogActionResult PsuAppContext::dialogAction(uint32_t timeoutMs, const char *&selectedActionName) {
@@ -875,7 +883,9 @@ void PsuAppContext::dialogClose() {
875883
popPage();
876884
}
877885
} else {
878-
osMessagePut(g_guiMessageQueueId, GUI_QUEUE_MESSAGE(GUI_QUEUE_MESSAGE_TYPE_DIALOG_CLOSE, 0), osWaitForever);
886+
if (getActivePageId() == getExternalAssetsFirstPageId()) {
887+
osMessagePut(g_guiMessageQueueId, GUI_QUEUE_MESSAGE(GUI_QUEUE_MESSAGE_TYPE_DIALOG_CLOSE, 0), osWaitForever);
888+
}
879889
}
880890
}
881891

@@ -2102,7 +2112,7 @@ void onGuiQueueMessageHook(uint8_t type, int16_t param) {
21022112
} else if (type == GUI_QUEUE_MESSAGE_TYPE_SHOW_SELECT) {
21032113
g_psuAppContext.doShowSelect();
21042114
} else if (type == GUI_QUEUE_MESSAGE_TYPE_DIALOG_OPEN) {
2105-
g_psuAppContext.dialogOpen();
2115+
g_psuAppContext.dialogOpen(nullptr);
21062116
} else if (type == GUI_QUEUE_MESSAGE_TYPE_DIALOG_CLOSE) {
21072117
g_psuAppContext.dialogClose();
21082118
} else if (type == GUI_QUEUE_MESSAGE_TYPE_SHOW_ASYNC_OPERATION_IN_PROGRESS) {

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ class PsuAppContext : public AppContext {
199199
int menuInput(const char *label, MenuType menuType, const char **menuItems);
200200
int select(const char **options, int defaultSelection);
201201

202-
void dialogOpen();
202+
bool dialogOpen(int *err);
203203
DialogActionResult dialogAction(uint32_t timeoutMs, const char *&selectedActionName);
204204
void dialogResetDataItemValues();
205205
void dialogSetDataItemValue(int16_t dataId, Value& value);

src/eez/modules/psu/scpi/display.cpp

+5-8
Original file line numberDiff line numberDiff line change
@@ -479,9 +479,7 @@ scpi_result_t scpi_cmd_displayWindowDialogOpen(scpi_t *context) {
479479
}
480480

481481
int err;
482-
if (eez::gui::loadExternalAssets(filePath, &err)) {
483-
psu::gui::g_psuAppContext.dialogOpen();
484-
} else {
482+
if (!eez::gui::loadExternalAssets(filePath, &err) || !psu::gui::g_psuAppContext.dialogOpen(&err)) {
485483
SCPI_ErrorPush(context, err);
486484
return SCPI_RES_ERR;
487485
}
@@ -526,9 +524,9 @@ scpi_result_t scpi_cmd_displayWindowDialogActionQ(scpi_t *context) {
526524
}
527525

528526
scpi_choice_def_t dataTypeChoice[] = {
529-
{ "INTEger", VALUE_TYPE_INT },
530-
{ "FLOAt", VALUE_TYPE_FLOAT },
531-
{ "STRIng", VALUE_TYPE_STR },
527+
{ "INTeger", VALUE_TYPE_INT },
528+
{ "FLOat", VALUE_TYPE_FLOAT },
529+
{ "STRing", VALUE_TYPE_STR },
532530
SCPI_CHOICE_LIST_END /* termination of option list */
533531
};
534532

@@ -548,8 +546,7 @@ scpi_result_t scpi_cmd_displayWindowDialogData(scpi_t *context) {
548546
dataItemName[valueTextLen] = 0;
549547
int16_t dataId = eez::gui::getDataIdFromName(dataItemName);
550548
if (dataId == 0) {
551-
// TODO
552-
SCPI_ErrorPush(context, SCPI_ERROR_EXECUTION_ERROR);
549+
SCPI_ErrorPush(context, SCPI_ERROR_ILLEGAL_PARAMETER_VALUE);
553550
return SCPI_RES_ERR;
554551
}
555552

src/eez/modules/psu/scpi/syst.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -660,7 +660,7 @@ scpi_result_t scpi_cmd_systemCpuOptionQ(scpi_t *context) {
660660
return SCPI_RES_OK;
661661
}
662662

663-
scpi_result_t scpi_cmd_systemSerialQ(scpi_t *context) {
663+
scpi_result_t scpi_cmd_systemCpuSnoQ(scpi_t *context) {
664664
SCPI_ResultText(context, getSerialNumber());
665665
return SCPI_RES_OK;
666666
}

src/eez/scpi/commands_simulator.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@
4848
SCPI_COMMAND("DISPlay[:WINdow][:STATe]?", scpi_cmd_displayWindowStateQ) \
4949
SCPI_COMMAND("DISPlay:DATA?", scpi_cmd_displayDataQ) \
5050
SCPI_COMMAND("DISPlay[:WINdow]:DLOG", scpi_cmd_displayWindowDlog) \
51-
SCPI_COMMAND("DISPlay[:WINdow]:INPUt?", scpi_cmd_displayWindowInputQ) \
52-
SCPI_COMMAND("DISPlay[:WINdow]:SELEct?", scpi_cmd_displayWindowSelectQ) \
51+
SCPI_COMMAND("DISPlay[:WINdow]:INPut?", scpi_cmd_displayWindowInputQ) \
52+
SCPI_COMMAND("DISPlay[:WINdow]:SELect?", scpi_cmd_displayWindowSelectQ) \
5353
SCPI_COMMAND("DISPlay[:WINdow]:DIALog[:OPEN]", scpi_cmd_displayWindowDialogOpen) \
5454
SCPI_COMMAND("DISPlay[:WINdow]:DIALog:ACTIon?", scpi_cmd_displayWindowDialogActionQ) \
5555
SCPI_COMMAND("DISPlay[:WINdow]:DIALog:DATA", scpi_cmd_displayWindowDialogData) \
@@ -392,4 +392,4 @@
392392
SCPI_COMMAND("DEBUg:EVENt", scpi_cmd_debugEvent) \
393393
SCPI_COMMAND("SYSTem:DATE:CLEar", scpi_cmd_systemDateClear) \
394394
SCPI_COMMAND("SYSTem:TIME:CLEar", scpi_cmd_systemTimeClear) \
395-
SCPI_COMMAND("SYSTem:SERial?", scpi_cmd_systemSerialQ)
395+
SCPI_COMMAND("SYSTem:CPU:SNO?", scpi_cmd_systemCpuSnoQ)

src/eez/scpi/commands_stm32.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@
4848
SCPI_COMMAND("DISPlay[:WINdow][:STATe]?", scpi_cmd_displayWindowStateQ) \
4949
SCPI_COMMAND("DISPlay:DATA?", scpi_cmd_displayDataQ) \
5050
SCPI_COMMAND("DISPlay[:WINdow]:DLOG", scpi_cmd_displayWindowDlog) \
51-
SCPI_COMMAND("DISPlay[:WINdow]:INPUt?", scpi_cmd_displayWindowInputQ) \
52-
SCPI_COMMAND("DISPlay[:WINdow]:SELEct?", scpi_cmd_displayWindowSelectQ) \
51+
SCPI_COMMAND("DISPlay[:WINdow]:INPut?", scpi_cmd_displayWindowInputQ) \
52+
SCPI_COMMAND("DISPlay[:WINdow]:SELect?", scpi_cmd_displayWindowSelectQ) \
5353
SCPI_COMMAND("DISPlay[:WINdow]:DIALog[:OPEN]", scpi_cmd_displayWindowDialogOpen) \
5454
SCPI_COMMAND("DISPlay[:WINdow]:DIALog:ACTIon?", scpi_cmd_displayWindowDialogActionQ) \
5555
SCPI_COMMAND("DISPlay[:WINdow]:DIALog:DATA", scpi_cmd_displayWindowDialogData) \
@@ -392,4 +392,4 @@
392392
SCPI_COMMAND("DEBUg:EVENt", scpi_cmd_debugEvent) \
393393
SCPI_COMMAND("SYSTem:DATE:CLEar", scpi_cmd_systemDateClear) \
394394
SCPI_COMMAND("SYSTem:TIME:CLEar", scpi_cmd_systemTimeClear) \
395-
SCPI_COMMAND("SYSTem:SERial?", scpi_cmd_systemSerialQ)
395+
SCPI_COMMAND("SYSTem:CPU:SNO?", scpi_cmd_systemCpuSnoQ)

0 commit comments

Comments
 (0)