added Envir code
[tridge/junkcode.git] / Envir / envir.html
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
2         "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
4 <head>
5 <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
6 <title>EnviR Data</title>
7
8 <script type="text/javascript">is_IE = false;</script>
9 <script type="text/javascript" src="lib/strftime-min.js"></script>
10 <script type="text/javascript" src="lib/rgbcolor.js"></script>
11 <script type="text/javascript" src="lib/dygraph-canvas.js"></script>
12 <script type="text/javascript" src="lib/dygraph.js"></script>
13 <script type="text/javascript" src="lib/debug.js"></script>
14 <script type="text/javascript" src="graphs.js"></script>
15 <script type="text/javascript" src="lib/date-picker/js/datepicker.js"></script>
16 <link href="lib/date-picker/css/datepicker.css" rel="stylesheet" type="text/css" />
17 </head>
18 <body>
19 <h1>EnviR Data</h1>
20
21 <p>Tips:</p>
22 <ul>
23 <li>You can zoom a time range by dragging the mouse over the range you
24   are interested in.</li>
25 <li>Double click to see the whole data set again.</li>
26 <li>You can change the rolling average value using the selection box
27   in the bottom left corner of each graph.</li>
28 <li>Use the green +/- icons to hide or show a particular graph</li>
29 <li>Hover your mouse over the '!' annotations to view them</li>
30 </ul>
31
32
33 <form id="MainForm" method="get" onsubmit="return false;" action="">
34     <fieldset>
35       <p>Select Date: <input type="text" class="w8em format-d-m-y highlight-days-67
36       range-low-2010-10-05" name="pvdate" id="pvdate" value="" maxlength="10" /></p>
37      <label>Daily<input   name="period" type='radio' value=1 checked='1' onclick='change_period(1)' /></label>
38      <label>&nbsp;Weekly<input  name="period" type='radio' value=0 onclick='change_period(7)' /></label>
39      <label>&nbsp;Monthly<input name="period" type='radio' value=0 onclick='change_period(31)' /></label>
40      <label>&nbsp;Yearly<input name="period" type='radio' value=0 onclick='change_period(366)' /></label>
41      <label>&nbsp;Averaging<input type='text' id='averaging' value=1 size=2 onchange='change_averaging()' /></label>
42     </fieldset>
43 </form>
44
45 <div id="loading"><font color="red">Loading ....</font></div>
46 <div id="nodata"><font color="red">No data available for chosen date</font></div>
47
48 <script type="text/javascript">
49 if (hashvars['debug'] == '1') {
50   enableDebug(true);
51 }
52 if (hashvars['date'] != undefined) {
53   pvdate = date_round(parse_date(hashvars['date']));
54 } else {
55   pvdate = canberraDate();
56 }
57 first_data = date_round(parse_date("2010-10-07"));
58 XML_directory = "../XML/";
59 setup_datepicker();
60
61 /*
62   return the list of XML files for date pvdate
63  */
64 function xml_files() {
65   var list = new Array();
66   var oneday = 24*60*60*1000;
67   var start_date = pvdate.getTime() - (period_days-1)*oneday;
68   if (start_date < first_data.getTime()) {
69     start_date = first_data.getTime();
70   }
71   for (var d=0; d<period_days; d++) {
72     var day = new Date(start_date + (d*oneday));
73     if (day.getTime() > pvdate.getTime()) {
74       break;
75     }
76     var f = XML_directory + date_YMD(day) + ".xml";
77     if (d == 0) {
78       list = f;
79     } else {
80       list += ',' + f;
81     }
82   }
83   writeDebug("xml files: " + list);
84
85   return [ list ];
86 }
87
88
89 /*
90   show all the live data graphs
91  */
92 function show_graphs() {
93   hide_div("nodata", true);
94
95   pvdate_base = pvdate.getTime();
96
97   graph_csv_files_func("Recent Data (W)",
98                        xml_files(),
99                        [ "msg.ch1.watts", "msg.ch2.watts", "msg.ch3.watts" ],
100                        null, null,
101                        { includeZero: true,
102                            averaging: false,
103                            maxtime: 15,
104                            series_base: [ 'Time', 'Chan1', 'Chan2', 'Chan3' ]});
105
106   function total(v) {
107     return pow = v[0] + v[1] + v[2];
108   }
109
110   graph_csv_files_func("Total (W)",
111                        xml_files(),
112                        [ "msg.ch1.watts", "msg.ch2.watts", "msg.ch3.watts" ],
113                        total, null,
114                        { includeZero: true,
115                          series_base: 'Total'});
116
117   graph_csv_files("Temperature (C)",
118                   xml_files(),
119                   "msg.tmpr",
120                   { includeZero: false });
121
122   graph_csv_files_func("Channels (W)",
123                        xml_files(),
124                        [ "msg.ch1.watts", "msg.ch2.watts", "msg.ch3.watts" ],
125                        null, null,
126                        { includeZero: true,
127                          series_base: [ 'Time', 'Chan1', 'Chan2', 'Chan3' ]});
128   load_annotations();
129
130   in_redraw = true;
131 }
132
133 show_graphs();
134 </script>
135
136 <p>
137 <small>Thanks to <a href="http://danvk.org/dygraphs/">dygraphs</a> for
138   the graphs</small></p>
139
140 </body>
141 </html>