mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2024-11-24 08:36:14 +01:00
Compare commits
3 Commits
306e071b70
...
31508b641d
Author | SHA1 | Date | |
---|---|---|---|
|
31508b641d | ||
|
b5d9798144 | ||
|
566ce1b7f8 |
|
@ -105,6 +105,7 @@ void CommandDistributor::parse(byte clientId,byte * buffer, RingStream * stream
|
||||||
void CommandDistributor::forget(byte clientId) {
|
void CommandDistributor::forget(byte clientId) {
|
||||||
if (clients[clientId]==WITHROTTLE_TYPE) WiThrottle::forget(clientId);
|
if (clients[clientId]==WITHROTTLE_TYPE) WiThrottle::forget(clientId);
|
||||||
clients[clientId]=NONE_TYPE;
|
clients[clientId]=NONE_TYPE;
|
||||||
|
if (virtualLCDClient==clientId) virtualLCDClient=RingStream::NO_CLIENT;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -285,3 +286,51 @@ void CommandDistributor::broadcastRouteState(uint16_t routeId, byte state ) {
|
||||||
void CommandDistributor::broadcastRouteCaption(uint16_t routeId, const FSH* caption ) {
|
void CommandDistributor::broadcastRouteCaption(uint16_t routeId, const FSH* caption ) {
|
||||||
broadcastReply(COMMAND_TYPE, F("<jB %d \"%S\">\n"),routeId,caption);
|
broadcastReply(COMMAND_TYPE, F("<jB %d \"%S\">\n"),routeId,caption);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
|
|
@ -60,8 +60,15 @@ public :
|
||||||
static void forget(byte clientId);
|
static void forget(byte clientId);
|
||||||
static void broadcastRouteState(uint16_t routeId,byte state);
|
static void broadcastRouteState(uint16_t routeId,byte state);
|
||||||
static void broadcastRouteCaption(uint16_t routeId,const FSH * caption);
|
static void broadcastRouteCaption(uint16_t routeId,const FSH * caption);
|
||||||
|
|
||||||
|
|
||||||
|
// 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
|
#endif
|
||||||
|
|
|
@ -659,7 +659,7 @@ void DCCEXParser::parseOne(Print *stream, byte *com, RingStream * ringStream)
|
||||||
return;
|
return;
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
case '=': // TACK MANAGER CONTROL <= [params]>
|
case '=': // TRACK MANAGER CONTROL <= [params]>
|
||||||
if (TrackManager::parseJ(stream, params, p))
|
if (TrackManager::parseJ(stream, params, p))
|
||||||
return;
|
return;
|
||||||
break;
|
break;
|
||||||
|
@ -832,6 +832,10 @@ void DCCEXParser::parseOne(Print *stream, byte *com, RingStream * ringStream)
|
||||||
case 'L': // LCC interface implemented in EXRAIL parser
|
case 'L': // LCC interface implemented in EXRAIL parser
|
||||||
break; // Will <X> if not intercepted by EXRAIL
|
break; // Will <X> if not intercepted by EXRAIL
|
||||||
|
|
||||||
|
case '@': // JMRI saying "give me virtual LCD msgs"
|
||||||
|
CommandDistributor::setVirtualLCDSerial(stream);
|
||||||
|
return;
|
||||||
|
|
||||||
default: //anything else will diagnose and drop out to <X>
|
default: //anything else will diagnose and drop out to <X>
|
||||||
DIAG(F("Opcode=%c params=%d"), opcode, params);
|
DIAG(F("Opcode=%c params=%d"), opcode, params);
|
||||||
for (int i = 0; i < params; i++)
|
for (int i = 0; i < params; i++)
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
#include "StringFormatter.h"
|
#include "StringFormatter.h"
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include "DisplayInterface.h"
|
#include "DisplayInterface.h"
|
||||||
|
#include "CommandDistributor.h"
|
||||||
|
|
||||||
bool Diag::ACK=false;
|
bool Diag::ACK=false;
|
||||||
bool Diag::CMD=false;
|
bool Diag::CMD=false;
|
||||||
|
@ -45,6 +46,14 @@ void StringFormatter::lcd(byte row, const FSH* input...) {
|
||||||
send2(&USB_SERIAL,input,args);
|
send2(&USB_SERIAL,input,args);
|
||||||
send(&USB_SERIAL,F(" *>\n"));
|
send(&USB_SERIAL,F(" *>\n"));
|
||||||
|
|
||||||
|
// send to virtual LCD collector (if any)
|
||||||
|
Print * virtualLCD=CommandDistributor::getVirtualLCDSerial(0,row);
|
||||||
|
if (virtualLCD) {
|
||||||
|
va_start(args, input);
|
||||||
|
send2(virtualLCD,input,args);
|
||||||
|
CommandDistributor::commitVirtualLCDSerial();
|
||||||
|
}
|
||||||
|
|
||||||
DisplayInterface::setRow(row);
|
DisplayInterface::setRow(row);
|
||||||
va_start(args, input);
|
va_start(args, input);
|
||||||
send2(DisplayInterface::getDisplayHandler(),input,args);
|
send2(DisplayInterface::getDisplayHandler(),input,args);
|
||||||
|
@ -52,6 +61,14 @@ void StringFormatter::lcd(byte row, const FSH* input...) {
|
||||||
|
|
||||||
void StringFormatter::lcd2(uint8_t display, byte row, const FSH* input...) {
|
void StringFormatter::lcd2(uint8_t display, byte row, const FSH* input...) {
|
||||||
va_list args;
|
va_list args;
|
||||||
|
|
||||||
|
// send to virtual LCD collector (if any)
|
||||||
|
Print * virtualLCD=CommandDistributor::getVirtualLCDSerial(display,row);
|
||||||
|
if (virtualLCD) {
|
||||||
|
va_start(args, input);
|
||||||
|
send2(virtualLCD,input,args);
|
||||||
|
CommandDistributor::commitVirtualLCDSerial();
|
||||||
|
}
|
||||||
|
|
||||||
DisplayInterface::setRow(display, row);
|
DisplayInterface::setRow(display, row);
|
||||||
va_start(args, input);
|
va_start(args, input);
|
||||||
|
|
|
@ -54,6 +54,5 @@ class StringFormatter
|
||||||
private:
|
private:
|
||||||
static void send2(Print * serial, const FSH* input,va_list args);
|
static void send2(Print * serial, const FSH* input,va_list args);
|
||||||
static void printPadded(Print* stream, long value, byte width, bool formatLeft);
|
static void printPadded(Print* stream, long value, byte width, bool formatLeft);
|
||||||
|
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue
Block a user