thermferm/thermferm.c

changeset 352
a8e106c95db4
parent 350
7283561977b1
child 355
8f946f9d125a
equal deleted inserted replaced
351:d8c410c320db 352:a8e106c95db4
1362 if (unit->door_state && unit->light_state) { 1362 if (unit->door_state && unit->light_state) {
1363 if (unit->light_wait > 0) { 1363 if (unit->light_wait > 0) {
1364 unit->light_wait--; 1364 unit->light_wait--;
1365 } else { 1365 } else {
1366 unit->light_state = 0; 1366 unit->light_state = 0;
1367 syslog(LOG_NOTICE, "Lights On => Off"); 1367 syslog(LOG_NOTICE, "Unit `%s' lights On => Off", unit->name);
1368 } 1368 }
1369 } 1369 }
1370 if (!unit->door_state && !unit->light_state) { 1370 if (!unit->door_state && !unit->light_state) {
1371 unit->light_wait = unit->light_delay; /* No delay to turn lights on */ 1371 unit->light_wait = unit->light_delay; /* No delay to turn lights on */
1372 unit->light_state = 1; 1372 unit->light_state = 1;
1373 syslog(LOG_NOTICE, "Lights Off => On"); 1373 syslog(LOG_NOTICE, "Unit `%s' lights Off => On", unit->name);
1374 } 1374 }
1375 device_out(unit->light_address, unit->light_state); 1375 device_out(unit->light_address, unit->light_state);
1376 } 1376 }
1377 1377
1378 /* 1378 /*
1438 } else if (P_err < 0) { 1438 } else if (P_err < 0) {
1439 Out = -100.0; 1439 Out = -100.0;
1440 } else { 1440 } else {
1441 Out = 0.0; 1441 Out = 0.0;
1442 } 1442 }
1443 if (((Out >= 1) && unit->heater_address) || ((Out <= -1) && unit->cooler_address) || 1443 // if (((Out >= 1) && unit->heater_address) || ((Out <= -1) && unit->cooler_address) ||
1444 (seconds == 60) || unit->heater_state || unit->cooler_state) { 1444 // (seconds == 60) || unit->heater_state || unit->cooler_state) {
1445 syslog(LOG_NOTICE, "sp=%.2f pv=%.2f P_err=%.2f Out=%.2f", 1445 // syslog(LOG_NOTICE, "sp=%.2f pv=%.2f P_err=%.2f Out=%.2f", sp, pv, P_err, Out);
1446 sp, pv, P_err, Out); 1446 // }
1447 }
1448 } 1447 }
1449 1448
1450 if (unit->heater_address && ! unit->cooler_state) { 1449 if (unit->heater_address && ! unit->cooler_state) {
1451 if (Out >= 1) { 1450 if (Out >= 1) {
1452 if (unit->heater_wait < unit->heater_delay) { 1451 if (unit->heater_wait < unit->heater_delay) {
1453 unit->heater_wait++; 1452 unit->heater_wait++;
1454 syslog(LOG_NOTICE, "heater_wait + %d/%d", unit->heater_wait, unit->heater_delay); 1453 // syslog(LOG_NOTICE, "heater_wait + %d/%d", unit->heater_wait, unit->heater_delay);
1455 } else { 1454 } else {
1456 int power = round(Out); 1455 int power = round(Out);
1457 if (unit->heater_state != power) { 1456 if (unit->heater_state != power) {
1458 syslog(LOG_NOTICE, "Heater %d%% => %d%%", unit->heater_state, power); 1457 syslog(LOG_NOTICE, "Unit `%s' heater %d%% => %d%%", unit->name, unit->heater_state, power);
1459 unit->heater_state = power; 1458 unit->heater_state = power;
1460 } 1459 }
1461 } 1460 }
1462 } else { 1461 } else {
1463 if (unit->heater_wait > 0) { 1462 if (unit->heater_wait > 0) {
1464 unit->heater_wait--; 1463 unit->heater_wait--;
1465 syslog(LOG_NOTICE, "heater_wait - %d/%d", unit->heater_wait, unit->heater_delay); 1464 // syslog(LOG_NOTICE, "heater_wait - %d/%d", unit->heater_wait, unit->heater_delay);
1466 } else { 1465 } else {
1467 if (unit->heater_state) { 1466 if (unit->heater_state) {
1468 syslog(LOG_NOTICE, "Heater On => Off"); 1467 syslog(LOG_NOTICE, "Unit `%s' heater On => Off", unit->name);
1469 unit->heater_state = 0; 1468 unit->heater_state = 0;
1470 } 1469 }
1471 } 1470 }
1472 } 1471 }
1473 if (unit->door_state) 1472 if (unit->door_state)
1478 1477
1479 if (unit->cooler_address && ! unit->heater_state) { 1478 if (unit->cooler_address && ! unit->heater_state) {
1480 if (Out <= -1) { 1479 if (Out <= -1) {
1481 if (unit->cooler_wait < unit->cooler_delay) { 1480 if (unit->cooler_wait < unit->cooler_delay) {
1482 unit->cooler_wait++; 1481 unit->cooler_wait++;
1483 syslog(LOG_NOTICE, "cooler_wait + %d/%d", unit->cooler_wait, unit->cooler_delay); 1482 // syslog(LOG_NOTICE, "cooler_wait + %d/%d", unit->cooler_wait, unit->cooler_delay);
1484 } else { 1483 } else {
1485 int power = round(0 - Out); 1484 int power = round(0 - Out);
1486 if (unit->cooler_state != power) { 1485 if (unit->cooler_state != power) {
1487 syslog(LOG_NOTICE, "Cooler %d%% => %d%%", unit->cooler_state, power); 1486 syslog(LOG_NOTICE, "Unit `%s' cooler %d%% => %d%%", unit->name, unit->cooler_state, power);
1488 unit->cooler_state = power; 1487 unit->cooler_state = power;
1489 } 1488 }
1490 } 1489 }
1491 } else { 1490 } else {
1492 if (unit->cooler_wait > 0) { 1491 if (unit->cooler_wait > 0) {
1493 unit->cooler_wait--; 1492 unit->cooler_wait--;
1494 syslog(LOG_NOTICE, "cooler_wait - %d/%d", unit->cooler_wait, unit->cooler_delay); 1493 // syslog(LOG_NOTICE, "cooler_wait - %d/%d", unit->cooler_wait, unit->cooler_delay);
1495 } else { 1494 } else {
1496 if (unit->cooler_state) { 1495 if (unit->cooler_state) {
1497 syslog(LOG_NOTICE, "Cooler On => Off"); 1496 syslog(LOG_NOTICE, "Unit `%s' cooler On => Off", unit->name);
1498 unit->cooler_state = 0; 1497 unit->cooler_state = 0;
1499 } 1498 }
1500 } 1499 }
1501 } 1500 }
1502 if (unit->door_state) 1501 if (unit->door_state)
1511 * cooling or heating. The Fan has a start/stop delay. 1510 * cooling or heating. The Fan has a start/stop delay.
1512 */ 1511 */
1513 if ((unit->heater_address && unit->heater_state) || (unit->cooler_address && unit->cooler_state)) { 1512 if ((unit->heater_address && unit->heater_state) || (unit->cooler_address && unit->cooler_state)) {
1514 if (unit->fan_wait < unit->fan_delay) { 1513 if (unit->fan_wait < unit->fan_delay) {
1515 unit->fan_wait++; 1514 unit->fan_wait++;
1516 syslog(LOG_NOTICE, "fan_wait + %d/%d", unit->fan_wait, unit->fan_delay); 1515 // syslog(LOG_NOTICE, "fan_wait + %d/%d", unit->fan_wait, unit->fan_delay);
1517 } else { 1516 } else {
1518 if (! unit->fan_state) { 1517 if (! unit->fan_state) {
1519 syslog(LOG_NOTICE, "Fan Off => On"); 1518 syslog(LOG_NOTICE, "Unit `%s' Fan Off => On", unit->name);
1520 unit->fan_state = 100; 1519 unit->fan_state = 100;
1521 } 1520 }
1522 } 1521 }
1523 } else { 1522 } else {
1524 if (unit->fan_wait > 0) { 1523 if (unit->fan_wait > 0) {
1525 unit->fan_wait--; 1524 unit->fan_wait--;
1526 syslog(LOG_NOTICE, "fan_wait - %d/%d", unit->fan_wait, unit->fan_delay); 1525 // syslog(LOG_NOTICE, "fan_wait - %d/%d", unit->fan_wait, unit->fan_delay);
1527 } else { 1526 } else {
1528 if (unit->fan_state) { 1527 if (unit->fan_state) {
1529 syslog(LOG_NOTICE, "Fan On => Off"); 1528 syslog(LOG_NOTICE, "Unit `%s' Fan On => Off", unit->name);
1530 unit->fan_state = 0; 1529 unit->fan_state = 0;
1531 } 1530 }
1532 } 1531 }
1533 } 1532 }
1534 if (unit->door_state) 1533 if (unit->door_state)
1647 unit->heater_wait = unit->cooler_wait = unit->fan_wait = unit->light_wait = 0; 1646 unit->heater_wait = unit->cooler_wait = unit->fan_wait = unit->light_wait = 0;
1648 device_out(unit->heater_address, unit->heater_state); 1647 device_out(unit->heater_address, unit->heater_state);
1649 device_out(unit->cooler_address, unit->cooler_state); 1648 device_out(unit->cooler_address, unit->cooler_state);
1650 device_out(unit->fan_address, unit->fan_state); 1649 device_out(unit->fan_address, unit->fan_state);
1651 device_out(unit->light_address, unit->light_state); 1650 device_out(unit->light_address, unit->light_state);
1652 syslog(LOG_NOTICE, "Stopped unit %s mode %s", unit->name, UNITMODE[unit->mode]); 1651 syslog(LOG_NOTICE, "Unit `%s' stopped in mode %s", unit->name, UNITMODE[unit->mode]);
1653 } 1652 }
1654 1653
1655 if (debug) 1654 if (debug)
1656 fprintf(stdout, (char *)"Out of loop\n"); 1655 fprintf(stdout, (char *)"Out of loop\n");
1657 1656

mercurial