thermferm/statetbl.h

Thu, 25 Apr 2024 14:26:47 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Thu, 25 Apr 2024 14:26:47 +0200
changeset 708
13555c27b592
parent 655
780cc08df263
permissions
-rw-r--r--

Version 0.9.19a6. Fixes after a short trial on the production controller. Fixed json for alternate beer termperature sensor. Fixed division by 1000 for the room temperature and humidity values. The dropdown list for devices shows the address instead of description in the list.

/**
 * @brief State table macro's
 */

#ifndef STATETBL_H
#define STATETBL_H

#define SM_DECL(proc,name) \
int proc(void)\
{\
    int sm_success=0;\
    char *sm_name=name;

#define SM_STATES \
    enum {

#define SM_NAMES \
    } sm_state; \
    char * sm_sname[] = {

#define SM_EDECL \
    };

#define SM_START(x) \
    sm_state=x;\
    if (debug)\
	syslog(LOG_NOTICE, "SM (%s): Start => %s", sm_name, sm_sname[sm_state]); \
    while (!sm_success) switch (sm_state)\
    {\
    default: syslog(LOG_WARNING, "Statemachine %s error: state=%d",sm_name,sm_state);\
    sm_success=-1;

#define SM_STATE(x) \
    break;\
    case x:

#define SM_END \
    }\

#define SM_RETURN \
    return (sm_success != 1);\
}

#define SM_PROCEED(x) \
    if (x != sm_state && debug) {\
	syslog(LOG_NOTICE, "SM (%s): %s => %s", sm_name, sm_sname[sm_state], sm_sname[x]);\
    }\
    sm_state=x; break;

#define SM_SUCCESS \
    if (debug)\
	syslog(LOG_NOTICE, "SM (%s): %s => Success", sm_name, sm_sname[sm_state]);\
    sm_success=1; break;

#define SM_ERROR \
    syslog(LOG_WARNING, "SM (%s): %s => Error", sm_name, sm_sname[sm_state]);\
    sm_success=-1; break;

#endif

mercurial