diff --git a/RMFT2.h b/RMFT2.h index cd6ed16..0e1c82f 100644 --- a/RMFT2.h +++ b/RMFT2.h @@ -44,6 +44,7 @@ enum OPCODE : byte {OPCODE_THROW,OPCODE_CLOSE, OPCODE_ONCLOSE, OPCODE_ONTHROW, OPCODE_SERVOTURNOUT, OPCODE_PINTURNOUT, OPCODE_PRINT,OPCODE_DCCACTIVATE, OPCODE_ONACTIVATE,OPCODE_ONDEACTIVATE,OPCODE_IFGTE,OPCODE_IFLT, + OPCODE_ROSTER, OPCODE_ROUTE,OPCODE_AUTOMATION,OPCODE_SEQUENCE,OPCODE_ENDTASK,OPCODE_ENDEXRAIL }; @@ -84,7 +85,9 @@ class LookList { static void turnoutEvent(int16_t id, bool closed); static void activateEvent(int16_t addr, bool active); static void emitTurnoutDescription(Print* stream,int16_t id); - + static const byte rosterNameCount; + static void emitWithrottleRoster(Print * stream); + static const FSH * getRosterFunctions(int16_t cabid); private: static void ComandFilter(Print * stream, byte & opcode, byte & paramCount, int16_t p[]); static bool parseSlash(Print * stream, byte & paramCount, int16_t p[]) ; diff --git a/RMFT2MacroReset.h b/RMFT2MacroReset.h index d255844..d7bf009 100644 --- a/RMFT2MacroReset.h +++ b/RMFT2MacroReset.h @@ -79,7 +79,8 @@ #undef RESET #undef RESUME #undef RETURN -#undef REV +#undef REV +#undef ROSTER #undef ROUTE #undef SENDLOCO #undef SEQUENCE @@ -164,6 +165,7 @@ #define RETURN #define REV(speed) #define ROUTE(id, description) +#define ROSTER(cab,name,funcmap...) #define SENDLOCO(cab,route) #define SEQUENCE(id) #define SERIAL(msg) diff --git a/RMFTMacros.h b/RMFTMacros.h index 25e6208..e8daa15 100644 --- a/RMFTMacros.h +++ b/RMFTMacros.h @@ -111,7 +111,38 @@ void RMFT2::emitTurnoutDescription(Print* stream,int16_t turnoutid) { StringFormatter::send(stream,desc,turnoutid); } -// Pass 5: create main routes table +// Pass 5: Roster names (count) +#include "RMFT2MacroReset.h" +#undef ROSTER +#define ROSTER(cabid,name,funcmap...) +1 + +const byte RMFT2::rosterNameCount=0 + #include "myAutomation.h" + ; + +// Pass 6: Roster names emitter +#include "RMFT2MacroReset.h" +#undef ROSTER +#define ROSTER(cabid,name,funcmap...) StringFormatter::send(stream,format,F(name),cabid,cabid<128?'S':'L'); +void RMFT2::emitWithrottleRoster(Print * stream) { + static const FSH * format=F("]\\[%S}|{%d}|{%c"); + StringFormatter::send(stream,F("RL%d"), rosterNameCount); + #include "myAutomation.h" + stream->write('\n'); +} + +// Pass 7: functions getter +#include "RMFT2MacroReset.h" +#undef ROSTER +#define ROSTER(cabid,name,funcmap...) case cabid: return F("" funcmap); +const FSH * RMFT2::getRosterFunctions(int16_t cabid) { + switch(cabid) { + #include "myAutomation.h" + default: return NULL; + } +} + +// Last Pass : create main routes table // Only undef the macros, not dummy them. #define RMFT2_UNDEF_ONLY #include "RMFT2MacroReset.h" @@ -180,6 +211,7 @@ void RMFT2::emitTurnoutDescription(Print* stream,int16_t turnoutid) { #define RESUME OPCODE_RESUME,0,0, #define RETURN OPCODE_RETURN,0,0, #define REV(speed) OPCODE_REV,V(speed), +#define ROSTER(cabid,name,funcmap...) #define ROUTE(id, description) OPCODE_ROUTE, V(id), #define SENDLOCO(cab,route) OPCODE_SENDLOCO,V(cab),OPCODE_PAD,V(route), #define SEQUENCE(id) OPCODE_SEQUENCE, V(id), diff --git a/WiThrottle.cpp b/WiThrottle.cpp index 7e9f27c..fbae00a 100644 --- a/WiThrottle.cpp +++ b/WiThrottle.cpp @@ -133,6 +133,7 @@ void WiThrottle::parse(RingStream * stream, byte * cmdx) { exRailSent=true; #ifdef RMFT_ACTIVE RMFT2::emitWithrottleRouteList(stream); + RMFT2::emitWithrottleRoster(stream); #endif } }