mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2024-12-25 05:31:24 +01:00
sync power state and turnout list/states to all clients
This commit is contained in:
parent
a7da30b236
commit
b03776c6f8
@ -71,7 +71,14 @@ bool WiThrottle::areYouUsingThrottle(int cab) {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
void WiThrottle::setSendPowerState() {
|
||||||
|
for (WiThrottle* wt=firstThrottle; wt!=NULL ; wt=wt->nextThrottle)
|
||||||
|
wt->sendPowerState = true;
|
||||||
|
}
|
||||||
|
void WiThrottle::setSendTurnoutList() {
|
||||||
|
for (WiThrottle* wt=firstThrottle; wt!=NULL ; wt=wt->nextThrottle)
|
||||||
|
wt->sendTurnoutList = true;
|
||||||
|
}
|
||||||
|
|
||||||
// One instance of WiThrottle per connected client, so we know what the locos are
|
// One instance of WiThrottle per connected client, so we know what the locos are
|
||||||
|
|
||||||
@ -140,6 +147,7 @@ void WiThrottle::parse(Print & stream, byte * cmdx) {
|
|||||||
if (cmd[1]=='P' && cmd[2]=='A' ) { //PPA power mode
|
if (cmd[1]=='P' && cmd[2]=='A' ) { //PPA power mode
|
||||||
DCCWaveform::mainTrack.setPowerMode(cmd[3]=='1'?POWERMODE::ON:POWERMODE::OFF);
|
DCCWaveform::mainTrack.setPowerMode(cmd[3]=='1'?POWERMODE::ON:POWERMODE::OFF);
|
||||||
StringFormatter::send(stream,F("PPA%x\n"),DCCWaveform::mainTrack.getPowerMode()==POWERMODE::ON);
|
StringFormatter::send(stream,F("PPA%x\n"),DCCWaveform::mainTrack.getPowerMode()==POWERMODE::ON);
|
||||||
|
setSendPowerState(); //tell all WiThrottle instances to send power state at next heartbeat
|
||||||
}
|
}
|
||||||
else if (cmd[1]=='T' && cmd[2]=='A') { // PTA accessory toggle
|
else if (cmd[1]=='T' && cmd[2]=='A') { // PTA accessory toggle
|
||||||
int id=getInt(cmd+4);
|
int id=getInt(cmd+4);
|
||||||
@ -159,7 +167,7 @@ void WiThrottle::parse(Print & stream, byte * cmdx) {
|
|||||||
}
|
}
|
||||||
Turnout::activate(id,newstate);
|
Turnout::activate(id,newstate);
|
||||||
StringFormatter::send(stream, F("PTA%c%d\n"),newstate?'4':'2',id );
|
StringFormatter::send(stream, F("PTA%c%d\n"),newstate?'4':'2',id );
|
||||||
sendTurnoutList = true;
|
setSendTurnoutList(); //tell all WiThrottle instances to send turnout list at next heartbeat
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'N': // Heartbeat (2)
|
case 'N': // Heartbeat (2)
|
||||||
|
@ -42,6 +42,8 @@ class WiThrottle {
|
|||||||
static int getLocoId(byte * cmd);
|
static int getLocoId(byte * cmd);
|
||||||
static char LorS(int cab);
|
static char LorS(int cab);
|
||||||
static bool isThrottleInUse(int cab);
|
static bool isThrottleInUse(int cab);
|
||||||
|
static void setSendTurnoutList();
|
||||||
|
static void setSendPowerState();
|
||||||
bool areYouUsingThrottle(int cab);
|
bool areYouUsingThrottle(int cab);
|
||||||
WiThrottle* nextThrottle;
|
WiThrottle* nextThrottle;
|
||||||
int clientid;
|
int clientid;
|
||||||
|
Loading…
Reference in New Issue
Block a user