Skip to content

Commit

Permalink
Merge ffb003c into 49b0de4
Browse files Browse the repository at this point in the history
  • Loading branch information
bewest committed Aug 2, 2015
2 parents 49b0de4 + ffb003c commit 67c3113
Show file tree
Hide file tree
Showing 6 changed files with 323 additions and 2 deletions.
3 changes: 2 additions & 1 deletion lib/protobuf.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function payload (p) {
}

function configure (opts) {
var Model = builder.Practical8601;
var Model = (opts && opts.model) ? opts.model : builder.Practical8601;

function my ( ) {
return my;
Expand Down Expand Up @@ -60,6 +60,7 @@ function configure (opts) {
}

configure.json = json;
configure.models = builder;
configure.payload = payload;

module.exports = configure;
79 changes: 79 additions & 0 deletions lib/protobuf/CookieMonsterDownload.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@

message CookieMonsterG4Download {
repeated CookieMonsterG4EGV sgv = 1; // Glucose records as reported by the G4
enum Unit {
MGDL = 0;
MMOL = 1;
}
optional Unit units = 2; // Units reported by the device
required uint64 download_timestamp = 3; // Timestamp of the download - should be UTC
enum DownloadStatus {
SUCCESS = 0;
NO_DATA = 1;
DEVICE_NOT_FOUND = 2;
IO_ERROR = 3;
APPLICATION_ERROR = 4;
NONE = 6;
UNKNOWN = 7;
}
optional DownloadStatus download_status = 4 [default = NONE]; // Status of the download
optional uint32 receiver_battery = 5; // Battery level as reported by the receiver
optional uint32 uploader_battery = 6; // Battery level as reported by the uploader
repeated CookieMonsterG4Meter meter = 7;
repeated CookieMonsterG4Sensor sensor = 8;
repeated CookieMonsterG4Cal cal = 9;
optional string driver = 10;
optional uint32 device_id = 11;
}


message CookieMonsterG4EGV {
required uint32 sgv = 1; // Glucose value
optional uint64 timestamp = 2; // timestamp of the record
optional uint64 sys_timestamp = 4; // system time stamp
enum Direction {
NONE = 0;
DOUBLE_UP = 1;
SINGLE_UP = 2;
FORTY_FIVE_UP = 3;
FLAT = 4;
FORTY_FIVE_DOWN = 5;
SINGLE_DOWN = 6;
DOUBLE_DOWN = 7;
NOT_COMPUTABLE = 8;
RATE_OUT_OF_RANGE = 9;
}
optional Direction direction = 3; // Trend arrow
}

message CookieMonsterG4Meter {
required uint32 meter_bg = 1;
optional uint32 meter_time = 2;
optional uint64 timestamp = 3;
optional uint64 sys_timestamp = 4; // system time stamp
}

message CookieMonsterG4Sensor {
required uint64 filtered = 1;
optional uint64 unfiltered = 2;
optional uint32 rssi = 3;
optional uint64 timestamp = 4;
optional uint64 sys_timestamp = 5; // system time stamp
}

message CookieMonsterG4Cal {
required double slope = 1;
optional double intercept = 2;
optional double scale = 3;
optional uint64 timestamp = 4;
optional uint64 sys_timestamp = 5; // system time stamp
}

message CookieMonsterReceiverStatus {
required uint64 timestamp = 1; // preferably UTC Unix epoch
enum ReceiverStatus {
RECEIVERCONNECTED = 0;
RECEIVERDISCONNECTED = 1;
}
repeated ReceiverStatus event = 2;
}
120 changes: 120 additions & 0 deletions lib/protobuf/Download.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
option java_package = "com.nightscout.core.model";

option java_outer_classname = "Download";

message Download {
repeated SensorGlucoseValueEntry sgv = 1; // Glucose records as reported by the G4
optional GlucoseUnit units = 2; // Units reported by the device
required string download_timestamp = 3; // ISO8601 timestamp reported by uploader
optional uint64 receiver_system_time_sec = 4; // Raw value of the receiver's system time
optional DownloadStatus download_status = 5 [default = NOT_APPLICABLE]; // Status of the download
optional uint32 receiver_battery = 6; // Battery level as reported by the receiver
optional uint32 uploader_battery = 7; // Battery level as reported by the uploader
repeated MeterEntry meter = 8;
repeated SensorEntry sensor = 9;
repeated CalibrationEntry cal = 10;
repeated InsertionEntry insert = 11;
optional string receiver_id = 12;
optional string transmitter_id = 13;
optional ReceiverState receiver_state = 14;
}

enum GlucoseUnit {
MGDL = 0;
MMOL = 1;
}

enum DownloadStatus {
SUCCESS = 0;
NO_DATA = 1;
DEVICE_NOT_FOUND = 2;
IO_ERROR = 3;
APPLICATION_ERROR = 4;
UNKNOWN = 5;
NOT_APPLICABLE = 6;
}

enum G4Trend {
TREND_NONE = 0;
DOUBLE_UP = 1; // More than 3 mg/dL per minute
SINGLE_UP = 2; // +2 to +3 mg/dL per minute
FORTY_FIVE_UP = 3; // +1 to +2 mg/dL per minute
FLAT = 4; // +/- 1 mg/dL per minute
FORTY_FIVE_DOWN = 5; // -1 to -2 mg/dL per minute
SINGLE_DOWN = 6; // -2 to -3 mg/dL per minute
DOUBLE_DOWN = 7; // more than -3 mg/dL per minute
NOT_COMPUTABLE = 8;
RATE_OUT_OF_RANGE = 9;
}

enum G4Noise {
NOISE_NONE = 0;
CLEAN = 1;
LIGHT = 2;
MEDIUM = 3;
HEAVY = 4;
NOT_COMPUTED = 5;
MAX = 6;
}

enum G4Insertion {
INSERTION_NONE = 0;
REMOVED = 1;
EXPIRED = 2;
RESIDUAL_DEVIATION = 3;
COUNTS_DEVIATION = 4;
SECOND_SESSION = 5;
OFF_TIME_LOSS = 6;
STARTED = 7;
BAD_TRANSMITTER = 8;
MANUFACTURING_MODE = 9;
MAX_VALUE = 10;
}

enum ReceiverStatus {
RECEIVER_CONNECTED = 0; // The receiver is connected to the uploader
RECEIVER_DISCONNECTED = 1; // The receiver is not connected to the uploader
}

message SensorGlucoseValueEntry {
required uint32 sgv_mgdl = 1; // Sensor Glucose Value
optional uint64 sys_timestamp_sec = 2; // System timestamp - Timestamp representing the internal clock of the receiver
optional uint64 disp_timestamp_sec = 3; // Display timestamp - Timestamp representing the user configured time displayed on the receiver
optional G4Trend trend = 4; // G4 Glucose trend arrow
optional G4Noise noise = 5; // Noise level that potentially affects the G4 sensor readings
}

message MeterEntry {
required uint32 meter_bg_mgdl = 1;
optional uint32 meter_time = 2;
optional uint64 sys_timestamp_sec = 3; // System timestamp - Timestamp representing the internal clock of the receiver
optional uint64 disp_timestamp_sec = 4; // Display timestamp - Timestamp representing the user configured time displayed on the receiver
}

message SensorEntry {
required uint64 filtered = 1;
optional uint64 unfiltered = 2;
optional uint32 rssi = 3;
optional uint64 sys_timestamp_sec = 4; // System timestamp - Timestamp representing the internal clock of the receiver
optional uint64 disp_timestamp_sec = 5; // Display timestamp - Timestamp representing the user configured time displayed on the receiver
}

message InsertionEntry {
required G4Insertion state = 1;
optional uint64 sys_timestamp_sec = 2; // System timestamp - Timestamp representing the internal clock of the receiver
optional uint64 disp_timestamp_sec = 3; // Display timestamp - Timestamp representing the user configured time displayed on the receiver
}

message CalibrationEntry {
required double slope = 1;
optional double intercept = 2;
optional double scale = 3;
optional double decay = 4;
optional uint64 sys_timestamp_sec = 5; // System timestamp - Timestamp representing the internal clock of the receiver
optional uint64 disp_timestamp_sec = 6; // Display timestamp - Timestamp representing the user configured time displayed on the receiver
}

message ReceiverState {
required uint64 timestamp_ms = 1;
optional ReceiverStatus event = 2;
}
115 changes: 115 additions & 0 deletions lib/protobuf/G4Download.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
message G4Download {
repeated SensorGlucoseValueEntry sgv = 1; // Glucose records as reported by the G4
optional GlucoseUnit units = 2; // Units reported by the device
required string download_timestamp = 3; // ISO8601 timestamp reported by uploader
optional uint64 receiver_system_time_sec = 4; // Raw value of the receiver's system time
optional DownloadStatus download_status = 5 [default = NOT_APPLICABLE]; // Status of the download
optional uint32 receiver_battery = 6; // Battery level as reported by the receiver
optional uint32 uploader_battery = 7; // Battery level as reported by the uploader
repeated MeterEntry meter = 8;
repeated SensorEntry sensor = 9;
repeated CalibrationEntry cal = 10;
repeated InsertionEntry insert = 11;
optional string receiver_id = 12;
optional string transmitter_id = 13;
}

enum GlucoseUnit {
MGDL = 0;
MMOL = 1;
}

enum DownloadStatus {
SUCCESS = 0;
NO_DATA = 1;
DEVICE_NOT_FOUND = 2;
IO_ERROR = 3;
APPLICATION_ERROR = 4;
UNKNOWN = 5;
NOT_APPLICABLE = 6;
}

enum G4Trend {
TREND_NONE = 0;
DOUBLE_UP = 1; // More than 3 mg/dL per minute
SINGLE_UP = 2; // +2 to +3 mg/dL per minute
FORTY_FIVE_UP = 3; // +1 to +2 mg/dL per minute
FLAT = 4; // +/- 1 mg/dL per minute
FORTY_FIVE_DOWN = 5; // -1 to -2 mg/dL per minute
SINGLE_DOWN = 6; // -2 to -3 mg/dL per minute
DOUBLE_DOWN = 7; // more than -3 mg/dL per minute
NOT_COMPUTABLE = 8;
RATE_OUT_OF_RANGE = 9;
}

enum G4Noise {
NOISE_NONE = 0;
CLEAN = 1;
LIGHT = 2;
MEDIUM = 3;
HEAVY = 4;
NOT_COMPUTED = 5;
MAX = 6;
}

enum G4Insertion {
INSERTION_NONE = 0;
REMOVED = 1;
EXPIRED = 2;
RESIDUAL_DEVIATION = 3;
COUNTS_DEVIATION = 4;
SECOND_SESSION = 5;
OFF_TIME_LOSS = 6;
STARTED = 7;
BAD_TRANSMITTER = 8;
MANUFACTURING_MODE = 9;
MAX_VALUE = 10;
}

enum ReceiverStatus {
RECEIVER_CONNECTED = 0; // The receiver is connected to the uploader
RECEIVER_DISCONNECTED = 1; // The receiver is not connected to the uploader
}

message SensorGlucoseValueEntry {
required uint32 sgv_mgdl = 1; // Sensor Glucose Value
optional uint64 sys_timestamp_sec = 2; // System timestamp - Timestamp representing the internal clock of the receiver
optional uint64 disp_timestamp_sec = 3; // Display timestamp - Timestamp representing the user configured time displayed on the receiver
optional G4Trend trend = 4; // G4 Glucose trend arrow
optional G4Noise noise = 5; // Noise level that potentially affects the G4 sensor readings
}

message MeterEntry {
required uint32 meter_bg_mgdl = 1;
optional uint32 meter_time = 2;
optional uint64 sys_timestamp_sec = 3; // System timestamp - Timestamp representing the internal clock of the receiver
optional uint64 disp_timestamp_sec = 4; // Display timestamp - Timestamp representing the user configured time displayed on the receiver
}

message SensorEntry {
required uint64 filtered = 1;
optional uint64 unfiltered = 2;
optional uint32 rssi = 3;
optional uint64 sys_timestamp_sec = 4; // System timestamp - Timestamp representing the internal clock of the receiver
optional uint64 disp_timestamp_sec = 5; // Display timestamp - Timestamp representing the user configured time displayed on the receiver
}

message InsertionEntry {
required G4Insertion state = 1;
optional uint64 sys_timestamp_sec = 2; // System timestamp - Timestamp representing the internal clock of the receiver
optional uint64 disp_timestamp_sec = 3; // Display timestamp - Timestamp representing the user configured time displayed on the receiver
}

message CalibrationEntry {
required double slope = 1;
optional double intercept = 2;
optional double scale = 3;
optional double decay = 4;
optional uint64 sys_timestamp_sec = 5; // System timestamp - Timestamp representing the internal clock of the receiver
optional uint64 disp_timestamp_sec = 6; // Display timestamp - Timestamp representing the user configured time displayed on the receiver
}

message ReceiverState {
required uint64 timestamp_ms = 1;
repeated ReceiverStatus event = 2;
}
6 changes: 6 additions & 0 deletions lib/protobuf/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
var ProtoBuf = require('protobufjs');

var builder = ProtoBuf.loadProtoFile(__dirname + "/SGV.proto");
var downloads = ProtoBuf.loadProtoFile(__dirname + "/Download.proto");

function build (name) {
var Model = builder.build(name);
Expand All @@ -13,5 +14,10 @@ models.forEach(function (model) {
build[model] = build(model);
});

downloads.models = ['Download', 'CookieMonsterSGVG4' ];
downloads.models.forEach(function (model) {
build[model] = downloads.build(model);
});

module.exports = build;

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sgvdata",
"version": "0.0.2",
"version": "0.1.0",
"description": "Utilities to deal with sensor glucose values.",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit 67c3113

Please sign in to comment.