pnlngspicedc.cpp

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

CPP
353
字号
//*****************************************************************************//                               PnlNgSpiceDC.cpp                             *//                              ------------------                            *//  Started     : 08/05/2004                                                  *//  Last Update : 01/07/2005                                                  *//  Copyright   : (C) 2004 by MSWaters                                        *//  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 "PnlNgSpiceDC.hpp"//*****************************************************************************// Implement an event table.BEGIN_EVENT_TABLE( PnlNgSpiceDC, PnlAnaBase )  EVT_CHOICE  ( ID_CHO_SRCCPNT, PnlNgSpiceDC::OnSrcCpnt )  EVT_RADIOBOX( ID_RBX_SWPTYPE, PnlNgSpiceDC::OnSwpType )END_EVENT_TABLE( )//*****************************************************************************// Constructor.PnlNgSpiceDC::PnlNgSpiceDC( wxWindow * poWin ) : PnlAnaBase( poWin ){  bSetType( Simulation::eANA_DC );  Create( );  InitSwpUnts( );  bClear( );}//*****************************************************************************// Destructor.PnlNgSpiceDC::~PnlNgSpiceDC( ){}//*****************************************************************************// Create the display objects.void  PnlNgSpiceDC::Create( void ){  // Disable the checkboxes for the parameters NG-Spice cannot calculate  m_oCbxCurrent.Disable( );  m_oCbxPower  .Disable( );  m_oCbxResist .Disable( );  // Set the sweep parameter labels  m_oSbxSwpPars.SetLabel( wxT("DC Sweep") );  m_oPnlStart  .bSetName( wxT("Start Value") );  m_oPnlStop   .bSetName( wxT("Stop Value") );  m_oPnlStep   .bSetName( wxT("Step Increment") );  // Create and add the sweep type radio buttons  wxString  osSwpType[2] = { wxT("Source"), wxT("Temp.C ") };  m_oRbxSwpType.Create( this, ID_RBX_SWPTYPE, wxT("Sweep Type"),                        wxPoint( 13, 123 ), wxDefaultSize, 2, osSwpType, 2 );  bSetSwpType( eSWEEP_SRC );  // Create and add input source controls  m_oLblSrcCpnt.Create( this, ID_UNUSED, wxT("Sweep Source"), wxPoint(  18, 176 ) );  m_oChoSrcCpnt.Create( this, ID_CHO_SRCCPNT,                 wxPoint( 113, 171 ),                        wxSize( 110, 27 ) );  CreateTemp( ); // Create and add the analysis temperature controls}//*****************************************************************************// Initialize the sweep parameter units.void  PnlNgSpiceDC::InitSwpUnts( void ){  wxString  os1;  ChoUnits::eUnitsType  eUnits;  if( m_oRbxSwpType.GetSelection( ) == 0 )  {    switch( wxToupper( m_oChoSrcCpnt.GetStringSelection( ).GetChar( 0 ) ) )    {      case wxT('R'): // Units of resistance        os1 = wxT("Resistance");        eUnits = ChoUnits::eUNTS_RES;        break;      case wxT('I'): // Units of current        os1 = wxT("Current");        eUnits = ChoUnits::eUNTS_CURR;        break;      case wxT('V'): // Units of voltage        os1 = wxT("Voltage");        eUnits = ChoUnits::eUNTS_VOLT;        break;      default: // No units        os1 = wxT("Value");        eUnits = ChoUnits::eUNTS_NONE;    }  }  else  {    os1 = wxT("Temperature");    eUnits = ChoUnits::eUNTS_TEMP;  }  m_oPnlStart.bSetName( wxString( wxT("Start ") ) + os1 );  m_oPnlStop .bSetName( wxString( wxT("Stop ")  ) + os1 );  m_oPnlStart.bSetUType( eUnits );  m_oPnlStop .bSetUType( eUnits );  m_oPnlStep .bSetUType( eUnits );}//*****************************************************************************// Set the state of the sweep type radio box.//// Argument List://   eSwpType - The enumerated sweep type specifier//// Return Values://   Success - TRUE//   Failure - FALSEbool  PnlNgSpiceDC::bSetSwpType( eSweepType eSwpType ){  wxCommandEvent  oEvtCmd;  if( eSwpType<eSWEEP_FST || eSwpType>eSWEEP_LST ) return( FALSE );  if( m_oRbxSwpType.GetCount( ) < eSwpType+1 )     return( FALSE );  m_oRbxSwpType.SetSelection( (int) eSwpType );  OnSwpType( oEvtCmd );  return( TRUE );}//*****************************************************************************// Clear the object attributes.//// Return Values://   TRUE  - Success//   FALSE - Failurebool  PnlNgSpiceDC::bClear( void ){  bool  bRtn=TRUE;  // Clear the base class  if( ! PnlAnaBase::bClear( ) )     bRtn = FALSE;  m_oPnlStart.bSetValue( (float)  0.0 );  m_oPnlStep .bSetValue( (float) 10.0 );  // Set the default sweep type  if( ! bSetSwpType( eSWEEP_SRC ) ) bRtn = FALSE;  // Set sweep default values  m_oChoSrcCpnt.Clear( );  m_oChoSrcCpnt.Append( wxT("None") );  m_oChoSrcCpnt.SetSelection( 0 );  return( bRtn );}//*****************************************************************************// Load information from a Simulation object.//// Argument List://   roSim - The Simulation object//// Return Values://   TRUE  - Success//   FALSE - Failurebool  PnlNgSpiceDC::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'):      case wxT('R'): 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( bRtn );  // Set the sweep source (before setting the sweep start, stop and step)  os1 = roSim.rosGetSrcCpnt( ).BeforeFirst( wxT(' ') );  if( m_oChoSrcCpnt.FindString( os1 ) != wxNOT_FOUND )    m_oChoSrcCpnt.SetStringSelection( os1 );  else bRtn = FALSE;  OnSrcCpnt( oEvtCmd );  // Perform any base class load tasks  if( ! PnlAnaBase::bLoad( roSim ) ) bRtn = FALSE;  // Set the sweep scale  m_oRbxSwpType.SetSelection( roSim.iGetSwpScale( ) );  OnSwpType( oEvtCmd );  return( TRUE );}//*****************************************************************************// Reload information from a Simulation object.//// Argument List://   roSim - The Simulation object//// Return Values://   TRUE  - Success//   FALSE - Failurebool  PnlNgSpiceDC::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  PnlNgSpiceDC::bSave( Simulation & roSim ){  wxString  os1;  float     f1;  int       i1;  // 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 type  i1 = m_oRbxSwpType.GetSelection( );  if( ! roSim.bSetSwpScale( i1 ) )    SetError( wxT("Sweep type couldn't be set.") );      // Set the source component and analysis temperature  if( i1 == eSWEEP_SRC )  {    // Set the component to be used as the sweep source    if( m_oChoSrcCpnt.GetSelection( ) > 0 )    {      os1 = m_oChoSrcCpnt.GetStringSelection( );      if( ! roSim.bSetSrcCpnt( os1 ) )        SetError( wxT("Source component couldn't be set.") );    }    else SetError( wxT("No source component has been selected.") );  }  return( bIsOk( ) );}//*****************************************************************************//                                                                            *//                             Event Handlers                                 *//                                                                            *//*****************************************************************************// Sweep type radio box event handler.//// Argument List://   roEvtCmd - An object holding information about the eventvoid  PnlNgSpiceDC::OnSwpType( wxCommandEvent & roEvtCmd ){  int  ix, iy;  InitSwpUnts( );  m_oSbxSwpPars.GetSize( &ix, &iy );  switch( m_oRbxSwpType.GetSelection( ) )  {    case eSWEEP_SRC: // DC Voltage sweep      m_oSbxSwpPars.SetSize( ix, 201 );      m_oLblSrcCpnt  .Show( TRUE );      m_oChoSrcCpnt  .Show( TRUE );      m_oSbxTemp     .Show( TRUE );      m_oPnlTemp     .Show( TRUE );      InitSwpUnts( );      break;    case eSWEEP_TEMP: // Temperature sweep      m_oSbxSwpPars.SetSize( ix, 167 );      m_oLblSrcCpnt.Show( FALSE );      m_oChoSrcCpnt.Show( FALSE );      m_oSbxTemp   .Show( FALSE );      m_oPnlTemp   .Show( FALSE );      InitSwpUnts( );      break;    default:      break;  }}//*****************************************************************************// Source component choice box event handler.//// Argument List://   roEvtCmd - An object holding information about the eventvoid  PnlNgSpiceDC::OnSrcCpnt( wxCommandEvent & roEvtCmd ){  InitSwpUnts( );}//*****************************************************************************

⌨️ 快捷键说明

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