1
0
mirror of https://github.com/DCC-EX/CommandStation-EX.git synced 2024-11-22 23:56:13 +01:00

format/indentation change only

This commit is contained in:
Harald Barth 2022-01-06 23:03:57 +01:00
parent 1934fdd0e1
commit b0915e8332
8 changed files with 1252 additions and 1256 deletions

View File

@ -42,8 +42,7 @@ void CommandDistributor::parse(byte clientId,byte * buffer, RingStream * stream
if (buffer[0] == '<') {
clients[clientId]=COMMAND_TYPE;
DCCEXParser::parse(stream, buffer, ring);
}
else {
} else {
clients[clientId]=WITHROTTLE_TYPE;
WiThrottle::getThrottle(clientId)->parse(ring, buffer);
}
@ -81,19 +80,19 @@ void CommandDistributor::broadcast(bool includeWithrottleClients) {
broadcastBufferWriter->flush();
}
#else
// For a UNO/NANO we can broadcast direct to just one Serial instead of the ring
// Redirect ring output ditrect to Serial
#define broadcastBufferWriter &Serial
// and ignore the internal broadcast call.
void CommandDistributor::broadcast(bool includeWithrottleClients) {
// For a UNO/NANO we can broadcast direct to just one Serial instead of the ring
// Redirect ring output ditrect to Serial
#define broadcastBufferWriter &Serial
// and ignore the internal broadcast call.
void CommandDistributor::broadcast(bool includeWithrottleClients) {
(void)includeWithrottleClients;
}
}
#endif
void CommandDistributor::broadcastSensor(int16_t id, bool on ) {
StringFormatter::send(broadcastBufferWriter,F("<%c %d>\n"), on?'Q':'q', id);
broadcast(false);
}
}
void CommandDistributor::broadcastTurnout(int16_t id, bool isClosed ) {
// For DCC++ classic compatibility, state reported to JMRI is 1 for thrown and 0 for closed;
@ -104,9 +103,9 @@ void CommandDistributor::broadcastTurnout(int16_t id, bool isClosed ) {
StringFormatter::send(broadcastBufferWriter,F("PTA%c%d\n"), isClosed?'2':'4', id);
#endif
broadcast(true);
}
}
void CommandDistributor::broadcastLoco(byte slot) {
void CommandDistributor::broadcastLoco(byte slot) {
DCC::LOCO * sp=&DCC::speedTable[slot];
StringFormatter::send(broadcastBufferWriter,F("<l %d %d %d %l>\n"),
sp->loco,slot,sp->speedCode,sp->functions);
@ -133,5 +132,3 @@ void CommandDistributor::broadcastPower() {
LCD(2,F("Power %S%S"),state=='1'?F("On"):F("Off"),reason);
broadcast(true);
}

View File

@ -121,7 +121,7 @@ void loop()
// Responsibility 2: handle any incoming commands on USB connection
SerialManager::loop();
// Responsibility 3: Optionally handle any incoming WiFi traffic
// Responsibility 3: Optionally handle any incoming WiFi traffic
#if WIFI_ON
WifiInterface::loop();
#endif
@ -146,8 +146,7 @@ void loop()
static int ramLowWatermark = __INT_MAX__; // replaced on first loop
int freeNow = minimumFreeMemory();
if (freeNow < ramLowWatermark)
{
if (freeNow < ramLowWatermark) {
ramLowWatermark = freeNow;
LCD(3,F("Free RAM=%5db"), ramLowWatermark);
}

View File

@ -87,28 +87,28 @@ LookList * RMFT2::onDeactivateLookup=NULL;
#define SKIPOP progCounter+=3
LookList::LookList(int16_t size) {
LookList::LookList(int16_t size) {
m_size=size;
m_loaded=0;
if (size) {
m_lookupArray=new int16_t[size];
m_resultArray=new int16_t[size];
}
}
}
void LookList::add(int16_t lookup, int16_t result) {
void LookList::add(int16_t lookup, int16_t result) {
if (m_loaded==m_size) return; // and forget
m_lookupArray[m_loaded]=lookup;
m_resultArray[m_loaded]=result;
m_loaded++;
}
}
int16_t LookList::find(int16_t value) {
int16_t LookList::find(int16_t value) {
for (int16_t i=0;i<m_size;i++) {
if (m_lookupArray[i]==value) return m_resultArray[i];
}
return -1;
}
}
/* static */ void RMFT2::begin() {
DCCEXParser::setRMFTFilter(RMFT2::ComandFilter);
@ -392,7 +392,7 @@ bool RMFT2::parseSlash(Print * stream, byte & paramCount, int16_t p[]) {
default:
return false;
}
}
}
// This emits Routes and Automations to Withrottle
@ -431,8 +431,7 @@ RMFT2::RMFT2(int progCtr) {
if (loopTask==NULL) {
loopTask=this;
next=this;
}
else {
} else {
next=loopTask->next;
loopTask->next=this;
}
@ -442,8 +441,11 @@ RMFT2::RMFT2(int progCtr) {
RMFT2::~RMFT2() {
driveLoco(1); // ESTOP my loco if any
setFlag(taskId,0,TASK_FLAG); // we are no longer using this id
if (next==this) loopTask=NULL;
else for (RMFT2* ring=next;;ring=ring->next) if (ring->next == this) {
if (next==this)
loopTask=NULL;
else
for (RMFT2* ring=next;;ring=ring->next)
if (ring->next == this) {
ring->next=next;
loopTask=next;
break;
@ -928,7 +930,7 @@ void RMFT2::kill(const FSH * reason, int operand) {
}
}
void RMFT2::turnoutEvent(int16_t turnoutId, bool closed) {
void RMFT2::turnoutEvent(int16_t turnoutId, bool closed) {
// Hunt for an ONTHROW/ONCLOSE for this turnout
int pc= (closed?onCloseLookup:onThrowLookup)->find(turnoutId);
if (pc<0) return;
@ -946,9 +948,9 @@ void RMFT2::kill(const FSH * reason, int operand) {
task=new RMFT2(pc); // new task starts at this instruction
task->onTurnoutId=turnoutId; // flag for recursion detector
}
}
void RMFT2::activateEvent(int16_t addr, bool activate) {
void RMFT2::activateEvent(int16_t addr, bool activate) {
// Hunt for an ONACTIVATE/ONDEACTIVATE for this accessory
int pc= (activate?onActivateLookup:onDeactivateLookup)->find(addr);
if (pc<0) return;
@ -966,15 +968,14 @@ void RMFT2::kill(const FSH * reason, int operand) {
task->onActivateAddr=addr; // flag for recursion detector
task=new RMFT2(pc); // new task starts at this instruction
}
}
void RMFT2::printMessage2(const FSH * msg) {
void RMFT2::printMessage2(const FSH * msg) {
DIAG(F("EXRAIL(%d) %S"),loco,msg);
}
}
// This is called by emitRouteDescriptions to emit a withrottle description for a route or autoomation.
void RMFT2::emitRouteDescription(Print * stream, char type, int id, const FSH * description) {
StringFormatter::send(stream,F("]\\[%c%d}|{%S}|{%c"),
type,id,description, type=='R'?'2':'4');
}

View File

@ -117,11 +117,11 @@ void WiThrottle::parse(RingStream * stream, byte * cmdx) {
for(Turnout *tt=Turnout::first();tt!=NULL;tt=tt->next()){
int id=tt->getId();
StringFormatter::send(stream,F("]\\[%d}|{"), id);
#ifdef RMFT_ACTIVE
#ifdef RMFT_ACTIVE
RMFT2::emitTurnoutDescription(stream,id);
#else
#else
StringFormatter::send(stream,F("%d"), id);
#endif
#endif
StringFormatter::send(stream,F("}|{%c"), Turnout::isClosed(id)?'2':'4');
}
StringFormatter::send(stream,F("\n"));
@ -137,8 +137,6 @@ void WiThrottle::parse(RingStream * stream, byte * cmdx) {
// allow heartbeat to slow down once all metadata sent
StringFormatter::send(stream,F("*%d\n"),HEARTBEAT_SECONDS);
}
}
while (cmd[0]) {
@ -226,6 +224,7 @@ void WiThrottle::parse(RingStream * stream, byte * cmdx) {
if (*cmd!='\0') cmd++; // skip \r or \n
}
}
int WiThrottle::getInt(byte * cmd) {
int i=0;
while (cmd[0]>='0' && cmd[0]<='9') {
@ -248,7 +247,7 @@ void WiThrottle::multithrottle(RingStream * stream, byte * cmd){
while(*aval !=';' && *aval !='\0') aval++;
if (*aval) aval+=2; // skip ;>
// DIAG(F("Multithrottle aval=%c cab=%d"), aval[0],locoid);
// DIAG(F("Multithrottle aval=%c cab=%d"), aval[0],locoid);
switch(cmd[2]) {
case '+': // add loco request
if (cmd[3]=='*') {
@ -351,7 +350,7 @@ void WiThrottle::multithrottle(RingStream * stream, byte * cmd){
void WiThrottle::locoAction(RingStream * stream, byte* aval, char throttleChar, int cab){
// Note cab=-1 for all cabs in the consist called throttleChar.
// DIAG(F("Loco Action aval=%c%c throttleChar=%c, cab=%d"), aval[0],aval[1],throttleChar, cab);
// DIAG(F("Loco Action aval=%c%c throttleChar=%c, cab=%d"), aval[0],aval[1],throttleChar, cab);
(void) stream;
switch (aval[0]) {
case 'V': // Vspeed
@ -411,14 +410,14 @@ void WiThrottle::locoAction(RingStream * stream, byte* aval, char throttleChar,
}
}
// convert between DCC++ speed values and WiThrottle speed values
// convert between DCC++ speed values and WiThrottle speed values
int WiThrottle::DCCToWiTSpeed(int DCCSpeed) {
if (DCCSpeed == 0) return 0; //stop is stop
if (DCCSpeed == 1) return -1; //eStop value
return DCCSpeed - 1; //offset others by 1
}
// convert between WiThrottle speed values and DCC++ speed values
// convert between WiThrottle speed values and DCC++ speed values
int WiThrottle::WiTToDCCSpeed(int WiTSpeed) {
if (WiTSpeed == 0) return 0; //stop is stop
if (WiTSpeed == -1) return 1; //eStop value