{"action":"created","comment":{"url":"https://api.github.com/repos/apache/incubator-quarks/pulls/comments/57581705","id":57581705,"diff_hunk":"@@ -0,0 +1,216 @@\n+/*\n+Licensed to the Apache Software Foundation (ASF) under one\n+or more contributor license agreements.  See the NOTICE file\n+distributed with this work for additional information\n+regarding copyright ownership.  The ASF licenses this file\n+to you under the Apache License, Version 2.0 (the\n+\"License\"); you may not use this file except in compliance\n+with the License.  You may obtain a copy of the License at\n+\n+  http://www.apache.org/licenses/LICENSE-2.0\n+\n+Unless required by applicable law or agreed to in writing,\n+software distributed under the License is distributed on an\n+\"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n+KIND, either express or implied.  See the License for the\n+specific language governing permissions and limitations\n+under the License.\n+*/\n+package quarks.test.svt.apps;\n+\n+\n+import java.util.concurrent.TimeUnit;\n+import com.google.gson.JsonObject;\n+import quarks.connectors.iot.QoS;\n+import quarks.test.svt.utils.sensor.gps.GpsSensor;\n+import quarks.test.svt.utils.sensor.gps.SimulatedGeofence;\n+import quarks.test.svt.utils.sensor.gps.SimulatedGpsSensor;\n+import quarks.topology.TStream;\n+import quarks.topology.TWindow;\n+import quarks.topology.Topology;\n+\n+/**\n+ * GPS analytics \n+ * <p>\n+ * Source is a stream of GPS sensor data {@link GpsSensor} \n+ * <p>\n+ * Here's an outline of the topology\n+ * <ul>\n+ * <li>Log GPS coordinates by publishing to IotF. The data may be used by a server application to display the vehicle on a map.\n+ *     </li>\n+ * <li>Filter to detect speeds above a threshold and publish alert IotF\n+ *     </li>\n+ * <li>Filter for GPS coordinates that are outside of a defined Geofence boundary\n+ *     </li>\n+ * <li>Windowing to detect hard driving: hard braking or hard acceleration and publish alert to IotF\n+ *     </li>    \n+ * </ul>\n+ * <p>\n+ */\n+public class GpsAnalyticsApplication{\n+\n+\tprivate final FleetManagementAnalyticsClientApplication app;\n+\tprivate final Topology topology;\n+\n+\t//TODO: make these configurable properties\n+\tboolean trackGpsLocation = true;\n+\tboolean trackSpeeding = true;\n+\tboolean trackGeofence = true;\n+\tboolean trackHardDriving = true;\t\n+\t// Hard braking and acceleration thresholds may depend on the vehicle model\n+\tdouble hardBrakingThreshold_MphPerSec = -8.25;  \n+\tdouble hardAccelerationThreshold_MphPerSec = 7.37;  \n+\tString driverId = \"driver1\";\n+\tString VIN = \"123456\"; \n+\tdouble maxSpeed_Mph = 70;\n+\n+\n+\tstatic double MILES_PER_HOUR_TO_METERS_PER_SEC =  0.44704;\n+\tdouble METERS_PER_HOUR_TO_MILES_PER_SEC = 1 / MILES_PER_HOUR_TO_METERS_PER_SEC;\n+\t// Convert 70 miles per hour to meters to sec\n+\tdouble MAX_SPEED_METERS_PER_SEC = maxSpeed_Mph * MILES_PER_HOUR_TO_METERS_PER_SEC ;\n+\tstatic double MPS_TO_MPH = 3.6;\n+\n+\n+\tpublic GpsAnalyticsApplication(Topology t, FleetManagementAnalyticsClientApplication app) {\n+\t\tthis.topology = t;\n+\t\tthis.app = app;\n+\t}\n+\n+\t/**\n+\t * Add the GPS sensor analytics to the topology.\n+\t */\n+\tpublic void addAnalytics() {\n+\n+\t\t// Generate source GPS data\n+\t\tSimulatedGpsSensor g = new SimulatedGpsSensor();\n+\t\tTStream<GpsSensor> gpsSensor = topology.poll(() -> g.nextGps(), 500, TimeUnit.MILLISECONDS);\n+\n+\t\t// Publish GPS data to IotF every 1 second","path":"test/svt/src/main/java/quarks/test/svt/apps/GpsAnalyticsApplication.java","position":89,"original_position":89,"commit_id":"d16e7845a41a33a5e3efeb618ad4d7cc8c939612","original_commit_id":"d16e7845a41a33a5e3efeb618ad4d7cc8c939612","user":{"login":"dlaboss","id":12643590,"avatar_url":"https://avatars.githubusercontent.com/u/12643590?v=3","gravatar_id":"","url":"https://api.github.com/users/dlaboss","html_url":"https://github.com/dlaboss","followers_url":"https://api.github.com/users/dlaboss/followers","following_url":"https://api.github.com/users/dlaboss/following{/other_user}","gists_url":"https://api.github.com/users/dlaboss/gists{/gist_id}","starred_url":"https://api.github.com/users/dlaboss/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dlaboss/subscriptions","organizations_url":"https://api.github.com/users/dlaboss/orgs","repos_url":"https://api.github.com/users/dlaboss/repos","events_url":"https://api.github.com/users/dlaboss/events{/privacy}","received_events_url":"https://api.github.com/users/dlaboss/received_events","type":"User","site_admin":false},"body":"Says \"every 1 second\" but its generating GPS data every 500ms above.\r\nIs publishing every second a likely or desired model for quarks enabled devices?  While that's much better than something much more frequent, the idea is to put analytics in the device to significantly reduce publish events / data transmission costs, no?","created_at":"2016-03-28T15:09:06Z","updated_at":"2016-03-28T15:09:06Z","html_url":"https://github.com/apache/incubator-quarks/pull/49#discussion_r57581705","pull_request_url":"https://api.github.com/repos/apache/incubator-quarks/pulls/49","_links":{"self":{"href":"https://api.github.com/repos/apache/incubator-quarks/pulls/comments/57581705"},"html":{"href":"https://github.com/apache/incubator-quarks/pull/49#discussion_r57581705"},"pull_request":{"href":"https://api.github.com/repos/apache/incubator-quarks/pulls/49"}}},"pull_request":{"url":"https://api.github.com/repos/apache/incubator-quarks/pulls/49","id":64225492,"html_url":"https://github.com/apache/incubator-quarks/pull/49","diff_url":"https://github.com/apache/incubator-quarks/pull/49.diff","patch_url":"https://github.com/apache/incubator-quarks/pull/49.patch","issue_url":"https://api.github.com/repos/apache/incubator-quarks/issues/49","number":49,"state":"open","locked":false,"title":"QUARKS-21 Initial GPS application with iotf support","user":{"login":"mnwone","id":17261872,"avatar_url":"https://avatars.githubusercontent.com/u/17261872?v=3","gravatar_id":"","url":"https://api.github.com/users/mnwone","html_url":"https://github.com/mnwone","followers_url":"https://api.github.com/users/mnwone/followers","following_url":"https://api.github.com/users/mnwone/following{/other_user}","gists_url":"https://api.github.com/users/mnwone/gists{/gist_id}","starred_url":"https://api.github.com/users/mnwone/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mnwone/subscriptions","organizations_url":"https://api.github.com/users/mnwone/orgs","repos_url":"https://api.github.com/users/mnwone/repos","events_url":"https://api.github.com/users/mnwone/events{/privacy}","received_events_url":"https://api.github.com/users/mnwone/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-03-26T02:09:56Z","updated_at":"2016-03-28T15:09:06Z","closed_at":null,"merged_at":null,"merge_commit_sha":"593e24a5ec76a6accb82c517dcc7775353431081","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/apache/incubator-quarks/pulls/49/commits","review_comments_url":"https://api.github.com/repos/apache/incubator-quarks/pulls/49/comments","review_comment_url":"https://api.github.com/repos/apache/incubator-quarks/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/incubator-quarks/issues/49/comments","statuses_url":"https://api.github.com/repos/apache/incubator-quarks/statuses/d16e7845a41a33a5e3efeb618ad4d7cc8c939612","head":{"label":"mnwone:QUARKS-21","ref":"QUARKS-21","sha":"d16e7845a41a33a5e3efeb618ad4d7cc8c939612","user":{"login":"mnwone","id":17261872,"avatar_url":"https://avatars.githubusercontent.com/u/17261872?v=3","gravatar_id":"","url":"https://api.github.com/users/mnwone","html_url":"https://github.com/mnwone","followers_url":"https://api.github.com/users/mnwone/followers","following_url":"https://api.github.com/users/mnwone/following{/other_user}","gists_url":"https://api.github.com/users/mnwone/gists{/gist_id}","starred_url":"https://api.github.com/users/mnwone/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mnwone/subscriptions","organizations_url":"https://api.github.com/users/mnwone/orgs","repos_url":"https://api.github.com/users/mnwone/repos","events_url":"https://api.github.com/users/mnwone/events{/privacy}","received_events_url":"https://api.github.com/users/mnwone/received_events","type":"User","site_admin":false},"repo":{"id":54755773,"name":"incubator-quarks","full_name":"mnwone/incubator-quarks","owner":{"login":"mnwone","id":17261872,"avatar_url":"https://avatars.githubusercontent.com/u/17261872?v=3","gravatar_id":"","url":"https://api.github.com/users/mnwone","html_url":"https://github.com/mnwone","followers_url":"https://api.github.com/users/mnwone/followers","following_url":"https://api.github.com/users/mnwone/following{/other_user}","gists_url":"https://api.github.com/users/mnwone/gists{/gist_id}","starred_url":"https://api.github.com/users/mnwone/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mnwone/subscriptions","organizations_url":"https://api.github.com/users/mnwone/orgs","repos_url":"https://api.github.com/users/mnwone/repos","events_url":"https://api.github.com/users/mnwone/events{/privacy}","received_events_url":"https://api.github.com/users/mnwone/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/mnwone/incubator-quarks","description":"Mirror of Apache Quarks (Incubating)","fork":true,"url":"https://api.github.com/repos/mnwone/incubator-quarks","forks_url":"https://api.github.com/repos/mnwone/incubator-quarks/forks","keys_url":"https://api.github.com/repos/mnwone/incubator-quarks/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mnwone/incubator-quarks/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mnwone/incubator-quarks/teams","hooks_url":"https://api.github.com/repos/mnwone/incubator-quarks/hooks","issue_events_url":"https://api.github.com/repos/mnwone/incubator-quarks/issues/events{/number}","events_url":"https://api.github.com/repos/mnwone/incubator-quarks/events","assignees_url":"https://api.github.com/repos/mnwone/incubator-quarks/assignees{/user}","branches_url":"https://api.github.com/repos/mnwone/incubator-quarks/branches{/branch}","tags_url":"https://api.github.com/repos/mnwone/incubator-quarks/tags","blobs_url":"https://api.github.com/repos/mnwone/incubator-quarks/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mnwone/incubator-quarks/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mnwone/incubator-quarks/git/refs{/sha}","trees_url":"https://api.github.com/repos/mnwone/incubator-quarks/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mnwone/incubator-quarks/statuses/{sha}","languages_url":"https://api.github.com/repos/mnwone/incubator-quarks/languages","stargazers_url":"https://api.github.com/repos/mnwone/incubator-quarks/stargazers","contributors_url":"https://api.github.com/repos/mnwone/incubator-quarks/contributors","subscribers_url":"https://api.github.com/repos/mnwone/incubator-quarks/subscribers","subscription_url":"https://api.github.com/repos/mnwone/incubator-quarks/subscription","commits_url":"https://api.github.com/repos/mnwone/incubator-quarks/commits{/sha}","git_commits_url":"https://api.github.com/repos/mnwone/incubator-quarks/git/commits{/sha}","comments_url":"https://api.github.com/repos/mnwone/incubator-quarks/comments{/number}","issue_comment_url":"https://api.github.com/repos/mnwone/incubator-quarks/issues/comments{/number}","contents_url":"https://api.github.com/repos/mnwone/incubator-quarks/contents/{+path}","compare_url":"https://api.github.com/repos/mnwone/incubator-quarks/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mnwone/incubator-quarks/merges","archive_url":"https://api.github.com/repos/mnwone/incubator-quarks/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mnwone/incubator-quarks/downloads","issues_url":"https://api.github.com/repos/mnwone/incubator-quarks/issues{/number}","pulls_url":"https://api.github.com/repos/mnwone/incubator-quarks/pulls{/number}","milestones_url":"https://api.github.com/repos/mnwone/incubator-quarks/milestones{/number}","notifications_url":"https://api.github.com/repos/mnwone/incubator-quarks/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mnwone/incubator-quarks/labels{/name}","releases_url":"https://api.github.com/repos/mnwone/incubator-quarks/releases{/id}","deployments_url":"https://api.github.com/repos/mnwone/incubator-quarks/deployments","created_at":"2016-03-26T00:55:05Z","updated_at":"2016-03-26T00:55:07Z","pushed_at":"2016-03-26T01:51:58Z","git_url":"git://github.com/mnwone/incubator-quarks.git","ssh_url":"git@github.com:mnwone/incubator-quarks.git","clone_url":"https://github.com/mnwone/incubator-quarks.git","svn_url":"https://github.com/mnwone/incubator-quarks","homepage":null,"size":19982,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"apache:master","ref":"master","sha":"0b58e1531137d0a661b16532545bbdcfc03f780b","user":{"login":"apache","id":47359,"avatar_url":"https://avatars.githubusercontent.com/u/47359?v=3","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"repo":{"id":53566183,"name":"incubator-quarks","full_name":"apache/incubator-quarks","owner":{"login":"apache","id":47359,"avatar_url":"https://avatars.githubusercontent.com/u/47359?v=3","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/apache/incubator-quarks","description":"Mirror of Apache Quarks (Incubating)","fork":false,"url":"https://api.github.com/repos/apache/incubator-quarks","forks_url":"https://api.github.com/repos/apache/incubator-quarks/forks","keys_url":"https://api.github.com/repos/apache/incubator-quarks/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apache/incubator-quarks/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apache/incubator-quarks/teams","hooks_url":"https://api.github.com/repos/apache/incubator-quarks/hooks","issue_events_url":"https://api.github.com/repos/apache/incubator-quarks/issues/events{/number}","events_url":"https://api.github.com/repos/apache/incubator-quarks/events","assignees_url":"https://api.github.com/repos/apache/incubator-quarks/assignees{/user}","branches_url":"https://api.github.com/repos/apache/incubator-quarks/branches{/branch}","tags_url":"https://api.github.com/repos/apache/incubator-quarks/tags","blobs_url":"https://api.github.com/repos/apache/incubator-quarks/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apache/incubator-quarks/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apache/incubator-quarks/git/refs{/sha}","trees_url":"https://api.github.com/repos/apache/incubator-quarks/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apache/incubator-quarks/statuses/{sha}","languages_url":"https://api.github.com/repos/apache/incubator-quarks/languages","stargazers_url":"https://api.github.com/repos/apache/incubator-quarks/stargazers","contributors_url":"https://api.github.com/repos/apache/incubator-quarks/contributors","subscribers_url":"https://api.github.com/repos/apache/incubator-quarks/subscribers","subscription_url":"https://api.github.com/repos/apache/incubator-quarks/subscription","commits_url":"https://api.github.com/repos/apache/incubator-quarks/commits{/sha}","git_commits_url":"https://api.github.com/repos/apache/incubator-quarks/git/commits{/sha}","comments_url":"https://api.github.com/repos/apache/incubator-quarks/comments{/number}","issue_comment_url":"https://api.github.com/repos/apache/incubator-quarks/issues/comments{/number}","contents_url":"https://api.github.com/repos/apache/incubator-quarks/contents/{+path}","compare_url":"https://api.github.com/repos/apache/incubator-quarks/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apache/incubator-quarks/merges","archive_url":"https://api.github.com/repos/apache/incubator-quarks/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apache/incubator-quarks/downloads","issues_url":"https://api.github.com/repos/apache/incubator-quarks/issues{/number}","pulls_url":"https://api.github.com/repos/apache/incubator-quarks/pulls{/number}","milestones_url":"https://api.github.com/repos/apache/incubator-quarks/milestones{/number}","notifications_url":"https://api.github.com/repos/apache/incubator-quarks/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apache/incubator-quarks/labels{/name}","releases_url":"https://api.github.com/repos/apache/incubator-quarks/releases{/id}","deployments_url":"https://api.github.com/repos/apache/incubator-quarks/deployments","created_at":"2016-03-10T08:00:06Z","updated_at":"2016-03-27T18:45:27Z","pushed_at":"2016-03-26T02:09:57Z","git_url":"git://github.com/apache/incubator-quarks.git","ssh_url":"git@github.com:apache/incubator-quarks.git","clone_url":"https://github.com/apache/incubator-quarks.git","svn_url":"https://github.com/apache/incubator-quarks","homepage":null,"size":20001,"stargazers_count":1,"watchers_count":1,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":12,"mirror_url":"git://git.apache.org/incubator-quarks.git","open_issues_count":2,"forks":12,"open_issues":2,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/incubator-quarks/pulls/49"},"html":{"href":"https://github.com/apache/incubator-quarks/pull/49"},"issue":{"href":"https://api.github.com/repos/apache/incubator-quarks/issues/49"},"comments":{"href":"https://api.github.com/repos/apache/incubator-quarks/issues/49/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/incubator-quarks/pulls/49/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/incubator-quarks/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/incubator-quarks/pulls/49/commits"},"statuses":{"href":"https://api.github.com/repos/apache/incubator-quarks/statuses/d16e7845a41a33a5e3efeb618ad4d7cc8c939612"}}}}