private LocationStatus GetLocationStatus(TelemetryJerkModel eventData) { if (eventData.Speed >= 8 && eventData.Speed < 25) { var highestVerticalJerk = eventData.Jerks.Max(j => Math.Abs(j.VerticalJerk)); var highestLateralJerk = eventData.Jerks.Max(j => Math.Abs(j.LateralJerk)); if (highestVerticalJerk >= 25 || highestLateralJerk >= 30) { return(LocationStatus.Critical); } } else { if (eventData.Speed >= 25) { var highestVerticalJerk = eventData.Jerks.Max(j => Math.Abs(j.VerticalJerk)); var highestLateralJerk = eventData.Jerks.Max(j => Math.Abs(j.LateralJerk)); if (highestVerticalJerk >= 30 || highestLateralJerk >= 34) { return(LocationStatus.Critical); } } } return(LocationStatus.Caution); }
private LocationJerkModel GetLocationJerkFromTelemetry(TelemetryJerkModel eventData) { LocationJerkModel newLocationJerkModel = null; if (eventData == null) { Trace.TraceWarning("Action event is null"); return(newLocationJerkModel); } try { // NOTE: all column names from ASA come out as lowercase; see // https://social.msdn.microsoft.com/Forums/office/en-US/c79a662b-5db1-4775-ba1a-23df1310091d/azure-table-storage-account-output-property-names-are-lowercase?forum=AzureStreamAnalytics newLocationJerkModel = new LocationJerkModel() { Latitude = eventData.Latitude, Longitude = eventData.Longitude, Altitude = eventData.Altitude, Status = LocationStatus.Caution, DeviceList = null }; string deviceId = eventData.DeviceId; if (deviceId != null) { newLocationJerkModel.DeviceList = new List <DeviceJerkModel>() { new DeviceJerkModel() { DeviceId = deviceId, Speed = eventData.Speed, Heading = eventData.Heading, CapturedJerks = eventData.Jerks } }; } else { Trace.TraceError("ActionProcessor: telemetryDeviceId value is empty"); } if (eventData.Speed > 5) { newLocationJerkModel.Status = GetLocationStatus(eventData); } } catch (Exception e) { Trace.TraceError("ActionProcessor: exception in ProcessTelemetryJerk:"); Trace.TraceError(e.ToString()); } return(newLocationJerkModel); }