thermferm/devices.c

branch
stable
changeset 601
44d41db09466
parent 596
e3d3cde32847
child 643
586d376ab629
equal deleted inserted replaced
590:1ff1a95a7614 601:44d41db09466
25 #include "rc-switch.h" 25 #include "rc-switch.h"
26 #include "panel.h" 26 #include "panel.h"
27 #include "xutil.h" 27 #include "xutil.h"
28 28
29 29
30 extern int debug;
31 extern sys_config Config; 30 extern sys_config Config;
32 extern int my_shutdown; 31 extern int my_shutdown;
33 32
34 #ifdef USE_SIMULATOR 33 #ifdef USE_SIMULATOR
35 34
311 enableTransmit(device->gpiopin); 310 enableTransmit(device->gpiopin);
312 rc = toggleSwitch(buf); 311 rc = toggleSwitch(buf);
313 disableTransmit(); 312 disableTransmit();
314 piLock(LOCK_DEVICES); 313 piLock(LOCK_DEVICES);
315 syslog(LOG_NOTICE, "RC433 command %s rc=%d", buf, rc); 314 syslog(LOG_NOTICE, "RC433 command %s rc=%d", buf, rc);
316 if (debug)
317 fprintf(stdout, "RC433 command %s rc=%d\n", buf, rc);
318 device->value = value; 315 device->value = value;
319 device->timestamp = time(NULL); 316 device->timestamp = time(NULL);
320 piUnlock(LOCK_DEVICES); 317 piUnlock(LOCK_DEVICES);
321 return rc; 318 return rc;
322 } 319 }
348 output = 0xff; 345 output = 0xff;
349 } 346 }
350 347
351 if ((write_w1(device->address, (char *)"output", output)) == 0) { 348 if ((write_w1(device->address, (char *)"output", output)) == 0) {
352 syslog(LOG_NOTICE, "DS2413 PIO%c value=%d (%s)", (device->subdevice == 0) ? 'A' : 'B', (value == 0) ? 0 : 1, device->comment); 349 syslog(LOG_NOTICE, "DS2413 PIO%c value=%d (%s)", (device->subdevice == 0) ? 'A' : 'B', (value == 0) ? 0 : 1, device->comment);
353 if (debug)
354 fprintf(stdout, "DS2413 PIO%c value=%d (%s)\n", (device->subdevice == 0) ? 'A' : 'B', (value == 0) ? 0 : 1, device->comment);
355 device->value = (value == 0) ? 0 : 1; 350 device->value = (value == 0) ? 0 : 1;
356 device->timestamp = time(NULL); 351 device->timestamp = time(NULL);
357 } 352 }
358 } 353 }
359 } 354 }
363 if ((device->type == DEVTYPE_SIM) && (device->direction == DEVDIR_OUT_BIN) && (device->present == DEVPRESENT_YES)) { 358 if ((device->type == DEVTYPE_SIM) && (device->direction == DEVDIR_OUT_BIN) && (device->present == DEVPRESENT_YES)) {
364 if ((strcmp((char *)"SimCooler", device->address) == 0) || (strcmp((char *)"SimHeater", device->address) == 0) || 359 if ((strcmp((char *)"SimCooler", device->address) == 0) || (strcmp((char *)"SimHeater", device->address) == 0) ||
365 (strcmp((char *)"SimFan" , device->address) == 0) || (strcmp((char *)"SimLight" , device->address) == 0)) { 360 (strcmp((char *)"SimFan" , device->address) == 0) || (strcmp((char *)"SimLight" , device->address) == 0)) {
366 if (value != device->value) { 361 if (value != device->value) {
367 syslog(LOG_NOTICE, "SIM %s value=%d", device->address, value); 362 syslog(LOG_NOTICE, "SIM %s value=%d", device->address, value);
368 if (debug)
369 fprintf(stdout, "SIM %s value=%d\n", device->address, value);
370 } 363 }
371 device->value = value; 364 device->value = value;
372 device->timestamp = time(NULL); 365 device->timestamp = time(NULL);
373 if (strcmp((char *)"SimCooler", device->address) == 0) 366 if (strcmp((char *)"SimCooler", device->address) == 0)
374 SIMcooling = value; 367 SIMcooling = value;

mercurial