MCPcopy Create free account
hub / github.com/NatLabRockies/SAM / fcall_simulate

Function fcall_simulate

src/script.cpp:286–320  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

284
285
286static void fcall_simulate( lk::invoke_t &cxt )
287{
288 LK_DOC("simulate", "Run the base case simulation for the currently active case. Errors and warnings are optionally returned in the first parameter. The results in the user interface are not updated by default, but can be via the second parameter.", "( [string:messages], [boolean: update UI] ):boolean" );
289 cxt.result().assign( 0.0 );
290 if ( Case *c = CurrentCase() )
291 {
292 Simulation &bcsim = c->BaseCase();
293 bcsim.Clear();
294
295 ExcelExchange &ex = c->ExcelExch();
296 if ( ex.Enabled )
297 ExcelExchange::RunExcelExchange( ex, c->Values(0), &bcsim );
298
299 if ( !bcsim.Prepare() )
300 {
301 cxt.result().assign( 0.0 );
302
303 if( cxt.arg_count() > 0 )
304 cxt.arg(0).assign( wxJoin( c->BaseCase().GetAllMessages(), '\n' ) );
305
306 return;
307 }
308
309 ScriptSimulationHandler ssh;
310 cxt.result().assign( bcsim.InvokeWithHandler( &ssh ) ? 1.0 : 0.0 );
311
312 if( cxt.arg_count() > 0 )
313 cxt.arg(0).assign( wxJoin( c->BaseCase().GetAllMessages(), '\n' ) );
314
315 if ( cxt.arg_count() > 1 && cxt.arg(1).as_boolean() )
316 if ( CaseWindow *cw = SamApp::Window()->GetCaseWindow( c ) )
317 cw->UpdateResults();
318 }
319 else cxt.error("no active case");
320}
321
322static void fcall_simulate_ssc_tests( lk::invoke_t &cxt )
323{

Callers

nothing calls this directly

Calls 8

CurrentCaseFunction · 0.85
assignMethod · 0.80
GetAllMessagesMethod · 0.80
InvokeWithHandlerMethod · 0.80
UpdateResultsMethod · 0.80
ClearMethod · 0.45
PrepareMethod · 0.45
GetCaseWindowMethod · 0.45

Tested by

no test coverage detected