From 28d984313384a76104b6d4e13822507e0d8b1bd6 Mon Sep 17 00:00:00 2001 From: Asbelos Date: Mon, 1 May 2023 14:25:45 +0100 Subject: [PATCH] Broadcast changes in EXRAIlr --- CommandDistributor.cpp | 7 ++----- CommandDistributor.h | 5 +++-- EXRAIL2.cpp | 5 ++++- EXRAIL2.h | 3 ++- EXRAIL2MacroReset.h | 2 ++ EXRAILMacros.h | 3 +++ 6 files changed, 16 insertions(+), 9 deletions(-) diff --git a/CommandDistributor.cpp b/CommandDistributor.cpp index 4b4159d..9684291 100644 --- a/CommandDistributor.cpp +++ b/CommandDistributor.cpp @@ -228,11 +228,8 @@ void CommandDistributor::broadcastPower() { LCD(2,F("Power %S%S"),state=='1'?F("On"):F("Off"),reason); } -void CommandDistributor::broadcastText(const FSH * msg) { - broadcastReply(COMMAND_TYPE, F("\n"),msg); -#ifdef CD_HANDLE_RING - broadcastReply(WITHROTTLE_TYPE, F("Hm%S\n"), msg); -#endif +void CommandDistributor::broadcastRaw(clientType type, char * msg) { + broadcastReply(type, F("%s"),msg); } void CommandDistributor::broadcastTrackState(const FSH* format,byte trackLetter,int16_t dcAddr) { diff --git a/CommandDistributor.h b/CommandDistributor.h index cad6271..45f8147 100644 --- a/CommandDistributor.h +++ b/CommandDistributor.h @@ -35,8 +35,9 @@ #endif class CommandDistributor { -private: +public: enum clientType: byte {NONE_TYPE,COMMAND_TYPE,WITHROTTLE_TYPE}; +private: static void broadcastToClients(clientType type); static StringBuffer * broadcastBufferWriter; #ifdef CD_HANDLE_RING @@ -52,7 +53,7 @@ public : static void setClockTime(int16_t time, int8_t rate, byte opt); static int16_t retClockTime(); static void broadcastPower(); - static void broadcastText(const FSH * msg); + static void broadcastRaw(clientType type,char * msg); static void broadcastTrackState(const FSH* format,byte trackLetter,int16_t dcAddr); template static void broadcastReply(clientType type, Targs... msg); static void forget(byte clientId); diff --git a/EXRAIL2.cpp b/EXRAIL2.cpp index 5b6986b..3f22055 100644 --- a/EXRAIL2.cpp +++ b/EXRAIL2.cpp @@ -1242,7 +1242,10 @@ void RMFT2::thrungeString(uint32_t strfar, thrunger mode, byte id) { DCCEXParser::parseOne(&USB_SERIAL,(byte*)buffer->getString(),NULL); break; case thrunge_broadcast: - // TODO CommandDistributor::broadcastText(buffer->getString()); + CommandDistributor::broadcastRaw(CommandDistributor::COMMAND_TYPE,buffer->getString()); + break; + case thrunge_withrottle: + CommandDistributor::broadcastRaw(CommandDistributor::WITHROTTLE_TYPE,buffer->getString()); break; case thrunge_lcd: LCD(id,F("%s"),buffer->getString()); diff --git a/EXRAIL2.h b/EXRAIL2.h index e3d9007..78ed949 100644 --- a/EXRAIL2.h +++ b/EXRAIL2.h @@ -77,7 +77,8 @@ enum OPCODE : byte {OPCODE_THROW,OPCODE_CLOSE, // Ensure thrunge_lcd is put last as there may be more than one display, // sequentially numbered from thrunge_lcd. enum thrunger: byte { - thrunge_print, thrunge_broadcast, thrunge_serial,thrunge_parse, + thrunge_print, thrunge_broadcast, thrunge_withrottle, + thrunge_serial,thrunge_parse, thrunge_serial1, thrunge_serial2, thrunge_serial3, thrunge_serial4, thrunge_serial5, thrunge_serial6, thrunge_lcn, diff --git a/EXRAIL2MacroReset.h b/EXRAIL2MacroReset.h index 5c047da..71b5251 100644 --- a/EXRAIL2MacroReset.h +++ b/EXRAIL2MacroReset.h @@ -142,6 +142,7 @@ #undef VIRTUAL_SIGNAL #undef VIRTUAL_TURNOUT #undef WAITFOR +#undef WITHROTTLE #undef XFOFF #undef XFON @@ -264,6 +265,7 @@ #define VIRTUAL_SIGNAL(id) #define VIRTUAL_TURNOUT(id,description...) #define WAITFOR(pin) +#define WITHROTTLE(msg) #define XFOFF(cab,func) #define XFON(cab,func) #endif diff --git a/EXRAILMacros.h b/EXRAILMacros.h index 633ce5a..e449fbf 100644 --- a/EXRAILMacros.h +++ b/EXRAILMacros.h @@ -153,6 +153,8 @@ const int StringMacroTracker1=__COUNTER__; lcdid=id;\ break;\ } +#undef WITHROTTLE +#define WITHROTTLE(msg) THRUNGE(msg,thrunge_withrottle) void RMFT2::printMessage(uint16_t id) { thrunger tmode; @@ -368,6 +370,7 @@ const HIGHFLASH int16_t RMFT2::SignalDefinitions[] = { #define UNLATCH(sensor_id) OPCODE_UNLATCH,V(sensor_id), #define VIRTUAL_SIGNAL(id) #define VIRTUAL_TURNOUT(id,description...) OPCODE_PINTURNOUT,V(id),OPCODE_PAD,V(0), +#define WITHROTTLE(msg) PRINT(msg) #define WAITFOR(pin) OPCODE_WAITFOR,V(pin), #define XFOFF(cab,func) OPCODE_XFOFF,V(cab),OPCODE_PAD,V(func), #define XFON(cab,func) OPCODE_XFON,V(cab),OPCODE_PAD,V(func),