thermferm/devices.c

changeset 262
d0014ccec615
parent 259
b7c967359771
child 268
dda91dfa4aa8
equal deleted inserted replaced
261:e4341cfbc2a8 262:d0014ccec615
472 #else 472 #else
473 void *my_devices_loop(void *threadid) 473 void *my_devices_loop(void *threadid)
474 #endif 474 #endif
475 { 475 {
476 devices_list *device; 476 devices_list *device;
477 #ifdef USE_SIMULATOR
478 simulator_list *simulator;
479 #endif
477 char *addr = NULL, line[60], *p = NULL; 480 char *addr = NULL, line[60], *p = NULL;
478 FILE *fp; 481 FILE *fp;
479 int temp, rc; 482 int temp, rc;
480 #ifdef HAVE_WIRINGPI_H 483 #ifdef HAVE_WIRINGPI_H
481 time_t now; 484 time_t now;
608 #ifdef USE_SIMULATOR 611 #ifdef USE_SIMULATOR
609 case DEVTYPE_SIM: 612 case DEVTYPE_SIM:
610 #ifdef HAVE_WIRINGPI_H 613 #ifdef HAVE_WIRINGPI_H
611 piLock(LOCK_DEVICES); 614 piLock(LOCK_DEVICES);
612 #endif 615 #endif
613 if (device->subdevice == 0) { 616 if (Config.simulators) {
614 device->value = 20000; 617 simulator = Config.simulators;
615 device->timestamp = time(NULL); 618 if (device->subdevice == 0) {
616 } else if (device->subdevice == 1) { 619 device->value = (int)(simulator->room_temperature * 1000);
617 device->value = 20125; 620 device->timestamp = time(NULL);
618 device->timestamp = time(NULL); 621 } else if (device->subdevice == 1) {
619 } else if (device->subdevice == 2) { 622 device->value = (int)(simulator->air_temperature * 1000);
620 device->value = 20250; 623 device->timestamp = time(NULL);
621 device->timestamp = time(NULL); 624 } else if (device->subdevice == 2) {
625 device->value = (int)(simulator->beer_temperature * 1000);
626 device->timestamp = time(NULL);
627 }
622 } 628 }
623 #ifdef HAVE_WIRINGPI_H 629 #ifdef HAVE_WIRINGPI_H
624 piUnlock(LOCK_DEVICES); 630 piUnlock(LOCK_DEVICES);
625 #endif 631 #endif
626 break; 632 break;

mercurial