Error reporting and runstate annotations away from standby and run. JC's nasty throbber included.

This commit is contained in:
rljonesau 2018-12-16 13:45:13 +11:00
parent 49bd71c569
commit 4019e42925
5 changed files with 84 additions and 35 deletions

View file

@ -31,7 +31,6 @@ char defaultJSONstr[64];
void decodeTimerDays(int timerID, const char* str);
void decodeTimerTime(int ID, int stop, const char*);
void decodeTimerRepeat(int ID, int state);
const char* buildErrorString();
void interpretJsonCommand(char* pLine)
@ -140,11 +139,10 @@ bool makeJsonString(CModerator& moderator, char* opStr, int len)
bSend |= moderator.addJson("TempMin", getHeaterInfo().getTemperature_Min(), root);
bSend |= moderator.addJson("TempMax", getHeaterInfo().getTemperature_Max(), root);
bSend |= moderator.addJson("TempBody", getHeaterInfo().getTemperature_HeatExchg(), root);
bSend |= moderator.addJson("RunState", getHeaterInfo().getRunState(), root);
if(moderator.addJson("ErrorState", getHeaterInfo().getErrState(), root )) {
bSend = true;
root.set("ErrorString", buildErrorString());
}
bSend |= moderator.addJson("RunState", getHeaterInfo().getRunState(), root);
bSend |= moderator.addJson("RunString", getHeaterInfo().getRunStateStr(), root); // verbose it up!
bSend |= moderator.addJson("ErrorState", getHeaterInfo().getErrState(), root );
bSend |= moderator.addJson("ErrorString", getHeaterInfo().getErrStateStrEx(), root); // verbose it up!
bSend |= moderator.addJson("Thermostat", getHeaterInfo().isThermostat(), root );
bSend |= moderator.addJson("PumpFixed", getHeaterInfo().getPump_Fixed(), root );
bSend |= moderator.addJson("PumpMin", getHeaterInfo().getPump_Min(), root );
@ -165,15 +163,6 @@ bool makeJsonString(CModerator& moderator, char* opStr, int len)
return bSend;
}
const char* buildErrorString()
{
static char ErrMsg[64];
sprintf(ErrMsg, "E-%02d: %s", getHeaterInfo().getErrState()-1, getHeaterInfo().getErrStateStr());
return ErrMsg;
}
void decodeTimerDays(int ID, const char* str)
{

View file

@ -63,7 +63,12 @@ template<class T>
void TModerator<T>::reset()
{
for(auto it = Memory.begin(); it != Memory.end(); ++it) {
it->second = it->second+100;
if(std::is_pointer<T>::value) {
it->second = NULL;
}
else {
it->second = it->second+100;
}
}
}
@ -71,29 +76,42 @@ class CModerator {
TModerator<int> iModerator;
TModerator<float> fModerator;
TModerator<unsigned char> ucModerator;
TModerator<const char*> szModerator;
public:
// integer values
bool shouldSend(const char* name, int value) {
return iModerator.shouldSend(name, value);
};
bool shouldSend(const char* name, float value) {
return fModerator.shouldSend(name, value);
};
bool shouldSend(const char* name, unsigned char value) {
return ucModerator.shouldSend(name, value);
};
bool addJson(const char* name, int value, JsonObject& root) {
return iModerator.addJson(name, value, root);
};
// float values
bool shouldSend(const char* name, float value) {
return fModerator.shouldSend(name, value);
};
bool addJson(const char* name, float value, JsonObject& root) {
return fModerator.addJson(name, value, root);
};
// unsigned char values
bool shouldSend(const char* name, unsigned char value) {
return ucModerator.shouldSend(name, value);
};
bool addJson(const char* name, unsigned char value, JsonObject& root) {
return ucModerator.addJson(name, value, root);
};
// const char* values
bool shouldSend(const char* name, const char* value) {
return szModerator.shouldSend(name, value);
};
bool addJson(const char* name, const char* value, JsonObject& root) {
return szModerator.addJson(name, value, root);
};
// force changes on all held values
void reset() {
iModerator.reset();
fModerator.reset();
ucModerator.reset();
szModerator.reset();
};
};

View file

@ -320,12 +320,13 @@ const char* Runstates [] PROGMEM = {
" Stopped/Ready ",
"Starting...",
"Igniting...",
" Ignition retry ",
"Ignition retry pause",
"Ignited",
"Running",
"Stopping",
"Shutting down",
"Cooling",
"Heating glow plug",
"Unknown run state"
};
@ -335,7 +336,10 @@ const char*
CProtocolPackage::getRunStateStr() const
{
uint8_t runstate = Heater.getRunState();
UPPERLIMIT(runstate, 9);
UPPERLIMIT(runstate, 10);
if(runstate == 2 && getPump_Actual() == 0) { // split runstate 2 - glow, then fuel
runstate = 9;
}
return Runstates[runstate];
}
@ -353,6 +357,24 @@ const char* Errstates [] PROGMEM = {
"Flame out", // E-08
"Temp sense", // E-09
"Ignition fail", // E-10
"Failed 1st ignition attempt", // E-11
"Unknown error?" // mystery code!
};
const char* ErrstatesEx [] PROGMEM = {
"E-00: OK",
"E-00: OK",
"E-01: Low voltage", // E-01
"E-02: High voltage", // E-02
"E-03: Glow plug fault", // E-03
"E-04: Pump fault", // E-04
"E-05: Overheat", // E-05
"E-06: Motor fault", // E-06
"E-07: Comms fault", // E-07
"E-08: Flame out", // E-08
"E-09: Temp sense", // E-09
"E-10: Ignition fail", // E-10
"E-11: Failed 1st ignition attempt", // E-11
"Unknown error?" // mystery code!
};
@ -360,6 +382,14 @@ const char*
CProtocolPackage::getErrStateStr() const
{
uint8_t errstate = Heater.getErrState();
UPPERLIMIT(errstate, 12);
UPPERLIMIT(errstate, 13);
return Errstates[errstate];
}
const char*
CProtocolPackage::getErrStateStrEx() const
{
uint8_t errstate = Heater.getErrState();
UPPERLIMIT(errstate, 13);
return ErrstatesEx[errstate];
}

View file

@ -213,6 +213,7 @@ public:
const char* getRunStateStr() const;
int getErrState() const { return Heater.getErrState(); };
const char* getErrStateStr() const;
const char* getErrStateStrEx() const;
float getBattVoltage() const { return Heater.getVoltage_Supply(); };
bool isThermostat() const { return Controller.isThermostat(); };
float getTemperature_Desired() const { return float(Controller.getTemperature_Desired()); };

View file

@ -17,9 +17,6 @@ const char* MAIN_PAGE PROGMEM = R"=====(
for(key in heater) {
console.log("JSON decode:", key, heater[key]);
switch(key) {
case "TempCurrent":
document.getElementById(key).innerHTML = heater[key];
break;
case "RunState":
if (heater[key] == 0) {
document.getElementById("myonoffswitch").checked = false;
@ -34,6 +31,13 @@ const char* MAIN_PAGE PROGMEM = R"=====(
document.getElementById("myonoffswitch").style = "block";
document.getElementById("onoffswitch").style.visibility = "visible";
}
document.getElementById("RunString").style.visibility = (heater[key] == 5 || heater[key] == 0) ? "hidden" : "visible";
break;
case "ErrorString":
case "PumpFixed":
case "RunString":
case "TempCurrent":
document.getElementById(key).innerHTML = heater[key];
break;
case "TempDesired":
document.getElementById("slide").value = heater[key];
@ -42,9 +46,6 @@ const char* MAIN_PAGE PROGMEM = R"=====(
case "ErrorState":
document.getElementById("ErrorDiv").hidden = heater[key] <= 1;
break;
case "ErrorString":
document.getElementById(key).innerHTML = heater[key];
break;
case "Thermostat":
if(heater[key] != 0) {
document.getElementById("FixedDiv").hidden = true;
@ -55,9 +56,6 @@ const char* MAIN_PAGE PROGMEM = R"=====(
document.getElementById("ThermoDiv").hidden = true;
}
break;
case "PumpFixed":
document.getElementById(key).innerHTML = heater[key];
break;
}
}
}
@ -286,6 +284,7 @@ function onSlide(newVal, JSONKey) {
var cmd = {};
cmd[JSONKey] = newVal; // note: variable name needs []
cmd.NVsave = 8861; // named variable DOESN'T !!
sendJSONobject(cmd);
}
@ -296,6 +295,16 @@ function onSlide(newVal, JSONKey) {
<meta name="viewport" content="height=device-height, width=device-width, initial-scale=1">
<style>
.throb_me {
animation: throbber 1s linear infinite;
}
@keyframes throbber {
50% {
opacity: 0;
}
}
.slider {
position: absolute;
cursor: pointer;
@ -449,6 +458,7 @@ MainPage {
}
</style>
<title>Chinese Diesel Heater Web Controller Interface</title>
</head>
<body onload="javascript:init()">
@ -477,6 +487,7 @@ MainPage {
<span class="onoffswitch-switch"></span>
</label>
</div>
<span class="throb_me" id="RunString" style="visibility:hidden"></span>
<div>
<h2>Temperature Control</h2>
@ -493,7 +504,7 @@ MainPage {
<div>
<b>Current Temp: </b><span id="TempCurrent">
</div>
<div id="ErrorDiv" style="color:red" hidden>
<div id="ErrorDiv" style="color:crimson" hidden>
<b>Error <span id="ErrorString"> </b>
</div>
</span>