mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2024-12-23 21:01:25 +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;
|
||||
}
|
||||
|
||||
// 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
|
||||
// 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.
|
||||
bool Turnout::activate(uint16_t id, bool closeFlag) {
|
||||
bool Turnout::setClosed(uint16_t id, bool closeFlag) {
|
||||
#ifdef EESTOREDEBUG
|
||||
if (closeFlag)
|
||||
DIAG(F("Turnout::close(%d)"), id);
|
||||
@ -119,7 +119,7 @@
|
||||
#endif
|
||||
Turnout *tt = Turnout::get(id);
|
||||
if (!tt) return false;
|
||||
bool ok = tt->activate(closeFlag);
|
||||
bool ok = tt->setClosedInternal(closeFlag);
|
||||
|
||||
if (ok) {
|
||||
// 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 bool activate(bool close) = 0; // Mandatory in subclass
|
||||
virtual bool setClosedInternal(bool close) = 0; // Mandatory in subclass
|
||||
virtual void save() {}
|
||||
|
||||
/*
|
||||
@ -144,18 +144,14 @@ public:
|
||||
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) {
|
||||
return activate(id, true);
|
||||
return setClosed(id, true);
|
||||
}
|
||||
|
||||
inline static bool setThrown(uint16_t id) {
|
||||
return activate(id, false);
|
||||
}
|
||||
|
||||
inline static bool setClosed(uint16_t id, bool close) {
|
||||
return activate(id, close);
|
||||
return setClosed(id, false);
|
||||
}
|
||||
|
||||
static bool setClosedStateOnly(uint16_t id, bool close) {
|
||||
@ -269,7 +265,7 @@ public:
|
||||
|
||||
protected:
|
||||
// ServoTurnout-specific code for throwing or closing a servo turnout.
|
||||
bool activate(bool close) override {
|
||||
bool setClosedInternal(bool close) override {
|
||||
#ifndef IO_NO_HAL
|
||||
IODevice::writeAnalogue(_servoTurnoutData.vpin,
|
||||
close ? _servoTurnoutData.closedPosition : _servoTurnoutData.thrownPosition, _servoTurnoutData.profile);
|
||||
@ -357,7 +353,7 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
bool activate(bool close) override {
|
||||
bool setClosedInternal(bool close) override {
|
||||
// DCC++ Classic behaviour is that Throw writes a 1 in the packet,
|
||||
// and Close writes a 0.
|
||||
// RCN-214 specifies that Throw is 0 and Close is 1.
|
||||
@ -439,7 +435,7 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
bool activate(bool close) override {
|
||||
bool setClosedInternal(bool close) override {
|
||||
IODevice::write(_vpinTurnoutData.vpin, close);
|
||||
_turnoutData.closed = close;
|
||||
return true;
|
||||
@ -490,7 +486,7 @@ public:
|
||||
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...
|
||||
LCN::send('T', _turnoutData.id, !close);
|
||||
// The _turnoutData.closed flag should be updated by a message from the LCN master, later.
|
||||
|
Loading…
Reference in New Issue
Block a user