Browse code

revisions 20151230

Jeff Owrey authored on 12/30/2015 20:43:27
Showing 2 changed files
... ...
@@ -43,7 +43,7 @@ import multiprocessing
43 43
     ### FILE AND FOLDER LOCATIONS ###
44 44
 
45 45
 _TMP_DIRECTORY = "/tmp/radmon" # folder for charts and output data file
46
-_RRD_FILE = "/home/{user}/database/radmonData.rrd"  # database that stores the data
46
+_RRD_FILE = "/home/{your user id}/database/radmonData.rrd"  # database that stores the data
47 47
 _OUTPUT_DATA_FILE = "/tmp/radmon/radmonData.js" # output file used by HTML docs
48 48
 
49 49
     ### GLOBAL CONSTANTS ###
... ...
@@ -177,8 +177,8 @@ def convertData(dData):
177 177
         local_sec = calendar.timegm(ts_utc)
178 178
         dData['UTC'] = local_sec
179 179
 
180
+        dData['Mode'] = dData['Mode'].lower()
180 181
         dData['uSvPerHr'] = dData.pop('uSv/hr')
181
-        dData['Mode'] = dData.pop('Mode').lower()
182 182
     except Exception, exError:
183 183
         print "%s convertData: %s" % (getTimeStamp(), exError)
184 184
         result = False
... ...
@@ -200,7 +200,7 @@ def writeOutputDataFile(dData):
200 200
     sData = '[{'
201 201
     for key in dData:
202 202
         sData += "\"%s\":\"%s\"," % (key, dData[key])
203
-    sData = sData[:-1] + '}]\n'
203
+    sData = sData[:-1] + '}]'
204 204
 
205 205
     # Write the string to the output data file for use by html documents.
206 206
     try:
... ...
@@ -50,6 +50,7 @@ img.chart {
50 50
 <body>
51 51
 <div id="frame">
52 52
 <h2>DIY Radiation Monitor</h2>
53
+<h4>Located in Albany, Oregon</h4>
53 54
 <hr>
54 55
 <b>
55 56
 
... ...
@@ -108,64 +109,63 @@ Device: <text id="status"></text><br>
108 109
 <br>
109 110
 <script>
110 111
 
111
-    function getRadmon() {
112
-      $.ajaxSetup({cache:false, url: "dynamic/radmonData.js",
113
-        success: function(result){
114
-          jStr = result.slice(1,-2);
115
-          dataObj = JSON.parse(jStr);
116
-          //data = dataObj.radmon;
112
+  function getRadmon() {
113
+    $.ajaxSetup({
114
+      cache:false, url: "dynamic/radmonData.js", success:
115
+        function(result){
116
+          var sData, dataObj;
117
+          sData = result.slice(1,-1);
118
+          dataObj = JSON.parse(sData);
117 119
           parseRadmon(dataObj);
118
-        }
119
-      });
120
-      $.ajax();
121
-    }
122
-
123
-    function getGraphs() {
124
-      document.getElementById("1-day-cpm").src = "dynamic/radGraph1.png";
125
-      document.getElementById("1-day-uSv").src = "dynamic/radGraph2.png";
126
-      document.getElementById("4-week-cpm").src = "dynamic/radGraph3.png";
127
-      document.getElementById("4-week-uSv").src = "dynamic/radGraph4.png";
128
-      document.getElementById("1-year-cpm").src = "dynamic/radGraph5.png";
129
-      document.getElementById("1-year-uSv").src = "dynamic/radGraph6.png";
130
-    }
131
-
132
-    function parseRadmon(dataItem) {
133
-      var timeStamp
134
-      var date;
135
-      var time;
136
-      var hourminute;
137
-
138
-      timeStamp = dataItem.date;
139
-      date = timeStamp.split(" ")[0];
140
-      time = timeStamp.split(" ")[1];
141
-      hourminute = time.split(":")[0] + ":" + time.split(":")[1];
142
-      $("#date").text(date);
143
-      $("#time").text(hourminute + " (PDT)");
144
-      
145
-      $("#cps").text(dataItem.CPS);
146
-      $("#cpm").text(dataItem.CPM);
147
-      $("#uSvPerHr").text(dataItem.uSvPerHr);
148
-
149
-      sTmp = (dataItem.Mode).toLowerCase();
150
-      $("#mode").text(sTmp);
151
-
152
-      $("#status").text(dataItem.status);
153
-      if (dataItem.status == "online") {
154
-        document.getElementById("status").style.color = "green";
155
-      }
156
-      else {
157
-        document.getElementById("status").style.color = "red";
158 120
       }
121
+    });
122
+    $.ajax();
123
+  }
124
+
125
+  function getGraphs() {
126
+    document.getElementById("1-day-cpm").src = "dynamic/radGraph1.png";
127
+    document.getElementById("1-day-uSv").src = "dynamic/radGraph2.png";
128
+    document.getElementById("4-week-cpm").src = "dynamic/radGraph3.png";
129
+    document.getElementById("4-week-uSv").src = "dynamic/radGraph4.png";
130
+    document.getElementById("1-year-cpm").src = "dynamic/radGraph5.png";
131
+    document.getElementById("1-year-uSv").src = "dynamic/radGraph6.png";
132
+  }
133
+
134
+  function parseRadmon(dataItem) {
135
+    var timeStamp, date, time, hourminute;
136
+
137
+    timeStamp = dataItem.date;
138
+    date = timeStamp.split(" ")[0];
139
+    time = timeStamp.split(" ")[1];
140
+    hourminute = time.split(":")[0] + ":" + time.split(":")[1];
141
+    $("#date").text(date);
142
+    $("#time").text(hourminute + " (PDT)");
143
+      
144
+    $("#cps").text(dataItem.CPS);
145
+    $("#cpm").text(dataItem.CPM);
146
+    $("#uSvPerHr").text(dataItem.uSvPerHr);
147
+    $("#mode").text(dataItem.Mode);
148
+
149
+    $("#status").text(dataItem.status);
150
+    if (dataItem.status == "online") {
151
+      document.getElementById("status").style.color = "green";
152
+    }
153
+    else {
154
+      document.getElementById("status").style.color = "red";
159 155
     }
156
+  }
160 157
 
161
-    $(document).ready(function() {
158
+  $(document).ready(
159
+    function() {
162 160
       getRadmon();
163 161
       getGraphs();
164 162
       setInterval(getRadmon, 10000);
165 163
       setInterval(getGraphs, 60000);
166
-    });
164
+    }
165
+  );
166
+
167
+</script>
167 168
 
168
-  </script>
169 169
 </body>
170 170
 </html>
171 171