thermferm/thermferm.c

changeset 276
a19cc3770f09
parent 275
a86c702c2e4f
child 277
6f9a7cca8f19
equal deleted inserted replaced
275:a86c702c2e4f 276:a19cc3770f09
831 time_t now, last = (time_t)0; 831 time_t now, last = (time_t)0;
832 units_list *unit; 832 units_list *unit;
833 profiles_list *profile; 833 profiles_list *profile;
834 prof_step *step; 834 prof_step *step;
835 int rc, run = 1, seconds = 0, minutes = 0, piddelay = 0, temp, deviation; 835 int rc, run = 1, seconds = 0, minutes = 0, piddelay = 0, temp, deviation;
836 int run_seconds, run_minutes, run_hours; 836 int run_seconds, run_minutes, run_hours, tot_minutes;
837 float err = 0.0, sp, pv, P_err, D_err, Out; 837 float err = 0.0, sp, pv, P_err, D_err, Out;
838 #ifdef HAVE_WIRINGPI_H 838 #ifdef HAVE_WIRINGPI_H
839 struct tm *tm; 839 struct tm *tm;
840 int row, key; 840 int row, key;
841 #else 841 #else
1123 /* 1123 /*
1124 * Calculate current profile step en desired temperature. 1124 * Calculate current profile step en desired temperature.
1125 * When all done, set state to PROFILE_DONE. 1125 * When all done, set state to PROFILE_DONE.
1126 */ 1126 */
1127 previous_target = profile->inittemp; 1127 previous_target = profile->inittemp;
1128 time_until_now = 0; 1128 time_until_now = current_step = tot_minutes = 0;
1129 current_step = 0;
1130 run_seconds = (int)(now - unit->prof_started - unit->prof_paused); 1129 run_seconds = (int)(now - unit->prof_started - unit->prof_paused);
1131 run_minutes = run_seconds / 60; 1130 run_minutes = run_seconds / 60;
1132 run_hours = run_minutes / 60; 1131 run_hours = run_minutes / 60;
1133 if (debug) 1132 if (debug)
1134 fprintf(stdout, "run_HMS=%d,%d,%d ", run_hours, run_minutes, run_seconds); 1133 fprintf(stdout, "run_HMS=%d,%d,%d ", run_hours, run_minutes, run_seconds);
1139 * step->steptime 1138 * step->steptime
1140 * step->resttime 1139 * step->resttime
1141 * step->target 1140 * step->target
1142 */ 1141 */
1143 current_step++; 1142 current_step++;
1143 tot_minutes += ((step->steptime + step->resttime) * 60);
1144 if ((run_hours >= time_until_now) && (run_hours < (time_until_now + step->steptime + step->resttime))) { 1144 if ((run_hours >= time_until_now) && (run_hours < (time_until_now + step->steptime + step->resttime))) {
1145 /* 1145 /*
1146 * This is our current step 1146 * This is our current step
1147 */ 1147 */
1148 valid_step = TRUE; 1148 valid_step = TRUE;
1167 } 1167 }
1168 if (debug) 1168 if (debug)
1169 fprintf(stdout, " %s %02d:%02d\n", valid_step ? "TRUE":"FALSE", minutes, seconds); 1169 fprintf(stdout, " %s %02d:%02d\n", valid_step ? "TRUE":"FALSE", minutes, seconds);
1170 1170
1171 if (valid_step == TRUE) { 1171 if (valid_step == TRUE) {
1172 if (((minutes == 15) || (minutes == 45)) && (seconds == 1)) { 1172 if (((minutes == 10) || (minutes == 40)) && (seconds == 1)) {
1173 syslog(LOG_NOTICE, "Profile `%s' running %dd %02d:%02d in step %d, target %.3f degrees", 1173 syslog(LOG_NOTICE, "Profile `%s' running %dd %02d:%02d in step %d, %d%% done, target %.3f degrees",
1174 profile->name, run_hours / 24, run_hours % 24, run_minutes % 60, current_step, unit->prof_target); 1174 profile->name, run_hours / 24, run_hours % 24, run_minutes % 60, current_step,
1175 (100 * run_minutes) / tot_minutes, unit->prof_target);
1175 } 1176 }
1176 } else { 1177 } else {
1177 /* 1178 /*
1178 * No more steps to do 1179 * No more steps to do
1179 */ 1180 */

mercurial