thermferm/devices.c

changeset 262
d0014ccec615
parent 259
b7c967359771
child 268
dda91dfa4aa8
--- a/thermferm/devices.c	Sat Aug 23 12:48:55 2014 +0200
+++ b/thermferm/devices.c	Sat Aug 23 23:38:18 2014 +0200
@@ -474,6 +474,9 @@
 #endif
 {
     devices_list	*device;
+#ifdef USE_SIMULATOR
+    simulator_list	*simulator;
+#endif
     char		*addr = NULL, line[60], *p = NULL;
     FILE		*fp;
     int			temp, rc;
@@ -610,15 +613,18 @@
 #ifdef HAVE_WIRINGPI_H
 			piLock(LOCK_DEVICES);
 #endif
-			if (device->subdevice == 0) {
-			    device->value = 20000;
-			    device->timestamp = time(NULL);
-			} else if (device->subdevice == 1) {
-			    device->value = 20125;
-			    device->timestamp = time(NULL);
-			} else if (device->subdevice == 2) {
-			    device->value = 20250;
-			    device->timestamp = time(NULL);
+			if (Config.simulators) {
+			    simulator = Config.simulators;
+			    if (device->subdevice == 0) {
+			    	device->value = (int)(simulator->room_temperature * 1000);
+			    	device->timestamp = time(NULL);
+			    } else if (device->subdevice == 1) {
+			    	device->value = (int)(simulator->air_temperature * 1000);
+			    	device->timestamp = time(NULL);
+			    } else if (device->subdevice == 2) {
+			    	device->value = (int)(simulator->beer_temperature * 1000);
+			    	device->timestamp = time(NULL);
+			    }
 			}
 #ifdef HAVE_WIRINGPI_H
 			piUnlock(LOCK_DEVICES);

mercurial