-
-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #59 from tidepool-org/kjq/addDeviceData
Add device data
- Loading branch information
Showing
39 changed files
with
325 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
* == BSD2 LICENSE == | ||
* Copyright (c) 2014, Tidepool Project | ||
* | ||
* This program is free software; you can redistribute it and/or modify it under | ||
* the terms of the associated License, which is identical to the BSD 2-Clause | ||
* License as published by the Open Source Initiative at opensource.org. | ||
* | ||
* This program is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
* FOR A PARTICULAR PURPOSE. See the License for more details. | ||
* | ||
* You should have received a copy of the License along with this program; if | ||
* not, you can obtain one from Tidepool Project at tidepool.org. | ||
* == BSD2 LICENSE == | ||
*/ | ||
|
||
var _ = require('lodash'); | ||
|
||
var common = require('./common.js'); | ||
var parsing = require('./parsing.js'); | ||
|
||
module.exports = function(rows, type) { | ||
var serials = [], multiple = false; | ||
for (var i = 0; i < rows.length; ++i) { | ||
if (rows[i][0].search(type) != -1) { | ||
var model = rows[i][1].replace(' -', ''); | ||
var serial = rows[i][2].replace('#', ''); | ||
serials.push({ | ||
deviceModel: model, | ||
deviceSerialNumber: serial | ||
}); | ||
} | ||
} | ||
if (serials.length > 1) { | ||
multiple = true; | ||
} | ||
return { | ||
getDeviceModel: function() { | ||
if (serials.length === 1) { | ||
return serials[0].deviceModel; | ||
} | ||
else if (serials.length > 1) { | ||
return 'multiple'; | ||
} | ||
else { | ||
throw new Error('No devices! Cannot retrieve deviceModel :('); | ||
} | ||
}, | ||
getDeviceSerialNumber: function() { | ||
if (serials.length === 1) { | ||
return serials[0].deviceSerialNumber; | ||
} | ||
else if (serials.length > 1) { | ||
return 'multiple'; | ||
} | ||
else { | ||
throw new Error('No devices! Cannot retrieve deviceSerialNumber :('); | ||
} | ||
}, | ||
hasMultiple: function() { return multiple; }, | ||
getPayload: function() { return {devices: serials}; } | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.