mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2024-11-24 08:36:14 +01:00
Compare commits
2 Commits
5f98d7b22f
...
ab3404a018
Author | SHA1 | Date | |
---|---|---|---|
|
ab3404a018 | ||
|
d690b09bb0 |
|
@ -272,3 +272,50 @@ void CommandDistributor::broadcastRaw(clientType type, char * msg) {
|
|||
void CommandDistributor::broadcastTrackState(const FSH* format,byte trackLetter, int16_t dcAddr) {
|
||||
broadcastReply(COMMAND_TYPE, format,trackLetter, dcAddr);
|
||||
}
|
||||
|
||||
Print * CommandDistributor::getVirtualLCDSerial(byte screen, byte row) {
|
||||
Print * stream=virtualLCDSerial;
|
||||
#ifdef CD_HANDLE_RING
|
||||
rememberVLCDClient=RingStream::NO_CLIENT;
|
||||
if (!stream && virtualLCDClient!=RingStream::NO_CLIENT) {
|
||||
// If we are broadcasting from a wifi/eth process we need to complete its output
|
||||
// before merging broadcasts in the ring, then reinstate it in case
|
||||
// the process continues to output to its client.
|
||||
if ((rememberVLCDClient = ring->peekTargetMark()) != RingStream::NO_CLIENT) {
|
||||
ring->commit();
|
||||
}
|
||||
ring->mark(virtualLCDClient);
|
||||
stream=ring;
|
||||
}
|
||||
#endif
|
||||
if (stream) StringFormatter::send(stream,F("<@ %d %d \""), screen,row);
|
||||
return stream;
|
||||
}
|
||||
|
||||
void CommandDistributor::commitVirtualLCDSerial() {
|
||||
#ifdef CD_HANDLE_RING
|
||||
if (virtualLCDClient!=RingStream::NO_CLIENT) {
|
||||
StringFormatter::send(ring,F("\">\n"));
|
||||
ring->commit();
|
||||
if (rememberVLCDClient!=RingStream::NO_CLIENT) ring->mark(rememberVLCDClient);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
StringFormatter::send(virtualLCDSerial,F("\">\n"));
|
||||
}
|
||||
|
||||
void CommandDistributor::setVirtualLCDSerial(Print * stream) {
|
||||
#ifdef CD_HANDLE_RING
|
||||
virtualLCDClient=RingStream::NO_CLIENT;
|
||||
if (stream && stream->availableForWrite()==RingStream::THIS_IS_A_RINGSTREAM) {
|
||||
virtualLCDClient=((RingStream *) stream)->peekTargetMark();
|
||||
virtualLCDSerial=nullptr;
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
virtualLCDSerial=stream;
|
||||
}
|
||||
|
||||
Print* CommandDistributor::virtualLCDSerial=nullptr;
|
||||
byte CommandDistributor::virtualLCDClient=0xFF;
|
||||
byte CommandDistributor::rememberVLCDClient=0;
|
|
@ -59,6 +59,14 @@ public :
|
|||
template<typename... Targs> static void broadcastReply(clientType type, Targs... msg);
|
||||
static void forget(byte clientId);
|
||||
|
||||
// Handling code for virtual LCD receiver.
|
||||
static Print * getVirtualLCDSerial(byte screen, byte row);
|
||||
static void commitVirtualLCDSerial();
|
||||
static void setVirtualLCDSerial(Print * stream);
|
||||
private:
|
||||
static Print * virtualLCDSerial;
|
||||
static byte virtualLCDClient;
|
||||
static byte rememberVLCDClient;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -913,6 +913,13 @@ void DCCEXParser::parseOne(Print *stream, byte *com, RingStream * ringStream)
|
|||
case 'L': // LCC interface implemented in EXRAIL parser
|
||||
break; // Will <X> if not intercepted by EXRAIL
|
||||
|
||||
case '@': // JMRI saying "give me virtual LCD msgs"
|
||||
CommandDistributor::setVirtualLCDSerial(stream);
|
||||
StringFormatter::send(stream,
|
||||
F("<@ 0 0 \"DCC-EX v" VERSION "\">\n"
|
||||
"<@ 0 1 \"Lic GPLv3\">\n"));
|
||||
return;
|
||||
|
||||
default: //anything else will diagnose and drop out to <X>
|
||||
DIAG(F("Opcode=%c params=%d"), opcode, params);
|
||||
for (int i = 0; i < params; i++)
|
||||
|
|
Loading…
Reference in New Issue
Block a user