# HG changeset patch # User Michiel Broek # Date 1407414011 -7200 # Node ID cc2b04d4db998a78a33c17b0e128c9cf4608a609 # Parent 4fc17ef4593f9314360429ae8d1ba063709cbc85 Init logfile when a unit is turned on. Added comments for profile processing. diff -r 4fc17ef4593f -r cc2b04d4db99 thermferm/server.c --- a/thermferm/server.c Tue Aug 05 22:50:33 2014 +0200 +++ b/thermferm/server.c Thu Aug 07 14:20:11 2014 +0200 @@ -1230,6 +1230,9 @@ } else if (val && (strcmp(kwd, (char *)"MODE") == 0)) { for (i = 0; i < 5; i++) { if (strcmp(val, UNITMODE[i]) == 0) { + /* Initialize log if the unit is turned on */ + if ((unit->mode == UNITMODE_OFF) && (i != UNITMODE_OFF)) + initlog(unit->name); unit->mode = i; /* Allways turn everything off after a mode change */ unit->heater_state = unit->cooler_state = unit->fan_state = 0; diff -r 4fc17ef4593f -r cc2b04d4db99 thermferm/thermferm.c --- a/thermferm/thermferm.c Tue Aug 05 22:50:33 2014 +0200 +++ b/thermferm/thermferm.c Thu Aug 07 14:20:11 2014 +0200 @@ -335,11 +335,11 @@ if (my_shutdown) run = 0; - /* - * Timed schedulers - */ now = time(NULL); if (now != last) { + /* + * Each second + */ last = now; seconds++; @@ -413,6 +413,22 @@ } /* + * Handle profile + */ + if ((unit->mode == UNITMODE_PROFILE) && (unit->profile)) { + /* + * unit->profile - uuid of the selected profile. + * unit->prof_started - start time or 0 if not yet running. + * unit->prof_state - PROFILE_OFF|PROFILE_PAUSE|PROFILE_RUN|PROFILE_DONE + * unit->prof_target - Calculated target temperature. + */ + // off. Target is ?? + // pause Target is keep target. + // run. Target must be calculated using steps. + // done. Target is last target. + } + + /* * Manual switching */ if (unit->mode == UNITMODE_NONE) {