Version 0.9.2 DLOG messages every minute unless a unit is off. More event messages added. The target temperatur is now taken from the PIDs.

Sun, 20 Jan 2019 13:34:09 +0100

author
Michiel Broek <mbroek@mbse.eu>
date
Sun, 20 Jan 2019 13:34:09 +0100
changeset 575
86496d2bc4bb
parent 574
362c4700937e
child 576
fbc6012405f1

Version 0.9.2 DLOG messages every minute unless a unit is off. More event messages added. The target temperatur is now taken from the PIDs.

configure file | annotate | diff | comparison | revisions
configure.ac file | annotate | diff | comparison | revisions
thermferm/mqtt.c file | annotate | diff | comparison | revisions
thermferm/server.c file | annotate | diff | comparison | revisions
thermferm/thermferm.c file | annotate | diff | comparison | revisions
thermferm/thermferm.h file | annotate | diff | comparison | revisions
--- a/configure	Sat Jan 19 22:07:42 2019 +0100
+++ b/configure	Sun Jan 20 13:34:09 2019 +0100
@@ -2035,7 +2035,7 @@
 
 
 PACKAGE="mbsePi-apps"
-VERSION="0.9.1"
+VERSION="0.9.2"
 COPYRIGHT="Copyright (C) 2014-2019 Michiel Broek, All Rights Reserved"
 CYEARS="2014-2019"
 
--- a/configure.ac	Sat Jan 19 22:07:42 2019 +0100
+++ b/configure.ac	Sun Jan 20 13:34:09 2019 +0100
@@ -8,7 +8,7 @@
 dnl General settings
 dnl After changeing the version number, run autoconf!
 PACKAGE="mbsePi-apps"
-VERSION="0.9.1"
+VERSION="0.9.2"
 COPYRIGHT="Copyright (C) 2014-2019 Michiel Broek, All Rights Reserved"
 CYEARS="2014-2019"
 AC_SUBST(PACKAGE)
--- a/thermferm/mqtt.c	Sat Jan 19 22:07:42 2019 +0100
+++ b/thermferm/mqtt.c	Sun Jan 20 13:34:09 2019 +0100
@@ -223,6 +223,8 @@
 						syslog(LOG_NOTICE, "DCMD change fermenter %s: stage to %s", message_alias, UNITSTAGE[i]);
 						unit->mqtt_flag |= MQTT_FLAG_DATA;
 				    	    	unit->stage = i;
+						if ((unit->mode != UNITMODE_OFF) && ! unit->event_msg)
+						    unit->event_msg = xstrcpy((char *)UNITSTAGE[i]);
 					    }
 					    break;
 					}
@@ -250,6 +252,8 @@
 						}
 						syslog(LOG_NOTICE, "DCMD change fermenter %s: mode to %s", message_alias, UNITMODE[i]);
 						unit->mode = i;
+						if ((unit->mode != UNITMODE_OFF) && ! unit->event_msg)
+						    unit->event_msg = xstrcpy((char *)UNITMODE[i]);
 						/* Allways turn everything off after a mode change */
 						unit->PID_cool->OutP = unit->PID_heat->OutP = 0.0;
 						unit->PID_cool->Mode = unit->PID_heat->Mode = PID_MODE_NONE;
@@ -395,6 +399,8 @@
 						    unit->prof_peak_abs = unit->prof_peak_rel = 0.0;
 						    syslog(LOG_NOTICE, "DCMD change fermenter `%s' profile start RUN", message_alias);
 						    unit->mqtt_flag |= MQTT_FLAG_DATA;
+						    if (! unit->event_msg)
+							unit->event_msg = xstrcpy((char *)"Profile start");
 						}
 				            } else if (! strcmp(cmd, (char *)"abort")) {
 						if ((unit->prof_state == PROFILE_RUN) || (unit->prof_state == PROFILE_PAUSE)) {
@@ -403,6 +409,8 @@
 						    unit->prof_peak_abs = unit->prof_peak_rel = 0.0;
 						    syslog(LOG_NOTICE, "DCMD change fermenter `%s' profile ABORT", message_alias);
 						    unit->mqtt_flag |= MQTT_FLAG_DATA;
+						    if (! unit->event_msg)
+							unit->event_msg = xstrcpy((char *)"Profile abort");
 						}
 					    } else if (! strcmp(cmd, (char *)"done")) {
 						if (unit->prof_state == PROFILE_DONE) {
@@ -547,7 +555,6 @@
 				if (unit->mqtt_flag & MQTT_FLAG_DEATH) {
 				    publishDDeath(unit);
 			    	}
-			    	unit->mqtt_flag |= MQTT_FLAG_DLOG;      // Something to log
 			    }
 			}
 			return;
--- a/thermferm/server.c	Sat Jan 19 22:07:42 2019 +0100
+++ b/thermferm/server.c	Sun Jan 20 13:34:09 2019 +0100
@@ -2375,7 +2375,6 @@
 				if (unit->mqtt_flag & MQTT_FLAG_DEATH) {
 				    publishDDeath(unit);
 				}
-			    	unit->mqtt_flag |= MQTT_FLAG_DLOG;	// Something to log
 			    }
 			}
 		    }
--- a/thermferm/thermferm.c	Sat Jan 19 22:07:42 2019 +0100
+++ b/thermferm/thermferm.c	Sun Jan 20 13:34:09 2019 +0100
@@ -1402,6 +1402,8 @@
 						if (((unit->beer_temperature - unit->air_temperature) / 1000.0) < (unit->prof_peak_rel - 0.5)) {
 						    unit->prof_primary_done = time(NULL);
 						    syslog(LOG_NOTICE, "Profile `%s' primary fermentation is ready (cooler mode)", unit->profile_name);
+						    if (! unit->event_msg)
+							unit->event_msg = xstrcpy((char *)"Primary peak");
 						}
 					    } else {
 					    	/*
@@ -1411,6 +1413,8 @@
 					    	if ((unit->beer_temperature / 1000.0) <  (unit->prof_peak_abs - 0.5)) {
 						    unit->prof_primary_done = time(NULL);
 						    syslog(LOG_NOTICE, "Profile `%s' primary fermentation is ready (free rise mode)", unit->profile_name);
+						    if (! unit->event_msg)
+							unit->event_msg = xstrcpy((char *)"Primary peak");
 					    	}
 					    }
 					}
@@ -1497,6 +1501,8 @@
 					    unit->prof_percent = 100;
 					    syslog(LOG_NOTICE, "Profile `%s' is done", unit->profile_name);
 					    unit->mqtt_flag |= MQTT_FLAG_DATA;
+					    if (! unit->event_msg)
+						unit->event_msg = xstrcpy((char *)"Profile finished");
 					}
 					break;
 
@@ -1685,7 +1691,6 @@
 				    pub_domoticz_output(unit->heater_idx, unit->heater_state);
 				    if (unit->heater_address) {
 					unit->mqtt_flag |= MQTT_FLAG_DATA;
-					unit->mqtt_flag |= MQTT_FLAG_DLOG;
 				    }
 				}
 			    }
@@ -1699,7 +1704,6 @@
 				    pub_domoticz_output(unit->heater_idx, unit->heater_state);
 				    if (unit->heater_address) {
 					unit->mqtt_flag |= MQTT_FLAG_DATA;
-					unit->mqtt_flag |= MQTT_FLAG_DLOG;
 				    }
 				}
 			    }
@@ -1723,7 +1727,6 @@
 				    pub_domoticz_output(unit->cooler_idx, unit->cooler_state);
 				    if (unit->cooler_address) {
 					unit->mqtt_flag |= MQTT_FLAG_DATA;
-				    	unit->mqtt_flag |= MQTT_FLAG_DLOG;
 				    }
 				}
 			    }
@@ -1737,7 +1740,6 @@
 				    pub_domoticz_output(unit->cooler_idx, unit->cooler_state);
 				    if (unit->cooler_address) {
 					unit->mqtt_flag |= MQTT_FLAG_DATA;
-					unit->mqtt_flag |= MQTT_FLAG_DLOG;
 				    }
 				}
 			    }
@@ -1765,7 +1767,6 @@
 				    pub_domoticz_output(unit->fan_idx, unit->fan_state);
 				    if (unit->fan_address) {
 					unit->mqtt_flag |= MQTT_FLAG_DATA;
-					unit->mqtt_flag |= MQTT_FLAG_DLOG;
 				    }
 			    	}
 			    }
@@ -1779,7 +1780,6 @@
 				    pub_domoticz_output(unit->fan_idx, unit->fan_state);
 				    if (unit->fan_address) {
 					unit->mqtt_flag |= MQTT_FLAG_DATA;
-					unit->mqtt_flag |= MQTT_FLAG_DLOG;
 				    }
 				}
 			    }
@@ -1854,13 +1854,6 @@
 			publishDDeath(unit);
 			unit->mqtt_flag &= ~MQTT_FLAG_DEATH;
 		    }
-		    if (unit->mqtt_flag & MQTT_FLAG_DLOG) {
-			publishDLog(unit);
-			if (unit->event_msg)
-			    free(unit->event_msg);
-			unit->event_msg = NULL;
-			unit->mqtt_flag &= ~MQTT_FLAG_DLOG;
-		    }
 		}
 
 		/*
@@ -1908,15 +1901,9 @@
 			snprintf(use_fan, 39, "NA");
 			snprintf(room_temp, 39, "NA");
 
-			if (unit->mode == UNITMODE_BEER) {
-			    snprintf(target_lo, 39, "%.1f", unit->beer_set);
-			    snprintf(target_hi, 39, "%.1f", unit->beer_set);
-			} else if (unit->mode == UNITMODE_FRIDGE) {
-			    snprintf(target_lo, 39, "%.1f", unit->fridge_set);
-			    snprintf(target_hi, 39, "%.1f", unit->fridge_set);
-			} else if (unit->mode == UNITMODE_PROFILE) {
-			    snprintf(target_lo, 39, "%.1f", unit->prof_target_lo);
-			    snprintf(target_hi, 39, "%.1f", unit->prof_target_hi);
+			if ((unit->mode == UNITMODE_BEER) || (unit->mode == UNITMODE_FRIDGE) || (unit->mode == UNITMODE_PROFILE)) {
+			    snprintf(target_lo, 39, "%.1f", unit->PID_heat->SetP);
+			    snprintf(target_hi, 39, "%.1f", unit->PID_cool->SetP);
 			}
 
 			if (unit->heater_address) {
@@ -1950,17 +1937,15 @@
 			logger(filename, buf);
 			free(filename);
 			filename = NULL;
+
+			publishDLog(unit);
+			if (unit->event_msg)
+			    free(unit->event_msg);
+			unit->event_msg = NULL;
 		    }
 		}
 
 		minutes++;
-		if ((minutes % 5) == 0) {
-		    for (unit = Config.units; unit; unit = unit->next) {
-			if (unit->mode != UNITMODE_OFF) {
-			    unit->mqtt_flag |= MQTT_FLAG_DLOG;
-			}
-		    }
-		}
 		if (minutes == 60) {
 		    minutes = 0;
 		    /*
@@ -2006,7 +1991,7 @@
 	device_out(unit->light_address, unit->light_state);
 	if (unit->mode != UNITMODE_OFF) {
 	    /*
-	     * If unit ia active, publish we are dying.
+	     * If unit is active, publish we are dying.
 	     */
 	    unit->mqtt_flag = MQTT_FLAG_DATA;
 	    publishDData(unit);
--- a/thermferm/thermferm.h	Sat Jan 19 22:07:42 2019 +0100
+++ b/thermferm/thermferm.h	Sun Jan 20 13:34:09 2019 +0100
@@ -236,7 +236,6 @@
 #define	MQTT_FLAG_DATA		0x0001		/* Show updated data values	*/
 #define	MQTT_FLAG_BIRTH		0x0002		/* Show birth instead of data	*/
 #define MQTT_FLAG_DEATH		0x0004		/* Show death of a unit		*/
-#define	MQTT_FLAG_DLOG		0x0008		/* Send DLOG message		*/
 
 
 

mercurial