{"action":"created","comment":{"url":"https://api.github.com/repos/tidepool-org/chrome-uploader/pulls/comments/77972102","id":77972102,"diff_hunk":"@@ -0,0 +1,121 @@\n+/*\n+ * == BSD2 LICENSE ==\n+ * Copyright (c) 2016, Tidepool Project\n+ *\n+ * This program is free software; you can redistribute it and/or modify it under\n+ * the terms of the associated License, which is identical to the BSD 2-Clause\n+ * License as published by the Open Source Initiative at opensource.org.\n+ *\n+ * This program is distributed in the hope that it will be useful, but WITHOUT\n+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n+ * FOR A PARTICULAR PURPOSE. See the License for more details.\n+ *\n+ * You should have received a copy of the License along with this program; if\n+ * not, you can obtain one from Tidepool Project at tidepool.org.\n+ * == BSD2 LICENSE ==\n+ */\n+\n+var _ = require('lodash');\n+var sundial = require('sundial');\n+var util = require('util');\n+\n+var annotate = require('../eventAnnotations');\n+\n+var debug = require('../bows')('MedtronicDriver');\n+\n+/**\n+ * Creates a new \"simulator\" for Medtronic pump data.\n+ *\n+ * Once all input activities are collected, the simulator will have accumulated events that the Tidepool Platform\n+ * will understand into a local \"events\" array.  You can retrieve the events by calling `getEvents()`\n+ *\n+ */\n+exports.make = function(config){\n+  var events = [];\n+\n+  var currBolus = null;\n+  var currWizard = null;\n+  var currTimestamp = null;\n+\n+  function setCurrBolus(bolus) {\n+    currBolus = bolus;\n+  }\n+\n+  function setCurrWizard(wizard) {\n+    currWizard = wizard;\n+  }\n+\n+  function ensureTimestamp(e){\n+    if (currTimestamp > e.time) {\n+      throw new Error(\n+        util.format('Timestamps must be in order.  Current timestamp was[%s], but got[%j]', currTimestamp, e)\n+      );\n+    }\n+    currTimestamp = e.time;\n+    return e;\n+  }\n+\n+  function simpleSimulate(e) {\n+    ensureTimestamp(e);\n+    events.push(e);\n+  }\n+\n+  return {\n+    bolus: function(event) {\n+      if(currWizard && currWizard.jsDate.getTime() === event.jsDate.getTime()) {","path":"lib/medtronic/medtronicSimulator.js","position":65,"original_position":65,"commit_id":"b393eb9eb0773f1d40a6a0ff9489c77ebae5d88a","original_commit_id":"b393eb9eb0773f1d40a6a0ff9489c77ebae5d88a","user":{"login":"gniezen","id":418233,"avatar_url":"https://avatars.githubusercontent.com/u/418233?v=3","gravatar_id":"","url":"https://api.github.com/users/gniezen","html_url":"https://github.com/gniezen","followers_url":"https://api.github.com/users/gniezen/followers","following_url":"https://api.github.com/users/gniezen/following{/other_user}","gists_url":"https://api.github.com/users/gniezen/gists{/gist_id}","starred_url":"https://api.github.com/users/gniezen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gniezen/subscriptions","organizations_url":"https://api.github.com/users/gniezen/orgs","repos_url":"https://api.github.com/users/gniezen/repos","events_url":"https://api.github.com/users/gniezen/events{/privacy}","received_events_url":"https://api.github.com/users/gniezen/received_events","type":"User","site_admin":false},"body":"I was just considering using `.time` instead, but it's probably safer to compare hammertimes than strings.","created_at":"2016-09-08T09:19:04Z","updated_at":"2016-09-08T09:19:04Z","html_url":"https://github.com/tidepool-org/chrome-uploader/pull/325#discussion_r77972102","pull_request_url":"https://api.github.com/repos/tidepool-org/chrome-uploader/pulls/325","_links":{"self":{"href":"https://api.github.com/repos/tidepool-org/chrome-uploader/pulls/comments/77972102"},"html":{"href":"https://github.com/tidepool-org/chrome-uploader/pull/325#discussion_r77972102"},"pull_request":{"href":"https://api.github.com/repos/tidepool-org/chrome-uploader/pulls/325"}}},"pull_request":{"url":"https://api.github.com/repos/tidepool-org/chrome-uploader/pulls/325","id":84280017,"html_url":"https://github.com/tidepool-org/chrome-uploader/pull/325","diff_url":"https://github.com/tidepool-org/chrome-uploader/pull/325.diff","patch_url":"https://github.com/tidepool-org/chrome-uploader/pull/325.patch","issue_url":"https://api.github.com/repos/tidepool-org/chrome-uploader/issues/325","number":325,"state":"open","locked":false,"title":"Initial work on Medtronic driver ","user":{"login":"gniezen","id":418233,"avatar_url":"https://avatars.githubusercontent.com/u/418233?v=3","gravatar_id":"","url":"https://api.github.com/users/gniezen","html_url":"https://github.com/gniezen","followers_url":"https://api.github.com/users/gniezen/followers","following_url":"https://api.github.com/users/gniezen/following{/other_user}","gists_url":"https://api.github.com/users/gniezen/gists{/gist_id}","starred_url":"https://api.github.com/users/gniezen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gniezen/subscriptions","organizations_url":"https://api.github.com/users/gniezen/orgs","repos_url":"https://api.github.com/users/gniezen/repos","events_url":"https://api.github.com/users/gniezen/events{/privacy}","received_events_url":"https://api.github.com/users/gniezen/received_events","type":"User","site_admin":false},"body":"This PR creates a new Medtronic driver and adds support for:\r\n\r\n- manual boluses (https://trello.com/c/OAHqN8Ng)\r\n- calculator boluses (https://trello.com/c/4Gn33urX)\r\n\r\nThis PR also refactors our USB HID library (`hidDevice.js`). The USB HID library, originally written by IOET while developing the initial version of the Bayer Contour Next driver, was modelled on our USB serial library. However, this introduced unnecessary complexity (buffers, interval timers etc.) that has now been removed. This also necessitated changes to the Bayer Contour Next driver as to not use an interval timer, which can cause unpredictable results.","created_at":"2016-09-07T11:06:11Z","updated_at":"2016-09-08T09:19:04Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1bcf373fd4ecabb1955855c29b9d14db44a3da11","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/tidepool-org/chrome-uploader/pulls/325/commits","review_comments_url":"https://api.github.com/repos/tidepool-org/chrome-uploader/pulls/325/comments","review_comment_url":"https://api.github.com/repos/tidepool-org/chrome-uploader/pulls/comments{/number}","comments_url":"https://api.github.com/repos/tidepool-org/chrome-uploader/issues/325/comments","statuses_url":"https://api.github.com/repos/tidepool-org/chrome-uploader/statuses/b393eb9eb0773f1d40a6a0ff9489c77ebae5d88a","head":{"label":"tidepool-org:gniezen/medtronic-bolus","ref":"gniezen/medtronic-bolus","sha":"b393eb9eb0773f1d40a6a0ff9489c77ebae5d88a","user":{"login":"tidepool-org","id":4390820,"avatar_url":"https://avatars.githubusercontent.com/u/4390820?v=3","gravatar_id":"","url":"https://api.github.com/users/tidepool-org","html_url":"https://github.com/tidepool-org","followers_url":"https://api.github.com/users/tidepool-org/followers","following_url":"https://api.github.com/users/tidepool-org/following{/other_user}","gists_url":"https://api.github.com/users/tidepool-org/gists{/gist_id}","starred_url":"https://api.github.com/users/tidepool-org/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tidepool-org/subscriptions","organizations_url":"https://api.github.com/users/tidepool-org/orgs","repos_url":"https://api.github.com/users/tidepool-org/repos","events_url":"https://api.github.com/users/tidepool-org/events{/privacy}","received_events_url":"https://api.github.com/users/tidepool-org/received_events","type":"Organization","site_admin":false},"repo":{"id":20790599,"name":"chrome-uploader","full_name":"tidepool-org/chrome-uploader","owner":{"login":"tidepool-org","id":4390820,"avatar_url":"https://avatars.githubusercontent.com/u/4390820?v=3","gravatar_id":"","url":"https://api.github.com/users/tidepool-org","html_url":"https://github.com/tidepool-org","followers_url":"https://api.github.com/users/tidepool-org/followers","following_url":"https://api.github.com/users/tidepool-org/following{/other_user}","gists_url":"https://api.github.com/users/tidepool-org/gists{/gist_id}","starred_url":"https://api.github.com/users/tidepool-org/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tidepool-org/subscriptions","organizations_url":"https://api.github.com/users/tidepool-org/orgs","repos_url":"https://api.github.com/users/tidepool-org/repos","events_url":"https://api.github.com/users/tidepool-org/events{/privacy}","received_events_url":"https://api.github.com/users/tidepool-org/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/tidepool-org/chrome-uploader","description":"A Chrome app for uploading diabetes device data to Tidepool's backend","fork":false,"url":"https://api.github.com/repos/tidepool-org/chrome-uploader","forks_url":"https://api.github.com/repos/tidepool-org/chrome-uploader/forks","keys_url":"https://api.github.com/repos/tidepool-org/chrome-uploader/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tidepool-org/chrome-uploader/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tidepool-org/chrome-uploader/teams","hooks_url":"https://api.github.com/repos/tidepool-org/chrome-uploader/hooks","issue_events_url":"https://api.github.com/repos/tidepool-org/chrome-uploader/issues/events{/number}","events_url":"https://api.github.com/repos/tidepool-org/chrome-uploader/events","assignees_url":"https://api.github.com/repos/tidepool-org/chrome-uploader/assignees{/user}","branches_url":"https://api.github.com/repos/tidepool-org/chrome-uploader/branches{/branch}","tags_url":"https://api.github.com/repos/tidepool-org/chrome-uploader/tags","blobs_url":"https://api.github.com/repos/tidepool-org/chrome-uploader/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tidepool-org/chrome-uploader/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tidepool-org/chrome-uploader/git/refs{/sha}","trees_url":"https://api.github.com/repos/tidepool-org/chrome-uploader/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tidepool-org/chrome-uploader/statuses/{sha}","languages_url":"https://api.github.com/repos/tidepool-org/chrome-uploader/languages","stargazers_url":"https://api.github.com/repos/tidepool-org/chrome-uploader/stargazers","contributors_url":"https://api.github.com/repos/tidepool-org/chrome-uploader/contributors","subscribers_url":"https://api.github.com/repos/tidepool-org/chrome-uploader/subscribers","subscription_url":"https://api.github.com/repos/tidepool-org/chrome-uploader/subscription","commits_url":"https://api.github.com/repos/tidepool-org/chrome-uploader/commits{/sha}","git_commits_url":"https://api.github.com/repos/tidepool-org/chrome-uploader/git/commits{/sha}","comments_url":"https://api.github.com/repos/tidepool-org/chrome-uploader/comments{/number}","issue_comment_url":"https://api.github.com/repos/tidepool-org/chrome-uploader/issues/comments{/number}","contents_url":"https://api.github.com/repos/tidepool-org/chrome-uploader/contents/{+path}","compare_url":"https://api.github.com/repos/tidepool-org/chrome-uploader/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tidepool-org/chrome-uploader/merges","archive_url":"https://api.github.com/repos/tidepool-org/chrome-uploader/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tidepool-org/chrome-uploader/downloads","issues_url":"https://api.github.com/repos/tidepool-org/chrome-uploader/issues{/number}","pulls_url":"https://api.github.com/repos/tidepool-org/chrome-uploader/pulls{/number}","milestones_url":"https://api.github.com/repos/tidepool-org/chrome-uploader/milestones{/number}","notifications_url":"https://api.github.com/repos/tidepool-org/chrome-uploader/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tidepool-org/chrome-uploader/labels{/name}","releases_url":"https://api.github.com/repos/tidepool-org/chrome-uploader/releases{/id}","deployments_url":"https://api.github.com/repos/tidepool-org/chrome-uploader/deployments","created_at":"2014-06-13T03:12:49Z","updated_at":"2016-08-06T18:00:55Z","pushed_at":"2016-09-07T14:56:00Z","git_url":"git://github.com/tidepool-org/chrome-uploader.git","ssh_url":"git@github.com:tidepool-org/chrome-uploader.git","clone_url":"https://github.com/tidepool-org/chrome-uploader.git","svn_url":"https://github.com/tidepool-org/chrome-uploader","homepage":"","size":6991,"stargazers_count":24,"watchers_count":24,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":23,"mirror_url":null,"open_issues_count":8,"forks":23,"open_issues":8,"watchers":24,"default_branch":"master"}},"base":{"label":"tidepool-org:gniezen/medtronic","ref":"gniezen/medtronic","sha":"1d511f67ade9059fc9a345e2f99b21ac254c1125","user":{"login":"tidepool-org","id":4390820,"avatar_url":"https://avatars.githubusercontent.com/u/4390820?v=3","gravatar_id":"","url":"https://api.github.com/users/tidepool-org","html_url":"https://github.com/tidepool-org","followers_url":"https://api.github.com/users/tidepool-org/followers","following_url":"https://api.github.com/users/tidepool-org/following{/other_user}","gists_url":"https://api.github.com/users/tidepool-org/gists{/gist_id}","starred_url":"https://api.github.com/users/tidepool-org/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tidepool-org/subscriptions","organizations_url":"https://api.github.com/users/tidepool-org/orgs","repos_url":"https://api.github.com/users/tidepool-org/repos","events_url":"https://api.github.com/users/tidepool-org/events{/privacy}","received_events_url":"https://api.github.com/users/tidepool-org/received_events","type":"Organization","site_admin":false},"repo":{"id":20790599,"name":"chrome-uploader","full_name":"tidepool-org/chrome-uploader","owner":{"login":"tidepool-org","id":4390820,"avatar_url":"https://avatars.githubusercontent.com/u/4390820?v=3","gravatar_id":"","url":"https://api.github.com/users/tidepool-org","html_url":"https://github.com/tidepool-org","followers_url":"https://api.github.com/users/tidepool-org/followers","following_url":"https://api.github.com/users/tidepool-org/following{/other_user}","gists_url":"https://api.github.com/users/tidepool-org/gists{/gist_id}","starred_url":"https://api.github.com/users/tidepool-org/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tidepool-org/subscriptions","organizations_url":"https://api.github.com/users/tidepool-org/orgs","repos_url":"https://api.github.com/users/tidepool-org/repos","events_url":"https://api.github.com/users/tidepool-org/events{/privacy}","received_events_url":"https://api.github.com/users/tidepool-org/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/tidepool-org/chrome-uploader","description":"A Chrome app for uploading diabetes device data to Tidepool's backend","fork":false,"url":"https://api.github.com/repos/tidepool-org/chrome-uploader","forks_url":"https://api.github.com/repos/tidepool-org/chrome-uploader/forks","keys_url":"https://api.github.com/repos/tidepool-org/chrome-uploader/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tidepool-org/chrome-uploader/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tidepool-org/chrome-uploader/teams","hooks_url":"https://api.github.com/repos/tidepool-org/chrome-uploader/hooks","issue_events_url":"https://api.github.com/repos/tidepool-org/chrome-uploader/issues/events{/number}","events_url":"https://api.github.com/repos/tidepool-org/chrome-uploader/events","assignees_url":"https://api.github.com/repos/tidepool-org/chrome-uploader/assignees{/user}","branches_url":"https://api.github.com/repos/tidepool-org/chrome-uploader/branches{/branch}","tags_url":"https://api.github.com/repos/tidepool-org/chrome-uploader/tags","blobs_url":"https://api.github.com/repos/tidepool-org/chrome-uploader/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tidepool-org/chrome-uploader/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tidepool-org/chrome-uploader/git/refs{/sha}","trees_url":"https://api.github.com/repos/tidepool-org/chrome-uploader/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tidepool-org/chrome-uploader/statuses/{sha}","languages_url":"https://api.github.com/repos/tidepool-org/chrome-uploader/languages","stargazers_url":"https://api.github.com/repos/tidepool-org/chrome-uploader/stargazers","contributors_url":"https://api.github.com/repos/tidepool-org/chrome-uploader/contributors","subscribers_url":"https://api.github.com/repos/tidepool-org/chrome-uploader/subscribers","subscription_url":"https://api.github.com/repos/tidepool-org/chrome-uploader/subscription","commits_url":"https://api.github.com/repos/tidepool-org/chrome-uploader/commits{/sha}","git_commits_url":"https://api.github.com/repos/tidepool-org/chrome-uploader/git/commits{/sha}","comments_url":"https://api.github.com/repos/tidepool-org/chrome-uploader/comments{/number}","issue_comment_url":"https://api.github.com/repos/tidepool-org/chrome-uploader/issues/comments{/number}","contents_url":"https://api.github.com/repos/tidepool-org/chrome-uploader/contents/{+path}","compare_url":"https://api.github.com/repos/tidepool-org/chrome-uploader/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tidepool-org/chrome-uploader/merges","archive_url":"https://api.github.com/repos/tidepool-org/chrome-uploader/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tidepool-org/chrome-uploader/downloads","issues_url":"https://api.github.com/repos/tidepool-org/chrome-uploader/issues{/number}","pulls_url":"https://api.github.com/repos/tidepool-org/chrome-uploader/pulls{/number}","milestones_url":"https://api.github.com/repos/tidepool-org/chrome-uploader/milestones{/number}","notifications_url":"https://api.github.com/repos/tidepool-org/chrome-uploader/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tidepool-org/chrome-uploader/labels{/name}","releases_url":"https://api.github.com/repos/tidepool-org/chrome-uploader/releases{/id}","deployments_url":"https://api.github.com/repos/tidepool-org/chrome-uploader/deployments","created_at":"2014-06-13T03:12:49Z","updated_at":"2016-08-06T18:00:55Z","pushed_at":"2016-09-07T14:56:00Z","git_url":"git://github.com/tidepool-org/chrome-uploader.git","ssh_url":"git@github.com:tidepool-org/chrome-uploader.git","clone_url":"https://github.com/tidepool-org/chrome-uploader.git","svn_url":"https://github.com/tidepool-org/chrome-uploader","homepage":"","size":6991,"stargazers_count":24,"watchers_count":24,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":23,"mirror_url":null,"open_issues_count":8,"forks":23,"open_issues":8,"watchers":24,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/tidepool-org/chrome-uploader/pulls/325"},"html":{"href":"https://github.com/tidepool-org/chrome-uploader/pull/325"},"issue":{"href":"https://api.github.com/repos/tidepool-org/chrome-uploader/issues/325"},"comments":{"href":"https://api.github.com/repos/tidepool-org/chrome-uploader/issues/325/comments"},"review_comments":{"href":"https://api.github.com/repos/tidepool-org/chrome-uploader/pulls/325/comments"},"review_comment":{"href":"https://api.github.com/repos/tidepool-org/chrome-uploader/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/tidepool-org/chrome-uploader/pulls/325/commits"},"statuses":{"href":"https://api.github.com/repos/tidepool-org/chrome-uploader/statuses/b393eb9eb0773f1d40a6a0ff9489c77ebae5d88a"}}}}
{"actor":{"display_login":"gniezen"}}