”2016-08-29”

This commit is contained in:
Martin Donnelly 2016-08-29 16:45:02 +01:00
parent 2dc5403e04
commit f1a0c84e6e
2 changed files with 10 additions and 7 deletions

View File

@ -48,8 +48,8 @@ var mdot = require('./lib/mdot/mdot.js');
var ids = ['CENSIS-LoRa-1','CENSIS-LoRa-2','CENSIS-LoRa-3','CENSIS-LoRa-4','HIE-mobile-1','HIE-demo','HIE-mobile-2','HIE-smart-campus-1','HIE-smart-campus-2','HIE-smart-campus-3','HIE-smart-campus-4','HIE-smart-campus-5','HIE-smart-campus-6','HIE-smart-campus-7','HIE-mDot-1']; var ids = ['CENSIS-LoRa-1','CENSIS-LoRa-2','CENSIS-LoRa-3','CENSIS-LoRa-4','HIE-mobile-1','HIE-demo','HIE-mobile-2','HIE-smart-campus-1','HIE-smart-campus-2','HIE-smart-campus-3','HIE-smart-campus-4','HIE-smart-campus-5','HIE-smart-campus-6','HIE-smart-campus-7','HIE-mDot-1'];
var data = {id: ids[device]}; var data = {id: ids[device]};
var startTs = Sugar.Date.create('2016-08-19 14:46:48'); var startTs = Sugar.Date.create('2016-07-19 14:46:48');
var endTs = Sugar.Date.create('2016-08-21 10:03:39'); var endTs = Sugar.Date.create('2016-08-29 10:03:39');
// logger.debug(startTs, endTs); // logger.debug(startTs, endTs);
// logger.debug(startTs.getTime(), endTs.getTime()); // logger.debug(startTs.getTime(), endTs.getTime());
@ -61,16 +61,17 @@ var mdot = require('./lib/mdot/mdot.js');
.then(function(d) { .then(function(d) {
'use strict'; 'use strict';
//Logger.debug(d); //Logger.debug(d);
logger.info('Number of items:', d.events.length);
for (var item in d.events) { for (var item in d.events) {
var newItem = d.events[item].evt; var newItem = d.events[item].evt;
newItem.topic=['','','','',ids[device]].join('/'); newItem.topic=['','','','',ids[device]].join('/');
// logger.debug(newItem); // logger.debug(newItem);
var gwTime = new Date(newItem.gateway_info['0'].gw_time); // var gwTime = new Date(newItem.gateway_info['0'].gw_time);
if ((gwTime > startTs) && (gwTime < endTs)) { /* if ((gwTime > startTs) && (gwTime < endTs)) {
doInsertEntry(newItem); // doInsertEntry(newItem);
} else { } else {
logger.warn('Out of range...'); logger.warn('Out of range...');
} }*/
} }

View File

@ -31,6 +31,7 @@ function getData(data, prev) {
var options = { var options = {
uri: 'https://qz0da4.internetofthings.ibmcloud.com/api/v0002/historian/types/mDot/devices/' + data.id + range, uri: 'https://qz0da4.internetofthings.ibmcloud.com/api/v0002/historian/types/mDot/devices/' + data.id + range,
//uri: 'https://qz0da4.internetofthings.ibmcloud.com/api/v0002/historian/types/Ti-CC3200/devices/LightingISP15',
headers: { headers: {
Authorization: buildAuthentication() Authorization: buildAuthentication()
}, },
@ -51,6 +52,7 @@ function getData(data, prev) {
Array.prototype.push.apply(prev.events, d.events); Array.prototype.push.apply(prev.events, d.events);
if (d.hasOwnProperty('bookmark')) { if (d.hasOwnProperty('bookmark')) {
logger.info('Getting more...');
data.bookmark = d.bookmark; data.bookmark = d.bookmark;
getData(data, prev).then(function(d) { getData(data, prev).then(function(d) {
resolve(d); resolve(d);