From 988fe7d4a7b36f275f06477dd369ef8615aa8223 Mon Sep 17 00:00:00 2001 From: ian Date: Wed, 16 Jul 2008 20:51:49 +0000 Subject: [PATCH] direction command --- hostside/README.commands | 2 ++ hostside/commands.c | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/hostside/README.commands b/hostside/README.commands index 08ef4ad..463dd53 100644 --- a/hostside/README.commands +++ b/hostside/README.commands @@ -199,6 +199,8 @@ INCOMPLETE LIST OF OTHER COMMANDS movfeat++ } see route++ !movfeat } see !route + direction forwards|backwards|change + DIRECT NMRA AND PIC INSTRUCTIONS Example (always the same msg): diff --git a/hostside/commands.c b/hostside/commands.c index 12d904c..52d2875 100644 --- a/hostside/commands.c +++ b/hostside/commands.c @@ -347,6 +347,23 @@ static int cmd_invert(ParseState *ps, const CmdInfo *ci) { return 0; } +static int cmd_direction(ParseState *ps, const CmdInfo *ci) { + Train *tra; + int backwards; + + MUSTECR( ps_needword(ps) ); + if (!thiswordstrcmp(ps,"forwards")) backwards= 0; + else if (!thiswordstrcmp(ps,"backwards")) backwards= 1; + else if (!thiswordstrcmp(ps,"change")) backwards= !tra->backwards; + else return badcmd(ps, "direction must be forwards|backwards|change"); + + MUSTECR( ps_needtrain(ps,&tra) ); + MUSTECR( ps_neednoargs(ps) ); + + MUSTECRPREDICT( safety_setdirection(tra,backwards,CMDPPC) ); + return 0; +} + /*---------- general machinery and the command table ----------*/ void command_doline(ParseState *ps, CommandInput *cmdi_arg) { @@ -396,5 +413,6 @@ const CmdInfo toplevel_cmds[]= { { "!invert", cmd_invert, CIXF_ANYSTA|CIXF_FORCE }, { "speed", cmd_speed }, { "!speed", cmd_speed, CIXF_ANYSTA|CIXF_FORCE }, + { "direction", cmd_direction }, { 0 } }; -- 2.30.2