simulator: fix a issue when the simulation ends, but ngspice is still running.

For instance if a lot of simulation results must be written to a file (using wrdata).
In this case the tools in simulator frame toolbar were never enabled.
This commit is contained in:
jean-pierre charras 2022-08-31 12:07:05 +02:00
parent 2dc6300501
commit f679400e91
1 changed files with 18 additions and 2 deletions

View File

@ -1742,8 +1742,24 @@ void SIM_PLOT_FRAME::onSimFinished( wxCommandEvent& aEvent )
if( !plotPanelWindow || plotPanelWindow->GetType() != simType )
plotPanelWindow = NewPlotPanel( m_circuitModel->GetSimCommand() );
// Sometimes (for instance with a directive like wrdata my_file.csv "my_signal")
// the simulator is in idle state (simulation is finished), but still running, during
// the time the file is written. So gives a slice of time to fully finish the work:
if( m_simulator->IsRunning() )
return;
{
int max_time = 40; // For a max timeout = 2s
do
{
wxMilliSleep( 50 );
wxYield();
if( max_time )
max_time--;
} while( max_time && m_simulator->IsRunning() );
}
// Is a warning message useful if the simulatior is still running?
// If there are any signals plotted, update them
if( SIM_PANEL_BASE::IsPlottable( simType ) )