mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2024-11-23 08:06:13 +01:00
fixups
This commit is contained in:
parent
44351b83ae
commit
26cf28dff7
|
@ -273,7 +273,7 @@ void CommandDistributor::broadcastTrackState(const FSH* format,byte trackLetter,
|
|||
broadcastReply(COMMAND_TYPE, format,trackLetter, dcAddr);
|
||||
}
|
||||
|
||||
void CommandDistributor::broadcastRouteState(uint16_t routeId, RouteState state ) {
|
||||
void CommandDistributor::broadcastRouteState(uint16_t routeId, byte state ) {
|
||||
broadcastReply(COMMAND_TYPE, F("<jB %d %d>\n"),routeId,state);
|
||||
}
|
||||
|
||||
|
|
|
@ -37,7 +37,6 @@
|
|||
class CommandDistributor {
|
||||
public:
|
||||
enum clientType: byte {NONE_TYPE,COMMAND_TYPE,WITHROTTLE_TYPE};
|
||||
enum RouteState: byte {STATE_ACTIVE,STATE_INACTIVE,STATE_HIDDEN};
|
||||
private:
|
||||
static void broadcastToClients(clientType type);
|
||||
static StringBuffer * broadcastBufferWriter;
|
||||
|
@ -59,7 +58,7 @@ public :
|
|||
static void broadcastTrackState(const FSH* format,byte trackLetter, int16_t dcAddr);
|
||||
template<typename... Targs> static void broadcastReply(clientType type, Targs... msg);
|
||||
static void forget(byte clientId);
|
||||
static void broadcastRouteState(uint16_t routeId,RouteState state);
|
||||
static void broadcastRouteState(uint16_t routeId,byte state);
|
||||
static void broadcastRouteCaption(uint16_t routeId,const FSH * caption);
|
||||
|
||||
|
||||
|
|
28
EXRAIL2.cpp
28
EXRAIL2.cpp
|
@ -100,6 +100,7 @@ LookList * RMFT2::onClockLookup=NULL;
|
|||
LookList * RMFT2::onRotateLookup=NULL;
|
||||
#endif
|
||||
LookList * RMFT2::onOverloadLookup=NULL;
|
||||
byte * RMFT2::routeStateArray=nullptr;
|
||||
|
||||
#define GET_OPCODE GETHIGHFLASH(RMFT2::RouteCode,progCounter)
|
||||
#define SKIPOP progCounter+=3
|
||||
|
@ -139,6 +140,15 @@ int16_t LookList::find(int16_t value) {
|
|||
}
|
||||
return -1;
|
||||
}
|
||||
int16_t LookList::findPosition(int16_t value) {
|
||||
for (int16_t i=0;i<m_size;i++) {
|
||||
if (m_lookupArray[i]==value) return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
int16_t LookList::size() {
|
||||
return m_size;
|
||||
}
|
||||
|
||||
LookList* RMFT2::LookListLoader(OPCODE op1, OPCODE op2, OPCODE op3) {
|
||||
int progCounter;
|
||||
|
@ -172,6 +182,7 @@ LookList* RMFT2::LookListLoader(OPCODE op1, OPCODE op2, OPCODE op3) {
|
|||
|
||||
// create lookups
|
||||
sequenceLookup=LookListLoader(OPCODE_ROUTE, OPCODE_AUTOMATION,OPCODE_SEQUENCE);
|
||||
routeStateArray=(byte *)calloc(sequenceLookup->size(),sizeof(byte));
|
||||
onThrowLookup=LookListLoader(OPCODE_ONTHROW);
|
||||
onCloseLookup=LookListLoader(OPCODE_ONCLOSE);
|
||||
onActivateLookup=LookListLoader(OPCODE_ONACTIVATE);
|
||||
|
@ -1131,13 +1142,13 @@ void RMFT2::loop2() {
|
|||
printMessage(operand);
|
||||
break;
|
||||
case OPCODE_ROUTE_HIDDEN:
|
||||
CommandDistributor::broadcastRouteState(operand,CommandDistributor::RouteState::STATE_HIDDEN);
|
||||
manageRoute(operand,2);
|
||||
break;
|
||||
case OPCODE_ROUTE_ACTIVE:
|
||||
CommandDistributor::broadcastRouteState(operand,CommandDistributor::RouteState::STATE_ACTIVE);
|
||||
manageRoute(operand,0);
|
||||
break;
|
||||
case OPCODE_ROUTE_INACTIVE:
|
||||
CommandDistributor::broadcastRouteState(operand,CommandDistributor::RouteState::STATE_INACTIVE);
|
||||
manageRoute(operand,1);
|
||||
break;
|
||||
|
||||
case OPCODE_ROUTE:
|
||||
|
@ -1462,3 +1473,14 @@ void RMFT2::thrungeString(uint32_t strfar, thrunger mode, byte id) {
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void RMFT2::manageRoute(uint16_t id, byte state) {
|
||||
CommandDistributor::broadcastRouteState(id,state);
|
||||
// Route state must be maintained for when new throttles connect.
|
||||
// locate route id in the Routes lookup
|
||||
int16_t position=sequenceLookup->findPosition(id);
|
||||
if (position<0) return;
|
||||
// set state beside it
|
||||
routeStateArray[position]=state;
|
||||
}
|
||||
|
|
@ -121,7 +121,9 @@ class LookList {
|
|||
public:
|
||||
LookList(int16_t size);
|
||||
void add(int16_t lookup, int16_t result);
|
||||
int16_t find(int16_t value);
|
||||
int16_t find(int16_t value); // finds result value
|
||||
int16_t findPosition(int16_t value); // finds index
|
||||
int16_t size();
|
||||
private:
|
||||
int16_t m_size;
|
||||
int16_t m_loaded;
|
||||
|
@ -217,6 +219,8 @@ private:
|
|||
static const int countLCCLookup;
|
||||
static int onLCCLookup[];
|
||||
static const byte compileFeatures;
|
||||
static void manageRoute(uint16_t id, byte state);
|
||||
static byte * routeStateArray;
|
||||
|
||||
// Local variables - exist for each instance/task
|
||||
RMFT2 *next; // loop chain
|
||||
|
|
|
@ -126,8 +126,8 @@
|
|||
#undef ROTATE
|
||||
#undef ROTATE_DCC
|
||||
#undef ROUTE
|
||||
#undef ROUTE_ACTVE
|
||||
#undef ROUTE_INACTVE
|
||||
#undef ROUTE_ACTIVE
|
||||
#undef ROUTE_INACTIVE
|
||||
#undef ROUTE_HIDDEN
|
||||
#undef ROUTE_CAPTION
|
||||
#undef SENDLOCO
|
||||
|
|
Loading…
Reference in New Issue
Block a user