1
0
mirror of https://github.com/DCC-EX/CommandStation-EX.git synced 2024-12-24 21:21:24 +01:00

<T> should send turnout definitions, not just states

This commit is contained in:
SteveT 2020-12-28 21:00:18 -05:00
parent f134d87c85
commit 7e7435eafa
4 changed files with 16 additions and 7 deletions

View File

@ -445,7 +445,7 @@ void DCCEXParser::parse(Print *stream, byte *com, bool blocking)
case 's': // <s> case 's': // <s>
StringFormatter::send(stream, F("<p%d>"), DCCWaveform::mainTrack.getPowerMode() == POWERMODE::ON); StringFormatter::send(stream, F("<p%d>"), DCCWaveform::mainTrack.getPowerMode() == POWERMODE::ON);
StringFormatter::send(stream, F("<iDCC-EX V-%S / %S / %S G-%S>"), F(VERSION), F(ARDUINO_TYPE), DCC::getMotorShieldName(), F(GITHUB_SHA)); StringFormatter::send(stream, F("<iDCC-EX V-%S / %S / %S G-%S>"), F(VERSION), F(ARDUINO_TYPE), DCC::getMotorShieldName(), F(GITHUB_SHA));
parseT(stream, 0, p); //send all Turnout states Turnout::printAll(stream); //send all Turnout states
Output::printAll(stream); //send all Output states Output::printAll(stream); //send all Output states
Sensor::printAll(stream); //send all Sensor states Sensor::printAll(stream); //send all Sensor states
// TODO Send stats of speed reminders table // TODO Send stats of speed reminders table
@ -529,7 +529,7 @@ bool DCCEXParser::parseZ(Print *stream, int params, int p[])
StringFormatter::send(stream, F("<O>")); StringFormatter::send(stream, F("<O>"));
return true; return true;
case 0: // <Z> case 0: // <Z> list Output definitions
{ {
bool gotone = false; bool gotone = false;
for (Output *tt = Output::firstOutput; tt != NULL; tt = tt->nextOutput) for (Output *tt = Output::firstOutput; tt != NULL; tt = tt->nextOutput)
@ -591,13 +591,14 @@ bool DCCEXParser::parseT(Print *stream, int params, int p[])
{ {
switch (params) switch (params)
{ {
case 0: // <T> list all turnout states case 0: // <T> list turnout definitions
{ {
bool gotOne = false; bool gotOne = false;
for (Turnout *tt = Turnout::firstTurnout; tt != NULL; tt = tt->nextTurnout) for (Turnout *tt = Turnout::firstTurnout; tt != NULL; tt = tt->nextTurnout)
{ {
gotOne = true; gotOne = true;
StringFormatter::send(stream, F("<H %d %d>"), tt->data.id, (tt->data.tStatus & STATUS_ACTIVE)!=0); StringFormatter::send(stream, F("<H %d %d %d %d>"), tt->data.id, tt->data.address,
tt->data.subAddress, (tt->data.tStatus & STATUS_ACTIVE)!=0);
} }
return gotOne; // will <X> if none found return gotOne; // will <X> if none found
} }
@ -646,7 +647,7 @@ bool DCCEXParser::parseS(Print *stream, int params, int p[])
StringFormatter::send(stream, F("<O>")); StringFormatter::send(stream, F("<O>"));
return true; return true;
case 0: // <S> list sensor states case 0: // <S> list sensor definitions
if (Sensor::firstSensor == NULL) if (Sensor::firstSensor == NULL)
return false; return false;
for (Sensor *tt = Sensor::firstSensor; tt != NULL; tt = tt->nextSensor) for (Sensor *tt = Sensor::firstSensor; tt != NULL; tt = tt->nextSensor)

View File

@ -34,8 +34,8 @@
#include "LCDDisplay.h" #include "LCDDisplay.h"
bool Diag::ACK=false; bool Diag::ACK=false;
bool Diag::CMD=false; bool Diag::CMD=true;
bool Diag::WIFI=false; bool Diag::WIFI=true;
bool Diag::WITHROTTLE=false; bool Diag::WITHROTTLE=false;
bool Diag::ETHERNET=false; bool Diag::ETHERNET=false;

View File

@ -21,10 +21,17 @@
#include "Turnouts.h" #include "Turnouts.h"
#include "EEStore.h" #include "EEStore.h"
#include "PWMServoDriver.h" #include "PWMServoDriver.h"
#include "StringFormatter.h"
#ifdef EESTOREDEBUG #ifdef EESTOREDEBUG
#include "DIAG.h" #include "DIAG.h"
#endif #endif
// print all turnout states to stream
void Turnout::printAll(Print *stream){
for (Turnout *tt = Turnout::firstTurnout; tt != NULL; tt = tt->nextTurnout)
StringFormatter::send(stream, F("<H %d %d>"), tt->data.id, (tt->data.tStatus & STATUS_ACTIVE)!=0);
} // Turnout::printAll
bool Turnout::activate(int n,bool state){ bool Turnout::activate(int n,bool state){
#ifdef EESTOREDEBUG #ifdef EESTOREDEBUG
DIAG(F("\nTurnout::activate(%d,%d)\n"),n,state); DIAG(F("\nTurnout::activate(%d,%d)\n"),n,state);

View File

@ -49,6 +49,7 @@ class Turnout {
static Turnout *create(int id , byte pin , int activeAngle, int inactiveAngle); static Turnout *create(int id , byte pin , int activeAngle, int inactiveAngle);
static Turnout *create(int id); static Turnout *create(int id);
void activate(bool state); void activate(bool state);
static void printAll(Print *);
#ifdef EESTOREDEBUG #ifdef EESTOREDEBUG
void print(Turnout *tt); void print(Turnout *tt);
#endif #endif