mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2024-11-23 08:06:13 +01:00
WAITFORTT ready for testing
This commit is contained in:
parent
004d7b6631
commit
bd02d1c15b
20
EXRAIL2.cpp
20
EXRAIL2.cpp
|
@ -95,7 +95,9 @@ LookList * RMFT2::onAmberLookup=NULL;
|
||||||
LookList * RMFT2::onGreenLookup=NULL;
|
LookList * RMFT2::onGreenLookup=NULL;
|
||||||
LookList * RMFT2::onChangeLookup=NULL;
|
LookList * RMFT2::onChangeLookup=NULL;
|
||||||
LookList * RMFT2::onClockLookup=NULL;
|
LookList * RMFT2::onClockLookup=NULL;
|
||||||
|
#ifndef IO_NO_HAL
|
||||||
LookList * RMFT2::onRotateLookup=NULL;
|
LookList * RMFT2::onRotateLookup=NULL;
|
||||||
|
#endif
|
||||||
|
|
||||||
#define GET_OPCODE GETHIGHFLASH(RMFT2::RouteCode,progCounter)
|
#define GET_OPCODE GETHIGHFLASH(RMFT2::RouteCode,progCounter)
|
||||||
#define SKIPOP progCounter+=3
|
#define SKIPOP progCounter+=3
|
||||||
|
@ -177,8 +179,9 @@ LookList* RMFT2::LookListLoader(OPCODE op1, OPCODE op2, OPCODE op3) {
|
||||||
onGreenLookup=LookListLoader(OPCODE_ONGREEN);
|
onGreenLookup=LookListLoader(OPCODE_ONGREEN);
|
||||||
onChangeLookup=LookListLoader(OPCODE_ONCHANGE);
|
onChangeLookup=LookListLoader(OPCODE_ONCHANGE);
|
||||||
onClockLookup=LookListLoader(OPCODE_ONTIME);
|
onClockLookup=LookListLoader(OPCODE_ONTIME);
|
||||||
|
#ifndef IO_NO_HAL
|
||||||
onRotateLookup=LookListLoader(OPCODE_ONROTATE);
|
onRotateLookup=LookListLoader(OPCODE_ONROTATE);
|
||||||
|
#endif
|
||||||
|
|
||||||
// Second pass startup, define any turnouts or servos, set signals red
|
// Second pass startup, define any turnouts or servos, set signals red
|
||||||
// add sequences onRoutines to the lookups
|
// add sequences onRoutines to the lookups
|
||||||
|
@ -1014,7 +1017,16 @@ void RMFT2::loop2() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
#ifndef IO_NO_HAL
|
||||||
|
case OPCODE_WAITFORTT: // OPCODE_WAITFOR,V(turntable_id)
|
||||||
|
if (Turntable::ttMoving(operand)) {
|
||||||
|
delayMe(100);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
|
||||||
case OPCODE_PRINT:
|
case OPCODE_PRINT:
|
||||||
printMessage(operand);
|
printMessage(operand);
|
||||||
break;
|
break;
|
||||||
|
@ -1039,10 +1051,12 @@ void RMFT2::loop2() {
|
||||||
case OPCODE_ONGREEN:
|
case OPCODE_ONGREEN:
|
||||||
case OPCODE_ONCHANGE:
|
case OPCODE_ONCHANGE:
|
||||||
case OPCODE_ONTIME:
|
case OPCODE_ONTIME:
|
||||||
|
#ifndef IO_NO_HAL
|
||||||
case OPCODE_DCCTURNTABLE: // Turntable definition ignored at runtime
|
case OPCODE_DCCTURNTABLE: // Turntable definition ignored at runtime
|
||||||
case OPCODE_EXTTTURNTABLE: // Turntable definition ignored at runtime
|
case OPCODE_EXTTTURNTABLE: // Turntable definition ignored at runtime
|
||||||
case OPCODE_TTADDPOSITION: // Turntable position definition ignored at runtime
|
case OPCODE_TTADDPOSITION: // Turntable position definition ignored at runtime
|
||||||
case OPCODE_ONROTATE:
|
case OPCODE_ONROTATE:
|
||||||
|
#endif
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -1187,10 +1201,12 @@ void RMFT2::changeEvent(int16_t vpin, bool change) {
|
||||||
if (change) handleEvent(F("CHANGE"),onChangeLookup,vpin);
|
if (change) handleEvent(F("CHANGE"),onChangeLookup,vpin);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef IO_NO_HAL
|
||||||
void RMFT2::rotateEvent(int16_t turntableId, bool change) {
|
void RMFT2::rotateEvent(int16_t turntableId, bool change) {
|
||||||
// Hunt or an ONROTATE for this turntable
|
// Hunt or an ONROTATE for this turntable
|
||||||
if (change) handleEvent(F("ROTATE"),onRotateLookup,turntableId);
|
if (change) handleEvent(F("ROTATE"),onRotateLookup,turntableId);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void RMFT2::clockEvent(int16_t clocktime, bool change) {
|
void RMFT2::clockEvent(int16_t clocktime, bool change) {
|
||||||
// Hunt for an ONTIME for this time
|
// Hunt for an ONTIME for this time
|
||||||
|
|
|
@ -63,8 +63,10 @@ enum OPCODE : byte {OPCODE_THROW,OPCODE_CLOSE,
|
||||||
OPCODE_ONCHANGE,
|
OPCODE_ONCHANGE,
|
||||||
OPCODE_ONCLOCKTIME,
|
OPCODE_ONCLOCKTIME,
|
||||||
OPCODE_ONTIME,
|
OPCODE_ONTIME,
|
||||||
|
#ifndef IO_NO_HAL
|
||||||
OPCODE_TTADDPOSITION,OPCODE_DCCTURNTABLE,OPCODE_EXTTTURNTABLE,
|
OPCODE_TTADDPOSITION,OPCODE_DCCTURNTABLE,OPCODE_EXTTTURNTABLE,
|
||||||
OPCODE_ONROTATE,OPCODE_ROTATE,OPCODE_IFTTPOSITION,
|
OPCODE_ONROTATE,OPCODE_ROTATE,OPCODE_IFTTPOSITION,OPCODE_WAITFORTT,
|
||||||
|
#endif
|
||||||
|
|
||||||
// OPcodes below this point are skip-nesting IF operations
|
// OPcodes below this point are skip-nesting IF operations
|
||||||
// placed here so that they may be skipped as a group
|
// placed here so that they may be skipped as a group
|
||||||
|
@ -197,7 +199,9 @@ private:
|
||||||
static LookList * onGreenLookup;
|
static LookList * onGreenLookup;
|
||||||
static LookList * onChangeLookup;
|
static LookList * onChangeLookup;
|
||||||
static LookList * onClockLookup;
|
static LookList * onClockLookup;
|
||||||
|
#ifndef IO_NO_HAL
|
||||||
static LookList * onRotateLookup;
|
static LookList * onRotateLookup;
|
||||||
|
#endif
|
||||||
|
|
||||||
// Local variables - exist for each instance/task
|
// Local variables - exist for each instance/task
|
||||||
RMFT2 *next; // loop chain
|
RMFT2 *next; // loop chain
|
||||||
|
|
|
@ -150,6 +150,9 @@
|
||||||
#undef VIRTUAL_SIGNAL
|
#undef VIRTUAL_SIGNAL
|
||||||
#undef VIRTUAL_TURNOUT
|
#undef VIRTUAL_TURNOUT
|
||||||
#undef WAITFOR
|
#undef WAITFOR
|
||||||
|
#ifndef IO_NO_HAL
|
||||||
|
#undef WAITFORTT
|
||||||
|
#endif
|
||||||
#undef WITHROTTLE
|
#undef WITHROTTLE
|
||||||
#undef XFOFF
|
#undef XFOFF
|
||||||
#undef XFON
|
#undef XFON
|
||||||
|
@ -281,6 +284,9 @@
|
||||||
#define VIRTUAL_SIGNAL(id)
|
#define VIRTUAL_SIGNAL(id)
|
||||||
#define VIRTUAL_TURNOUT(id,description...)
|
#define VIRTUAL_TURNOUT(id,description...)
|
||||||
#define WAITFOR(pin)
|
#define WAITFOR(pin)
|
||||||
|
#ifndef IO_NO_HAL
|
||||||
|
#define WAITFORTT(turntable_id)
|
||||||
|
#endif
|
||||||
#define WITHROTTLE(msg)
|
#define WITHROTTLE(msg)
|
||||||
#define XFOFF(cab,func)
|
#define XFOFF(cab,func)
|
||||||
#define XFON(cab,func)
|
#define XFON(cab,func)
|
||||||
|
|
|
@ -419,6 +419,9 @@ const HIGHFLASH int16_t RMFT2::SignalDefinitions[] = {
|
||||||
#define VIRTUAL_TURNOUT(id,description...) OPCODE_PINTURNOUT,V(id),OPCODE_PAD,V(0),
|
#define VIRTUAL_TURNOUT(id,description...) OPCODE_PINTURNOUT,V(id),OPCODE_PAD,V(0),
|
||||||
#define WITHROTTLE(msg) PRINT(msg)
|
#define WITHROTTLE(msg) PRINT(msg)
|
||||||
#define WAITFOR(pin) OPCODE_WAITFOR,V(pin),
|
#define WAITFOR(pin) OPCODE_WAITFOR,V(pin),
|
||||||
|
#ifndef IO_NO_HAL
|
||||||
|
#define WAITFORTT(turntable_id) OPCODE_WAITFORTT,V(turntable_id),
|
||||||
|
#endif
|
||||||
#define XFOFF(cab,func) OPCODE_XFOFF,V(cab),OPCODE_PAD,V(func),
|
#define XFOFF(cab,func) OPCODE_XFOFF,V(cab),OPCODE_PAD,V(func),
|
||||||
#define XFON(cab,func) OPCODE_XFON,V(cab),OPCODE_PAD,V(func),
|
#define XFON(cab,func) OPCODE_XFON,V(cab),OPCODE_PAD,V(func),
|
||||||
|
|
||||||
|
|
|
@ -115,6 +115,12 @@ uint8_t Turntable::getPosition(uint16_t id) {
|
||||||
return tto->getPosition();
|
return tto->getPosition();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Turntable::ttMoving(uint16_t id) {
|
||||||
|
Turntable *tto = get(id);
|
||||||
|
if (!tto) return false;
|
||||||
|
return tto->isMoving();
|
||||||
|
}
|
||||||
|
|
||||||
// Initiate a turntable move
|
// Initiate a turntable move
|
||||||
bool Turntable::setPosition(uint16_t id, uint8_t position, uint8_t activity) {
|
bool Turntable::setPosition(uint16_t id, uint8_t position, uint8_t activity) {
|
||||||
#if defined(DIAG_IO)
|
#if defined(DIAG_IO)
|
||||||
|
|
|
@ -179,6 +179,7 @@ public:
|
||||||
inline static bool exists(uint16_t id) { return get(id) != 0; }
|
inline static bool exists(uint16_t id) { return get(id) != 0; }
|
||||||
static bool setPosition(uint16_t id, uint8_t position, uint8_t activity=0);
|
static bool setPosition(uint16_t id, uint8_t position, uint8_t activity=0);
|
||||||
static uint8_t getPosition(uint16_t id);
|
static uint8_t getPosition(uint16_t id);
|
||||||
|
static bool ttMoving(uint16_t id);
|
||||||
inline static Turntable *first() { return _firstTurntable; }
|
inline static Turntable *first() { return _firstTurntable; }
|
||||||
static bool printAll(Print *stream) {
|
static bool printAll(Print *stream) {
|
||||||
bool gotOne = false;
|
bool gotOne = false;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user