1
0
mirror of https://github.com/DCC-EX/CommandStation-EX.git synced 2024-12-01 03:55:03 +01:00

Sensor Broadcast Exrail

Nonreal (eg id 200) Sensor broadcasting to wifi  via Exrail Latch/Unlatch
This commit is contained in:
84julian 2022-02-13 12:18:16 +01:00
parent bd9a04572d
commit cf0807d3c7
3 changed files with 24 additions and 0 deletions

View File

@ -49,6 +49,7 @@
#include "WiThrottle.h" #include "WiThrottle.h"
#include "DCCEXParser.h" #include "DCCEXParser.h"
#include "Turnouts.h" #include "Turnouts.h"
#include "Sensors.h" // Sensor feedback an rocrail senden
#include "CommandDistributor.h" #include "CommandDistributor.h"
@ -624,10 +625,12 @@ void RMFT2::loop2() {
case OPCODE_LATCH: case OPCODE_LATCH:
setFlag(operand,LATCH_FLAG); setFlag(operand,LATCH_FLAG);
Sensor::call(operand, 1); // sesor aktiv senden
break; break;
case OPCODE_UNLATCH: case OPCODE_UNLATCH:
setFlag(operand,0,LATCH_FLAG); setFlag(operand,0,LATCH_FLAG);
Sensor::call(operand, 0); // sensor inaktiv senden
break; break;
case OPCODE_SET: case OPCODE_SET:

View File

@ -189,6 +189,26 @@ void Sensor::printAll(Print *stream){
} // loop over all sensors } // loop over all sensors
} // Sensor::printAll } // Sensor::printAll
///////////////////////////////////////////////////////////////////////////////
//
// Static Function to call Sensor object.
//
///////////////////////////////////////////////////////////////////////////////
Sensor *Sensor::call(int snum, int pullUp){
Sensor *tt;
if (pullUp == 0)
CommandDistributor::broadcastSensor(readingSensor->data.snum=snum,readingSensor->active);
else
CommandDistributor::broadcastSensor(readingSensor->data.snum=snum,readingSensor->latchDelay = minReadCount );
// minReadCount could be better defind to always inactive??
return tt ;
}
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// Static Function to create/find Sensor object. // Static Function to create/find Sensor object.

View File

@ -76,6 +76,7 @@ public:
static void store(); static void store();
#endif #endif
static Sensor *create(int id, VPIN vpin, int pullUp); static Sensor *create(int id, VPIN vpin, int pullUp);
static Sensor *call(int id, int pullUp); // broadcast sensor to rocrail
static Sensor* get(int id); static Sensor* get(int id);
static bool remove(int id); static bool remove(int id);
static void checkAll(); static void checkAll();