# HG changeset patch # User Michiel Broek # Date 1676127196 -3600 # Node ID 29e7223e37ae4420c95686f1d3a206d12d381d1f # Parent 897bf2a43253d288ea2d7cf936a33a9a8a3d13f3 Version 0.3.42 added yeast_lo and yeast_hi fields to the iSpindel records and structures. diff -r 897bf2a43253 -r 29e7223e37ae bmsd/bms.h --- a/bmsd/bms.h Sat Jan 14 11:25:20 2023 +0100 +++ b/bmsd/bms.h Sat Feb 11 15:53:16 2023 +0100 @@ -310,7 +310,9 @@ } brewer_list; -// Make it universal and make it connectable with a beer. +/** + * @brief Structure for the iSpindels. Stored in database table 'mon_ispindels'. + */ typedef struct _ispindel_list { struct _ispindel_list *next; char *uuid; ///< Fixed uuid string. @@ -328,6 +330,8 @@ float gravity; ///< Gravity in Plato int interval; ///< Measure interval float og_gravity; ///< OG gravity in Plato detected + float yeast_lo; ///< Yeast low temperature limit + float yeast_hi; ///< Yeast high temperature limit } sys_ispindel_list; diff -r 897bf2a43253 -r 29e7223e37ae bmsd/ispindels.c --- a/bmsd/ispindels.c Sat Jan 14 11:25:20 2023 +0100 +++ b/bmsd/ispindels.c Sat Feb 11 15:53:16 2023 +0100 @@ -3,7 +3,7 @@ * @brief Handle ispindels data * @author Michiel Broek * - * Copyright (C) 2019-2022 + * Copyright (C) 2019-2023 * * This file is part of the bms (Brewery Management System) * @@ -58,7 +58,13 @@ msg = xstrcat(msg, ispindel->beercode); msg = xstrcat(msg, (char *)"\",\"beername\":\""); msg = xstrcat(msg, ispindel->beername); - msg = xstrcat(msg, (char *)"\",\"temperature\":"); + msg = xstrcat(msg, (char *)"\",\"yeast_lo\":"); + snprintf(buf, 64, "%.3f", ispindel->yeast_lo); + msg = xstrcat(msg, buf); + msg = xstrcat(msg, (char *)",\"yeast_hi\":"); + snprintf(buf, 64, "%.3f", ispindel->yeast_hi); + msg = xstrcat(msg, buf); + msg = xstrcat(msg, (char *)",\"temperature\":"); snprintf(buf, 64, "%.4f", ispindel->temperature); msg = xstrcat(msg, buf); msg = xstrcat(msg, (char *)",\"angle\":"); @@ -89,7 +95,8 @@ struct json_object *jobj, *val; sys_ispindel_list *tmpp; char *node = NULL, *alias = NULL, *mode = NULL, *beeruuid = NULL, *beercode = NULL, *beername = NULL; - char query[512], *end; + float yeast_lo = 20, yeast_hi = 25; + char query[512], buf[65], *end; MYSQL *con2 = NULL; /* @@ -106,6 +113,10 @@ beercode = xstrcpy((char *)json_object_get_string(val)); if (json_object_object_get_ex(jobj, "beername", &val)) beername = xstrcpy((char *)json_object_get_string(val)); + if (json_object_object_get_ex(jobj, "yeast_lo", &val)) + yeast_lo = json_object_get_double(val); + if (json_object_object_get_ex(jobj, "yeast_hi", &val)) + yeast_hi = json_object_get_double(val); if (json_object_object_get_ex(jobj, "mode", &val)) mode = xstrcpy((char *)json_object_get_string(val)); json_object_put(jobj); @@ -130,7 +141,13 @@ end += mysql_real_escape_string(con2, end, beercode, strlen(beercode)); end = stpcpy(end, "', beername='"); end += mysql_real_escape_string(con2, end, beername, strlen(beername)); - end = stpcpy(end, "', og_gravity='0.0' WHERE node='"); + end = stpcpy(end, "', og_gravity='0.0', yeast_lo='"); + snprintf(buf, 64, "%.3f", yeast_lo); + end = stpcpy(end, buf); + end = stpcpy(end, "', yeast_hi='"); + snprintf(buf, 64, "%.3f", yeast_hi); + end = stpcpy(end, buf); + end = stpcpy(end, "' WHERE node='"); end += mysql_real_escape_string(con2, end, node, strlen(node)); end = stpcpy(end, "'"); @@ -148,6 +165,8 @@ free(tmpp->beeruuid); tmpp->beeruuid = xstrcpy(beeruuid); tmpp->og_gravity = 0.0; + tmpp->yeast_lo = yeast_lo; + tmpp->yeast_hi = yeast_hi; /* Report new state to the client */ ispindel_ws_send(tmpp); syslog(LOG_NOTICE, "Set ispindel %s/%s new beer %s %s", node, alias, beercode, beername); diff -r 897bf2a43253 -r 29e7223e37ae bmsd/mysql.c --- a/bmsd/mysql.c Sat Jan 14 11:25:20 2023 +0100 +++ b/bmsd/mysql.c Sat Feb 11 15:53:16 2023 +0100 @@ -3,7 +3,7 @@ * @brief MySQL/MariaDB access. * @author Michiel Broek * - * Copyright (C) 2018-2022 + * Copyright (C) 2018-2023 * * This file is part of the bms (Brewery Management System) * @@ -306,6 +306,8 @@ ispindel->interval = atoi(row[13]); ispindel->mode = xstrcpy(row[14]); ispindel->og_gravity = atof(row[15]); + ispindel->yeast_lo = atof(row[16]); + ispindel->yeast_hi = atof(row[17]); if (ispindels == NULL) { ispindels = ispindel; @@ -714,9 +716,11 @@ snprintf(query, 2559, "INSERT INTO mon_ispindels SET uuid='%s', alias='%s', node='%s', online='%d', mode='%s', alarm='%d', " \ - "angle='%.6f', temperature='%.4f', battery='%.6f', gravity='%.6f', up_interval='%d', og_gravity='0.0'", + "angle='%.6f', temperature='%.4f', battery='%.6f', gravity='%.6f', up_interval='%d', og_gravity='0.0', " \ + "yeast_lo='%.1f', yeast_hi='%.1f'", ispindel->uuid, ispindel->alias, ispindel->node, ispindel->online ? 1:0, ispindel->mode, ispindel->alarm, - ispindel->angle, ispindel->temperature, ispindel->battery, ispindel->gravity, ispindel->interval); + ispindel->angle, ispindel->temperature, ispindel->battery, ispindel->gravity, ispindel->interval, + ispindel->yeast_lo, ispindel->yeast_hi); if (bms_mysql_query(query) == 0) { syslog(LOG_NOTICE, "MySQL: insert new ispindel %s", ispindel->node); @@ -732,9 +736,11 @@ snprintf(query, 2559, "UPDATE mon_ispindels SET online='%d', mode='%s', alias='%s', alarm='%d', " \ - "angle='%.6f', temperature='%.4f', battery='%.6f', gravity='%.6f', up_interval='%d', og_gravity=GREATEST(og_gravity, '%.6f') WHERE uuid='%s'", + "angle='%.6f', temperature='%.4f', battery='%.6f', gravity='%.6f', up_interval='%d', og_gravity=GREATEST(og_gravity, '%.6f'), " \ + "yeast_lo='%.1f', yeast_hi='%.1f' WHERE uuid='%s'", ispindel->online ? 1:0, ispindel->mode, ispindel->alias, ispindel->alarm, - ispindel->angle, ispindel->temperature, ispindel->battery, ispindel->gravity, ispindel->interval, ispindel->gravity, ispindel->uuid); + ispindel->angle, ispindel->temperature, ispindel->battery, ispindel->gravity, ispindel->interval, ispindel->gravity, + ispindel->yeast_lo, ispindel->yeast_hi, ispindel->uuid); bms_mysql_query(query); free(query); } diff -r 897bf2a43253 -r 29e7223e37ae config.status --- a/config.status Sat Jan 14 11:25:20 2023 +0100 +++ b/config.status Sat Feb 11 15:53:16 2023 +0100 @@ -433,7 +433,7 @@ This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." -ac_pwd='/home/mbroek/MyProjects/bms' +ac_pwd='/mnt/home/mbroek/MyProjects/bms' srcdir='.' test -n "$AWK" || AWK=awk # The default lists apply if the user does not specify any file. @@ -619,9 +619,9 @@ S["CFLAGS"]="-g -O2 -fomit-frame-pointer -fno-strict-aliasing -Wall -Wshadow -Wwrite-strings -Wstrict-prototypes -Winline -I/usr/include/libxml2 -I/usr/include/u"\ "uid" S["CC"]="gcc" -S["CYEARS"]="2016-2022" -S["COPYRIGHT"]="Copyright (C) 2016-2022 Michiel Broek, All Rights Reserved" -S["VERSION"]="0.3.41" +S["CYEARS"]="2016-2023" +S["COPYRIGHT"]="Copyright (C) 2016-2023 Michiel Broek, All Rights Reserved" +S["VERSION"]="0.3.42" S["PACKAGE"]="bms" S["SUBDIRS"]="bmsd doc script tools www" S["target_alias"]="" @@ -709,8 +709,8 @@ D["PACKAGE_STRING"]=" \"\"" D["PACKAGE_BUGREPORT"]=" \"\"" D["PACKAGE_URL"]=" \"\"" -D["VERSION"]=" \"0.3.41\"" -D["COPYRIGHT"]=" \"Copyright (C) 2016-2022 Michiel Broek, All Rights Reserved\"" +D["VERSION"]=" \"0.3.42\"" +D["COPYRIGHT"]=" \"Copyright (C) 2016-2023 Michiel Broek, All Rights Reserved\"" D["STDC_HEADERS"]=" 1" D["HAVE_SYS_TYPES_H"]=" 1" D["HAVE_SYS_STAT_H"]=" 1" diff -r 897bf2a43253 -r 29e7223e37ae configure --- a/configure Sat Jan 14 11:25:20 2023 +0100 +++ b/configure Sat Feb 11 15:53:16 2023 +0100 @@ -2031,9 +2031,9 @@ PACKAGE="bms" -VERSION="0.3.41" -COPYRIGHT="Copyright (C) 2016-2022 Michiel Broek, All Rights Reserved" -CYEARS="2016-2022" +VERSION="0.3.42" +COPYRIGHT="Copyright (C) 2016-2023 Michiel Broek, All Rights Reserved" +CYEARS="2016-2023" diff -r 897bf2a43253 -r 29e7223e37ae configure.ac --- a/configure.ac Sat Jan 14 11:25:20 2023 +0100 +++ b/configure.ac Sat Feb 11 15:53:16 2023 +0100 @@ -8,9 +8,9 @@ dnl General settings dnl After changeing the version number, run autoconf! PACKAGE="bms" -VERSION="0.3.41" -COPYRIGHT="Copyright (C) 2016-2022 Michiel Broek, All Rights Reserved" -CYEARS="2016-2022" +VERSION="0.3.42" +COPYRIGHT="Copyright (C) 2016-2023 Michiel Broek, All Rights Reserved" +CYEARS="2016-2023" AC_SUBST(PACKAGE) AC_SUBST(VERSION) AC_SUBST(COPYRIGHT)