Fix a few issue in simulation (noticeable only when the calculation time is high):

- Wait for end of simulation before return from "C" locale to current locale
(to avoid data files created by ngspice using curr locale instead of "C" locale)
- Do not allow changing signal list to plot during simulation calculation
(avoid crashes)
This commit is contained in:
jean-pierre charras 2021-05-05 20:26:56 +02:00
parent 61289ab39a
commit d4e5861c62
2 changed files with 32 additions and 3 deletions

View File

@ -282,8 +282,25 @@ bool NGSPICE::LoadNetlist( const string& aNetlist )
bool NGSPICE::Run() bool NGSPICE::Run()
{ {
wxBusyCursor dummy;
LOCALE_IO c_locale; // ngspice works correctly only with C locale LOCALE_IO c_locale; // ngspice works correctly only with C locale
return Command( "bg_run" ); // bg_* commands execute in a separate thread bool success = Command( "bg_run" ); // bg_* commands execute in a separate thread
if( success )
{
// wait for end of simulation.
// calling wxYield() allows printing activity, and stopping ngspice from GUI
// Also note: do not user wxSafeYield, because when using it we cannot stop
// ngspice from the GUI
do
{
wxMilliSleep( 50 );
wxYield();
} while( m_ngSpice_Running() );
}
return success;
} }
@ -296,7 +313,7 @@ bool NGSPICE::Stop()
bool NGSPICE::IsRunning() bool NGSPICE::IsRunning()
{ {
LOCALE_IO c_locale; // ngspice works correctly only with C locale // No need to use C locale here
return m_ngSpice_Running(); return m_ngSpice_Running();
} }

View File

@ -1336,6 +1336,12 @@ void SIM_PLOT_FRAME::onSettings( wxCommandEvent& event )
void SIM_PLOT_FRAME::onAddSignal( wxCommandEvent& event ) void SIM_PLOT_FRAME::onAddSignal( wxCommandEvent& event )
{ {
if( IsSimulationRunning() )
{
DisplayInfoMessage( this, _( "Simulator is running. Try later" ) );
return;
}
SIM_PLOT_PANEL* plotPanel = CurrentPlot(); SIM_PLOT_PANEL* plotPanel = CurrentPlot();
if( !plotPanel || !m_exporter || plotPanel->GetType() != m_exporter->GetSimType() ) if( !plotPanel || !m_exporter || plotPanel->GetType() != m_exporter->GetSimType() )
@ -1354,6 +1360,12 @@ void SIM_PLOT_FRAME::onProbe( wxCommandEvent& event )
if( m_schematicFrame == NULL ) if( m_schematicFrame == NULL )
return; return;
if( IsSimulationRunning() )
{
DisplayInfoMessage( this, _( "Simulator is running. Try later" ) );
return;
}
m_schematicFrame->GetToolManager()->RunAction( EE_ACTIONS::simProbe ); m_schematicFrame->GetToolManager()->RunAction( EE_ACTIONS::simProbe );
m_schematicFrame->Raise(); m_schematicFrame->Raise();
} }