mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2024-11-22 23:56:13 +01:00
BLOCKENTER 1
This commit is contained in:
parent
cda27f0420
commit
0188fc6b22
2
DCC.h
2
DCC.h
|
@ -122,7 +122,7 @@ public:
|
|||
private:
|
||||
static byte loopStatus;
|
||||
static byte defaultMomentumA; // Accelerating
|
||||
static byte defaultMomentumD; // Accelerating
|
||||
static byte defaultMomentumD; // Decelerating
|
||||
static void setThrottle2(uint16_t cab, uint8_t speedCode);
|
||||
static void setFunctionInternal(int cab, byte fByte, byte eByte, byte count);
|
||||
static bool issueReminder(LOCO * slot);
|
||||
|
|
18
EXRAIL2.cpp
18
EXRAIL2.cpp
|
@ -86,6 +86,8 @@ LookList * RMFT2::onClockLookup=NULL;
|
|||
LookList * RMFT2::onRotateLookup=NULL;
|
||||
#endif
|
||||
LookList * RMFT2::onOverloadLookup=NULL;
|
||||
LookList * RMFT2::onBlockEnterLookup=NULL;
|
||||
LookList * RMFT2::onBlockExitLookup=NULL;
|
||||
byte * RMFT2::routeStateArray=nullptr;
|
||||
const FSH * * RMFT2::routeCaptionArray=nullptr;
|
||||
int16_t * RMFT2::stashArray=nullptr;
|
||||
|
@ -130,11 +132,11 @@ int16_t LookList::find(int16_t value) {
|
|||
void LookList::chain(LookList * chain) {
|
||||
m_chain=chain;
|
||||
}
|
||||
void LookList::handleEvent(const FSH* reason,int16_t id) {
|
||||
void LookList::handleEvent(const FSH* reason,int16_t id, int16_t loco) {
|
||||
// New feature... create multiple ONhandlers
|
||||
for (int i=0;i<m_size;i++)
|
||||
if (m_lookupArray[i]==id)
|
||||
RMFT2::startNonRecursiveTask(reason,id,m_resultArray[i]);
|
||||
RMFT2::startNonRecursiveTask(reason,id,m_resultArray[i],loco);
|
||||
}
|
||||
|
||||
|
||||
|
@ -202,6 +204,8 @@ LookList* RMFT2::LookListLoader(OPCODE op1, OPCODE op2, OPCODE op3) {
|
|||
onRotateLookup=LookListLoader(OPCODE_ONROTATE);
|
||||
#endif
|
||||
onOverloadLookup=LookListLoader(OPCODE_ONOVERLOAD);
|
||||
onBlockEnterLookup=LookListLoader(OPCODE_ONBLOCKENTER);
|
||||
onBlockExitLookup=LookListLoader(OPCODE_ONBLOCKEXIT);
|
||||
// onLCCLookup is not the same so not loaded here.
|
||||
|
||||
// Second pass startup, define any turnouts or servos, set signals red
|
||||
|
@ -1281,6 +1285,12 @@ void RMFT2::activateEvent(int16_t addr, bool activate) {
|
|||
else onDeactivateLookup->handleEvent(F("DEACTIVATE"),addr);
|
||||
}
|
||||
|
||||
void RMFT2::blockEvent(int16_t block, int16_t loco, bool entering) {
|
||||
// Hunt for an ONBLOCKENTER/ONBLOCKEXIT for this accessory
|
||||
if (entering) onBlockEnterLookup->handleEvent(F("BLOCKENTER"),block,loco);
|
||||
else onBlockExitLookup->handleEvent(F("BLOCKEXIT"),block,loco);
|
||||
}
|
||||
|
||||
void RMFT2::changeEvent(int16_t vpin, bool change) {
|
||||
// Hunt for an ONCHANGE for this sensor
|
||||
if (change) onChangeLookup->handleEvent(F("CHANGE"),vpin);
|
||||
|
@ -1331,7 +1341,7 @@ void RMFT2::killBlinkOnVpin(VPIN pin) {
|
|||
}
|
||||
}
|
||||
|
||||
void RMFT2::startNonRecursiveTask(const FSH* reason, int16_t id,int pc) {
|
||||
void RMFT2::startNonRecursiveTask(const FSH* reason, int16_t id,int pc, int16_t loco) {
|
||||
// Check we dont already have a task running this handler
|
||||
RMFT2 * task=loopTask;
|
||||
while(task) {
|
||||
|
@ -1343,7 +1353,7 @@ void RMFT2::startNonRecursiveTask(const FSH* reason, int16_t id,int pc) {
|
|||
if (task==loopTask) break;
|
||||
}
|
||||
|
||||
task=new RMFT2(pc); // new task starts at this instruction
|
||||
task=new RMFT2(pc,loco); // new task starts at this instruction
|
||||
task->onEventStartPosition=pc; // flag for recursion detector
|
||||
}
|
||||
|
||||
|
|
10
EXRAIL2.h
10
EXRAIL2.h
|
@ -77,6 +77,7 @@ enum OPCODE : byte {OPCODE_THROW,OPCODE_CLOSE,OPCODE_TOGGLE_TURNOUT,
|
|||
OPCODE_ROUTE_DISABLED,
|
||||
OPCODE_STASH,OPCODE_CLEAR_STASH,OPCODE_CLEAR_ALL_STASH,OPCODE_PICKUP_STASH,
|
||||
OPCODE_ONBUTTON,OPCODE_ONSENSOR,
|
||||
OPCODE_ONBLOCKENTER,OPCODE_ONBLOCKEXIT,
|
||||
// OPcodes below this point are skip-nesting IF operations
|
||||
// placed here so that they may be skipped as a group
|
||||
// see skipIfBlock()
|
||||
|
@ -119,6 +120,7 @@ enum BlinkState: byte {
|
|||
static const byte FEATURE_STASH = 0x08;
|
||||
static const byte FEATURE_BLINK = 0x04;
|
||||
static const byte FEATURE_SENSOR = 0x02;
|
||||
static const byte FEATURE_BLOCK = 0x01;
|
||||
|
||||
|
||||
// Flag bits for status of hardware and TPL
|
||||
|
@ -145,7 +147,7 @@ class LookList {
|
|||
int16_t findPosition(int16_t value); // finds index
|
||||
int16_t size();
|
||||
void stream(Print * _stream);
|
||||
void handleEvent(const FSH* reason,int16_t id);
|
||||
void handleEvent(const FSH* reason,int16_t id, int16_t loco=0);
|
||||
|
||||
private:
|
||||
int16_t m_size;
|
||||
|
@ -170,6 +172,7 @@ class LookList {
|
|||
static void clockEvent(int16_t clocktime, bool change);
|
||||
static void rotateEvent(int16_t id, bool change);
|
||||
static void powerEvent(int16_t track, bool overload);
|
||||
static void blockEvent(int16_t block, int16_t loco, bool entering);
|
||||
static bool signalAspectEvent(int16_t address, byte aspect );
|
||||
static const int16_t SERVO_SIGNAL_FLAG=0x4000;
|
||||
static const int16_t ACTIVE_HIGH_SIGNAL_FLAG=0x2000;
|
||||
|
@ -188,7 +191,7 @@ class LookList {
|
|||
static const FSH * getRosterFunctions(int16_t id);
|
||||
static const FSH * getTurntableDescription(int16_t id);
|
||||
static const FSH * getTurntablePositionDescription(int16_t turntableId, uint8_t positionId);
|
||||
static void startNonRecursiveTask(const FSH* reason, int16_t id,int pc);
|
||||
static void startNonRecursiveTask(const FSH* reason, int16_t id,int pc, int16_t loco=0);
|
||||
static bool readSensor(uint16_t sensorId);
|
||||
static bool isSignal(int16_t id,char rag);
|
||||
|
||||
|
@ -241,6 +244,9 @@ private:
|
|||
static LookList * onRotateLookup;
|
||||
#endif
|
||||
static LookList * onOverloadLookup;
|
||||
static LookList * onBlockEnterLookup;
|
||||
static LookList * onBlockExitLookup;
|
||||
|
||||
|
||||
static const int countLCCLookup;
|
||||
static int onLCCLookup[];
|
||||
|
|
Loading…
Reference in New Issue
Block a user