cwIoFlowCtl.h/cpp : Added program_is_initialized().

This commit is contained in:
kevin 2024-09-21 17:18:46 -04:00
parent 4f2174c82d
commit 64d5886392
2 changed files with 16 additions and 2 deletions

View File

@ -80,6 +80,7 @@ namespace cw
flow::handle_t flowH; // flow::handle_t flowH; //
char* proj_dir; // current project directory char* proj_dir; // current project directory
bool init_fl;
bool done_fl; bool done_fl;
} io_flow_ctl_t; } io_flow_ctl_t;
@ -121,6 +122,8 @@ namespace cw
mem::release(p->proj_dir); mem::release(p->proj_dir);
p->pgm_idx = kInvalidIdx; p->pgm_idx = kInvalidIdx;
p->done_fl = true;
p->init_fl = false;
errLabel: errLabel:
return rc; return rc;
@ -485,6 +488,7 @@ namespace cw
if( rc == kEofRC ) if( rc == kEofRC )
{ {
p->done_fl = true; p->done_fl = true;
p->init_fl = false;
rc = kOkRC; rc = kOkRC;
} }
} }
@ -642,6 +646,7 @@ cw::rc_t cw::io_flow_ctl::program_load( handle_t h, unsigned pgm_idx )
p->pgm_idx = pgm_idx; p->pgm_idx = pgm_idx;
p->done_fl = false; p->done_fl = false;
p->init_fl = false;
errLabel: errLabel:
return rc; return rc;
@ -697,7 +702,7 @@ cw::rc_t cw::io_flow_ctl::program_initialize( handle_t h, unsigned preset_idx )
rc_t rc = kOkRC; rc_t rc = kOkRC;
io_flow_ctl_t* p = _handleToPtr(h); io_flow_ctl_t* p = _handleToPtr(h);
if( p->pgm_idx == kInvalidIdx || p->done_fl || !p->flowH.isValid() ) if( p->pgm_idx == kInvalidIdx || p->init_fl || p->done_fl || !p->flowH.isValid() )
{ {
cwLogError(kInvalidStateRC,"A valid pre-initialized program is not loaded."); cwLogError(kInvalidStateRC,"A valid pre-initialized program is not loaded.");
goto errLabel; goto errLabel;
@ -713,10 +718,18 @@ cw::rc_t cw::io_flow_ctl::program_initialize( handle_t h, unsigned preset_idx )
goto errLabel; goto errLabel;
} }
p->init_fl = true;
errLabel: errLabel:
return rc; return rc;
} }
bool cw::io_flow_ctl::program_is_initialized( handle_t h )
{
io_flow_ctl_t* p = _handleToPtr(h);
return p->init_fl;
}
cw::rc_t cw::io_flow_ctl::exec_nrt( handle_t h ) cw::rc_t cw::io_flow_ctl::exec_nrt( handle_t h )
{ {
rc_t rc = kOkRC; rc_t rc = kOkRC;
@ -777,7 +790,7 @@ bool cw::io_flow_ctl::is_executable( handle_t h )
io_flow_ctl_t* p = _handleToPtr(h); io_flow_ctl_t* p = _handleToPtr(h);
// A program must be loaded, initialized and execution cannot be complete // A program must be loaded, initialized and execution cannot be complete
return p->pgm_idx != kInvalidIdx && p->done_fl==false; return p->pgm_idx != kInvalidIdx && p->init_fl && p->done_fl==false;
} }
bool cw::io_flow_ctl::is_exec_complete( handle_t h ) bool cw::io_flow_ctl::is_exec_complete( handle_t h )

View File

@ -32,6 +32,7 @@ namespace cw
// Create the network and prepare to enter runtime. // Create the network and prepare to enter runtime.
rc_t program_initialize( handle_t h, unsigned preset_idx=kInvalidIdx ); rc_t program_initialize( handle_t h, unsigned preset_idx=kInvalidIdx );
bool program_is_initialized( handle_t h );
// Execute the currently loaded non-real-time program to completion. // Execute the currently loaded non-real-time program to completion.
rc_t exec_nrt( handle_t h ); rc_t exec_nrt( handle_t h );