frmmain.cpp
来自「gspiceui电子CAD仿真程序.用于电路参数模拟仿真」· C++ 代码 · 共 1,136 行 · 第 1/3 页
CPP
1,136 行
m_oPrcGWave.bSetLogFile( os1 );}//*****************************************************************************// Clear the object attributes.bool FrmMain::bClear( void ){ bool bRtn=TRUE; // Clear all previously selected test points m_oLbxNodes.Clear( ); m_oLbxCpnts.Clear( ); // Clear simulation object attributes m_oSimn.bClear( ); // Clear the simulation object and the analysis panels if( m_poNbkSimr != NULL ) if( ! m_poNbkSimr->bClear( ) ) bRtn = FALSE; // Clear the text controls if( ! m_oNbkTxtCtls.bClear( ) ) bRtn = FALSE; m_oNbkTxtCtls.Initialize( ); // Terminate any viewer processes if( ! m_oPrcGWave.bKill( ) ) bRtn = FALSE; return( bRtn );}//*****************************************************************************// Load information from the Simulation object.//// Return Values:// TRUE - Success// FALSE - Failurebool FrmMain::bLoadSimn( void ){ TextCtrl * poTxtCtl; uint ui1; size_t szt1; // Load the nodes into the list box const wxArrayString & roasNodeLbls = m_oSimn.roasGetNodeLbls( ); for( ui1=0; ui1<roasNodeLbls.GetCount( ); ui1++ ) m_oLbxNodes.Append( roasNodeLbls.Item( ui1 ) ); // Select the test nodes const wxArrayString & roasTstNodes = m_oSimn.roasGetTstNodes( ); for( ui1=0; ui1<roasTstNodes.GetCount( ); ui1++ ) m_oLbxNodes.SetStringSelection( roasTstNodes.Item( ui1 ) ); // Load the components into the list box const wxArrayString & roasCpntLbls = m_oSimn.roasGetCpntLbls( ); for( ui1=0; ui1<roasCpntLbls.GetCount( ); ui1++ ) m_oLbxCpnts.Append( roasCpntLbls.Item( ui1 ) ); // Select the test components const wxArrayString & roasTstCpnts = m_oSimn.roasGetTstCpnts( ); for( ui1=0; ui1<roasTstCpnts.GetCount( ); ui1++ ) m_oLbxCpnts.SetStringSelection( roasTstCpnts.Item( ui1 ) ); // Load the raw circuit description into the text control m_oNbkTxtCtls.bClear( NbkTxtCtls::ePAGE_NETLIST ); poTxtCtl = m_oNbkTxtCtls.poGetPage( NbkTxtCtls::ePAGE_NETLIST ); poTxtCtl->Clear( ); for( szt1=0; szt1<m_oSimn.GetCount( ); szt1++ ) poTxtCtl->bAppendLine( m_oSimn.Item( szt1 ) ); poTxtCtl->SetInsertionPoint( 0 ); // Go to top of the netlist text control return( TRUE );}//*****************************************************************************// Reload information from the Simulation object.//// Return Values:// TRUE - Success// FALSE - Failurebool FrmMain::bReloadSimn( void ){ wxArrayString oasTstNodes; wxArrayString oasTstCpnts; size_t szt1; int i1; // Parse the simulator commands InitSimrEng( m_oSimn.eGetSimrType( ) ); m_poPrcSimr->bParseSim( m_oSimn ); // Record the nodes that are currently selected for( i1=0; i1<m_oLbxNodes.GetCount( ); i1++ ) if( m_oLbxNodes.IsSelected( i1 ) ) oasTstNodes.Add( m_oLbxNodes.GetString( i1 ) ); // Record the components that are currently selected for( i1=0; i1<m_oLbxCpnts.GetCount( ); i1++ ) if( m_oLbxCpnts.IsSelected( i1 ) ) oasTstCpnts.Add( m_oLbxCpnts.GetString( i1 ) ); // Clear the lists of nodes and components m_oLbxNodes.Clear( ); m_oLbxCpnts.Clear( ); bLoadSimn( ); // Load the Simulation object // Select nodes that where previously selected if( ! oasTstNodes.IsEmpty( ) ) { for( szt1=0; szt1<oasTstNodes.GetCount( ); szt1++ ) { i1 = m_oLbxNodes.FindString( oasTstNodes.Item( szt1 ) ); if( i1 != wxNOT_FOUND ) m_oLbxNodes.Select( i1 ); } } // Select components that where previously selected if( ! oasTstCpnts.IsEmpty( ) ) { for( szt1=0; szt1<oasTstCpnts.GetCount( ); szt1++ ) { i1 = m_oLbxCpnts.FindString( oasTstCpnts.Item( szt1 ) ); if( i1 != wxNOT_FOUND ) m_oLbxCpnts.Select( i1 ); } } // Reload the analysis notebook with circuit description information if( m_poNbkSimr != NULL ) m_poNbkSimr->bReload( m_oSimn ); return( TRUE );}//*****************************************************************************// Save information to the Simulation object.//// Return Values:// TRUE - Success// FALSE - Failurebool FrmMain::bSaveSimn( void ){ wxArrayInt oaiSelNodes, oaiSelCpnts; size_t szt1; int iSelNo; wxString osSel, osErrMsg; // Clear all previously selected test points m_oSimn.ClrTstNodes( ); m_oSimn.ClrTstCpnts( ); // Get an array of indexes to the selected test points m_oLbxNodes.GetSelections( oaiSelNodes ); m_oLbxCpnts.GetSelections( oaiSelCpnts ); // Have any test points (ie. nodes or components) been selected? if( oaiSelNodes.GetCount( )>0 || oaiSelCpnts.GetCount( )>0 ) { // Load the test nodes into the simulation object for( szt1=0; szt1<oaiSelNodes.GetCount( ); szt1++ ) { iSelNo = oaiSelNodes.Item( szt1 ); osSel = m_oLbxNodes.GetString( iSelNo ); m_oSimn.bAddTstNode( osSel ); } // Load the test components into the simulation object for( szt1=0; szt1<oaiSelCpnts.GetCount( ); szt1++ ) { iSelNo = oaiSelCpnts.Item( szt1 ); osSel = m_oLbxCpnts.GetString( iSelNo ); m_oSimn.bAddTstCpnt( (const wxString &) osSel ); } // Setup the simulation parameters if( m_poNbkSimr->bSave( m_oSimn ) ) { // Create the simulation file if( ! m_poPrcSimr->bMakeSim( m_oSimn ) ) osErrMsg = wxT("Couldn't create simulation."); } else osErrMsg = m_poNbkSimr->psGetError( ); } else osErrMsg = wxT("No nodes or components have been selected."); if( ! osErrMsg.IsEmpty( ) ) { ::wxSetCursor( wxNullCursor ); DlgErrMsg( wxT("Create Simulation Error"), osErrMsg ); return( FALSE ); } return( TRUE );}//*****************************************************************************// Display a dialog box containing an error message.//// Argument List:// rosTitle - The dialogue box title// rosMsg - The error messagevoid FrmMain::DlgErrMsg( const wxString & rosTitle, const wxString & rosMsg ){ wxString os1; if( IsShown( ) ) { os1 << rosTitle << wxT(" : ") << rosMsg; SetStatusText( os1 ); wxMessageDialog oMsgDlg( this, rosMsg, rosTitle, wxOK | wxICON_ERROR ); oMsgDlg.ShowModal( ); }}//*****************************************************************************// Check that the electronic circuit simulator engine is present and accounted// for, if not display an error message.//// Argument List:// poPrcSimr - The utility object to be tested//// Return Values:// TRUE - Success// FALSE - Failurebool FrmMain::bOkSimr( PrcSimrBase * poPrcSimr ){ wxString osErrMsg; // Check that gnetlist exists and is accessible if( ! poPrcSimr->bBinExists( ) ) { osErrMsg << wxT("\nCan't find ") << poPrcSimr->roGetBinary( ).GetFullName( ) << wxT(" which is required to run electronic simulation.\n") << wxT("There is no path to it or it has not been installed.\n\n"); DlgErrMsg( wxT("Configuration Fault"), osErrMsg ); return( FALSE ); } return( TRUE );}//*****************************************************************************// Check that the results plotter utility is present and accounted for, if not// display an error message.//// Argument List:// poPrcGWave - The utility object to be tested//// Return Values:// TRUE - Success// FALSE - Failurebool FrmMain::bOkGWave( PrcGWave * poPrcGWave ){ wxString os1; // Check that the plotter utility exists and is accessible if( ! poPrcGWave->bBinExists( ) ) { os1 << wxT("\nCan't find ") << poPrcGWave->roGetBinary( ).GetFullName( ) << wxT(" which is required to plot simulation results.\n") << wxT("There is no path to it or it has not been installed.\n\n"); DlgErrMsg( wxT("Configuration Fault"), os1 ); return( FALSE ); } return( TRUE );}//*****************************************************************************// Set the frame title.//// Return Values:// TRUE - Success// FALSE - Failurebool FrmMain::bSetTitle( void ){ wxString os1; size_t szt1; os1 << APP_NAME << wxT(", ") << APP_VERSION; const wxArrayString & roas1 = m_oFileTsks.roasGetSchems( ); if( roas1.GetCount( ) > 0 ) { os1 << wxT(" - "); for( szt1=0; szt1<roas1.GetCount( ); szt1++ ) { if( szt1 > 0 ) os1 << wxT(", "); os1 << roas1.Item( szt1 ); } } else if( ! m_oFileTsks.rosGetNetList( ).IsEmpty( ) ) os1 << wxT(" - ") << m_oFileTsks.rosGetNetList( ); wxFrame::SetTitle( os1 ); return( TRUE );}//*****************************************************************************// Set the schematic file name/s.//// Argument List:// roasFileName - A string array containing the full path and file name/s//// Return Values:// TRUE - Success// FALSE - Failurebool FrmMain::bSetSchems( const wxArrayString & roasFileName ){ if( ! m_oFileTsks.bSetSchems( roasFileName ) ) return( FALSE ); bSetTitle( ); // Set frame title text InitLogFiles( ); // Initialize the process log file return( TRUE );}//*****************************************************************************// Set the net list file name.//// Argument List:// rosFileName - A string containing the full path and file name//// Return Values:// TRUE - Success// FALSE - Failurebool FrmMain::bSetNetList( const wxString & rosFileName ){ if( ! m_oFileTsks.bSetNetList( rosFileName ) ) return( FALSE ); bSetTitle( ); // Set frame title text InitLogFiles( ); // Initialize the process log file return( TRUE );}//*****************************************************************************// *// Event Handlers *// *//*****************************************************************************// Open a circuit description file.//// Argument List:// roEvtCmd - The event to be processedvoid FrmMain::OnOpen( wxCommandEvent & roEvtCmd ){ // Get a net list file name from the user and attempt to open it if( m_oFileTsks.bOpen( m_oSimn ) ) { // Parse the simulator commands InitSimrEng( m_oSimn.eGetSimrType( ) ); m_poPrcSimr->bParseSim( m_oSimn ); // Load the analysis notebook with circuit description information if( m_poNbkSimr != NULL ) m_poNbkSimr->bLoad( m_oSimn ); // Attempt to load the Simulation information if( bLoadSimn( ) ) SetStatusText( wxT(" Net list file opened successfully") ); else SetStatusText( wxT(" Error/s encountered opening a net list file") ); m_oNbkTxtCtls.bSetPage( NbkTxtCtls::ePAGE_NETLIST ); m_oNbkTxtCtls.bSetPosn( 0 ); // Go to the top of the netlist text control DELAY_MS( 100 ); // Allow time for the GUI to be updated }}//*****************************************************************************// Import a schematic file using gnetlist to convert the schematic to a circuit// description.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?