mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2025-07-28 09:53:45 +02:00
Merge branch 'devel' of https://github.com/DCC-EX/CommandStation-EX into devel
This commit is contained in:
@@ -254,21 +254,56 @@ void CommandDistributor::broadcastPower() {
|
||||
if (TrackManager::getPower(t, pstr))
|
||||
broadcastReply(COMMAND_TYPE, F("<p%s>\n"),pstr);
|
||||
|
||||
byte trackcount=0;
|
||||
byte oncount=0;
|
||||
byte offcount=0;
|
||||
for(byte t=0; t<TrackManager::MAX_TRACKS; t++) {
|
||||
if (TrackManager::isActive(t)) {
|
||||
trackcount++;
|
||||
// do not call getPower(t) unless isActive(t)!
|
||||
if (TrackManager::getPower(t) == POWERMODE::ON)
|
||||
oncount++;
|
||||
else
|
||||
offcount++;
|
||||
}
|
||||
}
|
||||
//DIAG(F("t=%d on=%d off=%d"), trackcount, oncount, offcount);
|
||||
|
||||
char state='2';
|
||||
if (oncount==0 || offcount == trackcount)
|
||||
state = '0';
|
||||
else if (oncount == trackcount) {
|
||||
state = '1';
|
||||
}
|
||||
|
||||
// additional info about MAIN, PROG and JOIN
|
||||
bool main=TrackManager::getMainPower()==POWERMODE::ON;
|
||||
bool prog=TrackManager::getProgPower()==POWERMODE::ON;
|
||||
bool join=TrackManager::isJoined();
|
||||
//DIAG(F("m=%d p=%d j=%d"), main, prog, join);
|
||||
const FSH * reason=F("");
|
||||
char state='1';
|
||||
if (main && prog && join) reason=F(" JOIN");
|
||||
else if (main && prog);
|
||||
else if (main) reason=F(" MAIN");
|
||||
else if (prog) reason=F(" PROG");
|
||||
else state='0';
|
||||
broadcastReply(COMMAND_TYPE, F("<p%c%S>\n"),state,reason);
|
||||
if (join) {
|
||||
reason = F("JOIN");
|
||||
broadcastReply(COMMAND_TYPE, F("<p1 %S>\n"),reason);
|
||||
} else {
|
||||
if (main) {
|
||||
//reason = F("MAIN");
|
||||
broadcastReply(COMMAND_TYPE, F("<p1 MAIN>\n"));
|
||||
}
|
||||
if (prog) {
|
||||
//reason = F("PROG");
|
||||
broadcastReply(COMMAND_TYPE, F("<p1 PROG>\n"));
|
||||
}
|
||||
}
|
||||
|
||||
if (state != '2')
|
||||
broadcastReply(COMMAND_TYPE, F("<p%c>\n"),state);
|
||||
#ifdef CD_HANDLE_RING
|
||||
broadcastReply(WITHROTTLE_TYPE, F("PPA%c\n"), main?'1':'0');
|
||||
// send '1' if all main are on, otherwise global state (which in that case is '0' or '2')
|
||||
broadcastReply(WITHROTTLE_TYPE, F("PPA%c\n"), main?'1': state);
|
||||
#endif
|
||||
LCD(2,F("Power %S%S"),state=='1'?F("On"):F("Off"),reason);
|
||||
|
||||
LCD(2,F("Power %S %S"),state=='1'?F("On"): ( state=='0'? F("Off") : F("SC") ),reason);
|
||||
}
|
||||
|
||||
void CommandDistributor::broadcastRaw(clientType type, char * msg) {
|
||||
|
Reference in New Issue
Block a user