mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2024-12-24 13:21:23 +01:00
Remove 'activate' functions from turnout classes.
Remove the static 'activate' function and rename the virtual 'activate' function to 'setClosedInternal'.
This commit is contained in:
parent
39a69e340e
commit
0875d27b0a
@ -106,11 +106,11 @@
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Static activate function is invoked from close(), throw() etc. to perform the
|
// Static setClosed function is invoked from close(), throw() etc. to perform the
|
||||||
// common parts of the turnout operation. Code which is specific to a turnout
|
// common parts of the turnout operation. Code which is specific to a turnout
|
||||||
// type should be placed in the virtual function activate(bool) which is
|
// type should be placed in the virtual function setClosedInternal(bool) which is
|
||||||
// called from here.
|
// called from here.
|
||||||
bool Turnout::activate(uint16_t id, bool closeFlag) {
|
bool Turnout::setClosed(uint16_t id, bool closeFlag) {
|
||||||
#ifdef EESTOREDEBUG
|
#ifdef EESTOREDEBUG
|
||||||
if (closeFlag)
|
if (closeFlag)
|
||||||
DIAG(F("Turnout::close(%d)"), id);
|
DIAG(F("Turnout::close(%d)"), id);
|
||||||
@ -119,7 +119,7 @@
|
|||||||
#endif
|
#endif
|
||||||
Turnout *tt = Turnout::get(id);
|
Turnout *tt = Turnout::get(id);
|
||||||
if (!tt) return false;
|
if (!tt) return false;
|
||||||
bool ok = tt->activate(closeFlag);
|
bool ok = tt->setClosedInternal(closeFlag);
|
||||||
|
|
||||||
if (ok) {
|
if (ok) {
|
||||||
// Write byte containing new closed/thrown state to EEPROM if required. Note that eepromAddress
|
// Write byte containing new closed/thrown state to EEPROM if required. Note that eepromAddress
|
||||||
|
20
Turnouts.h
20
Turnouts.h
@ -93,7 +93,7 @@ protected:
|
|||||||
* Virtual functions
|
* Virtual functions
|
||||||
*/
|
*/
|
||||||
|
|
||||||
virtual bool activate(bool close) = 0; // Mandatory in subclass
|
virtual bool setClosedInternal(bool close) = 0; // Mandatory in subclass
|
||||||
virtual void save() {}
|
virtual void save() {}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -144,18 +144,14 @@ public:
|
|||||||
return !isClosed(id);
|
return !isClosed(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool activate(uint16_t id, bool closeFlag);
|
static bool setClosed(uint16_t id, bool closeFlag);
|
||||||
|
|
||||||
inline static bool setClosed(uint16_t id) {
|
inline static bool setClosed(uint16_t id) {
|
||||||
return activate(id, true);
|
return setClosed(id, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline static bool setThrown(uint16_t id) {
|
inline static bool setThrown(uint16_t id) {
|
||||||
return activate(id, false);
|
return setClosed(id, false);
|
||||||
}
|
|
||||||
|
|
||||||
inline static bool setClosed(uint16_t id, bool close) {
|
|
||||||
return activate(id, close);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool setClosedStateOnly(uint16_t id, bool close) {
|
static bool setClosedStateOnly(uint16_t id, bool close) {
|
||||||
@ -269,7 +265,7 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
// ServoTurnout-specific code for throwing or closing a servo turnout.
|
// ServoTurnout-specific code for throwing or closing a servo turnout.
|
||||||
bool activate(bool close) override {
|
bool setClosedInternal(bool close) override {
|
||||||
#ifndef IO_NO_HAL
|
#ifndef IO_NO_HAL
|
||||||
IODevice::writeAnalogue(_servoTurnoutData.vpin,
|
IODevice::writeAnalogue(_servoTurnoutData.vpin,
|
||||||
close ? _servoTurnoutData.closedPosition : _servoTurnoutData.thrownPosition, _servoTurnoutData.profile);
|
close ? _servoTurnoutData.closedPosition : _servoTurnoutData.thrownPosition, _servoTurnoutData.profile);
|
||||||
@ -357,7 +353,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool activate(bool close) override {
|
bool setClosedInternal(bool close) override {
|
||||||
// DCC++ Classic behaviour is that Throw writes a 1 in the packet,
|
// DCC++ Classic behaviour is that Throw writes a 1 in the packet,
|
||||||
// and Close writes a 0.
|
// and Close writes a 0.
|
||||||
// RCN-214 specifies that Throw is 0 and Close is 1.
|
// RCN-214 specifies that Throw is 0 and Close is 1.
|
||||||
@ -439,7 +435,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool activate(bool close) override {
|
bool setClosedInternal(bool close) override {
|
||||||
IODevice::write(_vpinTurnoutData.vpin, close);
|
IODevice::write(_vpinTurnoutData.vpin, close);
|
||||||
_turnoutData.closed = close;
|
_turnoutData.closed = close;
|
||||||
return true;
|
return true;
|
||||||
@ -490,7 +486,7 @@ public:
|
|||||||
return tt;
|
return tt;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool activate(bool close) override {
|
bool setClosedInternal(bool close) override {
|
||||||
// Assume that the LCN command still uses 1 for throw and 0 for close...
|
// Assume that the LCN command still uses 1 for throw and 0 for close...
|
||||||
LCN::send('T', _turnoutData.id, !close);
|
LCN::send('T', _turnoutData.id, !close);
|
||||||
// The _turnoutData.closed flag should be updated by a message from the LCN master, later.
|
// The _turnoutData.closed flag should be updated by a message from the LCN master, later.
|
||||||
|
Loading…
Reference in New Issue
Block a user