2022-10-23 22:15:32 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2020-2022 KiCad Developers.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2022-06-03 21:24:59 +00:00
|
|
|
#include <wx/cmdline.h>
|
|
|
|
|
2022-02-26 01:47:14 +00:00
|
|
|
#include <qa_utils/utility_registry.h>
|
2022-10-23 22:15:32 +00:00
|
|
|
#include <pcbnew_utils/board_test_utils.h>
|
2022-02-26 01:47:14 +00:00
|
|
|
|
|
|
|
#include "pns_log_file.h"
|
|
|
|
#include "pns_log_viewer_frame.h"
|
|
|
|
|
2022-06-03 21:24:59 +00:00
|
|
|
|
|
|
|
static const wxCmdLineEntryDesc g_cmdLineDesc[] = {
|
|
|
|
{
|
|
|
|
wxCMD_LINE_SWITCH,
|
|
|
|
"h",
|
|
|
|
"help",
|
|
|
|
_( "displays help on the command line parameters" ).mb_str(),
|
|
|
|
wxCMD_LINE_VAL_NONE,
|
|
|
|
wxCMD_LINE_OPTION_HELP,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
wxCMD_LINE_OPTION,
|
|
|
|
"i",
|
|
|
|
"iteration-limit",
|
|
|
|
_( "Max number of iterations" ).mb_str(),
|
|
|
|
wxCMD_LINE_VAL_NUMBER,
|
|
|
|
wxCMD_LINE_PARAM_OPTIONAL,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
wxCMD_LINE_OPTION,
|
|
|
|
"s",
|
|
|
|
"steps-limit",
|
|
|
|
_( "execute log up to steps-limit events" ).mb_str(),
|
|
|
|
wxCMD_LINE_VAL_NUMBER,
|
|
|
|
wxCMD_LINE_PARAM_OPTIONAL,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
wxCMD_LINE_PARAM,
|
|
|
|
"filename",
|
|
|
|
"filename",
|
|
|
|
_( "log file name (no extensions)" ).mb_str(),
|
|
|
|
wxCMD_LINE_VAL_STRING,
|
|
|
|
wxCMD_LINE_OPTION_MANDATORY,
|
|
|
|
},
|
|
|
|
{ wxCMD_LINE_NONE }
|
|
|
|
};
|
|
|
|
|
2022-02-26 01:47:14 +00:00
|
|
|
int replay_main_func( int argc, char* argv[] )
|
|
|
|
{
|
2022-06-03 21:24:59 +00:00
|
|
|
wxCmdLineParser cl_parser( argc, argv );
|
|
|
|
cl_parser.SetDesc( g_cmdLineDesc );
|
2022-10-23 22:15:32 +00:00
|
|
|
cl_parser.AddUsageText(
|
|
|
|
_( "PNS Log (Re)player. Allows to step through the log written by the ROUTER_TOOL "
|
2022-06-03 21:24:59 +00:00
|
|
|
"in debug KiCad builds." ) );
|
2022-02-26 01:47:14 +00:00
|
|
|
|
2022-06-03 21:24:59 +00:00
|
|
|
int cmd_parsed_ok = cl_parser.Parse();
|
|
|
|
|
|
|
|
if( cl_parser.Found("help") )
|
2022-02-26 01:47:14 +00:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2022-06-03 21:24:59 +00:00
|
|
|
if( cmd_parsed_ok != 0 )
|
2022-02-26 01:47:14 +00:00
|
|
|
{
|
2022-06-03 21:24:59 +00:00
|
|
|
printf("P&S Log Replay/Debug tool. For command line options, call %s -h.\n\n", argv[0] );
|
|
|
|
return ( cmd_parsed_ok == -1 ) ? KI_TEST::RET_CODES::OK : KI_TEST::RET_CODES::BAD_CMDLINE;
|
2022-02-26 01:47:14 +00:00
|
|
|
}
|
|
|
|
|
2022-06-03 21:24:59 +00:00
|
|
|
wxString filename;
|
|
|
|
|
2022-10-23 22:15:32 +00:00
|
|
|
#if 0
|
2022-06-03 21:24:59 +00:00
|
|
|
long iter_limit = 256;
|
|
|
|
long steps_limit = -1;
|
|
|
|
cl_parser.Found( "iteration-limit", &iter_limit );
|
|
|
|
cl_parser.Found( "steps-limit", &steps_limit );
|
2022-10-23 22:15:32 +00:00
|
|
|
#endif
|
2022-02-26 01:47:14 +00:00
|
|
|
|
2022-10-23 22:15:32 +00:00
|
|
|
filename = cl_parser.GetParam(0);
|
2022-06-03 21:24:59 +00:00
|
|
|
|
|
|
|
auto frame = new PNS_LOG_VIEWER_FRAME( nullptr );
|
|
|
|
|
|
|
|
PNS_LOG_FILE* logFile = new PNS_LOG_FILE;
|
2022-10-23 22:15:32 +00:00
|
|
|
|
|
|
|
KI_TEST::CONSOLE_LOG log;
|
|
|
|
KI_TEST::CONSOLE_MSG_REPORTER reporter( &log );
|
|
|
|
|
|
|
|
logFile->Load( wxFileName( argv[1] ), &reporter );
|
2022-02-26 01:47:14 +00:00
|
|
|
frame->SetLogFile( logFile );
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static bool registered = UTILITY_REGISTRY::Register( {
|
|
|
|
"replay",
|
|
|
|
"PNS Log Player",
|
|
|
|
replay_main_func,
|
|
|
|
} );
|