//************************************************************************************************** // PrcGWave.cpp * // -------------- * // Started : 2004-03-29 * // Last Update : 2016-10-23 * // 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 "PrcGWave.hpp" //************************************************************************************************** // Constructor. PrcGWave::PrcGWave( void ) : PrcBase( wxPROCESS_REDIRECT ) { // Initialize the object attributes m_oNameResults.Clear( ); m_oNameLog .Clear( ); // Attempt to set and find the gWave binary bSetBinFile( BIN_GWAVE ); } //************************************************************************************************** // Destructor. PrcGWave::~PrcGWave( ) { } //************************************************************************************************** // Set the simulation results file name. // // Argument List: // psFileName - a string containing the full path and file name // // Return Values: // true - Success // false - Failure bool PrcGWave::bSetResultsFile( const wxString & rosFileName ) { wxFileName ofn1; ofn1 = rosFileName; if( ofn1.GetPath( ).IsEmpty( ) ) ofn1.SetPath( wxT(".") ); if( ! ofn1.IsOk( ) ) return( false ); if( ! ofn1.FileExists( ) ) return( false ); m_oNameResults = ofn1; return( true ); } //************************************************************************************************** // Filter the results file so that the data viewer utility is happy with it. // // There are several things that a data viewer can object to : // - gwave doesn't like the GNU-Cap banner at the start to the results file, so it's removed here. // - gwave doesn't like error messages interspersed with the lines of data, so they are removed // here. // - For good measure lines and fields are also formatted. // // Return Values: // true - Success // false - Failure bool PrcGWave::bFilterFile( void ) { wxString os1; size_t sz1, sz2; wxChar oc1; bool bRtn=true; // Attempt to open the results file wxTextFile oFileCct( m_oNameResults.GetFullPath( ) ); if( ! oFileCct.Exists( ) ) return( false ); if( ! oFileCct.Open( ) ) return( false ); // Has this file been formatted already? if( oFileCct.GetFirstLine( ).GetChar( 0 ) == wxT('#') ) return( true ); // Find the beginning of the data area (ie. the last line beginning with '#') for( sz1=sz2=0; sz1