| 478 | } |
| 479 | |
| 480 | bool Simulation::InvokeSSC(bool silent, const wxString& fn) |
| 481 | { |
| 482 | SingleThreadHandler sc; |
| 483 | |
| 484 | wxProgressDialog* prog = 0; |
| 485 | |
| 486 | ConfigInfo* cfg = m_case->GetConfiguration(); |
| 487 | if (!cfg) |
| 488 | { |
| 489 | m_errors.Add("no valid configuration for this case"); |
| 490 | return false; |
| 491 | } |
| 492 | |
| 493 | m_simlist = cfg->Simulations; |
| 494 | |
| 495 | if (!silent) |
| 496 | { |
| 497 | prog = new wxProgressDialog("Simulation", "in progress", 100, |
| 498 | SamApp::GetMainTopWindow(), |
| 499 | wxPD_SMOOTH | wxPD_AUTO_HIDE ); |
| 500 | prog->Show(); |
| 501 | |
| 502 | sc.SetProgressDialog(prog); |
| 503 | } |
| 504 | |
| 505 | // Warning - be careful here if threading! |
| 506 | std::ifstream test(fn.ToStdString().c_str()); |
| 507 | std::string json_str((std::istreambuf_iterator<char>(test)), std::istreambuf_iterator<char>()); |
| 508 | auto p_data = json_to_ssc_data(json_str.c_str()); |
| 509 | |
| 510 | bool ok = InvokeSSCWithHandler(&sc, p_data); |
| 511 | if (!ok) { |
| 512 | wxMessageBox("ssc simulation failed " + wxJoin(m_errors, '\n')); |
| 513 | } |
| 514 | |
| 515 | ssc_data_free(p_data); |
| 516 | |
| 517 | if (prog) prog->Destroy(); |
| 518 | |
| 519 | return ok; |
| 520 | } |
| 521 | |
| 522 | |
| 523 |
no test coverage detected