1
0
mirror of https://github.com/DCC-EX/CommandStation-EX.git synced 2024-11-24 08:36:14 +01:00

Compare commits

..

No commits in common. "a16214790ee5cc003204c80864a6e6afe43711b2" and "ef47257d67afc8b66f33b0cbbaea10e4cdddb6e7" have entirely different histories.

5 changed files with 19 additions and 61 deletions

View File

@ -254,56 +254,21 @@ void CommandDistributor::broadcastPower() {
if (TrackManager::getPower(t, pstr)) if (TrackManager::getPower(t, pstr))
broadcastReply(COMMAND_TYPE, F("<p%s>\n"),pstr); broadcastReply(COMMAND_TYPE, F("<p%s>\n"),pstr);
byte trackcount=0;
byte oncount=0;
byte offcount=0;
for(byte t=0; t<TrackManager::MAX_TRACKS; t++) {
if (TrackManager::isActive(t)) {
trackcount++;
// do not call getPower(t) unless isActive(t)!
if (TrackManager::getPower(t) == POWERMODE::ON)
oncount++;
else
offcount++;
}
}
//DIAG(F("t=%d on=%d off=%d"), trackcount, oncount, offcount);
char state='2';
if (oncount==0 || offcount == trackcount)
state = '0';
else if (oncount == trackcount) {
state = '1';
}
// additional info about MAIN, PROG and JOIN
bool main=TrackManager::getMainPower()==POWERMODE::ON; bool main=TrackManager::getMainPower()==POWERMODE::ON;
bool prog=TrackManager::getProgPower()==POWERMODE::ON; bool prog=TrackManager::getProgPower()==POWERMODE::ON;
bool join=TrackManager::isJoined(); bool join=TrackManager::isJoined();
//DIAG(F("m=%d p=%d j=%d"), main, prog, join);
const FSH * reason=F(""); const FSH * reason=F("");
if (join) { char state='1';
reason = F("JOIN"); if (main && prog && join) reason=F(" JOIN");
broadcastReply(COMMAND_TYPE, F("<p1 %S>\n"),reason); else if (main && prog);
} else { else if (main) reason=F(" MAIN");
if (main) { else if (prog) reason=F(" PROG");
//reason = F("MAIN"); else state='0';
broadcastReply(COMMAND_TYPE, F("<p1 MAIN>\n")); broadcastReply(COMMAND_TYPE, F("<p%c%S>\n"),state,reason);
}
if (prog) {
//reason = F("PROG");
broadcastReply(COMMAND_TYPE, F("<p1 PROG>\n"));
}
}
if (state != '2')
broadcastReply(COMMAND_TYPE, F("<p%c>\n"),state);
#ifdef CD_HANDLE_RING #ifdef CD_HANDLE_RING
// send '1' if all main are on, otherwise global state (which in that case is '0' or '2') broadcastReply(WITHROTTLE_TYPE, F("PPA%c\n"), main?'1':'0');
broadcastReply(WITHROTTLE_TYPE, F("PPA%c\n"), main?'1': state);
#endif #endif
LCD(2,F("Power %S%S"),state=='1'?F("On"):F("Off"),reason);
LCD(2,F("Power %S %S"),state=='1'?F("On"): ( state=='0'? F("Off") : F("SC") ),reason);
} }
void CommandDistributor::broadcastRaw(clientType type, char * msg) { void CommandDistributor::broadcastRaw(clientType type, char * msg) {

View File

@ -1 +1 @@
#define GITHUB_SHA "devel-202311230948Z" #define GITHUB_SHA "devel-202311220953Z"

View File

@ -54,6 +54,7 @@ const int16_t HASH_KEYWORD_INV = 11857;
MotorDriver * TrackManager::track[MAX_TRACKS]; MotorDriver * TrackManager::track[MAX_TRACKS];
int16_t TrackManager::trackDCAddr[MAX_TRACKS]; int16_t TrackManager::trackDCAddr[MAX_TRACKS];
POWERMODE TrackManager::mainPowerGuess=POWERMODE::OFF;
byte TrackManager::lastTrack=0; byte TrackManager::lastTrack=0;
bool TrackManager::progTrackSyncMain=false; bool TrackManager::progTrackSyncMain=false;
bool TrackManager::progTrackBoosted=false; bool TrackManager::progTrackBoosted=false;
@ -209,9 +210,6 @@ void TrackManager::setDCSignal(int16_t cab, byte speedbyte) {
bool TrackManager::setTrackMode(byte trackToSet, TRACK_MODE mode, int16_t dcAddr) { bool TrackManager::setTrackMode(byte trackToSet, TRACK_MODE mode, int16_t dcAddr) {
if (trackToSet>lastTrack || track[trackToSet]==NULL) return false; if (trackToSet>lastTrack || track[trackToSet]==NULL) return false;
// Remember track mode we came from for later
TRACK_MODE oldmode = track[trackToSet]->getMode();
//DIAG(F("Track=%c Mode=%d"),trackToSet+'A', mode); //DIAG(F("Track=%c Mode=%d"),trackToSet+'A', mode);
// DC tracks require a motorDriver that can set brake! // DC tracks require a motorDriver that can set brake!
if (mode & TRACK_MODE_DC) { if (mode & TRACK_MODE_DC) {
@ -272,6 +270,7 @@ bool TrackManager::setTrackMode(byte trackToSet, TRACK_MODE mode, int16_t dcAddr
} }
track[trackToSet]->setMode(mode); track[trackToSet]->setMode(mode);
trackDCAddr[trackToSet]=dcAddr; trackDCAddr[trackToSet]=dcAddr;
streamTrackState(NULL,trackToSet);
// When a track is switched, we must clear any side effects of its previous // When a track is switched, we must clear any side effects of its previous
// state, otherwise trains run away or just dont move. // state, otherwise trains run away or just dont move.
@ -338,11 +337,10 @@ bool TrackManager::setTrackMode(byte trackToSet, TRACK_MODE mode, int16_t dcAddr
applyDCSpeed(trackToSet); applyDCSpeed(trackToSet);
} }
// Turn off power if we changed the mode of this track // Normal running tracks are set to the global power state
if (mode != oldmode) track[trackToSet]->setPower(
track[trackToSet]->setPower(POWERMODE::OFF); (mode & (TRACK_MODE_MAIN | TRACK_MODE_DC | TRACK_MODE_EXT | TRACK_MODE_BOOST)) ?
streamTrackState(NULL,trackToSet); mainPowerGuess : POWERMODE::OFF);
//DIAG(F("TrackMode=%d"),mode); //DIAG(F("TrackMode=%d"),mode);
return true; return true;
} }

View File

@ -77,13 +77,9 @@ class TrackManager {
static void loop(); static void loop();
static POWERMODE getMainPower(); static POWERMODE getMainPower();
static POWERMODE getProgPower(); static POWERMODE getProgPower();
static inline POWERMODE getPower(byte t) { return track[t]->getPower(); }
static bool getPower(byte t, char s[]); static bool getPower(byte t, char s[]);
static void setJoin(bool join); static void setJoin(bool join);
static bool isJoined() { return progTrackSyncMain;} static bool isJoined() { return progTrackSyncMain;}
static inline bool isActive (byte tr) {
if (tr > lastTrack) return false;
return track[tr]->getMode() & (TRACK_MODE_MAIN|TRACK_MODE_PROG|TRACK_MODE_DC|TRACK_MODE_BOOST|TRACK_MODE_EXT);}
static void setJoinRelayPin(byte joinRelayPin); static void setJoinRelayPin(byte joinRelayPin);
static void sampleCurrent(); static void sampleCurrent();
static void reportGauges(Print* stream); static void reportGauges(Print* stream);
@ -112,6 +108,7 @@ class TrackManager {
static void addTrack(byte t, MotorDriver* driver); static void addTrack(byte t, MotorDriver* driver);
static byte lastTrack; static byte lastTrack;
static byte nextCycleTrack; static byte nextCycleTrack;
static POWERMODE mainPowerGuess;
static void applyDCSpeed(byte t); static void applyDCSpeed(byte t);
static int16_t trackDCAddr[MAX_TRACKS]; // dc address if TRACK_MODE_DC static int16_t trackDCAddr[MAX_TRACKS]; // dc address if TRACK_MODE_DC

View File

@ -3,9 +3,7 @@
#include "StringFormatter.h" #include "StringFormatter.h"
#define VERSION "5.2.8" #define VERSION "5.2.7"
// 5.2.8 - Bugfix: Do not turn off all tracks on change
// give better power messages
// 5.2.7 - Bugfix: EXRAIL ling segment // 5.2.7 - Bugfix: EXRAIL ling segment
// - Bugfix: Back out wrongly added const // - Bugfix: Back out wrongly added const
// - Bugfix ESP32: Do not inverse DCX direction signal twice // - Bugfix ESP32: Do not inverse DCX direction signal twice