mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2024-12-25 13:41:23 +01:00
Fixes to power modes
Fixes to Power Modes
This commit is contained in:
parent
b472230b47
commit
61ae7e66b2
@ -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 ) {
|
||||
|
@ -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<typename... Targs> static void broadcastReply(clientType type, Targs... msg);
|
||||
static void forget(byte clientId);
|
||||
static void broadcastRouteState(uint16_t routeId,byte state);
|
||||
|
@ -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("----");
|
||||
}
|
||||
}
|
||||
}
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user