pnlngspicetr.cpp

来自「gspiceui电子CAD仿真程序.用于电路参数模拟仿真」· C++ 代码 · 共 327 行

CPP
327
字号
//*****************************************************************************//                               PnlNgSpiceTR.cpp                             *//                              ------------------                            *//  Started     : 05/08/2004                                                  *//  Last Update : 09/06/2005                                                  *//  Copyright   : (C) 2004 by M.S.Waters                                      *//  Email       : M.Waters@bom.gov.au                                         *//*****************************************************************************//*****************************************************************************//                                                                            *//    This program is free software; you can redistribute it and/or modify    *//    it under the terms of the GNU General Public License as published by    *//    the Free Software Foundation; either version 2 of the License, or       *//    (at your option) any later version.                                     *//                                                                            *//*****************************************************************************#include "PnlNgSpiceTR.hpp"//*****************************************************************************// Implement an event table.BEGIN_EVENT_TABLE( PnlNgSpiceTR, PnlAnaBase )  EVT_CHOICE( ID_CHO_SRCCPNT, PnlNgSpiceTR::OnChoSrcCpnt )  EVT_BUTTON( ID_BTN_SETUP,   PnlNgSpiceTR::OnBtnSetup   )END_EVENT_TABLE( )//*****************************************************************************// Constructor.PnlNgSpiceTR::PnlNgSpiceTR( wxWindow * poWin )                          : PnlAnaBase( poWin ), m_oDlgSrcCfg( poWin ){  bSetType( Simulation::eANA_TR );  Create( );  InitSrcDlg( );  bClear( );}//*****************************************************************************// Destructor.PnlNgSpiceTR::~PnlNgSpiceTR( ){}//*****************************************************************************// Create the display objects.void  PnlNgSpiceTR::Create( void ){  int  ix, iy;  // Disable the checkboxes for the parameters NG-Spice cannot calculate  m_oCbxCurrent.Disable( );  m_oCbxPower  .Disable( );  m_oCbxResist .Disable( );  // Set the frequency sweep parameter labels  m_oSbxSwpPars.GetSize( &ix, &iy );  m_oSbxSwpPars.SetSize(  ix, 167 );  m_oSbxSwpPars.SetLabel( wxT("Transient Sweep") );  m_oPnlStart  .bSetName( wxT("Start Time") );  m_oPnlStop   .bSetName( wxT("Stop Time") );  m_oPnlStep   .bSetName( wxT("Step Increment") );  // Set sweep parameter units  m_oPnlStart.bSetUType( ChoUnits::eUNTS_TIME );  m_oPnlStop .bSetUType( ChoUnits::eUNTS_TIME );  m_oPnlStep .bSetUType( ChoUnits::eUNTS_TIME );  // Create and add the initial conditions radio buttons  wxString  osInitC[3] = { wxT("Cold"), wxT("Warm"), wxT("Use ICs ") };  m_oRbxInitC.Create( this, ID_UNUSED, wxT("Initial Conditions"),                      wxPoint( 13, 123 ), wxDefaultSize, 3, osInitC, 3 );  bSetInitC( eINITC_COLD );  // Create and add generator controls  new wxStaticBox     ( this, ID_UNUSED, wxT("Voltage Source"),                        wxPoint(  6, 175 ), wxSize( 228, 55 ) );  m_oChoSrcCpnt.Create( this, ID_CHO_SRCCPNT,                        wxPoint( 18, 195 ), wxSize( 107, 27 ) );  m_oBtnSetup  .Create( this, ID_BTN_SETUP, wxT("Setup ..."),                        wxPoint(130, 195 ), wxSize(  95, 27 ) );  // Create and add the analysis temperature controls  CreateTemp( );}//*****************************************************************************// Initialize the voltage source dialog.void  PnlNgSpiceTR::InitSrcDlg( void ){  m_oDlgSrcCfg.bSetPnlValue( DlgSrcCfg::ID_PNL_INITV,    0.0, wxT("mV")   );  m_oDlgSrcCfg.bSetPnlValue( DlgSrcCfg::ID_PNL_PULSEV, 500.0, wxT("mV")   );  m_oDlgSrcCfg.bSetPnlValue( DlgSrcCfg::ID_PNL_DELAY,    5.0, wxT("msec") );  m_oDlgSrcCfg.bSetPnlValue( DlgSrcCfg::ID_PNL_RISE,    10.0, wxT("usec") );  m_oDlgSrcCfg.bSetPnlValue( DlgSrcCfg::ID_PNL_WIDTH,   20.0, wxT("msec") );  m_oDlgSrcCfg.bSetPnlValue( DlgSrcCfg::ID_PNL_FALL,    10.0, wxT("usec") );  m_oDlgSrcCfg.bSetPnlValue( DlgSrcCfg::ID_PNL_PERIOD,  40.0, wxT("msec") );}//*****************************************************************************// Set the state of the initial conditions radio box.//// Argument List://   eInitC - The enumerated initial conditions specifier//// Return Values://   Success - TRUE//   Failure - FALSEbool  PnlNgSpiceTR::bSetInitC( eInitCType eInitC ){  if( eInitC<eINITC_FST || eInitC>eINITC_LST ) return( FALSE );  if( m_oRbxInitC.GetCount( ) < eInitC+1 )     return( FALSE );  m_oRbxInitC.SetSelection( (int) eInitC );  return( TRUE );}//*****************************************************************************// Clear the object attributes.//// Return Values://   TRUE  - Success//   FALSE - Failurebool  PnlNgSpiceTR::bClear( void ){  bool  bRtn=TRUE;  // Clear the base class  if( ! PnlAnaBase::bClear( ) )    bRtn = FALSE;  m_oPnlStart.bSetValue( (float) 0.0 );  m_oPnlStep .bSetValue( (float) 1.0 );  // Set the default sweep units  m_oPnlStart.bSetUnits( wxT("msec") );  m_oPnlStop .bSetUnits( wxT("msec") );  m_oPnlStep .bSetUnits( wxT("msec") );  // Set default initial condition values  if( ! bSetInitC( eINITC_COLD ) ) bRtn = FALSE;  // Set input source default values  m_oChoSrcCpnt.Clear( );  m_oChoSrcCpnt.Append( wxT("None") );  m_oChoSrcCpnt.SetSelection( 0 );  // Clear the generator dialog  InitSrcDlg( );  return( bRtn );}//*****************************************************************************// Load information from a Simulation object.//// Argument List://   roSim - The Simulation object//// Return Values://   TRUE  - Success//   FALSE - Failurebool  PnlNgSpiceTR::bLoad( Simulation & roSim ){  wxCommandEvent  oEvtCmd;  wxString  os1;  bool      bRtn=TRUE;  uint      ui1;  m_oChoSrcCpnt.Clear( );  m_oChoSrcCpnt.Append( wxT("None") );  // Load the components into the choice box  const wxArrayString & roasCpnts = roSim.roasGetCpntLbls( );  for( ui1=0; ui1<roasCpnts.GetCount( ); ui1++ )  {    os1 = roasCpnts.Item( ui1 );    if( os1.Length( ) <= 0 ) continue;    switch( wxToupper( os1.GetChar( 0 ) ) )    {      case wxT('V'):      case wxT('I'): break;      default : continue;    }    m_oChoSrcCpnt.Append( os1 );  }  m_oChoSrcCpnt.SetStringSelection( wxT("None") );  // Don't go any further if the analysis type doesn't match  if( roSim.eGetAnaType( ) != eGetType( ) )                 return( TRUE );  // Perform any base class load tasks  if( ! PnlAnaBase::bLoad( roSim ) )                        bRtn = FALSE;  // Set the initial conditions  if( ! bSetInitC( (eInitCType) roSim.iGetSwpScale( ) ) )   bRtn = FALSE;  // Set the sweep source  os1 = roSim.rosGetSrcCpnt( ).BeforeFirst( wxT(' ') );  if( m_oChoSrcCpnt.FindString( os1 ) != wxNOT_FOUND )    m_oChoSrcCpnt.SetStringSelection( os1 );  else bRtn = FALSE;  OnChoSrcCpnt( oEvtCmd );  // Load the source setup dialog  if( ! m_oDlgSrcCfg.bSetSrcCmd( roSim.rosGetSrcCpnt( ) ) ) bRtn = FALSE;  return( bRtn );}//*****************************************************************************// Reload information from a Simulation object.//// Argument List://   roSim - The Simulation object//// Return Values://   TRUE  - Success//   FALSE - Failurebool  PnlNgSpiceTR::bReload( Simulation & roSim ){  wxString  os1;  os1 = m_oChoSrcCpnt.GetStringSelection( );    if( ! bLoad( roSim ) ) return( FALSE );  if( !os1.IsEmpty( ) && os1!=wxT("None") )    m_oChoSrcCpnt.SetStringSelection( os1 );  return( TRUE );}//*****************************************************************************// Save information to a simulation object.// (Prior to it being passed to a simulator object.)//// Argument List://   roSim - The Simulation object//// Return Values://   TRUE  - Success//   FALSE - Failurebool  PnlNgSpiceTR::bSave( Simulation & roSim ){  wxStringTokenizer  ostk1;  wxString  os1;  float     f1;  int       i1;  size_t    szt1;  // Execute base class save tasks  PnlAnaBase::bSave( roSim );  // Check that the step size is valid  f1 = fabs( roSim.fGetSwpStop( ) - roSim.fGetSwpStart( ) );  if( roSim.fGetSwpStep( ) > f1 )    SetError( wxT("Step size is greater than sweep range.") );  // Set the sweep parameters  i1 = m_oRbxInitC.GetSelection( );  if( ! roSim.bSetSwpScale( i1 ) )    SetError( wxT("Sweep scale couldn't be set.") );  // Set the component to be used as the sweep source  if( m_oChoSrcCpnt.GetSelection( ) > 0 )  {    for( szt1=0; szt1<roSim.roasGetCpnts( ).GetCount( ); szt1++ )    {      os1 = roSim.roasGetCpnts( ).Item( szt1 );      if( os1.BeforeFirst( wxT(' ') ) == m_oChoSrcCpnt.GetStringSelection( ) )        break;    }    ostk1.SetString( os1 );    os1.Empty( );    for( szt1=0; szt1<3; szt1++ ) os1 << ostk1.GetNextToken( ) << wxT(' ');    os1 << m_oDlgSrcCfg.rosGetSrcCmd( );  }  else os1.Empty( );  if( ! roSim.bSetSrcCpnt( os1 ) )    SetError( wxT("Source (generator) component couldn't be set.") );  return( bIsOk( ) );}//*****************************************************************************//                                                                            *//                             Event Handlers                                 *//                                                                            *//*****************************************************************************// Generator component choice control event handler.//// Argument List://   roEvtCmd - An object holding information about the eventvoid  PnlNgSpiceTR::OnChoSrcCpnt( wxCommandEvent & roEvtCmd ){  if( m_oChoSrcCpnt.GetSelection( ) > 0 ) m_oBtnSetup.Enable( );  else                                    m_oBtnSetup.Disable( );}//*****************************************************************************// Generator component setup button control event handler.//// Argument List://   roEvtCmd - An object holding information about the eventvoid  PnlNgSpiceTR::OnBtnSetup( wxCommandEvent & roEvtCmd ){  m_oDlgSrcCfg.CenterOnParent( );  m_oDlgSrcCfg.ShowModal( );}//*****************************************************************************

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?