Changeset 2540
- Timestamp:
- Jul 3, 2014, 2:27:20 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/net.sf.basedb.labenv/trunk/src/net/sf/basedb/labenv/util/LabSensorUtil.java
r2342 r2540 186 186 } 187 187 // Get raw variable values from Base64-decoded byte array 188 int ch1 = (d20ByteArray[26] & 0xFF) | ((d20ByteArray[27] & 0xFF) << 8); 189 int ch2 = (d20ByteArray[42] & 0xFF) | ((d20ByteArray[43] & 0xFF) << 8); 190 // Variable nowTime is the number of seconds since 1070-01-01 00:00:00 191 long nowTime = (d20ByteArray[6] & 0xFF) | ((d20ByteArray[7] & 0xFF) << 8) | ((d20ByteArray[8] & 0xFF) << 16) | ((d20ByteArray[9] & 0xFF) << 24); 192 // Get variable values from raw variable values 193 temperature = (ch1 - 1000)/10.0; 194 humidity = (ch2 - 1000)/10.0; 195 // Convert nowTime to number of ms since 1070-01-01 00:00:00 before getting dateTime 196 dateTime = new Date(nowTime*1000); 197 labEnvironmentData = new LabEnvironmentData(sensorUrl, sensorName, serialNumber, dateTime, temperature, humidity); 188 if (d20ByteArray.length >= 44) 189 { 190 int ch1 = (d20ByteArray[26] & 0xFF) | ((d20ByteArray[27] & 0xFF) << 8); 191 int ch2 = (d20ByteArray[42] & 0xFF) | ((d20ByteArray[43] & 0xFF) << 8); 192 // Variable nowTime is the number of seconds since 1070-01-01 00:00:00 193 long nowTime = (d20ByteArray[6] & 0xFF) | ((d20ByteArray[7] & 0xFF) << 8) | ((d20ByteArray[8] & 0xFF) << 16) | ((d20ByteArray[9] & 0xFF) << 24); 194 // Get variable values from raw variable values 195 temperature = (ch1 - 1000)/10.0; 196 humidity = (ch2 - 1000)/10.0; 197 // Convert nowTime to number of ms since 1070-01-01 00:00:00 before getting dateTime 198 dateTime = new Date(nowTime*1000); 199 labEnvironmentData = new LabEnvironmentData(sensorUrl, sensorName, serialNumber, dateTime, temperature, humidity); 200 } 201 else 202 { 203 log.debug("createLabEnvironmentData(" + sensorUrl + ", " + sensorName + "): d20ByteArray.length = " + d20ByteArray.length + " < 44"); 204 } 198 205 } 199 206 catch (ParseException e) … … 231 238 if (statusCode != HttpStatus.SC_OK) 232 239 { 233 log.debug(" Error when trying to execute GetMethod: " + getMethod.getStatusLine());240 log.debug("fetchDataFromUrl(" + url + "): Error when trying to execute GetMethod: " + getMethod.getStatusLine()); 234 241 } 235 242 // Display response … … 239 246 catch (IOException e) 240 247 { 241 log.debug(" IOException when trying to execute HttpClient method : " +e);248 log.debug("fetchDataFromUrl(" + url + "): IOException when trying to execute HttpClient method : ", e); 242 249 ioErrorString = e.getMessage(); 243 250 } 244 251 catch (Exception e1) 245 252 { 246 log.debug(" Exception when trying to execute HttpClient method : " +e1);253 log.debug("fetchDataFromUrl(" + url + "): Exception when trying to execute HttpClient method : ", e1); 247 254 ioErrorString = e1.getMessage(); 248 255 } … … 256 263 else 257 264 { 258 log.debug("Connection to GetMethod already closed."); 259 } 260 } 265 log.debug("fetchDataFromUrl(" + url + "): Connection to GetMethod already closed."); 266 } 267 } 268 //log.debug("fetchDataFromUrl(" + url + "): content = " + content); 261 269 return content; 262 270 }
Note: See TracChangeset
for help on using the changeset viewer.