private static TelemetryKey register(String code, Semantic semantic, Subsystem subsystem, int subsystemId = 0) { TelemetryKey key = new TelemetryKey(subsystem, code); TelemetryFields.Add(key, TelemetryField.Create(code, semantic, subsystem, subsystemId)); return(key); }
public static TelemetryField GetTelemetryFieldByKeyOrNull(TelemetryKey telemetryKey) { if (TelemetryFields.TryGetValue(telemetryKey, out TelemetryField telemetry)) { return(telemetry); } return(null); }
private void onTelemetryReceived(VehicleTelemetry listOfTelemetry) { int vehicleId = listOfTelemetry.Vehicle.Id; Dictionary <TelemetryKey, TelemetryValue> dict = new Dictionary <TelemetryKey, TelemetryValue>(); lock (_latestValues) { if (!_latestValues.TryGetValue(vehicleId, out _)) { _latestValues.Add(vehicleId, new Dictionary <TelemetryKey, TelemetryValue>()); } } lock (_latestValues) { int count = listOfTelemetry.Telemetry.Count; for (int i = 0; i < count; i++) { Telemetry telemetry = listOfTelemetry.Telemetry[i]; if (telemetry.TelemetryField == null) { continue; } TelemetryKey key = TelemetryKeys.Register(telemetry.TelemetryField); var tv = TelemetryValue.MapValue(telemetry.Value); if (!_latestValues[vehicleId].ContainsKey(key)) { _latestValues[vehicleId].Add(key, tv); } else { _latestValues[vehicleId][key] = tv; } if (!dict.ContainsKey(key)) { dict.Add(key, tv); } else { dict[key] = tv; } } } if (_tlmCallBack != null) { foreach (KeyValuePair <TelemetryKey, TelemetryValue> entry in dict) { _tlmCallBack(vehicleId, entry.Key, entry.Value); } } }
public static TelemetryField GetTelemetryFieldByKey(TelemetryKey telemetryKey) { return(TelemetryFields[telemetryKey]); }