eeschema: Add sync functions to SPICE_SIMULATOR
SPICE simulator can be called also during IBIS model determination, and in the future in ERC. Therefore a necessity arises to implement exclusive access.
This commit is contained in:
parent
cf611f1742
commit
2fed8aa4b8
|
@ -476,10 +476,17 @@ void SIM_PLOT_FRAME::StartSimulation( const wxString& aSimCommand )
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::unique_lock<std::mutex> simulatorLock( m_simulator->GetMutex(), std::try_to_lock );
|
||||||
|
|
||||||
|
if( simulatorLock.owns_lock() )
|
||||||
|
{
|
||||||
m_simulator->LoadNetlist( formatter.GetString() );
|
m_simulator->LoadNetlist( formatter.GetString() );
|
||||||
updateTuners();
|
updateTuners();
|
||||||
applyTuners();
|
applyTuners();
|
||||||
m_simulator->Run();
|
m_simulator->Run();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
DisplayErrorMessage( this, _( "Another simulation is already running." ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1807,14 +1814,22 @@ void SIM_PLOT_FRAME::onSimUpdate( wxCommandEvent& aEvent )
|
||||||
StartSimulation();
|
StartSimulation();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
std::unique_lock<std::mutex> simulatorLock( m_simulator->GetMutex(), std::try_to_lock );
|
||||||
|
|
||||||
|
if( simulatorLock.owns_lock() )
|
||||||
{
|
{
|
||||||
// Incremental update
|
// Incremental update
|
||||||
m_simConsole->Clear();
|
m_simConsole->Clear();
|
||||||
|
|
||||||
// Do not export netlist, it is already stored in the simulator
|
// Do not export netlist, it is already stored in the simulator
|
||||||
applyTuners();
|
applyTuners();
|
||||||
|
|
||||||
m_simulator->Run();
|
m_simulator->Run();
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
DisplayErrorMessage( this, _( "Another simulation is already running." ) );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
#include "sim_types.h"
|
#include "sim_types.h"
|
||||||
#include "spice_settings.h"
|
#include "spice_settings.h"
|
||||||
|
|
||||||
|
#include <mutex>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <complex>
|
#include <complex>
|
||||||
|
@ -63,6 +64,14 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual void Init( const SPICE_SIMULATOR_SETTINGS* aSettings = nullptr ) = 0;
|
virtual void Init( const SPICE_SIMULATOR_SETTINGS* aSettings = nullptr ) = 0;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @return mutex for exclusive access to the simulator.
|
||||||
|
*/
|
||||||
|
std::mutex& GetMutex()
|
||||||
|
{
|
||||||
|
return m_mutex;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load a netlist for the simulation.
|
* Load a netlist for the simulation.
|
||||||
*
|
*
|
||||||
|
@ -204,6 +213,10 @@ protected:
|
||||||
|
|
||||||
///< We don't own this. We are just borrowing it from the #SCHEMATIC_SETTINGS.
|
///< We don't own this. We are just borrowing it from the #SCHEMATIC_SETTINGS.
|
||||||
std::shared_ptr<SPICE_SIMULATOR_SETTINGS> m_settings;
|
std::shared_ptr<SPICE_SIMULATOR_SETTINGS> m_settings;
|
||||||
|
|
||||||
|
private:
|
||||||
|
///< For interprocess synchronisation.
|
||||||
|
std::mutex m_mutex;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* SPICE_SIMULATOR_H */
|
#endif /* SPICE_SIMULATOR_H */
|
||||||
|
|
Loading…
Reference in New Issue