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 = current_step = tot_minutes = 0; |
1128 time_until_now = current_step = 0; |
1129 run_seconds = (int)(now - unit->prof_started - unit->prof_paused); |
1129 run_seconds = (int)(now - unit->prof_started - unit->prof_paused); |
1130 run_minutes = run_seconds / 60; |
1130 run_minutes = run_seconds / 60; |
1131 run_hours = run_minutes / 60; |
1131 run_hours = run_minutes / 60; |
1132 if (debug) |
1132 if (debug) |
1133 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); |
|
1134 |
|
1135 /* |
|
1136 * See how long this profile will take |
|
1137 */ |
|
1138 tot_minutes = 0; |
|
1139 for (step = profile->steps; step; step = step->next) { |
|
1140 tot_minutes += ((step->steptime + step->resttime) * 60); |
|
1141 } |
1134 |
1142 |
1135 valid_step = FALSE; |
1143 valid_step = FALSE; |
1136 for (step = profile->steps; step; step = step->next) { |
1144 for (step = profile->steps; step; step = step->next) { |
1137 /* |
1145 /* |
1138 * step->steptime |
1146 * step->steptime |
1139 * step->resttime |
1147 * step->resttime |
1140 * step->target |
1148 * step->target |
1141 */ |
1149 */ |
1142 current_step++; |
1150 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))) { |
1151 if ((run_hours >= time_until_now) && (run_hours < (time_until_now + step->steptime + step->resttime))) { |
1145 /* |
1152 /* |
1146 * This is our current step |
1153 * This is our current step |
1147 */ |
1154 */ |
1148 valid_step = TRUE; |
1155 valid_step = TRUE; |