|
@@ -59,11 +59,13 @@ void *coffeeThread(void *threadid) {
|
|
|
//read the database values
|
|
|
if(!(totalHeatingTime = sqlGetConf(CFGHeatingTime))){
|
|
|
logger_error("coffee.cpp: Couldn't read the heating time from the database");
|
|
|
- pthread_exit(EXIT_SUCCESS);
|
|
|
+ //pthread_exit(EXIT_SUCCESS);
|
|
|
+ exit(EXIT_FAILURE);
|
|
|
}
|
|
|
if(!(brewCounter = sqlGetConf(CFGbrewcounter))){
|
|
|
logger_error("coffee.cpp: Couldn't read the brew counter from the database");
|
|
|
- pthread_exit(EXIT_SUCCESS);
|
|
|
+ //pthread_exit(EXIT_SUCCESS);
|
|
|
+ exit(EXIT_FAILURE);
|
|
|
}
|
|
|
|
|
|
event_subscribe("terminate", &coffeeTerminate);
|
|
@@ -107,6 +109,7 @@ void *coffeeThread(void *threadid) {
|
|
|
changeState(STATE_IDLE);
|
|
|
}
|
|
|
} else {
|
|
|
+ logger_error("Not enough Water in tank detected\n");
|
|
|
changeState(STATE_ERROR);
|
|
|
}
|
|
|
break;
|
|
@@ -116,6 +119,12 @@ void *coffeeThread(void *threadid) {
|
|
|
*
|
|
|
*/
|
|
|
case STATE_WAIT_OFF:
|
|
|
+ if (halIsHeating()) {
|
|
|
+ halMachineOff();
|
|
|
+ coffeeIncreaseHeatingTime(halgetHeatingTime());
|
|
|
+ writeBackCache();
|
|
|
+ changeState(STATE_OFF);
|
|
|
+ }
|
|
|
if (SigValueEmpty())
|
|
|
pause();
|
|
|
switch (getSigValue()) {
|
|
@@ -209,6 +218,11 @@ void *coffeeThread(void *threadid) {
|
|
|
changeState(STATE_OFF);
|
|
|
break;
|
|
|
|
|
|
+ case SigInt1Rls:
|
|
|
+ //turn machine off when heating is finished
|
|
|
+ changeState(STATE_WAIT_OFF);
|
|
|
+ break;
|
|
|
+
|
|
|
case SigPressCls:
|
|
|
changeState(STATE_HEATING);
|
|
|
break;
|
|
@@ -271,7 +285,7 @@ void *coffeeThread(void *threadid) {
|
|
|
void coffeeHandler(int signum, siginfo_t *siginfo, void *context) {
|
|
|
sigval_t sigVal = (siginfo->si_value);
|
|
|
sigValue = sigVal.sival_int;
|
|
|
- logger(V_BREW, "CoffeeHandler called with %d\n", sigValue);
|
|
|
+ logger(V_BREW, "coffee.cpp: CoffeeHandler called with Signal %d\n", sigValue);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -322,10 +336,6 @@ void brewTimeHandler(void) {
|
|
|
* handles program termination
|
|
|
*/
|
|
|
void coffeeTerminate(event_t *event) {
|
|
|
- if (event->len != sizeof(coffee_status_t)) {
|
|
|
- logger_error("Invalid use of event %s\n", event->event);
|
|
|
- return;
|
|
|
- }
|
|
|
logger(V_BREW, "Coffee.cpp: Thread terminating");
|
|
|
//stop brewing
|
|
|
halRelaisOff(RELAIS_PUMP);
|