Consolidated new generated run states into protocol handler, new JSON for suspend mode

This commit is contained in:
rljonesau 2019-04-05 06:39:58 +11:00
parent cce60328c0
commit 708a8087b1
7 changed files with 78 additions and 77 deletions

View file

@ -1223,13 +1223,3 @@ bool isCyclicActive()
return bUserON && (NVstore.getCyclicMode() != 0); return bUserON && (NVstore.getCyclicMode() != 0);
} }
int getRunStateEx()
{
int heaterstate = getHeaterInfo().getRunState();
if(heaterstate == 0) {
if(isCyclicActive()) {
heaterstate = 10; // special state for cyclic suspended
}
}
return heaterstate;
}

View file

@ -180,8 +180,10 @@ CBasicScreen::keyHandler(uint8_t event)
// impossible with 5 way switch! // impossible with 5 way switch!
uint8_t doubleKey = key_Down | key_Up; uint8_t doubleKey = key_Down | key_Up;
if((event & doubleKey) == doubleKey) { if((event & doubleKey) == doubleKey) {
if(reqThermoToggle()) if(reqThermoToggle()) {
_showSetMode = millis() + 2000; _showSetMode = millis() + 2000;
NVstore.save();
}
else else
_reqOEMWarning(); _reqOEMWarning();
} }
@ -208,21 +210,18 @@ CBasicScreen::keyHandler(uint8_t event)
} }
// hold CENTRE to turn ON or OFF // hold CENTRE to turn ON or OFF
if(event & key_Centre) { if(event & key_Centre) {
if(getHeaterInfo().getRunState()) { int runstate = getHeaterInfo().getRunStateEx();
// running, request OFF if(runstate) { // running, including cyclic mode idle
if(repeatCount > 5) { if(repeatCount > 5) {
repeatCount = -2; // prevent double handling repeatCount = -1;
requestOff(); requestOff();
} }
} }
else { else { // standard idle state
// standby, request ON // standby, request ON
if(repeatCount > 3) { if(repeatCount > 3) {
repeatCount = -1; repeatCount = -1;
if(isCyclicActive()) requestOn();
requestOff(); // actually shut off cyclic mode if already in idle
else
requestOn();
} }
} }
} }
@ -264,7 +263,7 @@ CBasicScreen::keyHandler(uint8_t event)
void void
CBasicScreen::showRunState() CBasicScreen::showRunState()
{ {
int runstate = getHeaterInfo().getRunState(); int runstate = getHeaterInfo().getRunStateEx();
int errstate = getHeaterInfo().getErrState(); int errstate = getHeaterInfo().getErrState();
if(errstate) errstate--; // correct for +1 biased return value if(errstate) errstate--; // correct for +1 biased return value
@ -272,8 +271,8 @@ CBasicScreen::showRunState()
static bool toggle = false; static bool toggle = false;
const char* toPrint = NULL; const char* toPrint = NULL;
_display.setTextColor(WHITE, BLACK); _display.setTextColor(WHITE, BLACK);
if(runstate >= 0 && runstate <= 8) { // if(runstate >= 0 && runstate <= 8) {
if(((runstate == 0) || (runstate > 5)) && errstate) { if(errstate && ((runstate == 0) || (runstate > 5))) {
// flash error code // flash error code
char msg[16]; char msg[16];
@ -293,22 +292,18 @@ CBasicScreen::showRunState()
} }
else { else {
if(runstate) { if(runstate) {
if(runstate < 5) toPrint = "Starting"; toPrint = getHeaterInfo().getRunStateStr();
else if(runstate == 5) toPrint = "Running"; // simplify starting states
else if(isCyclicActive()) { switch(runstate) {
if(runstate > 5) toPrint = "Suspending..."; case 1:
} case 2:
else { case 3:
if(runstate == 8) toPrint = "Cooling"; case 4:
else toPrint = "Shutting down"; toPrint = "Starting";
break;
} }
} }
else { // }
if(isCyclicActive()) {
toPrint = "Suspended";
}
}
}
} }
if(toPrint) { if(toPrint) {
// locate at bottom centre // locate at bottom centre

View file

@ -81,8 +81,8 @@ CDetailedScreen::show()
const char* c = String(getTemperatureSensor()).c_str(); const char* c = String(getTemperatureSensor()).c_str();
int runstate = getHeaterInfo().getRunState();//HtrFrame.getRunState(); int runstate = getHeaterInfo().getRunStateEx();
int errstate = getHeaterInfo().getErrState(); //HtrFrame.getErrState(); int errstate = getHeaterInfo().getErrState();
if(errstate) errstate--; // correct for +1 biased return value if(errstate) errstate--; // correct for +1 biased return value
long tDelta = millis() - _showTarget; long tDelta = millis() - _showTarget;
@ -106,7 +106,7 @@ CDetailedScreen::show()
_animatePump = false; _animatePump = false;
_animateGlow = false; _animateGlow = false;
if(runstate) { if(runstate != 0 && runstate != 10) { // not idle modes
float power = getHeaterInfo().getGlowPlug_Power(); float power = getHeaterInfo().getGlowPlug_Power();
if(power > 1) { if(power > 1) {
showGlowPlug(power); showGlowPlug(power);
@ -188,7 +188,8 @@ CDetailedScreen::keyHandler(uint8_t event)
if(_keyRepeatCount >= 0) { if(_keyRepeatCount >= 0) {
_keyRepeatCount++; _keyRepeatCount++;
if(event & key_Centre) { if(event & key_Centre) {
if(getHeaterInfo().getRunState()) { int runstate = getHeaterInfo().getRunStateEx();
if(runstate) { // running, including cyclic mode idle
if(_keyRepeatCount > 5) { if(_keyRepeatCount > 5) {
_keyRepeatCount = -1; // prevent double handling _keyRepeatCount = -1; // prevent double handling
requestOff(); requestOff();
@ -197,17 +198,17 @@ CDetailedScreen::keyHandler(uint8_t event)
else { else {
if(_keyRepeatCount > 3) { if(_keyRepeatCount > 3) {
_keyRepeatCount = -1; // prevent double handling _keyRepeatCount = -1; // prevent double handling
if(isCyclicActive()) requestOn();
requestOff();
else
requestOn();
} }
} }
} }
if(event & key_Down) { if(event & key_Down) {
if(_keyRepeatCount > 1) { // held Down - togle thermo/fixed mode if(_keyRepeatCount > 1) { // held Down - togle thermo/fixed mode
_keyRepeatCount = -1; // prevent double handling _keyRepeatCount = -1; // prevent double handling
if(reqThermoToggle()) _showTarget = millis() + 3500; if(reqThermoToggle()) {
_showTarget = millis() + 3500;
NVstore.save();
}
else _reqOEMWarning(); else _reqOEMWarning();
} }
} }
@ -398,36 +399,27 @@ CDetailedScreen::showRunState(int runstate, int errstate)
const char* toPrint = NULL; const char* toPrint = NULL;
int yPos = 25; int yPos = 25;
_display.setTextColor(WHITE, BLACK); _display.setTextColor(WHITE, BLACK);
if(runstate >= 0 && runstate <= 8) { if(errstate && ((runstate == 0) || (runstate > 5))) {
if(errstate && ((runstate == 0) || (runstate > 5))) { // an error is present in idle or states beyond running, show it
// an error is present in idle or states beyond running, show it // create an "E-XX" message to display
// create an "E-XX" message to display char msg[16];
char msg[16]; sprintf(msg, "E-%02d", errstate);
sprintf(msg, "E-%02d", errstate); if(runstate > 5)
if(runstate > 5) yPos -= _display.textHeight();
yPos -= _display.textHeight(); _display.setCursor(_display.xCentre(), yPos);
_display.setCursor(_display.xCentre(), yPos); // flash error code
// flash error code toggle = !toggle;
toggle = !toggle; if(toggle)
if(toggle) _display.printCentreJustified(msg);
_display.printCentreJustified(msg);
else {
_display.printCentreJustified(" ");
}
yPos += _display.textHeight();
toPrint = getHeaterInfo().getErrStateStr();
}
else { else {
// no errors, heater normal _display.printCentreJustified(" ");
if(isCyclicActive()) {
if(runstate == 0) toPrint = "Suspended";
else if(runstate > 5) toPrint = "Suspending...";
else toPrint = getHeaterInfo().getRunStateStr();
}
else {
toPrint = getHeaterInfo().getRunStateStr();
}
} }
yPos += _display.textHeight();
toPrint = getHeaterInfo().getErrStateStr();
}
else {
// no errors, heater normal
toPrint = getHeaterInfo().getRunStateStr();
} }
if(toPrint) { if(toPrint) {
_printMenuText(_display.xCentre(), yPos, toPrint, false, eCentreJustify); _printMenuText(_display.xCentre(), yPos, toPrint, false, eCentreJustify);

View file

@ -323,6 +323,24 @@ CProtocol::setSystemVoltage(float fVal)
Controller.OperatingVoltage = val; Controller.OperatingVoltage = val;
} }
int CProtocolPackage::getRunStateEx() const
{
int runstate = getRunState();
if(isCyclicActive()) {
// special states for cyclic suspended
switch(runstate) {
case 0: runstate = 10; break; // standby, awaiting temperature drop
case 7: runstate = 11; break; // shutting down due to cyclic trip
case 8: runstate = 12; break; // cooling due to cyclic trip
}
}
if(runstate == 2 && getPump_Actual() == 0) { // split runstate 2 - glow, then fuel
runstate = 9;
}
return runstate;
}
const char* Runstates [] PROGMEM = { const char* Runstates [] PROGMEM = {
" Stopped/Ready ", // 0 " Stopped/Ready ", // 0
"Starting...", // 1 "Starting...", // 1
@ -335,6 +353,8 @@ const char* Runstates [] PROGMEM = {
"Cooling", // 8 "Cooling", // 8
"Heating glow plug", // 9 - interpreted state - actually runstate 2 with no pump action! "Heating glow plug", // 9 - interpreted state - actually runstate 2 with no pump action!
"Suspended", // 10 - interpreted state - cyclic mode has suspended heater "Suspended", // 10 - interpreted state - cyclic mode has suspended heater
"Suspending...", // 11 - interpreted state - cyclic mode is suspending heater
"Suspend cooling", // 12 - interpreted state - cyclic mode is suspending heater
"Unknown run state" "Unknown run state"
}; };
@ -344,7 +364,7 @@ const char*
CProtocolPackage::getRunStateStr() const CProtocolPackage::getRunStateStr() const
{ {
uint8_t runstate = getRunStateEx(); uint8_t runstate = getRunStateEx();
UPPERLIMIT(runstate, 10); UPPERLIMIT(runstate, 13);
if(runstate == 2 && getPump_Actual() == 0) { // split runstate 2 - glow, then fuel if(runstate == 2 && getPump_Actual() == 0) { // split runstate 2 - glow, then fuel
runstate = 9; runstate = 9;
} }

View file

@ -217,6 +217,7 @@ class CProtocolPackage {
public: public:
void set(const CProtocol& htr, const CProtocol& ctl) { Heater = htr; Controller = ctl; }; void set(const CProtocol& htr, const CProtocol& ctl) { Heater = htr; Controller = ctl; };
int getRunState() const { return Heater.getRunState(); }; int getRunState() const { return Heater.getRunState(); };
int getRunStateEx() const; // extra support for cyclic thermostat mode
const char* getRunStateStr() const; const char* getRunStateStr() const;
int getErrState() const; int getErrState() const;
const char* getErrStateStr() const; const char* getErrStateStr() const;

View file

@ -56,7 +56,6 @@ extern bool hasOEMLCDcontroller();
extern int getBlueWireStat(); extern int getBlueWireStat();
extern int getSmartError(); extern int getSmartError();
extern bool isCyclicActive(); extern bool isCyclicActive();
extern int getRunStateEx();

View file

@ -86,6 +86,9 @@ void interpretJsonCommand(char* pLine)
else if(strcmp("FanMax", it->key) == 0) { else if(strcmp("FanMax", it->key) == 0) {
setFanMax(it->value.as<short>()); setFanMax(it->value.as<short>());
} }
else if(strcmp("ThermostatOvertemp", it->key) == 0) {
NVstore.setCyclicMode(it->value.as<unsigned char>());
}
else if(strcmp("ThermostatMethod", it->key) == 0) { else if(strcmp("ThermostatMethod", it->key) == 0) {
NVstore.setThermostatMethodMode(it->value.as<unsigned char>()); NVstore.setThermostatMethodMode(it->value.as<unsigned char>());
} }
@ -178,7 +181,7 @@ bool makeJSONString(CModerator& moderator, char* opStr, int len)
bSend |= moderator.addJson("TempMax", getHeaterInfo().getTemperature_Max(), root); bSend |= moderator.addJson("TempMax", getHeaterInfo().getTemperature_Max(), root);
bSend |= moderator.addJson("TempBody", getHeaterInfo().getTemperature_HeatExchg(), root); bSend |= moderator.addJson("TempBody", getHeaterInfo().getTemperature_HeatExchg(), root);
// bSend |= moderator.addJson("RunState", getHeaterInfo().getRunState(), root); // bSend |= moderator.addJson("RunState", getHeaterInfo().getRunState(), root);
bSend |= moderator.addJson("RunState", getRunStateEx(), root); bSend |= moderator.addJson("RunState", getHeaterInfo().getRunStateEx(), root);
bSend |= moderator.addJson("RunString", getHeaterInfo().getRunStateStr(), root); // verbose it up! bSend |= moderator.addJson("RunString", getHeaterInfo().getRunStateStr(), root); // verbose it up!
bSend |= moderator.addJson("ErrorState", getHeaterInfo().getErrState(), root ); bSend |= moderator.addJson("ErrorState", getHeaterInfo().getErrState(), root );
bSend |= moderator.addJson("ErrorString", getHeaterInfo().getErrStateStrEx(), root); // verbose it up! bSend |= moderator.addJson("ErrorString", getHeaterInfo().getErrStateStrEx(), root); // verbose it up!
@ -215,6 +218,7 @@ bool makeJSONStringEx(CModerator& moderator, char* opStr, int len)
bSend |= moderator.addJson("ThermostatMethod", NVstore.getThermostatMethodMode(), root); bSend |= moderator.addJson("ThermostatMethod", NVstore.getThermostatMethodMode(), root);
bSend |= moderator.addJson("ThermostatWindow", NVstore.getThermostatMethodWindow(), root); bSend |= moderator.addJson("ThermostatWindow", NVstore.getThermostatMethodWindow(), root);
bSend |= moderator.addJson("ThermostatOvertemp", NVstore.getCyclicMode(), root);
if(bSend) { if(bSend) {
root.printTo(opStr, len); root.printTo(opStr, len);