|
@@ -57,7 +57,8 @@ void *coffeeThread(void *threadid) {
|
|
|
|
|
|
logger(V_BREW, "Determining inital state\n");
|
|
|
//determine inital state
|
|
|
- if (halGetRelaisState(RELAIS_POWER) && halGetRelaisState(RELAIS_HEAT) && !halGetRelaisState(RELAIS_PUMP)) {
|
|
|
+ if (halGetRelaisState(RELAIS_POWER) && halGetRelaisState(RELAIS_HEAT)
|
|
|
+ && !halGetRelaisState(RELAIS_PUMP)) {
|
|
|
//wait for heat relais to switch
|
|
|
sleep(1);
|
|
|
if (halIsHeating()) { //Heating is on
|
|
@@ -103,7 +104,7 @@ void *coffeeThread(void *threadid) {
|
|
|
*
|
|
|
*/
|
|
|
case STATE_INITALHEATING:
|
|
|
- beginHeating = clock();
|
|
|
+ //beginHeating = clock();
|
|
|
if (SigValueEmpty())
|
|
|
pause();
|
|
|
switch (getSigValue()) {
|
|
@@ -117,16 +118,17 @@ void *coffeeThread(void *threadid) {
|
|
|
changeState(STATE_IDLE);
|
|
|
break;
|
|
|
}
|
|
|
+ /* FIXME See notes below
|
|
|
endHeating = clock();
|
|
|
heatingTime = double(endHeating - beginHeating) / CLOCKS_PER_SEC;
|
|
|
- coffeeIncreaseHeatingTime((uint64_t)heatingTime);
|
|
|
+ coffeeIncreaseHeatingTime((uint64_t) heatingTime);*/
|
|
|
break;
|
|
|
|
|
|
/*
|
|
|
*
|
|
|
*/
|
|
|
case STATE_HEATING:
|
|
|
- beginHeating = clock();
|
|
|
+ //beginHeating = clock();
|
|
|
if (SigValueEmpty())
|
|
|
pause();
|
|
|
switch (getSigValue()) {
|
|
@@ -147,9 +149,19 @@ void *coffeeThread(void *threadid) {
|
|
|
changeState(STATE_BREWMANUAL);
|
|
|
break;
|
|
|
}
|
|
|
+ /*
|
|
|
+ * @TODO FIXME:
|
|
|
+ * The time measurement makes no sense, since the FSM loops and there are a lot of interrupts that
|
|
|
+ * should be considered (like buttons or proximity sensor)
|
|
|
+ * Suggestion: capture time snapshot once at change to heating. If a change to another state occurs,
|
|
|
+ * capture again (like before, this capture is interrupted quite often)
|
|
|
+ *
|
|
|
+ * Another con: coffeeIncreaseHeatingTime() takes long for accessing the database, maybe store
|
|
|
+ * values at termination or periodically
|
|
|
+
|
|
|
endHeating = clock();
|
|
|
heatingTime = double(endHeating - beginHeating) / CLOCKS_PER_SEC;
|
|
|
- coffeeIncreaseHeatingTime((uint64_t)heatingTime);
|
|
|
+ coffeeIncreaseHeatingTime((uint64_t) heatingTime);*/
|
|
|
break;
|
|
|
/*
|
|
|
*
|
|
@@ -351,6 +363,6 @@ void coffeeIncreaseBrewCounter(void) {
|
|
|
void coffeeIncreaseHeatingTime(uint64_t heatingTime) {
|
|
|
uint64_t totalHeatingTime = sqlGetConf(CFGHeatingTime);
|
|
|
if (sqlSetConf(CFGHeatingTime, (totalHeatingTime + heatingTime))) {
|
|
|
- logger_error("Couldn't write heating time to database");
|
|
|
+ logger_error("Couldn't write heating time to database");
|
|
|
}
|
|
|
}
|