//************************************************************************************************** // PrcGNetList.cpp * // ----------------- * // Started : 2004-01-28 * // Last Update : 2016-10-30 * // Copyright : (C) 2004-2016 MSWaters * //************************************************************************************************** //************************************************************************************************** // * // 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 3 of the License, or (at your option) any later version. * // * //************************************************************************************************** #include "PrcGNetList.hpp" //************************************************************************************************** // Allocate storage for static data members. wxArrayString PrcGNetList::m_oasGuileProcs; //************************************************************************************************** // Constructor. PrcGNetList::PrcGNetList( void ) : PrcBase( wxPROCESS_REDIRECT ) { // Clear the object attributes bClear( ); // Attempt to set and find the gnetlist binary bSetBinFile( BIN_GNETLIST ); // Set the log file name bSetLogFile( GNETLST_LOG_FILE ); } //************************************************************************************************** // Destructor. PrcGNetList::~PrcGNetList( ) { } //************************************************************************************************** // Clear the object attributes. // // Return Values : // true - Success // false - Failure bool PrcGNetList::bClear( void ) { bSetSchemFiles( wxT("") ); bSetNetLstFile( wxT("") ); bSetGuileProc ( wxT("") ); // Initialize the array of Guile procedure names and set the default InitGuileProcs( ); return( true ); } //************************************************************************************************** // Initialize the array of possible Guile procedure names. void PrcGNetList::InitGuileProcs( void ) { wxArrayString oas1; wxString os1, os2; size_t sz1; m_oasGuileProcs.Clear( ); m_oasGuileProcs.Add( wxT("") ); if( wxExecute( wxT("gnetlist --list-backends"), oas1 ) == 0 ) { if( oas1.GetCount( ) > 1 ) { for( sz1=1; sz1= m_oaNameSchems.GetCount( ) ) return( oFnEmpty ); return( m_oaNameSchems[ szIndex ] ); } //************************************************************************************************** // Get a Guile procedure from the list of procedure names. // // Argument List : // szIndex - A zero based index to the procedure name // (If szIndex = CUR_SEL_PROC return currently selected procedure) // // Return Values : // Success - The procedure name // Failure - An empty string const wxString & PrcGNetList::rosGetGuileProc( size_t szIndex ) { static wxString osEmpty; if( szIndex == GNETLST_CUR_PROC ) szIndex = m_szGuileProc; if( szIndex >= m_oasGuileProcs.GetCount( ) ) return( osEmpty ); return( m_oasGuileProcs[ szIndex ] ); } //************************************************************************************************** // Make a netlist file from a schematic file. // // (Eg. using the following: gnetlist -v -g spice-sdb -o test.ckt test.sch) // // Return Values : // true - Success // false - Failure bool PrcGNetList::bExec( void ) { wxString osArgLst; wxString os1; size_t sz1; // Test file names needed by this function if( ! bBinExists( ) ) return( false ); if( m_oaNameSchems.IsEmpty( ) ) return( false ); if( ! m_oNameNetLst.IsOk( ) ) if( ! bSetNetLstFile( ) ) return( false ); // Set the various gnetlist modes if( g_oConfig.bGetVerboseMode( ) ) osArgLst << wxT("-v "); if( ! g_oConfig.bGetIncludeMode( ) ) osArgLst << wxT("-O include_mode "); if( g_oConfig.bGetEmbedMode( ) ) osArgLst << wxT("-O embedd_mode "); if( g_oConfig.bGetNoMungeMode( ) ) osArgLst << wxT("-O nomunge_mode "); osArgLst << wxT("-O sort_mode "); // Specify the guile procedure name to be used osArgLst << wxT("-g "); os1 = m_oasGuileProcs.Item( m_szGuileProc ); if( os1.IsEmpty( ) ) os1 = GNETLST_GUILE_PROC; osArgLst << os1 << wxT(' '); // Append input and output file names osArgLst << wxT("-o ") << m_oNameNetLst.GetFullPath( ); for( sz1=0; sz1