mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2025-01-24 19:28:53 +01:00
Revert to original DCC++ Classic Turnout command polarity.
Revert to <T id 1> command being 'throw' and <T id 0> being 'close', for turnouts.
This commit is contained in:
parent
777d189cc5
commit
08cfe41cf3
@ -679,22 +679,17 @@ bool DCCEXParser::parseT(Print *stream, int16_t params, int16_t p[])
|
||||
{
|
||||
bool state = false;
|
||||
switch (p[1]) {
|
||||
// By default turnout command uses 0=throw, 1=close,
|
||||
// but legacy DCC++ behaviour is 1=throw, 0=close.
|
||||
// Turnout messages use 1=throw, 0=close.
|
||||
case 0:
|
||||
state = Turnout::useClassicTurnoutCommands;
|
||||
break;
|
||||
case 1:
|
||||
state = !Turnout::useClassicTurnoutCommands;
|
||||
break;
|
||||
case HASH_KEYWORD_C:
|
||||
state = true;
|
||||
break;
|
||||
case 1:
|
||||
case HASH_KEYWORD_T:
|
||||
state= false;
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
return false; // Invalid parameter
|
||||
}
|
||||
if (!Turnout::setClosed(p[0], state)) return false;
|
||||
|
||||
|
26
Turnouts.cpp
26
Turnouts.cpp
@ -42,12 +42,6 @@
|
||||
* Public static data
|
||||
*/
|
||||
int Turnout::turnoutlistHash = 0;
|
||||
|
||||
#if defined(USE_RCN_213_TURNOUT_COMMANDS)
|
||||
const bool Turnout::useClassicTurnoutCommands = false;
|
||||
#else
|
||||
const bool Turnout::useClassicTurnoutCommands = true;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Protected static functions
|
||||
@ -75,10 +69,9 @@
|
||||
}
|
||||
|
||||
// For DCC++ classic compatibility, state reported to JMRI is 1 for thrown and 0 for closed;
|
||||
// if consistency with RCN-213 has been selected, it is 0 for thrown and 1 for closed.
|
||||
void Turnout::printState(Print *stream) {
|
||||
StringFormatter::send(stream, F("<H %d %d>\n"),
|
||||
_turnoutData.id, _turnoutData.closed ^ useClassicTurnoutCommands);
|
||||
_turnoutData.id, !_turnoutData.closed);
|
||||
}
|
||||
|
||||
// Remove nominated turnout from turnout linked list and delete the object.
|
||||
@ -207,7 +200,7 @@
|
||||
return tt;
|
||||
}
|
||||
|
||||
// Display, on the specified stream, the current state of the turnout (1 or 0).
|
||||
// Display, on the specified stream, the current state of the turnout (1=thrown or 0=closed).
|
||||
void Turnout::printState(uint16_t id, Print *stream) {
|
||||
Turnout *tt = get(id);
|
||||
if (!tt) tt->printState(stream);
|
||||
@ -281,12 +274,11 @@
|
||||
return tt;
|
||||
}
|
||||
|
||||
// For DCC++ classic compatibility, state reported to JMRI is 1 for thrown and 0 for closed;
|
||||
// if consistency with RCN-213 has been selected, it is 0 for thrown and 1 for closed.
|
||||
// For DCC++ classic compatibility, state reported to JMRI is 1 for thrown and 0 for closed
|
||||
void ServoTurnout::print(Print *stream) {
|
||||
StringFormatter::send(stream, F("<H %d SERVO %d %d %d %d %d>\n"), _turnoutData.id, _servoTurnoutData.vpin,
|
||||
_servoTurnoutData.thrownPosition, _servoTurnoutData.closedPosition, _servoTurnoutData.profile,
|
||||
_turnoutData.closed ^ useClassicTurnoutCommands);
|
||||
!_turnoutData.closed);
|
||||
}
|
||||
|
||||
// ServoTurnout-specific code for throwing or closing a servo turnout.
|
||||
@ -373,11 +365,11 @@
|
||||
void DCCTurnout::print(Print *stream) {
|
||||
StringFormatter::send(stream, F("<H %d DCC %d %d %d>\n"), _turnoutData.id,
|
||||
(((_dccTurnoutData.address-1) >> 2)+1), ((_dccTurnoutData.address-1) & 3),
|
||||
_turnoutData.closed ^ useClassicTurnoutCommands);
|
||||
!_turnoutData.closed);
|
||||
// Also report using classic DCC++ syntax for DCC accessory turnouts, since JMRI expects this.
|
||||
StringFormatter::send(stream, F("<H %d %d %d %d>\n"), _turnoutData.id,
|
||||
(((_dccTurnoutData.address-1) >> 2)+1), ((_dccTurnoutData.address-1) & 3),
|
||||
_turnoutData.closed ^ useClassicTurnoutCommands);
|
||||
!_turnoutData.closed);
|
||||
}
|
||||
|
||||
bool DCCTurnout::setClosedInternal(bool close) {
|
||||
@ -447,9 +439,10 @@
|
||||
return tt;
|
||||
}
|
||||
|
||||
// Report 1 for thrown, 0 for closed.
|
||||
void VpinTurnout::print(Print *stream) {
|
||||
StringFormatter::send(stream, F("<H %d VPIN %d %d>\n"), _turnoutData.id, _vpinTurnoutData.vpin,
|
||||
_turnoutData.closed ^ useClassicTurnoutCommands);
|
||||
!_turnoutData.closed);
|
||||
}
|
||||
|
||||
bool VpinTurnout::setClosedInternal(bool close) {
|
||||
@ -511,8 +504,9 @@
|
||||
//void save() override { }
|
||||
//static Turnout *load(struct TurnoutData *turnoutData) {
|
||||
|
||||
// Report 1 for thrown, 0 for closed.
|
||||
void LCNTurnout::print(Print *stream) {
|
||||
StringFormatter::send(stream, F("<H %d LCN %d>\n"), _turnoutData.id,
|
||||
_turnoutData.closed ^ useClassicTurnoutCommands);
|
||||
!_turnoutData.closed);
|
||||
}
|
||||
|
||||
|
@ -141,15 +141,4 @@ The configuration file for DCC-EX Command Station
|
||||
// don't add it to your config.h.
|
||||
#define DCC_TURNOUTS_RCN_213
|
||||
|
||||
// In addition to the above, there is an option to allow the values in the <T> commands
|
||||
// sent and received from JMRI to be changed to be consistent with the definition in
|
||||
// RCN-213. In DCC++ Classic and in previous versions of DCC++EX, a <T id 1> command
|
||||
// requested a 'throw' and <T id 0> requested a 'close'.
|
||||
// The macro below, when present, allows this behaviour to be reversed so that a <T id 1>
|
||||
// requests the turnout to 'close' and <T id 0> requests it to 'throw'.
|
||||
// This should only be used if the command processor (JMRI) writing to the serial port
|
||||
// supports it, otherwise turnout operation commands received over the serial port
|
||||
// will be reversed.
|
||||
//#define USE_RCN_213_TURNOUT_COMMANDS
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////
|
||||
|
Loading…
Reference in New Issue
Block a user