Spice sim: Have more detailed error messages
This commit is contained in:
parent
86c7db46b9
commit
bd1f3d85f4
|
@ -312,10 +312,7 @@ void SIM_PLOT_FRAME::initWorkbook()
|
||||||
filename.SetPath( Prj().GetProjectPath() );
|
filename.SetPath( Prj().GetProjectPath() );
|
||||||
|
|
||||||
if( !loadWorkbook( filename.GetFullPath() ) )
|
if( !loadWorkbook( filename.GetFullPath() ) )
|
||||||
{
|
|
||||||
// Empty the workbook filename to prevent error messages from appearing again
|
|
||||||
m_simulator->Settings()->SetWorkbookFilename( "" );
|
m_simulator->Settings()->SetWorkbookFilename( "" );
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -789,7 +786,6 @@ bool SIM_PLOT_FRAME::updatePlot( const wxString& aName, SIM_PLOT_TYPE aType, con
|
||||||
std::vector<double> sub_y( data_y.begin() + offset,
|
std::vector<double> sub_y( data_y.begin() + offset,
|
||||||
data_y.begin() + offset + inner );
|
data_y.begin() + offset + inner );
|
||||||
|
|
||||||
//if( aPlotPanel->AddTrace( name, inner, sub_x.data(), sub_y.data(), aType, aParam ) )
|
|
||||||
m_workbook->AddTrace( aPlotPanel, name, inner, sub_x.data(), sub_y.data(), aType,
|
m_workbook->AddTrace( aPlotPanel, name, inner, sub_x.data(), sub_y.data(), aType,
|
||||||
aParam );
|
aParam );
|
||||||
|
|
||||||
|
@ -928,9 +924,12 @@ bool SIM_PLOT_FRAME::loadWorkbook( const wxString& aPath )
|
||||||
|
|
||||||
long plotsCount;
|
long plotsCount;
|
||||||
|
|
||||||
if( !file.GetFirstLine().ToLong( &plotsCount ) ) // GetFirstLine instead of GetNextLine
|
if( !file.GetFirstLine().ToLong( &plotsCount ) ) // GetFirstLine instead of GetNextLine
|
||||||
{
|
{
|
||||||
file.Close();
|
file.Close();
|
||||||
|
DisplayErrorMessage( this,
|
||||||
|
_( "Error loading workbook: First line is not convertible to `long`." ) );
|
||||||
|
|
||||||
updateFrame();
|
updateFrame();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -941,6 +940,10 @@ bool SIM_PLOT_FRAME::loadWorkbook( const wxString& aPath )
|
||||||
|
|
||||||
if( !file.GetNextLine().ToLong( &plotType ) )
|
if( !file.GetNextLine().ToLong( &plotType ) )
|
||||||
{
|
{
|
||||||
|
file.Close();
|
||||||
|
DisplayErrorMessage( this, wxString::Format(
|
||||||
|
_( "Error loading workbook: Line %d is not convertible to `long`." ), 6*i+2 ) );
|
||||||
|
|
||||||
updateFrame();
|
updateFrame();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -958,6 +961,11 @@ bool SIM_PLOT_FRAME::loadWorkbook( const wxString& aPath )
|
||||||
|
|
||||||
if( !file.GetNextLine().ToLong( &tracesCount ) )
|
if( !file.GetNextLine().ToLong( &tracesCount ) )
|
||||||
{
|
{
|
||||||
|
file.Close();
|
||||||
|
DisplayErrorMessage( this, wxString::Format(
|
||||||
|
_( "Error loading workbook: Line %d is not convertible to `long`." ), 6*i+4 )
|
||||||
|
);
|
||||||
|
|
||||||
updateFrame();
|
updateFrame();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -970,16 +978,34 @@ bool SIM_PLOT_FRAME::loadWorkbook( const wxString& aPath )
|
||||||
if( !file.GetNextLine().ToLong( &traceType ) )
|
if( !file.GetNextLine().ToLong( &traceType ) )
|
||||||
{
|
{
|
||||||
file.Close();
|
file.Close();
|
||||||
|
DisplayErrorMessage( this, wxString::Format(
|
||||||
|
_( "Error loading workbook: Line %d is not convertible to `long`." ), 6*i+5
|
||||||
|
) );
|
||||||
|
|
||||||
updateFrame();
|
updateFrame();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
name = file.GetNextLine();
|
name = file.GetNextLine();
|
||||||
param = file.GetNextLine();
|
|
||||||
|
|
||||||
if( name.IsEmpty() || param.IsEmpty() )
|
if( name.IsEmpty() )
|
||||||
{
|
{
|
||||||
file.Close();
|
file.Close();
|
||||||
|
DisplayErrorMessage( this, wxString::Format(
|
||||||
|
_( "Error loading workbook: Line %d is empty" ), 6*i+6 ) );
|
||||||
|
|
||||||
|
updateFrame();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
param = file.GetNextLine();
|
||||||
|
|
||||||
|
if( param.IsEmpty() )
|
||||||
|
{
|
||||||
|
file.Close();
|
||||||
|
DisplayErrorMessage( this, wxString::Format(
|
||||||
|
_( "Error loading workbook: Line %d is empty" ), 6*i+7 ) );
|
||||||
|
|
||||||
updateFrame();
|
updateFrame();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1025,6 +1051,12 @@ bool SIM_PLOT_FRAME::saveWorkbook( const wxString& aPath )
|
||||||
{
|
{
|
||||||
const SIM_PANEL_BASE* basePanel = dynamic_cast<const SIM_PANEL_BASE*>( m_workbook->GetPage( i ) );
|
const SIM_PANEL_BASE* basePanel = dynamic_cast<const SIM_PANEL_BASE*>( m_workbook->GetPage( i ) );
|
||||||
|
|
||||||
|
if( !basePanel )
|
||||||
|
{
|
||||||
|
file.AddLine( wxString::Format( "%llu", 0ull ) );
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
file.AddLine( wxString::Format( "%d", basePanel->GetType() ) );
|
file.AddLine( wxString::Format( "%d", basePanel->GetType() ) );
|
||||||
file.AddLine( m_workbook->GetSimCommand( basePanel ) );
|
file.AddLine( m_workbook->GetSimCommand( basePanel ) );
|
||||||
|
|
||||||
|
@ -1033,17 +1065,16 @@ bool SIM_PLOT_FRAME::saveWorkbook( const wxString& aPath )
|
||||||
if( !plotPanel )
|
if( !plotPanel )
|
||||||
{
|
{
|
||||||
file.AddLine( wxString::Format( "%llu", 0ull ) );
|
file.AddLine( wxString::Format( "%llu", 0ull ) );
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
file.AddLine( wxString::Format( "%llu", plotPanel->GetTraces().size() ) );
|
|
||||||
|
|
||||||
for( const auto& trace : plotPanel->GetTraces() )
|
file.AddLine( wxString::Format( "%llu", plotPanel->GetTraces().size() ) );
|
||||||
{
|
|
||||||
file.AddLine( wxString::Format( "%d", trace.second->GetType() ) );
|
for( const auto& trace : plotPanel->GetTraces() )
|
||||||
file.AddLine( trace.second->GetName() );
|
{
|
||||||
file.AddLine( trace.second->GetParam() );
|
file.AddLine( wxString::Format( "%d", trace.second->GetType() ) );
|
||||||
}
|
file.AddLine( trace.second->GetName() );
|
||||||
|
file.AddLine( trace.second->GetParam() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1052,7 +1083,9 @@ bool SIM_PLOT_FRAME::saveWorkbook( const wxString& aPath )
|
||||||
|
|
||||||
// Store the filename of the last saved workbook. It will be used to restore the simulation if
|
// Store the filename of the last saved workbook. It will be used to restore the simulation if
|
||||||
// the frame is closed and then opened again.
|
// the frame is closed and then opened again.
|
||||||
m_simulator->Settings()->SetWorkbookFilename( wxFileName( savePath ).GetFullName() );
|
if( res )
|
||||||
|
m_simulator->Settings()->SetWorkbookFilename( wxFileName( savePath ).GetFullName() );
|
||||||
|
|
||||||
m_workbook->ClrModified();
|
m_workbook->ClrModified();
|
||||||
updateFrame();
|
updateFrame();
|
||||||
|
|
||||||
|
@ -1096,9 +1129,7 @@ void SIM_PLOT_FRAME::menuOpenWorkbook( wxCommandEvent& event )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_savedWorkbooksPath = openDlg.GetDirectory();
|
m_savedWorkbooksPath = openDlg.GetDirectory();
|
||||||
|
loadWorkbook( openDlg.GetPath() );
|
||||||
if( !loadWorkbook( openDlg.GetPath() ) )
|
|
||||||
DisplayErrorMessage( this, _( "There was an error while opening the workbook file" ) );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1115,8 +1146,7 @@ void SIM_PLOT_FRAME::menuSaveWorkbook( wxCommandEvent& event )
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !saveWorkbook( Prj().AbsolutePath( m_simulator->Settings()->GetWorkbookFilename() ) ) )
|
saveWorkbook( Prj().AbsolutePath( m_simulator->Settings()->GetWorkbookFilename() ) );
|
||||||
DisplayErrorMessage( this, _( "There was an error while saving the workbook file" ) );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1141,8 +1171,7 @@ void SIM_PLOT_FRAME::menuSaveWorkbookAs( wxCommandEvent& event )
|
||||||
|
|
||||||
m_savedWorkbooksPath = saveAsDlg.GetDirectory();
|
m_savedWorkbooksPath = saveAsDlg.GetDirectory();
|
||||||
|
|
||||||
if( !saveWorkbook( saveAsDlg.GetPath() ) )
|
saveWorkbook( saveAsDlg.GetPath() );
|
||||||
DisplayErrorMessage( this, _( "There was an error while saving the workbook file" ) );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue