# HG changeset patch # User Michiel Broek # Date 1409749329 -7200 # Node ID 9e6fb5aed61802decd8b2917fdbeae8bf4917833 # Parent affe4d2adc94e9ba89f9252104f84e47161ce96b Profile progress is visible in the web interface diff -r affe4d2adc94 -r 9e6fb5aed618 thermferm/rdconfig.c --- a/thermferm/rdconfig.c Tue Sep 02 16:54:18 2014 +0200 +++ b/thermferm/rdconfig.c Wed Sep 03 15:02:09 2014 +0200 @@ -856,6 +856,7 @@ unit->idle_rangeH = 1.0; unit->idle_rangeL = -1.0; unit->prof_started = unit->prof_paused = (time_t)0; + unit->prof_percent = 0; unit->PID_err_old = unit->PID_I_err = 0.0; cur = cur->xmlChildrenNode; diff -r affe4d2adc94 -r 9e6fb5aed618 thermferm/server.c --- a/thermferm/server.c Tue Sep 02 16:54:18 2014 +0200 +++ b/thermferm/server.c Wed Sep 03 15:02:09 2014 +0200 @@ -1458,6 +1458,7 @@ unit->idle_rangeH = 1.0; unit->idle_rangeL = -1.0; unit->prof_started = unit->prof_paused = (time_t)0; + unit->prof_percent = 0; unit->PID_err_old = unit->PID_I_err = 0.0; /* @@ -1546,7 +1547,11 @@ srv_send((char *)"BEER_SET,%.1f", unit->beer_set); srv_send((char *)"PROFILE,%s", unit->profile); srv_send((char *)"PROF_STARTED,%d", (int)unit->prof_started); - srv_send((char *)"PROF_STATE,%s", PROFSTATE[unit->prof_state]); + if (unit->prof_state == PROFILE_RUN) { + srv_send((char *)"PROF_STATE,%s %d%%", PROFSTATE[unit->prof_state], unit->prof_percent); + } else { + srv_send((char *)"PROF_STATE,%s", PROFSTATE[unit->prof_state]); + } srv_send((char *)"PROF_TARGET,%.3f", unit->prof_target); srv_send((char *)"TEMP_SET_MIN,%.1f", unit->temp_set_min); srv_send((char *)"TEMP_SET_MAX,%.1f", unit->temp_set_max); diff -r affe4d2adc94 -r 9e6fb5aed618 thermferm/thermferm.c --- a/thermferm/thermferm.c Tue Sep 02 16:54:18 2014 +0200 +++ b/thermferm/thermferm.c Wed Sep 03 15:02:09 2014 +0200 @@ -1112,6 +1112,7 @@ switch (unit->prof_state) { case PROFILE_OFF: unit->prof_target = profile->inittemp; + unit->prof_percent = 0; break; case PROFILE_PAUSE: /* @@ -1176,16 +1177,18 @@ fprintf(stdout, " %s %02d:%02d\n", valid_step ? "TRUE":"FALSE", minutes, seconds); if (valid_step == TRUE) { + unit->prof_percent = (100 * run_minutes) / tot_minutes; if (((minutes == 10) || (minutes == 40)) && (seconds == 1)) { syslog(LOG_NOTICE, "Profile `%s' running %dd %02d:%02d in step %d, %d%% done, target %.3f degrees", profile->name, run_hours / 24, run_hours % 24, run_minutes % 60, current_step, - (100 * run_minutes) / tot_minutes, unit->prof_target); + unit->prof_percent, unit->prof_target); } } else { /* * No more steps to do */ unit->prof_state = PROFILE_DONE; + unit->prof_percent = 100; syslog(LOG_NOTICE, "Profile `%s' is done", profile->name); } break; @@ -1201,6 +1204,7 @@ previous_target = step->target; } unit->prof_target = previous_target; + unit->prof_percent = 100; break; } /* switch */ } diff -r affe4d2adc94 -r 9e6fb5aed618 thermferm/thermferm.h --- a/thermferm/thermferm.h Tue Sep 02 16:54:18 2014 +0200 +++ b/thermferm/thermferm.h Wed Sep 03 15:02:09 2014 +0200 @@ -138,6 +138,7 @@ int prof_state; /* Profile OFF|PAUSE|RUN|DONE */ float prof_target; /* Profile current target temp */ time_t prof_paused; /* Profile total pause time */ + int prof_percent; /* Profile percentage done */ float PID_I_err; /* PID Intergal error */ float PID_err_old; /* PID old error value */ } units_list; diff -r affe4d2adc94 -r 9e6fb5aed618 www-thermferm/getstate.php --- a/www-thermferm/getstate.php Tue Sep 02 16:54:18 2014 +0200 +++ b/www-thermferm/getstate.php Wed Sep 03 15:02:09 2014 +0200 @@ -26,7 +26,7 @@ if (isset($_GET["uuid"])) $uuid = $_GET["uuid"]; else - $uuid = "0e261929-486d-4117-897a-2b23509157c6"; + $uuid = "48c9ae27-3f58-41c9-ae4b-1d57b249c45a"; $answer = send_cmd('UNIT GET '.$uuid); $arr = explode("\r\n", $answer); @@ -40,6 +40,7 @@ $fridge_set = "NA"; $beer_set = "NA"; $heater = $cooler = $fan = "no"; +$prof_state = "OFF"; if (startsWith($arr[0], "213")) { @@ -83,6 +84,8 @@ $target_temperature = $f[1]; if (($f[0] == "PROF_TARGET") && ($mode == "PROFILE")) $target_temperature = $f[1]; + if (($f[0] == "PROF_STATE") && ($mode == "PROFILE")) + $prof_state = $f[1]; $j++; } } @@ -137,7 +140,8 @@ 'led3' => $led3, 'sw1' => $sw1, 'sw2' => $sw2, - 'sw3' => $sw3 + 'sw3' => $sw3, + 'profile_state' => $prof_state ); diff -r affe4d2adc94 -r 9e6fb5aed618 www-thermferm/liveview.php --- a/www-thermferm/liveview.php Tue Sep 02 16:54:18 2014 +0200 +++ b/www-thermferm/liveview.php Wed Sep 03 15:02:09 2014 +0200 @@ -194,6 +194,8 @@ $outstr .= ' $("#load_sw1_'.$unr.'").html(data.sw1);'.PHP_EOL; $outstr .= ' $("#load_sw2_'.$unr.'").html(data.sw2);'.PHP_EOL; $outstr .= ' $("#load_sw3_'.$unr.'").html(data.sw3);'.PHP_EOL; + if ($mode == "PROFILE") + $outstr .= ' $("#prof_state_'.$unr.'").html(data.profile_state);'.PHP_EOL; $outstr .= ' });'.PHP_EOL; $outstr .= ' }, 10000);'.PHP_EOL; $outstr .= ' });'.PHP_EOL; @@ -268,7 +270,7 @@ } } $outstr .= '
Profile: '.$prof_name.'
'.PHP_EOL; - $outstr .= '
State: '.$prof_state.'
'.PHP_EOL; + $outstr .= '
State: '.$prof_state.'
'.PHP_EOL; $outstr .= '
'.PHP_EOL; if ($prof_state == "OFF") { @@ -292,7 +294,7 @@ if ($profile != "(null)") $outstr .= ' '.PHP_EOL; - } else if ($prof_state == "RUN") { + } else if (startsWith($prof_state, "RUN")) { $outstr .= ' '.PHP_EOL; $outstr .= ' '.PHP_EOL; $outstr .= ' '.PHP_EOL; @@ -304,7 +306,6 @@ $outstr .= ' '.PHP_EOL; $outstr .= ' '.PHP_EOL; } - //$outstr .= ' '.PHP_EOL; $outstr .= ' '.PHP_EOL; $outstr .= '
'.PHP_EOL; }