Github user mnwone commented on a diff in the pull request:
https://github.com/apache/incubator-quarks/pull/49#discussion_r57754004
--- Diff:
test/svt/src/main/java/quarks/test/svt/apps/GpsAnalyticsApplication.java ---
@@ -0,0 +1,216 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+*/
+package quarks.test.svt.apps;
+
+
+import java.util.concurrent.TimeUnit;
+import com.google.gson.JsonObject;
+import quarks.connectors.iot.QoS;
+import quarks.test.svt.utils.sensor.gps.GpsSensor;
+import quarks.test.svt.utils.sensor.gps.SimulatedGeofence;
+import quarks.test.svt.utils.sensor.gps.SimulatedGpsSensor;
+import quarks.topology.TStream;
+import quarks.topology.TWindow;
+import quarks.topology.Topology;
+
+/**
+ * GPS analytics
+ * <p>
+ * Source is a stream of GPS sensor data {@link GpsSensor}
+ * <p>
+ * Here's an outline of the topology
+ * <ul>
+ * <li>Log GPS coordinates by publishing to IotF. The data may be used by
a server application to display the vehicle on a map.
+ * </li>
+ * <li>Filter to detect speeds above a threshold and publish alert IotF
+ * </li>
+ * <li>Filter for GPS coordinates that are outside of a defined Geofence
boundary
+ * </li>
+ * <li>Windowing to detect hard driving: hard braking or hard acceleration
and publish alert to IotF
+ * </li>
+ * </ul>
+ * <p>
+ */
+public class GpsAnalyticsApplication{
+
+ private final FleetManagementAnalyticsClientApplication app;
+ private final Topology topology;
+
+ //TODO: make these configurable properties
+ boolean trackGpsLocation = true;
+ boolean trackSpeeding = true;
+ boolean trackGeofence = true;
+ boolean trackHardDriving = true;
+ // Hard braking and acceleration thresholds may depend on the vehicle
model
+ double hardBrakingThreshold_MphPerSec = -8.25;
+ double hardAccelerationThreshold_MphPerSec = 7.37;
+ String driverId = "driver1";
+ String VIN = "123456";
+ double maxSpeed_Mph = 70;
+
+
+ static double MILES_PER_HOUR_TO_METERS_PER_SEC = 0.44704;
+ double METERS_PER_HOUR_TO_MILES_PER_SEC = 1 /
MILES_PER_HOUR_TO_METERS_PER_SEC;
+ // Convert 70 miles per hour to meters to sec
+ double MAX_SPEED_METERS_PER_SEC = maxSpeed_Mph *
MILES_PER_HOUR_TO_METERS_PER_SEC ;
+ static double MPS_TO_MPH = 3.6;
+
+
+ public GpsAnalyticsApplication(Topology t,
FleetManagementAnalyticsClientApplication app) {
+ this.topology = t;
+ this.app = app;
+ }
+
+ /**
+ * Add the GPS sensor analytics to the topology.
+ */
+ public void addAnalytics() {
+
+ // Generate source GPS data
+ SimulatedGpsSensor g = new SimulatedGpsSensor();
+ TStream<GpsSensor> gpsSensor = topology.poll(() -> g.nextGps(),
500, TimeUnit.MILLISECONDS);
+
+ // Publish GPS data to IotF every 1 second
--- End diff --
The thinking was that a server application can have a real-time
visualization of a map displaying all the vehicles. In general, I agree the
goal is to run analytics on the car and minimize transmission cost.
Is publishing every 10 secs more reasonable?
Will make the comment and code consistent.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---