diff --git a/src/caw/html/ui.cfg b/src/caw/html/ui.cfg
index 2ac9bd5..c432a28 100644
--- a/src/caw/html/ui.cfg
+++ b/src/caw/html/ui.cfg
@@ -17,6 +17,7 @@
select:{ name: pgmSelId, title:"Programs", children: {} },
select:{ name: pgmPresetSelId, title:"Presets", children: {}, enable:false },
button:{ name: pgmLoadBtnId, title:"Load", enable:false },
+ button:{ name: pgmPrintBtnId, title:"Print", enable:false },
check: { name: runCheckId, title: "Run", enable:false },
},
diff --git a/src/caw/main.cpp b/src/caw/main.cpp
index 5437dd3..9a0ce50 100644
--- a/src/caw/main.cpp
+++ b/src/caw/main.cpp
@@ -74,6 +74,7 @@ ui::appIdMap_t appIdMapA[] = {
{ kPanelDivId, kPgmSelId, "pgmSelId" },
{ kPanelDivId, kPgmPresetSelId, "pgmPresetSelId" },
{ kPanelDivId, kPgmLoadBtnId, "pgmLoadBtnId" },
+ { kPanelDivId, kPgmPrintBtnId, "pgmPrintBtnId" },
{ kPanelDivId, kRunCheckId, "runCheckId" },
{ kPanelDivId, kRootNetPanelId, "rootNetPanelId" },
@@ -168,6 +169,8 @@ rc_t _on_pgm_select(app_t* app, unsigned pgmSelOptId )
unsigned pgm_idx = kInvalidIdx;
unsigned pgmPresetSelUuId = io::uiFindElementUuId( app->ioH, kPgmPresetSelId );
unsigned pgmLoadBtnUuId = io::uiFindElementUuId( app->ioH, kPgmLoadBtnId );
+ unsigned pgmPrintBtnUuId = io::uiFindElementUuId( app->ioH, kPgmPrintBtnId );
+ unsigned runCheckUuId = io::uiFindElementUuId( app->ioH, kRunCheckId );
unsigned preset_cnt = 0;
if( !(kPgmBaseSelId <= pgmSelOptId && pgmSelOptId <= kPgmMaxSelId ) )
@@ -185,6 +188,8 @@ rc_t _on_pgm_select(app_t* app, unsigned pgmSelOptId )
uiSetEnable( app->ioH, pgmPresetSelUuId, false ); // Disable the preset menu and load btn in anticipation of error.
uiSetEnable( app->ioH, pgmLoadBtnUuId, false ); //
+ uiSetEnable( app->ioH, pgmPrintBtnUuId, false ); //
+ uiSetEnable( app->ioH, runCheckUuId, false ); //
app->pgm_preset_idx = kInvalidIdx; // The preset menu is empty and so there can be no valid preset selected.
pgm_idx = pgmSelOptId - kPgmBaseSelId; // Calc the ioFlowCtl preset index of the selected preset.
@@ -232,6 +237,13 @@ rc_t _on_pgm_preset_select( app_t* app, unsigned pgmPresetSelOptId )
app->pgm_preset_idx = pgmPresetSelOptId - kPgmPresetBaseSelId;
+ if( program_is_initialized(app->ioFlowH) )
+ if((rc = program_apply_preset( app->ioFlowH, app->pgm_preset_idx )) == kOkRC )
+ {
+ // if the app isn't running then update the UI manually
+ if( !app->run_fl )
+ rc = send_ui_updates(app->ioFlowH);
+ }
errLabel:
@@ -265,6 +277,7 @@ rc_t _on_pgm_load(app_t* app )
}
uiSetEnable(app->ioH, io::uiFindElementUuId( app->ioH, kRunCheckId ), true );
+ uiSetEnable(app->ioH, io::uiFindElementUuId( app->ioH, kPgmPrintBtnId ), true );
}
@@ -273,6 +286,15 @@ errLabel:
return rc;
}
+rc_t _on_pgm_print( app_t* app )
+{
+ rc_t rc = kOkRC;
+ if( app->ioFlowH.isValid() )
+ print_network(app->ioFlowH);
+
+ return rc;
+}
+
rc_t _on_pgm_run( app_t* app, bool run_check_fl )
{
rc_t rc = kOkRC;
@@ -373,6 +395,10 @@ rc_t _ui_value_callback(app_t* app, const io::ui_msg_t& m )
case kPgmLoadBtnId:
_on_pgm_load(app);
break;
+
+ case kPgmPrintBtnId:
+ _on_pgm_print(app);
+ break;
case kRunCheckId:
io::uiSetTitle(app->ioH,m.uuId,m.value->u.b ? "Off" : "On" );
@@ -727,8 +753,9 @@ void _test_stub( app_t& app )
int main( int argc, char* argv[] )
{
rc_t rc = kOkRC;
- app_t app = { .pgm_preset_idx=kInvalidIdx }; // all zero except ...
bool exec_complete_fl = false;
+ app_t app = {}; // all zero
+ app.pgm_preset_idx = kInvalidIdx;
cw::log::createGlobal();