From fefbe68309cb1fab9c2868f05cf67be44a6bdfc5 Mon Sep 17 00:00:00 2001 From: kevin Date: Fri, 20 Dec 2024 13:23:22 -0500 Subject: [PATCH] cwIoFlowCtl.h/cpp : Added program_apply_preset(), send_ui_updates(). --- cwIoFlowCtl.cpp | 41 +++++++++++++++++++++++++++++++++++++++++ cwIoFlowCtl.h | 4 ++++ 2 files changed, 45 insertions(+) diff --git a/cwIoFlowCtl.cpp b/cwIoFlowCtl.cpp index d177320..57b72b6 100644 --- a/cwIoFlowCtl.cpp +++ b/cwIoFlowCtl.cpp @@ -21,6 +21,7 @@ #include "cwDspTypes.h" #include "cwFlowDecl.h" #include "cwFlow.h" +#include "cwFlowValue.h" #include "cwFlowTypes.h" #include "cwIo.h" @@ -804,6 +805,35 @@ bool cw::io_flow_ctl::program_is_initialized( handle_t h ) return p->init_fl; } +cw::rc_t cw::io_flow_ctl::program_apply_preset( handle_t h, unsigned preset_idx ) +{ + rc_t rc = kOkRC; + const char* preset_label = nullptr; + io_flow_ctl_t* p = _handleToPtr(h); + if( !p->init_fl ) + { + rc = cwLogError(kInvalidStateRC,"The preset cannot be applied because the program is not initialized."); + goto errLabel; + } + + if((preset_label = flow::preset_label(p->flowH,preset_idx)) == nullptr ) + { + rc = cwLogError(kInvalidArgRC,"The preset index '%i' is invalid.",preset_idx); + goto errLabel; + } + + if((rc = apply_preset(p->flowH,preset_label)) != kOkRC ) + { + rc = cwLogError(rc,"Application of the preset '%s' failed.",preset_label); + goto errLabel; + + } + +errLabel: + return rc; + +} + const cw::flow::ui_net_t* cw::io_flow_ctl::program_ui_net( handle_t h ) { io_flow_ctl_t* p = _handleToPtr(h); @@ -881,6 +911,17 @@ bool cw::io_flow_ctl::is_exec_complete( handle_t h ) return p->done_fl; } +cw::rc_t cw::io_flow_ctl::send_ui_updates( handle_t h ) +{ + rc_t rc = kOkRC; + io_flow_ctl_t* p = _handleToPtr(h); + if( program_is_initialized(h) ) + rc = send_ui_updates(p->flowH); + + return rc; +} + + cw::rc_t cw::io_flow_ctl::get_variable_value( handle_t h, const flow::ui_var_t* ui_var, bool& value_ref ) { return get_variable_value( _handleToPtr(h)->flowH, ui_var, value_ref ); } diff --git a/cwIoFlowCtl.h b/cwIoFlowCtl.h index 5553df2..dc71687 100644 --- a/cwIoFlowCtl.h +++ b/cwIoFlowCtl.h @@ -36,6 +36,8 @@ namespace cw rc_t program_initialize( handle_t h, unsigned preset_idx=kInvalidIdx ); bool program_is_initialized( handle_t h ); + rc_t program_apply_preset( handle_t h, unsigned preset_idx ); + // Get the UI description data structures for the current program. const flow::ui_net_t* program_ui_net( handle_t h ); @@ -52,6 +54,8 @@ namespace cw // The current program has completed. bool is_exec_complete( handle_t h ); + rc_t send_ui_updates( handle_t h ); + rc_t get_variable_value( handle_t h, const flow::ui_var_t* ui_var, bool& value_ref ); rc_t get_variable_value( handle_t h, const flow::ui_var_t* ui_var, int& value_ref ); rc_t get_variable_value( handle_t h, const flow::ui_var_t* ui_var, unsigned& value_ref );