Andrew Boyson / web

Dependents:   oldheating gps motorhome heating

Committer:
andrewboyson
Date:
Tue Apr 16 19:18:27 2019 +0000
Revision:
94:d7226b2c14b6
Parent:
89:615fb951df69
Child:
95:8c9dda8a0caf
Used a class for the utc time to handle both the server 'real' time and a pseudo 'next leap' time. Also split the includes into building blocks so that many of the js scripts could be made up from them.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
andrewboyson 14:c3c43c8faf0e 1 #include <time.h>
andrewboyson 14:c3c43c8faf0e 2
andrewboyson 30:6a08abbe6301 3 #include "http.h"
andrewboyson 30:6a08abbe6301 4 #include "page.h"
andrewboyson 30:6a08abbe6301 5 #include "page-derived.h"
andrewboyson 30:6a08abbe6301 6 #include "http-server.h"
andrewboyson 14:c3c43c8faf0e 7
andrewboyson 14:c3c43c8faf0e 8 void HttpClockHtml()
andrewboyson 14:c3c43c8faf0e 9 {
andrewboyson 14:c3c43c8faf0e 10 HttpOk("text/html; charset=UTF-8", "no-cache", NULL, NULL);
andrewboyson 30:6a08abbe6301 11 PageAddHeader(PageSite, "Clock", "settings.css", "clock.js");
andrewboyson 30:6a08abbe6301 12 PageAddNav(CLOCK_PAGE);
andrewboyson 30:6a08abbe6301 13 PageAddH1(PageSite, "Clock");
andrewboyson 14:c3c43c8faf0e 14
andrewboyson 24:0ed9f1faea96 15 PageAddH2("Status");
andrewboyson 77:4689596a2f3f 16 PageAddAjaxLed("RTC is set" , "ajax-rtc-set" );
andrewboyson 77:4689596a2f3f 17 PageAddAjaxLed("Clock is set" , "ajax-clock-set" );
andrewboyson 77:4689596a2f3f 18 PageAddAjaxLed("External source is ok", "ajax-source-ok" );
andrewboyson 77:4689596a2f3f 19 PageAddAjaxLed("Time synchronised" , "ajax-time-locked");
andrewboyson 77:4689596a2f3f 20 PageAddAjaxLed("Rate synchronised" , "ajax-rate-locked");
andrewboyson 73:4e769dbbf9f2 21
andrewboyson 15:2cea2bbd5046 22 PageAddH2("Server UTC time");
andrewboyson 77:4689596a2f3f 23 HttpAddText("<div id='ajax-date-utc'></div>\r\n");
andrewboyson 14:c3c43c8faf0e 24
andrewboyson 14:c3c43c8faf0e 25 PageAddH2("Server local time");
andrewboyson 77:4689596a2f3f 26 HttpAddText("<div id='ajax-date-pc'></div>\r\n");
andrewboyson 14:c3c43c8faf0e 27
andrewboyson 24:0ed9f1faea96 28 PageAddH2("Server - PC (ms)");
andrewboyson 77:4689596a2f3f 29 HttpAddText("<div id='ajax-date-diff'></div>\r\n");
andrewboyson 14:c3c43c8faf0e 30
andrewboyson 24:0ed9f1faea96 31 PageAddH2("UTC");
andrewboyson 94:d7226b2c14b6 32 PageAddAjaxInputToggle("Enable epoch change" , "ajax-leap-enable" , "chg-clock-leap-enable" );
andrewboyson 94:d7226b2c14b6 33 PageAddAjaxInputToggle("Direction of next epoch" , "ajax-leap-forward" , "chg-clock-leap-forward");
andrewboyson 94:d7226b2c14b6 34 PageAddAjaxInput ("Year next epoch starts" , 4, "ajax-leap-year" , "set-clock-leap-year" );
andrewboyson 94:d7226b2c14b6 35 PageAddAjaxInput ("Month next epoch starts" , 4, "ajax-leap-month" , "set-clock-leap-month" );
andrewboyson 94:d7226b2c14b6 36 PageAddAjaxInput ("Current era offset" , 4, "ajax-leap-count" , "set-clock-leap-count" );
andrewboyson 14:c3c43c8faf0e 37
andrewboyson 87:c51478679090 38 HttpAddText("<div><button type='button' onclick='DisplayLeap()'>Display leap</button></div>\r\n");
andrewboyson 21:048b7dbdf0aa 39
andrewboyson 22:f45bbb468439 40 HttpAddText("<div>The leap seconds list is available from <a href='https://www.ietf.org/timezones/data/leap-seconds.list' target='_blank'>ietf</a></div>\r\n");
andrewboyson 14:c3c43c8faf0e 41
andrewboyson 24:0ed9f1faea96 42 PageAddH2("Governer");
andrewboyson 94:d7226b2c14b6 43 PageAddAjaxInput ("Ppb" , 5, "ajax-ppb" , "ppb" );
andrewboyson 94:d7226b2c14b6 44 PageAddAjaxInput ("Ppb divisor" , 5, "ajax-ppb-divisor" , "ppbdivisor" );
andrewboyson 94:d7226b2c14b6 45 PageAddAjaxInput ("Ppb max change" , 5, "ajax-ppb-max-chg" , "ppbmaxchange" );
andrewboyson 94:d7226b2c14b6 46 PageAddAjaxInput ("Ppb synced limit" , 5, "ajax-ppb-syn-lim" , "syncedlimitppb");
andrewboyson 94:d7226b2c14b6 47 PageAddAjaxInput ("Ppb synced hysteresis" , 5, "ajax-ppb-syn-hys" , "syncedhysppb" );
andrewboyson 94:d7226b2c14b6 48 PageAddAjaxInput ("Offset divisor" , 5, "ajax-off-divisor" , "slewdivisor" );
andrewboyson 94:d7226b2c14b6 49 PageAddAjaxInput ("Offset max (ms)" , 5, "ajax-off-max" , "slewmax" );
andrewboyson 94:d7226b2c14b6 50 PageAddAjaxInput ("Offset synced limit (ms)", 5, "ajax-off-syn-lim" , "syncedlimitns" );
andrewboyson 94:d7226b2c14b6 51 PageAddAjaxInput ("Offset synced hys (ms)" , 5, "ajax-off-syn-hys" , "syncedhysns" );
andrewboyson 94:d7226b2c14b6 52 PageAddAjaxInput ("Offset reset limit (s)" , 5, "ajax-off-rst-lim" , "maxoffsetsecs" );
andrewboyson 94:d7226b2c14b6 53 PageAddAjaxInputToggle("Trace" , "ajax-gov-trace" , "clockgovtrace" );
andrewboyson 15:2cea2bbd5046 54
andrewboyson 62:74036bb0d1dc 55 PageAddH2("NTP");
andrewboyson 94:d7226b2c14b6 56 PageAddAjaxInput ("Server url" , 5, "ajax-ntp-server" , "ntpserver" );
andrewboyson 94:d7226b2c14b6 57 PageAddAjaxInput ("Initial interval (s)" , 5, "ajax-ntp-initial" , "clockinitial" );
andrewboyson 94:d7226b2c14b6 58 PageAddAjaxInput ("Normal interval (m)" , 5, "ajax-ntp-normal" , "clocknormal" );
andrewboyson 94:d7226b2c14b6 59 PageAddAjaxInput ("Retry interval (s)" , 5, "ajax-ntp-retry" , "clockretry" );
andrewboyson 94:d7226b2c14b6 60 PageAddAjaxInput ("Offset (ms)" , 5, "ajax-ntp-offset" , "clockoffset" );
andrewboyson 94:d7226b2c14b6 61 PageAddAjaxInput ("Max delay (ms)" , 5, "ajax-ntp-max-delay", "clockmaxdelay" );
andrewboyson 62:74036bb0d1dc 62
andrewboyson 14:c3c43c8faf0e 63 PageAddH2("Scan times");
andrewboyson 94:d7226b2c14b6 64 PageAddAjaxLabelled ("Program cycles avg", "ajax-scan-avg");
andrewboyson 94:d7226b2c14b6 65 PageAddAjaxLabelled ("Program cycles max", "ajax-scan-max");
andrewboyson 94:d7226b2c14b6 66 PageAddAjaxLabelled ("Program cycles min", "ajax-scan-min");
andrewboyson 14:c3c43c8faf0e 67
andrewboyson 14:c3c43c8faf0e 68 PageAddEnd();
andrewboyson 14:c3c43c8faf0e 69 }