thermferm/server.c

changeset 79
eb9dd60aa791
parent 77
143077e54255
child 80
81bf78a7618e
--- a/thermferm/server.c	Wed Jun 25 17:18:01 2014 +0200
+++ b/thermferm/server.c	Wed Jun 25 19:42:03 2014 +0200
@@ -70,6 +70,44 @@
 
 
 
+int unit_add(char *name)
+{
+    units_list	*unit, *tmp;
+    uuid_t	uu;
+
+    unit = (units_list *)malloc(sizeof(units_list));
+    unit->next = NULL;
+    unit->uuid = malloc(37);
+    uuid_generate(uu);
+    uuid_unparse(uu, unit->uuid);
+    unit->name = xstrcpy(name);
+    unit->air_address = unit->beer_address = unit->io1_address = unit->io2_address = unit->profile = NULL;
+    unit->volume = 0.0;
+    unit->heater_available = unit->cooler_available = unit->fan_available = FALSE;
+    unit->air_temp = unit->beer_temp = unit->beer_set = unit->fridge_set = 20.0;
+    unit->heater_state = unit->cooler_state = unit->fan_state = unit->door_state = unit->mode = 0;
+    unit->temp_set_min = 1.0;
+    unit->temp_set_max = 30.0;
+    unit->idle_rangeH = 1.0;
+    unit->idle_rangeL = -1.0;
+    unit->prof_started = (time_t)0;
+
+
+    if (Config.units == NULL) {
+	Config.units = unit;
+    } else {
+	for (tmp = Config.units; tmp; tmp = tmp->next) {
+	    if (tmp->next == NULL) {
+		tmp->next = unit;
+		break;
+	    }
+	}
+    }
+    return 0;
+}
+
+
+
 /*
  * Send message to client
  */

mercurial