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>
|
|
|
|
|
|
|
|
#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 );
|
|
|
|
cl_parser.AddUsageText( _( "PNS Log (Re)player. Allows to step through the log written by the ROUTER_TOOL "
|
|
|
|
"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] );
|
|
|
|
// Help and invalid input both stop here
|
|
|
|
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;
|
|
|
|
|
|
|
|
long iter_limit = 256;
|
|
|
|
long steps_limit = -1;
|
|
|
|
cl_parser.Found( "iteration-limit", &iter_limit );
|
|
|
|
cl_parser.Found( "steps-limit", &steps_limit );
|
|
|
|
filename = cl_parser.GetParam(0);
|
2022-02-26 01:47:14 +00:00
|
|
|
|
2022-06-03 21:24:59 +00:00
|
|
|
printf("iters %d steps %d file '%s'\n", iter_limit, steps_limit, (const char *) filename.c_str() );
|
|
|
|
|
|
|
|
auto frame = new PNS_LOG_VIEWER_FRAME( nullptr );
|
|
|
|
|
|
|
|
PNS_LOG_FILE* logFile = new PNS_LOG_FILE;
|
|
|
|
logFile->Load( wxFileName( argv[1] ) );
|
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,
|
|
|
|
} );
|