diff --git a/CommandDistributor.cpp b/CommandDistributor.cpp index fa70e0c..66f2ce0 100644 --- a/CommandDistributor.cpp +++ b/CommandDistributor.cpp @@ -275,8 +275,8 @@ void CommandDistributor::broadcastRaw(clientType type, char * msg) { broadcastReply(type, F("%s"),msg); } -void CommandDistributor::broadcastTrackState(const FSH* format,byte trackLetter, int16_t dcAddr) { - broadcastReply(COMMAND_TYPE, format, trackLetter, dcAddr); +void CommandDistributor::broadcastTrackState(const FSH* format,byte trackLetter, const FSH* tm, int16_t dcAddr) { + broadcastReply(COMMAND_TYPE, format, trackLetter, tm, dcAddr); } void CommandDistributor::broadcastRouteState(uint16_t routeId, byte state ) { diff --git a/CommandDistributor.h b/CommandDistributor.h index 359c0fe..a38410a 100644 --- a/CommandDistributor.h +++ b/CommandDistributor.h @@ -55,7 +55,7 @@ public : static int16_t retClockTime(); static void broadcastPower(); static void broadcastRaw(clientType type,char * msg); - static void broadcastTrackState(const FSH* format,byte trackLetter, int16_t dcAddr); + static void broadcastTrackState(const FSH* format,byte trackLetter, const FSH* tm, int16_t dcAddr); template static void broadcastReply(clientType type, Targs... msg); static void forget(byte clientId); static void broadcastRouteState(uint16_t routeId,byte state); diff --git a/TrackManager.cpp b/TrackManager.cpp index 7c1e651..1b0e75a 100644 --- a/TrackManager.cpp +++ b/TrackManager.cpp @@ -402,41 +402,49 @@ void TrackManager::streamTrackState(Print* stream, byte t) { if (track[t]==NULL) return; auto format=F("<= %d XXX>\n"); TRACK_MODE tm = track[t]->getMode(); - if (tm & TRACK_MODE_MAIN) { - if(tm & TRACK_MODE_AUTOINV) - format=F("<= %c MAIN A>\n"); - else if (tm & TRACK_MODE_INV) - format=F("<= %c MAIN I>\n"); - else - format=F("<= %c MAIN>\n"); - } -#ifndef DISABLE_PROG - else if (tm & TRACK_MODE_PROG) - format=F("<= %c PROG>\n"); -#endif - else if (tm & TRACK_MODE_NONE) - format=F("<= %c NONE>\n"); - else if(tm & TRACK_MODE_EXT) - format=F("<= %c EXT>\n"); - else if(tm & TRACK_MODE_BOOST) { - if(tm & TRACK_MODE_AUTOINV) - format=F("<= %c B A>\n"); - else if (tm & TRACK_MODE_INV) - format=F("<= %c B I>\n"); - else - format=F("<= %c B>\n"); - } - else if (tm & TRACK_MODE_DC) { - if (tm & TRACK_MODE_INV) - format=F("<= %c DCX %d>\n"); - else - format=F("<= %c DC %d>\n"); - } + +// if (tm & TRACK_MODE_MAIN) { +// if(tm & TRACK_MODE_AUTOINV) +// format=F("<= %c MAIN A>\n"); +// else if (tm & TRACK_MODE_INV) +// format=F("<= %c MAIN I>\n"); +// else +// format=F("<= %c MAIN>\n"); +// } +// #ifndef DISABLE_PROG +// else if (tm & TRACK_MODE_PROG) +// format=F("<= %c PROG>\n"); +// #endif +// else if (tm & TRACK_MODE_NONE) +// format=F("<= %c NONE>\n"); +// else if(tm & TRACK_MODE_EXT) +// format=F("<= %c EXT>\n"); +// else if(tm & TRACK_MODE_BOOST) { +// if(tm & TRACK_MODE_AUTOINV) +// format=F("<= %c B A>\n"); +// else if (tm & TRACK_MODE_INV) +// format=F("<= %c B I>\n"); +// else +// format=F("<= %c B>\n"); +// } +// else +// if (tm & TRACK_MODE_DC) { +// if (tm & TRACK_MODE_INV) +// format=F("<= %c DCX %d>\n"); +// else +// format=F("<= %c DC %d>\n"); +// } +if (tm & TRACK_MODE_DC || tm & TRACK_MODE_INV) + format=F("<= %c %S %d>\n"); + else + format=F("<= %c %S>\n"); + + if (stream) - StringFormatter::send(stream,format,'A'+t, trackDCAddr[t]); + StringFormatter::send(stream,format,'A'+t, getModeName(tm), trackDCAddr[t]); else - CommandDistributor::broadcastTrackState(format,'A'+t, trackDCAddr[t]); + CommandDistributor::broadcastTrackState(format,'A'+t, getModeName(tm), trackDCAddr[t]); } @@ -630,26 +638,31 @@ bool TrackManager::isProg(byte t) { return false; } -byte TrackManager::returnMode(byte t) { - return (track[t]->getMode()); +TRACK_MODE TrackManager::returnMode(byte t) { + return ((TRACK_MODE)track[t]->getMode()); } int16_t TrackManager::returnDCAddr(byte t) { return (trackDCAddr[t]); } -const char* TrackManager::getModeName(byte Mode) { + +const FSH* TrackManager::getModeName(TRACK_MODE Mode) { //DIAG(F("PowerMode %d"), Mode); switch (Mode) { - case 1: return "NONE"; - case 2: return "MAIN"; - case 4: return "PROG"; - case 8: return "DC"; - case 16: return "DCX"; - case 32: return "EXT"; - default: return "----"; + case TRACK_MODE_NONE: return F("NONE"); + case TRACK_MODE_MAIN: return F("MAIN"); + case TRACK_MODE_PROG: return F("PROG"); + case TRACK_MODE_DC: return F("DC"); + case TRACK_MODE_EXT: return F("EXT"); + case TRACK_MODE_BOOST: return F("BOOST"); + case TRACK_MODE_ALL: return F("ALL"); + case TRACK_MODE_INV: return F("INV"); + case TRACK_MODE_DCX: return F("DCX"); + case TRACK_MODE_AUTOINV: return F("AUTOINV"); + default: return F("----"); } -} +} \ No newline at end of file diff --git a/TrackManager.h b/TrackManager.h index 644c45a..df8cfd1 100644 --- a/TrackManager.h +++ b/TrackManager.h @@ -89,9 +89,9 @@ class TrackManager { static void streamTrackState(Print* stream, byte t); static bool isPowerOn(byte t); static bool isProg(byte t); - static byte returnMode(byte t); + static TRACK_MODE returnMode(byte t); static int16_t returnDCAddr(byte t); - static const char* getModeName(byte Mode); + static const FSH* getModeName(TRACK_MODE Mode); static int16_t joinRelay; static bool progTrackSyncMain; // true when prog track is a siding switched to main