📄 prcgnetlist.cpp
字号:
//*****************************************************************************// GNetList.cpp *// -------------- *// Started : 28/01/2004 *// Last Update : 18/06/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 "PrcGNetList.hpp"#include <wx/arrimpl.cpp>WX_DEFINE_OBJARRAY( ArrayFileName );//*****************************************************************************// Constructor.PrcGNetList::PrcGNetList( void ) : PrcBase( wxPROCESS_REDIRECT ){ // Initialize all other object attributes m_oaFnmSchems.Clear( ); m_oFnmNetList.Clear( ); // Attempt to set and find the gnetlist binary bSetBinary( wxT("gnetlist") ); // Initialize the array of Guile procedure names InitGuileProcs( ); bSetGuileProc( wxT("") );}//*****************************************************************************// Destructor.PrcGNetList::~PrcGNetList( ){}//*****************************************************************************// Clear the object attributes.//// Return Values:// TRUE - Success// FALSE - Failurebool PrcGNetList::bClear( void ){ m_oaFnmSchems.Clear( ); m_oFnmNetList.Clear( ); bSetGuileProc( wxT("") ); return( TRUE );} //*****************************************************************************// Initialize the array of possible Guile procedure names.void PrcGNetList::InitGuileProcs( void ){ m_oasGuileProcs.Clear( ); m_oasGuileProcs.Add( wxT("") ); // None m_oasGuileProcs.Add( wxT("allegro") ); // Allegro netlist format m_oasGuileProcs.Add( wxT("bae") ); // BAE netlist format m_oasGuileProcs.Add( wxT("bom") ); // BOM2 - Bill of Materials m_oasGuileProcs.Add( wxT("bom2") ); // BOM - Bill of Materials m_oasGuileProcs.Add( wxT("drc") ); // DRC - Start of a design rule checker m_oasGuileProcs.Add( wxT("geda") ); // gEDA - native format, mainly used for testing m_oasGuileProcs.Add( wxT("gossip") ); // Gossip netlist format m_oasGuileProcs.Add( wxT("pads") ); // PADS netlist format m_oasGuileProcs.Add( wxT("PCB") ); // PCB m_oasGuileProcs.Add( wxT("PCBboard") ); // PCBboard m_oasGuileProcs.Add( wxT("protelII") ); // ProtelII netlist format m_oasGuileProcs.Add( wxT("spice") ); // Spice compatible netlist format m_oasGuileProcs.Add( wxT("spice-sdb") ); // Enhanced spice compatible netlist format m_oasGuileProcs.Add( wxT("switcap") ); // Switcap netlist format m_oasGuileProcs.Add( wxT("tango") ); // Tango netlist format m_oasGuileProcs.Add( wxT("verilog") ); // Verilog code m_oasGuileProcs.Add( wxT("vhdl") ); // VHDL code m_oasGuileProcs.Add( wxT("vipec") ); // VIPEC netlist format}//*****************************************************************************// Set the schematic to net list conversion utility file name.//// Argument List:// rosFileName - The full path and file name of the GNetList binary//// Return Values:// TRUE - Success// FALSE - Failurebool PrcGNetList::bSetGNetList( const wxString & rosFileName ){ return( bSetBinary( rosFileName.c_str( ) ) );}//*****************************************************************************// Set the schematic file name.//// Argument List:// rosFileName - The full path and file name of a schematic//// Return Values:// TRUE - Success// FALSE - Failurebool PrcGNetList::bSetSchem( const wxString & rosFileName ){ wxArrayString oas1; if( rosFileName.IsEmpty( ) ) return( FALSE ); oas1.Add( rosFileName ); return( bSetSchems( oas1 ) );}//*****************************************************************************// Set the schematic file names.//// Argument List:// roasFileNames - A string array containing the full path and file names//// Return Values:// TRUE - Success// FALSE - Failurebool PrcGNetList::bSetSchems( const wxArrayString & roasFileNames ){ wxFileName oFName; size_t szt1; // Check the argument is valid if( roasFileNames.IsEmpty( ) ) return( FALSE ); // Clear the current list of schematic files m_oaFnmSchems.Clear( ); // Add the new schematic file name/s to the list for( szt1=0; szt1<roasFileNames.GetCount( ); szt1++ ) { oFName = roasFileNames.Item( szt1 ); if( oFName.GetPath( ).IsEmpty( ) ) oFName.SetPath( wxT(".") ); if( ! oFName.IsOk( ) ) continue; if( ! oFName.FileExists( ) ) continue; m_oaFnmSchems.Add( oFName ); } // Check that at least one schematic file name was accepted if( m_oaFnmSchems.IsEmpty( ) ) return( FALSE ); // Set the net list file name bSetNetList( ); // Set the log file path oFName = roGetLogFile( ); oFName.SetPath( m_oaFnmSchems.Item( 0 ).GetPath( ) ); bSetLogFile( oFName.GetFullPath( ) ); // Check if any of the schematic files were invalid if( m_oaFnmSchems.GetCount( ) != roasFileNames.GetCount( ) ) return( FALSE ); return( TRUE );}//*****************************************************************************// Set the full net list file name.//// Argument List:// rosFileName - A string containing the full path and file name// (If psFileName is NULL use the schematic file name to create// a net list file name)//// Return Values:// TRUE - Success// FALSE - Failurebool PrcGNetList::bSetNetList( const wxString & rosFileName ){ wxFileName oFName; // Set the net list name if( ! rosFileName.IsEmpty( ) ) oFName = rosFileName; else { oFName = roGetSchem( ); oFName.SetExt( wxT("gspiceui.ckt") ); } // Set the net list path if it hasn't been set if( oFName.GetPath( ).IsEmpty( ) ) oFName.SetPath( wxT(".") ); // Check that the file name is OK if( ! oFName.IsOk( ) ) return( FALSE ); // Set the net list file path and name m_oFnmNetList = oFName; // Set the log file path oFName = roGetLogFile( ); oFName.SetPath( m_oFnmNetList.GetPath( ) ); bSetLogFile( oFName.GetFullPath( ) ); return( TRUE );}//*****************************************************************************// Set the Guile procedure to be used to import the schematic file.//// Argument List:// rosGuileProc - The Guile procedure name//// Return Values:// TRUE - Success// FALSE - Failurebool PrcGNetList::bSetGuileProc( const wxString & rosGuileProc ){ int i1; if( rosGuileProc.IsEmpty( ) ) return( FALSE ); i1 = m_oasGuileProcs.Index( rosGuileProc ); if( i1 == wxNOT_FOUND ) return( FALSE ); m_sztGuileProc = (size_t) i1; return( TRUE );}//*****************************************************************************// Get a schematic file from the list of schematic files.//// Argument List:// sztIndex - A zero based index to the file name//// Return Values:// Success - The procedure name// Failure - An empty file nameconst wxFileName & PrcGNetList::roGetSchem( size_t sztIndex ){ static wxFileName oFnmEmpty; if( sztIndex>=sztGetSchemCnt( ) ) return( oFnmEmpty ); return( m_oaFnmSchems[ sztIndex ] );}//*****************************************************************************// Get a Guile procedure from the list of procedure names.//// Argument List:// sztIndex - A zero based index to the procedure name// (An index = 0 corresponds to the currently selected procedure)//// Return Values:// Success - The procedure name// Failure - An empty stringconst wxString & PrcGNetList::rosGetGuileProc( size_t sztIndex ){ static wxString osEmpty; if( sztIndex==0 && m_sztGuileProc>0 ) sztIndex = m_sztGuileProc; if( sztIndex<=0 || sztIndex>=sztGetGuileProcCnt( ) ) return( osEmpty ); return( m_oasGuileProcs[ sztIndex ] );}//*****************************************************************************// Make a net list file from a schematic file.// (Eg. using the following: gnetlist -v -g spice-sdb -o test.ckt test.sch)//// Return Values:// TRUE - Success// FALSE - Failurebool PrcGNetList::bExec( void ){ wxString osArgLst; wxString os1; size_t szt1; // Test file names needed by this function if( ! bBinExists( ) ) return( FALSE ); if( m_oaFnmSchems.IsEmpty( ) ) return( FALSE ); if( ! m_oFnmNetList.IsOk( ) ) if( ! bSetNetList( ) ) return( FALSE ); // Enable GNetList verbose mode osArgLst = wxT("-v"); // Specify the guile procedure name to be used osArgLst << wxT(" -g"); os1 = m_oasGuileProcs.Item( m_sztGuileProc ); if( ! os1.IsEmpty( ) ) osArgLst << wxT(' ') << os1; // Append input and output file names osArgLst << wxT(" -o ") << m_oFnmNetList.GetFullPath( ); for( szt1=0; szt1<m_oaFnmSchems.GetCount( ); szt1++ ) osArgLst << wxT(" ") << m_oaFnmSchems.Item( szt1 ).GetFullPath( ); bSetArgLst( osArgLst.c_str( ) ); // Execute the process if( ! PrcBase::bExec( ) ) return( FALSE ); // Capture the process output if( ! bLogOutput( ) ) return( FALSE ); return( TRUE );}//*****************************************************************************
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -