ADDED checkbox for saving SPICE digital event data.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/17828
This commit is contained in:
Jeff Young 2024-05-12 15:45:42 +01:00
parent 0008991f02
commit e73d2a32dc
14 changed files with 114 additions and 3 deletions

View File

@ -110,6 +110,7 @@ public:
wxCheckBox* m_SaveAllVoltages;
wxCheckBox* m_SaveAllCurrents;
wxCheckBox* m_SaveAllDissipations;
wxCheckBox* m_SaveAllEvents;
wxCheckBox* m_RunExternalSpiceCommand;
wxTextCtrl* m_CommandStringCtrl;
wxTextCtrl* m_TitleStringCtrl;
@ -208,6 +209,7 @@ enum id_netlist {
ID_SAVE_ALL_VOLTAGES,
ID_SAVE_ALL_CURRENTS,
ID_SAVE_ALL_DISSIPATIONS,
ID_SAVE_ALL_EVENTS,
ID_RUN_SIMULATOR
};
@ -224,6 +226,7 @@ EXPORT_NETLIST_PAGE::EXPORT_NETLIST_PAGE( wxNotebook* aParent, const wxString& a
m_SaveAllVoltages = nullptr;
m_SaveAllCurrents = nullptr;
m_SaveAllDissipations = nullptr;
m_SaveAllEvents = nullptr;
m_RunExternalSpiceCommand = nullptr;
m_custom = aCustom;
@ -341,6 +344,12 @@ void DIALOG_EXPORT_NETLIST::InstallPageSpice()
page->m_SaveAllDissipations->SetValue( settings.m_SpiceSaveAllDissipations );
page->m_LeftBoxSizer->Add( page->m_SaveAllDissipations, 0, wxBOTTOM | wxRIGHT, 5 );
page->m_SaveAllEvents = new wxCheckBox( page, ID_SAVE_ALL_EVENTS,
_( "Save all digital event data" ) );
page->m_SaveAllEvents->SetToolTip( _( "If not set, write a directive to prevent the saving of digital event data (esave none)" ) );
page->m_SaveAllEvents->SetValue( settings.m_SpiceSaveAllEvents );
page->m_LeftBoxSizer->Add( page->m_SaveAllEvents, 0, wxBOTTOM | wxRIGHT, 5 );
page->m_RunExternalSpiceCommand = new wxCheckBox( page, ID_RUN_SIMULATOR,
_( "Run external simulator command:" ) );
@ -448,6 +457,7 @@ bool DIALOG_EXPORT_NETLIST::NetlistUpdateOpt()
bool saveAllVoltages = m_PanelNetType[ PANELSPICE ]->m_SaveAllVoltages->IsChecked();
bool saveAllCurrents = m_PanelNetType[ PANELSPICE ]->m_SaveAllCurrents->IsChecked();
bool saveAllDissipations = m_PanelNetType[ PANELSPICE ]->m_SaveAllDissipations->IsChecked();
bool saveAllEvents = m_PanelNetType[ PANELSPICE ]->m_SaveAllEvents->IsChecked();
wxString spiceCmdString = m_PanelNetType[ PANELSPICE ]->m_CommandStringCtrl->GetValue();
bool curSheetAsRoot = m_PanelNetType[ PANELSPICE ]->m_CurSheetAsRoot->GetValue();
bool spiceModelCurSheetAsRoot = m_PanelNetType[ PANELSPICEMODEL ]->m_CurSheetAsRoot->GetValue();
@ -458,6 +468,7 @@ bool DIALOG_EXPORT_NETLIST::NetlistUpdateOpt()
changed |= ( settings.m_SpiceSaveAllVoltages != saveAllVoltages );
changed |= ( settings.m_SpiceSaveAllCurrents != saveAllCurrents );
changed |= ( settings.m_SpiceSaveAllDissipations != saveAllDissipations );
changed |= ( settings.m_SpiceSaveAllEvents != saveAllEvents );
changed |= ( settings.m_SpiceCommandString != spiceCmdString );
changed |= ( settings.m_SpiceCurSheetAsRoot != curSheetAsRoot );
changed |= ( settings.m_SpiceModelCurSheetAsRoot != spiceModelCurSheetAsRoot );
@ -466,6 +477,7 @@ bool DIALOG_EXPORT_NETLIST::NetlistUpdateOpt()
settings.m_SpiceSaveAllVoltages = saveAllVoltages;
settings.m_SpiceSaveAllCurrents = saveAllCurrents;
settings.m_SpiceSaveAllDissipations = saveAllDissipations;
settings.m_SpiceSaveAllEvents = saveAllEvents;
settings.m_SpiceCommandString = spiceCmdString;
settings.m_SpiceCurSheetAsRoot = curSheetAsRoot;
settings.m_SpiceModelCurSheetAsRoot = spiceModelCurSheetAsRoot;
@ -511,6 +523,9 @@ bool DIALOG_EXPORT_NETLIST::TransferDataFromWindow()
if( currPage->m_SaveAllDissipations->GetValue() )
netlist_opt |= NETLIST_EXPORTER_SPICE::OPTION_SAVE_ALL_DISSIPATIONS;
if( currPage->m_SaveAllEvents->GetValue() )
netlist_opt |= NETLIST_EXPORTER_SPICE::OPTION_SAVE_ALL_EVENTS;
if( currPage->m_CurSheetAsRoot->GetValue() )
netlist_opt |= NETLIST_EXPORTER_SPICE::OPTION_CUR_SHEET_AS_ROOT;

View File

@ -517,6 +517,9 @@ void DIALOG_SIM_COMMAND::ApplySettings( SIM_TAB* aTab )
if( !m_saveAllDissipations->GetValue() )
options &= ~NETLIST_EXPORTER_SPICE::OPTION_SAVE_ALL_DISSIPATIONS;
if( !m_saveAllEvents->GetValue() )
options &= ~NETLIST_EXPORTER_SPICE::OPTION_SAVE_ALL_EVENTS;
aTab->SetSimOptions( options );
m_simulatorFrame->ReloadSimulator( m_simCommand, options );

View File

@ -64,6 +64,7 @@ public:
m_saveAllVoltages->SetValue( aOptions & NETLIST_EXPORTER_SPICE::OPTION_SAVE_ALL_VOLTAGES );
m_saveAllCurrents->SetValue( aOptions & NETLIST_EXPORTER_SPICE::OPTION_SAVE_ALL_CURRENTS );
m_saveAllDissipations->SetValue( aOptions & NETLIST_EXPORTER_SPICE::OPTION_SAVE_ALL_DISSIPATIONS );
m_saveAllEvents->SetValue( aOptions & NETLIST_EXPORTER_SPICE::OPTION_SAVE_ALL_EVENTS );
}
void SetPlotSettings( const SIM_TAB* aSimTab );

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version 4.0.0-0-g0efcecf02)
// C++ code generated with wxFormBuilder (version 4.0.0-0-g0efcecf)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
@ -653,6 +653,9 @@ DIALOG_SIM_COMMAND_BASE::DIALOG_SIM_COMMAND_BASE( wxWindow* parent, wxWindowID i
m_saveAllDissipations = new wxCheckBox( m_panelCommand, wxID_ANY, _("Save all power dissipations"), wxDefaultPosition, wxDefaultSize, 0 );
bSizer88->Add( m_saveAllDissipations, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 );
m_saveAllEvents = new wxCheckBox( m_panelCommand, wxID_ANY, _("Save all digital event data"), wxDefaultPosition, wxDefaultSize, 0 );
bSizer88->Add( m_saveAllEvents, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 );
m_compatibilityModeSizer = new wxBoxSizer( wxHORIZONTAL );
wxStaticText* compatibilityLabel;

View File

@ -7590,6 +7590,71 @@
<property name="window_style"></property>
</object>
</object>
<object class="sizeritem" expanded="true">
<property name="border">5</property>
<property name="flag">wxBOTTOM|wxRIGHT|wxLEFT</property>
<property name="proportion">0</property>
<object class="wxCheckBox" expanded="true">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="checked">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="drag_accept_files">0</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Save all digital event data</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_saveAllEvents</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
</object>
</object>
<object class="sizeritem" expanded="true">
<property name="border">5</property>
<property name="flag">wxEXPAND|wxTOP|wxBOTTOM</property>

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version 4.0.0-0-g0efcecf02)
// C++ code generated with wxFormBuilder (version 4.0.0-0-g0efcecf)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
@ -159,6 +159,7 @@ class DIALOG_SIM_COMMAND_BASE : public DIALOG_SHIM
wxCheckBox* m_saveAllVoltages;
wxCheckBox* m_saveAllCurrents;
wxCheckBox* m_saveAllDissipations;
wxCheckBox* m_saveAllEvents;
wxBoxSizer* m_compatibilityModeSizer;
wxChoice* m_compatibilityMode;
wxPanel* m_panelPlotSetup;

View File

@ -58,11 +58,13 @@ public:
OPTION_SAVE_ALL_DISSIPATIONS = 0x0100,
OPTION_CUR_SHEET_AS_ROOT = 0x0200,
OPTION_SIM_COMMAND = 0x0400,
OPTION_SAVE_ALL_EVENTS = 0x0800,
OPTION_DEFAULT_FLAGS = OPTION_ADJUST_INCLUDE_PATHS
| OPTION_ADJUST_PASSIVE_VALS
| OPTION_SAVE_ALL_VOLTAGES
| OPTION_SAVE_ALL_CURRENTS
| OPTION_SAVE_ALL_DISSIPATIONS
| OPTION_SAVE_ALL_EVENTS
};
NETLIST_EXPORTER_SPICE( SCHEMATIC_IFACE* aSchematic, wxWindow* aDialogParent = nullptr );

View File

@ -62,6 +62,7 @@ SCHEMATIC_SETTINGS::SCHEMATIC_SETTINGS( JSON_SETTINGS* aParent, const std::strin
m_SpiceSaveAllVoltages( false ),
m_SpiceSaveAllCurrents( false ),
m_SpiceSaveAllDissipations( false ),
m_SpiceSaveAllEvents( true ),
m_SpiceModelCurSheetAsRoot( true ),
m_NgspiceSettings( nullptr )
{
@ -230,6 +231,9 @@ SCHEMATIC_SETTINGS::SCHEMATIC_SETTINGS( JSON_SETTINGS* aParent, const std::strin
m_params.emplace_back( new PARAM<bool>( "spice_save_all_dissipations",
&m_SpiceSaveAllDissipations, false ) );
m_params.emplace_back( new PARAM<bool>( "space_save_all_events",
&m_SpiceSaveAllEvents, true ) );
m_params.emplace_back( new PARAM<bool>( "spice_model_current_sheet_as_root",
&m_SpiceModelCurSheetAsRoot, true ) );

View File

@ -95,6 +95,7 @@ public:
bool m_SpiceSaveAllVoltages;
bool m_SpiceSaveAllCurrents;
bool m_SpiceSaveAllDissipations;
bool m_SpiceSaveAllEvents;
wxString m_SpiceCommandString; // A command string to run external spice
bool m_SpiceModelCurSheetAsRoot;

View File

@ -287,6 +287,13 @@ bool NGSPICE::Attach( const std::shared_ptr<SIMULATION_MODEL>& aModel, const wxS
SIMULATOR::Attach( aModel, aSimCommand, aSimOptions, aInputPath, aReporter );
updateNgspiceSettings();
LoadNetlist( formatter.GetString() );
if( !( aSimOptions & NETLIST_EXPORTER_SPICE::OPTION_SAVE_ALL_EVENTS ) )
{
Command( "echo Command: esave none" );
Command( "esave none" );
}
return true;
}
else

View File

@ -1969,7 +1969,8 @@ bool SIMULATOR_FRAME_UI::loadJsonWorkbook( const wxString& aPath )
for( const nlohmann::json& tab_js : js[ "tabs" ] )
{
wxString simCommand;
int simOptions = NETLIST_EXPORTER_SPICE::OPTION_ADJUST_PASSIVE_VALS;
int simOptions = NETLIST_EXPORTER_SPICE::OPTION_ADJUST_PASSIVE_VALS
| NETLIST_EXPORTER_SPICE::OPTION_SAVE_ALL_EVENTS;
for( const nlohmann::json& cmd : tab_js[ "commands" ] )
{
@ -1981,6 +1982,8 @@ bool SIMULATOR_FRAME_UI::loadJsonWorkbook( const wxString& aPath )
simOptions |= NETLIST_EXPORTER_SPICE::OPTION_SAVE_ALL_CURRENTS;
else if( cmd == ".probe allp" )
simOptions |= NETLIST_EXPORTER_SPICE::OPTION_SAVE_ALL_DISSIPATIONS;
else if( cmd == ".kicad esavenone" )
simOptions &= ~NETLIST_EXPORTER_SPICE::OPTION_SAVE_ALL_EVENTS;
else
simCommand += wxString( cmd.get<wxString>() ).Trim();
}
@ -2169,6 +2172,9 @@ bool SIMULATOR_FRAME_UI::SaveWorkbook( const wxString& aPath )
if( options & NETLIST_EXPORTER_SPICE::OPTION_SAVE_ALL_DISSIPATIONS )
commands_js.push_back( ".probe allp" );
if( !( options & NETLIST_EXPORTER_SPICE::OPTION_SAVE_ALL_EVENTS ) )
commands_js.push_back( ".kicad esavenone" );
nlohmann::json tab_js = nlohmann::json(
{ { "analysis", SPICE_SIMULATOR::TypeToName( simType, true ) },
{ "commands", commands_js } } );

View File

@ -273,6 +273,7 @@ public:
return NETLIST_EXPORTER_SPICE::OPTION_SAVE_ALL_VOLTAGES
| NETLIST_EXPORTER_SPICE::OPTION_SAVE_ALL_CURRENTS
| NETLIST_EXPORTER_SPICE::OPTION_SAVE_ALL_DISSIPATIONS
| NETLIST_EXPORTER_SPICE::OPTION_SAVE_ALL_EVENTS
| NETLIST_EXPORTER_SPICE::OPTION_ADJUST_INCLUDE_PATHS
| NETLIST_EXPORTER_SPICE::OPTION_SIM_COMMAND;
}

View File

@ -286,6 +286,7 @@ public:
return NETLIST_EXPORTER_SPICE::OPTION_SAVE_ALL_VOLTAGES
| NETLIST_EXPORTER_SPICE::OPTION_SAVE_ALL_CURRENTS
| NETLIST_EXPORTER_SPICE::OPTION_SAVE_ALL_DISSIPATIONS
| NETLIST_EXPORTER_SPICE::OPTION_SAVE_ALL_EVENTS
| NETLIST_EXPORTER_SPICE::OPTION_ADJUST_INCLUDE_PATHS
| NETLIST_EXPORTER_SPICE::OPTION_SIM_COMMAND;
}

View File

@ -65,6 +65,7 @@ public:
unsigned GetNetlistOptions() override
{
unsigned options = NETLIST_EXPORTER_SPICE::OPTION_ADJUST_INCLUDE_PATHS
| NETLIST_EXPORTER_SPICE::OPTION_SAVE_ALL_EVENTS
| NETLIST_EXPORTER_SPICE::OPTION_SIM_COMMAND;
if( m_SaveCurrents )