⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 prcgnucap.cpp

📁 gspiceui电子CAD仿真程序.用于电路参数模拟仿真
💻 CPP
📖 第 1 页 / 共 3 页
字号:
  // Extract the parameters to derive, any complex parts and the test component  // and/or test node labels  while( ostk1.HasMoreTokens( ) )  {    // Extract the next field    os1 = ostk1.GetNextToken( );    if( os1.Length( ) < 4 ) { bRtn = FALSE; continue; }    // Extract the parameter specifier    switch( wxToupper( os1.GetChar( 0 ) ) )    {      case wxT('V'): roSim.bSetOutPar( Simulation::ePAR_VLT, TRUE ); break;      case wxT('I'): roSim.bSetOutPar( Simulation::ePAR_CUR, TRUE ); break;      case wxT('P'): roSim.bSetOutPar( Simulation::ePAR_PWR, TRUE ); break;      case wxT('R'): roSim.bSetOutPar( Simulation::ePAR_RES, TRUE ); break;      default: bRtn = FALSE; break;    }    // Extract the complex part    if( roSim.eGetAnaType( ) == Simulation::eANA_AC )    {      switch( wxToupper( os1.GetChar( 1 ) ) )      {        case wxT('M'): roSim.bSetOutCpx( Simulation::eCPX_MAG,   TRUE ); break;        case wxT('P'): roSim.bSetOutCpx( Simulation::eCPX_PHASE, TRUE ); break;        case wxT('R'): roSim.bSetOutCpx( Simulation::eCPX_REAL,  TRUE ); break;        case wxT('I'): roSim.bSetOutCpx( Simulation::eCPX_IMAG,  TRUE ); break;        default: bRtn = FALSE; break;      }      if( wxToupper( os1.GetChar( 1 )==wxT('M') ) )        if( os1.Mid( 2, 2 ).Upper( ) == wxT("DB") )          roSim.bSetOutCpx( Simulation::eCPX_MAGDB, TRUE );    }    // Extract the component or node label    szt1 = os1.Index( wxT('(') );    szt2 = os1.Index( wxT(')') );    if( (int)szt1==wxNOT_FOUND || (int)szt2==wxNOT_FOUND || (szt1+1)>=szt2 )       { bRtn = FALSE; continue; }    os1 = os1.Mid( szt1+1, szt2-szt1-1 );    if(      roSim.roasGetNodeLbls( ).Index( os1 ) != wxNOT_FOUND )      roSim.bAddTstNode( os1 );    else if( roSim.roasGetCpntLbls( ).Index( os1 ) != wxNOT_FOUND )      roSim.bAddTstCpnt( os1 );    else bRtn = FALSE;  }  return( bRtn );}//*****************************************************************************// Create the simulator command sequence for an operating point analysis.//// Argument List://   roSim - Simulation objectvoid  PrcGnuCap::MakeCmdOP( Simulation & roSim ){  wxString  osCmdOP;  wxString  osCmdPR;  wxString  osPar, os1;  uint      uiPar;  m_osInput = wxT("Temp");  // Create the OP command  osCmdOP = wxT(".OP ");  osCmdOP << roSim.rosGetSwpStart( );  if( roSim.fGetSwpStop( ) != roSim.fGetSwpStart( ) )  {    osCmdOP << wxT(' ') << roSim.rosGetSwpStop( );    if( roSim.fGetSwpStep( ) != 0.0 )    {      switch( roSim.iGetSwpScale( ) )      {        case 0:          osCmdOP << wxT(" BY ");          osCmdOP << roSim.rosGetSwpStep( );          break;        case 1:          osCmdOP << wxT(" TI ");          osCmdOP << roSim.rosGetSwpStep( );          break;      }    }  }  // Create the PRINT command  osCmdPR = wxT(".PR OP");  for( uiPar=Simulation::ePAR_FST; uiPar<=Simulation::ePAR_LST; uiPar++ )  {    if( ! roSim.bGetOutPar( (Simulation::eParType) uiPar ) ) continue;    switch( uiPar )    {      case Simulation::ePAR_VLT: osPar = wxT("V("); break;      case Simulation::ePAR_CUR: osPar = wxT("I("); break;      case Simulation::ePAR_PWR: osPar = wxT("P("); break;      case Simulation::ePAR_RES: osPar = wxT("R("); break;      default: continue;    }    // Add any components and/or nodes to derivation list for this parameter    os1 = rosMakeArgsPR( roSim, osPar );    if( ! os1.IsEmpty( ) ) osCmdPR << os1;  }  // Add simulation commands to Simulation object  roSim.bAddSimCmd( osCmdPR );  roSim.bAddSimCmd( osCmdOP );}//*****************************************************************************// Create the simulator command sequence for a DC analysis.//// Argument List://   roSim - Simulation objectvoid  PrcGnuCap::MakeCmdDC( Simulation & roSim ){  wxString  osCmdPR;  wxString  osCmdDC;  wxString  osPar, os1;  uint      uiPar;  m_osInput = roSim.rosGetSrcCpnt( );  // Create the DC command  osCmdDC = wxT(".DC ");  osCmdDC << m_osInput << wxT(' ') << roSim.rosGetSwpStart( );  roSim.bSetSrcCpnt( wxT("") );  if( roSim.fGetSwpStop( ) != roSim.fGetSwpStart( ) )  {    osCmdDC << wxT(' ') << roSim.rosGetSwpStop( );    if( roSim.fGetSwpStep( ) != 0.0 )    {      switch( roSim.iGetSwpScale( ) )      {        case 0:          osCmdDC << wxT(" BY ");          osCmdDC << roSim.rosGetSwpStep( );          break;        case 1:          osCmdDC << wxT(" TI ");          osCmdDC << roSim.rosGetSwpStep( );          break;        case 2:          osCmdDC << wxT(" DE ");          osCmdDC << (int) roSim.fGetSwpStep( );          break;      }    }  }  osCmdDC << wxT(" TE ") << roSim.rosGetTempC( );  // Create the PRINT command  osCmdPR = wxT(".PR DC");  for( uiPar=Simulation::ePAR_FST; uiPar<=Simulation::ePAR_LST; uiPar++ )  {    if( ! roSim.bGetOutPar( (Simulation::eParType) uiPar ) ) continue;    switch( uiPar )    {      case Simulation::ePAR_VLT: osPar = wxT("V("); break;      case Simulation::ePAR_CUR: osPar = wxT("I("); break;      case Simulation::ePAR_PWR: osPar = wxT("P("); break;      case Simulation::ePAR_RES: osPar = wxT("R("); break;      default: continue;    }    // Add any components and/or nodes to derivation list for this parameter    os1 = rosMakeArgsPR( roSim, osPar );    if( ! os1.IsEmpty( ) ) osCmdPR << os1;  }  // Add simulation commands to Simulation object  roSim.bAddSimCmd( osCmdPR );  roSim.bAddSimCmd( osCmdDC );}//*****************************************************************************// Create the simulator command sequence for a AC analysis.//// Argument List://   roSim - Simulation objectvoid  PrcGnuCap::MakeCmdAC( Simulation & roSim ){  wxString  osCmdOP;  wxString  osCmdAC;  wxString  osCmdPR;  wxString  osPar, osCpx, os1;  uint      uiPar, uiCpx;  m_osInput.Empty( );  // Create the OP command  osCmdOP = wxT(".OP ");  osCmdOP << roSim.rosGetTempC( );  // Create the AC command  osCmdAC = wxT(".AC ");  osCmdAC << roSim.rosGetSwpStart( );  if( roSim.fGetSwpStop( ) != roSim.fGetSwpStart( ) )  {    osCmdAC << wxT(' ') << roSim.rosGetSwpStop( );    if( roSim.fGetSwpStep( ) != 0.0 )    {      switch( roSim.iGetSwpScale( ) )      {        case 0:          osCmdAC << wxT(" BY ");          osCmdAC << roSim.rosGetSwpStep( );          break;        case 1:          osCmdAC << wxT(" TI ");          osCmdAC << roSim.rosGetSwpStep( );          break;        case 2:          osCmdAC << wxT(" DE ");          osCmdAC << (int) roSim.fGetSwpStep( );          break;        case 3:          osCmdAC << wxT(" OC ");          osCmdAC << (int) roSim.fGetSwpStep( );          break;      }    }  }  osCmdAC << wxT(" TE ") << roSim.rosGetTempC( );  // Create the PRINT commands  osCmdPR = wxT(".PR AC");  for( uiPar=Simulation::ePAR_FST; uiPar<=Simulation::ePAR_LST; uiPar++ )  {    if( ! roSim.bGetOutPar( (Simulation::eParType) uiPar ) ) continue;    // Add the parameter prefix    switch( uiPar )    {      case Simulation::ePAR_VLT: osPar = wxT('V'); break;      case Simulation::ePAR_CUR: osPar = wxT('I'); break;      case Simulation::ePAR_PWR: osPar = wxT('P'); break;      case Simulation::ePAR_RES: osPar = wxT('R'); break;      default: continue;    }    // Add the complex part prefix    for( uiCpx=Simulation::eCPX_FST; uiCpx<Simulation::eCPX_LST; uiCpx++ )    {      if( ! roSim.bGetOutCpx( (Simulation::eCpxType) uiCpx ) ) continue;      osCpx = osPar;      switch( uiCpx )      {        case Simulation::eCPX_MAG:   osCpx << wxT('M'); break;        case Simulation::eCPX_PHASE: osCpx << wxT('P'); break;        case Simulation::eCPX_REAL:  osCpx << wxT('R'); break;        case Simulation::eCPX_IMAG:  osCpx << wxT('I'); break;        default: continue;      }      if( uiCpx != Simulation::eCPX_PHASE )        if( roSim.bGetOutCpx( Simulation::eCPX_MAGDB ) )          osCpx << wxT("DB");      osCpx << wxT('(');      // Add any components and/or nodes to derivation list for this parameter      os1 = rosMakeArgsPR( roSim, osCpx );      if( ! os1.IsEmpty( ) ) osCmdPR << os1;    }  }  // Add simulation commands to Simulation object  roSim.bAddSimCmd( osCmdPR );  roSim.bAddSimCmd( osCmdOP );  roSim.bAddSimCmd( osCmdAC );}//*****************************************************************************// Create the simulator command sequence for a transient analysis.//// Argument List://   roSim - Simulation objectvoid  PrcGnuCap::MakeCmdTR( Simulation & roSim ){  wxString  osCmdPR;  wxString  osCmdTR;  wxString  osPar, os1;  uint      uiPar;  m_osInput.Empty( );  // Create the TR command  osCmdTR = wxT(".TR ");  osCmdTR << roSim.rosGetSwpStart( );  if( roSim.fGetSwpStop( ) != roSim.fGetSwpStart( ) )  {    osCmdTR << wxT(' ') << roSim.rosGetSwpStop( );    osCmdTR << wxT(' ') << roSim.rosGetSwpStep( );  }  osCmdTR << wxT(" TE ") << roSim.rosGetTempC( );  osCmdTR << ( roSim.iGetSwpScale( )==0 ? wxT(" COLD") : wxT(" UIC") );  // Create the PRINT commands  osCmdPR = wxT(".PR TR");  for( uiPar=Simulation::ePAR_FST; uiPar<=Simulation::ePAR_LST; uiPar++ )  {    if( ! roSim.bGetOutPar( (Simulation::eParType) uiPar ) ) continue;    switch( uiPar )    {      case Simulation::ePAR_VLT: osPar = wxT("V("); break;      case Simulation::ePAR_CUR: osPar = wxT("I("); break;      case Simulation::ePAR_PWR: osPar = wxT("P("); break;      case Simulation::ePAR_RES: osPar = wxT("R("); break;      default: continue;    }    // Add any components and/or nodes to derivation list for this parameter    os1 = rosMakeArgsPR( roSim, osPar );    if( ! os1.IsEmpty( ) ) osCmdPR << os1;  }  // Add simulation commands to Simulation object  roSim.bAddSimCmd( osCmdPR );  roSim.bAddSimCmd( osCmdTR );}//*****************************************************************************// Create the simulator command sequence for a fourier analysis.//// Argument List://   roSim - Simulation objectvoid  PrcGnuCap::MakeCmdFO( Simulation & roSim ){  wxString  osCmdPR;  wxString  osCmdFO;  wxString  osPar, os1;  uint      uiPar;  m_osInput.Empty( );  // Create the TR command  osCmdFO = wxT(".FO ");  osCmdFO << roSim.rosGetSwpStart( );  if( roSim.fGetSwpStop( ) != roSim.fGetSwpStart( ) )  {    osCmdFO << wxT(' ') << roSim.rosGetSwpStop( );    osCmdFO << wxT(' ') << roSim.rosGetSwpStep( );  }  osCmdFO << wxT(" TE ") << roSim.rosGetTempC( );  osCmdFO << wxT(" COLD");  // Create the PRINT commands  osCmdPR = wxT(".PR FO");  for( uiPar=Simulation::ePAR_FST; uiPar<=Simulation::ePAR_LST; uiPar++ )  {    if( ! roSim.bGetOutPar( (Simulation::eParType) uiPar ) ) continue;    switch( uiPar )    {      case Simulation::ePAR_VLT: osPar = wxT("V("); break;      case Simulation::ePAR_CUR: osPar = wxT("I("); break;      case Simulation::ePAR_PWR: osPar = wxT("P("); break;      case Simulation::ePAR_RES: osPar = wxT("R("); break;      default: continue;    }    // Add any components and/or nodes to derivation list for this parameter    os1 = rosMakeArgsPR( roSim, osPar );    if( ! os1.IsEmpty( ) ) osCmdPR << os1;  }  // Add simulation commands to Simulation object  roSim.bAddSimCmd( osCmdPR );  roSim.bAddSimCmd( osCmdFO );}//*****************************************************************************// Generate the simulator commands to be executed based on the simulation// specifications and the NetList description.//// Arguments://   roSim - The net list and simulation specification//// Return Values://   TRUE  - Success//   FALSE - Failurebool  PrcGnuCap::bMakeCmds( Simulation & roSim ){  switch( roSim.eGetAnaType( ) )  {    case Simulation::eANA_OP: MakeCmdOP( roSim ); break;    case Simulation::eANA_DC: MakeCmdDC( roSim ); break;    case Simulation::eANA_AC: MakeCmdAC( roSim ); break;    case Simulation::eANA_TR: MakeCmdTR( roSim ); break;    case Simulation::eANA_FO: MakeCmdFO( roSim ); break;    default: return( FALSE );

⌨️ 快捷键说明

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