| 284 | |
| 285 | |
| 286 | static 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 | |
| 322 | static void fcall_simulate_ssc_tests( lk::invoke_t &cxt ) |
| 323 | { |
nothing calls this directly
no test coverage detected