public void updateAnalyzer(GaugeDeviceSensor sensor) { var deviceType = sensor.device.serialNumber.deviceModel; int index; if (deviceType == EDeviceModel.P500 || deviceType == EDeviceModel.PT500) { index = analyzerOpen(Core.Content.Analyzer.ESide.Low); if (index != -1) { sensor.analyzerSlot = index; ion.currentAnalyzer.sensorList.Add(sensor); } ////CONSOLIDATED DATA STRUCTURE METHOD OF ADDING TO ANALYZER //if(ion.currentAnalyzer.AddSensorToSide(Core.Content.Analyzer.ESide.Low,sensor)){ //} else if (ion.currentAnalyzer.AddSensorToSide(Core.Content.Analyzer.ESide.High,sensor)){ //} else { //} } else if (deviceType == EDeviceModel.P800 || deviceType == EDeviceModel.PT800) { index = analyzerOpen(Core.Content.Analyzer.ESide.High); if (index != -1) { sensor.analyzerSlot = index; ion.currentAnalyzer.sensorList.Add(sensor); } ////CONSOLIDATED DATA STRUCTURE METHOD OF ADDING TO ANALYZER //if (ion.currentAnalyzer.AddSensorToSide(Core.Content.Analyzer.ESide.High, sensor)) { //} else if (ion.currentAnalyzer.AddSensorToSide(Core.Content.Analyzer.ESide.Low, sensor)) { //} else { //} } else { index = analyzerOpen(Core.Content.Analyzer.ESide.Low); if (analyzerOpen(Core.Content.Analyzer.ESide.Low) != -1) { sensor.analyzerSlot = index; ion.currentAnalyzer.sensorList.Add(sensor); } ////CONSOLIDATED DATA STRUCTURE METHOD OF ADDING TO ANALYZER //if (ion.currentAnalyzer.AddSensorToSide(Core.Content.Analyzer.ESide.Low, sensor)) { //} else if (ion.currentAnalyzer.AddSensorToSide(Core.Content.Analyzer.ESide.High, sensor)) { //} else { //} } }
private void WriteGaugeDeviceSensor(GaugeDeviceSensor sensor, BinaryWriter writer) { // Write the serial number of the sensor's device writer.Write(sensor.device.serialNumber.ToString()); // Write the sensor index of the sensor writer.Write(sensor.index); }
private void AddSensorToWorkbench(GaugeDeviceSensor sensor) { if (ion.currentWorkbench.ContainsDevice(this.device)) { Toast(GetString(Resource.String.workbench_error_already_contains_sensor)); } else { var device = sensor.device; var deviceType = device.serialNumber.deviceModel; if (deviceType == EDeviceModel.PT500 || deviceType == EDeviceModel.PT800) { /// TODO make fixed add temp to workbench var manifold = new Manifold(device.sensors[0], device.sensors[1]); manifold.AddSensorProperty(new SecondarySensorProperty(manifold)); manifold.AddSensorProperty(new SuperheatSubcoolSensorProperty(manifold)); ion.currentWorkbench.Add(manifold); Toast(GetString(Resource.String.workbench_added_sensor)); } else { var manifold = new Manifold(sensor); if (deviceType == EDeviceModel.AV760) { manifold.AddSensorProperty(new RateOfChangeSensorProperty(manifold, ion.preferences.device.trendInterval)); } ion.currentWorkbench.AddSensor(sensor); Toast(GetString(Resource.String.workbench_added_sensor)); } Activity.Finish(); } }
public void addDeviceSensor(sensor area, GaugeDeviceSensor sensor) { Console.WriteLine("Adding a device sensor " + sensor.device.serialNumber.rawSerial + " that is located at spot " + analyzerSensors.viewList.IndexOf(area) + " but belongs to area " + area.snapArea.AccessibilityIdentifier); if (ion.currentAnalyzer.IndexOfSensor(sensor) == -1) { ion.currentAnalyzer.PutSensor(analyzerSensors.viewList.IndexOf(area), sensor, true); sensor.analyzerSlot = analyzerSensors.viewList.IndexOf(area); sensor.analyzerArea = Convert.ToInt32(area.snapArea.AccessibilityIdentifier); if (ion.currentAnalyzer.sensorList == null) { ion.currentAnalyzer.sensorList = new List <Sensor>(); } if (!ion.currentAnalyzer.sensorList.Contains(sensor)) { ion.currentAnalyzer.sensorList.Add(sensor); } area.currentSensor = sensor; area.updateUI(); } else { Console.WriteLine("Sensor exists at index " + ion.currentAnalyzer.IndexOfSensor(sensor)); } }
public void Bind(IION ion, GaugeDeviceSensor gds) { this.ion = ion; this.sensor = gds; Invalidate(); }
private void AddSensorToAnalyzer(GaugeDeviceSensor sensor) { var deviceType = sensor.device.serialNumber.deviceModel; if (deviceType == EDeviceModel.P500 || deviceType == EDeviceModel.PT500) { if (ion.currentAnalyzer.IsSideFull(Analyzer.ESide.Low)) { Toast(string.Format(GetString(Resource.String.analyzer_side_full_1sarg), GetString(Resource.String.analyzer_side_low))); } else if (ion.currentAnalyzer.HasSensor(sensor)) { Toast(GetString(Resource.String.analyzer_sensor_already_in_viewer)); } else { ion.currentAnalyzer.AddSensorToSide(Analyzer.ESide.Low, sensor); Toast(GetString(Resource.String.analyzer_added_to_low)); Activity.Finish(); } } else if (deviceType == EDeviceModel.P800 || deviceType == EDeviceModel.PT800) { if (ion.currentAnalyzer.IsSideFull(Analyzer.ESide.High)) { Toast(string.Format(GetString(Resource.String.analyzer_side_full_1sarg), GetString(Resource.String.analyzer_side_high))); } else if (ion.currentAnalyzer.HasSensor(sensor)) { Toast(GetString(Resource.String.analyzer_sensor_already_in_viewer)); } else { ion.currentAnalyzer.AddSensorToSide(Analyzer.ESide.High, sensor); Toast(GetString(Resource.String.analyzer_added_to_high)); Activity.Finish(); } } else { if (!ion.currentAnalyzer.IsSideFull(Analyzer.ESide.Low)) { ion.currentAnalyzer.AddSensorToSide(Analyzer.ESide.Low, sensor); Toast(GetString(Resource.String.analyzer_added_to_low)); Activity.Finish(); } else if (!ion.currentAnalyzer.IsSideFull(Analyzer.ESide.High)) { ion.currentAnalyzer.AddSensorToSide(Analyzer.ESide.High, sensor); Toast(GetString(Resource.String.analyzer_added_to_high)); Activity.Finish(); } else { Toast(GetString(Resource.String.analyzer_full)); } } }
/// <summary> /// Sets graph data for the given sensor. If the image data is null, then existing graph data will be cleared. /// </summary> /// <returns><c>true</c>, if sensor data graph was added, <c>false</c> otherwise.</returns> /// <param name="sensor">Sensor.</param> /// <param name="image">Image.</param> public bool SetSensorDataGraph(GaugeDeviceSensor sensor, IonImage image = null) { if (!dataLogResults.ContainsKey(sensor)) { return(false); } graphImages[sensor] = image; return(true); }
private void InvalidateLocationForSensor(GaugeDeviceSensor sensor, View container) { var wb = container.FindViewById <ImageView>(Resource.Id.workbench); var anal = container.FindViewById <ImageView>(Resource.Id.analyzer); if (ion.currentWorkbench.ContainsSensor(sensor)) { wb.SetBackgroundResource(0); wb.SetImageResource(Resource.Drawable.ic_devices_on_workbench); wb.SetOnClickListener(new ViewClickAction((v) => { var adb = new IONAlertDialog(Activity); adb.SetTitle(Resource.String.workbench_remove); adb.SetMessage(Resource.String.workbench_remove_sensor); adb.SetNegativeButton(Resource.String.cancel, (sender, args) => { }); adb.SetPositiveButton(Resource.String.remove, (sender, e) => { ion.currentWorkbench.Remove(sensor); }); adb.Show(); })); } else { wb.SetBackgroundResource(Resource.Drawable.xml_rect_gold_black_bordered); wb.SetImageResource(Resource.Drawable.ic_devices_add_to_workbench); wb.SetOnClickListener(new ViewClickAction((v) => { AddSensorToWorkbench(sensor); })); } if (ion.currentAnalyzer.HasSensor(sensor)) { anal.SetBackgroundResource(0); anal.SetImageResource(Resource.Drawable.ic_devices_on_analyzer); anal.SetOnClickListener(new ViewClickAction((c) => { var adb = new IONAlertDialog(Activity); adb.SetTitle(Resource.String.analyzer_remove_sensor); adb.SetMessage(Resource.String.analyzer_remove_sensor_remote); adb.SetNegativeButton(Resource.String.cancel, (sender, args) => { }); adb.SetPositiveButton(Resource.String.remove, (sender, e) => { ion.currentAnalyzer.RemoveSensor(sensor); }); adb.Show(); })); } else { anal.SetBackgroundResource(Resource.Drawable.xml_rect_gold_black_bordered); anal.SetImageResource(Resource.Drawable.ic_devices_add_to_analyzer); anal.SetOnClickListener(new ViewClickAction((c) => { AddSensorToAnalyzer(sensor); })); } }
public void UpdateFromGaugeSensor(GaugeDeviceSensor sensor) { if (viewSensor == null) { return; } var device = ((GaugeDeviceSensor)viewSensor)?.device; var state = device.connection.connectionState; labelHeader.Text = device.serialNumber.deviceModel.GetTypeString() + ": " + viewSensor.name; imageSensorIcon.Image = DeviceUtil.GetUIImageFromDeviceModel(device.serialNumber.deviceModel); labelMeasurement.Text = sensor.ToFormattedString(); labelUnit.Text = sensor.unit.ToString(); activityConnectStatus.Hidden = EConnectionState.Resolving != sensor.device.connection.connectionState; buttonConnection.Hidden = false; UpdateAlarm(sensor); if (device.isConnected) { UpdateBatteryIcon(device.battery); buttonConnection.SetImage(UIImage.FromBundle("ic_bluetooth_connected"), UIControlState.Normal); buttonConnection.BackgroundColor = UIColor.Green; labelMeasurement.TextColor = new UIColor(Colors.BLACK); labelUnit.TextColor = new UIColor(Colors.BLACK); labelConnectionStatus.Text = "Connected"; labelConnectionStatus.TextColor = UIColor.Green; } else { if (EConnectionState.Broadcasting == device.connection.connectionState) { UpdateBatteryIcon(device.battery); labelConnectionStatus.Text = "Long Range Mode"; labelConnectionStatus.TextColor = UIColor.Blue; } else { labelConnectionStatus.Text = "Disconnected"; labelConnectionStatus.TextColor = UIColor.Red; UpdateBatteryIcon(-1); } buttonConnection.SetImage(UIImage.FromBundle("ic_bluetooth_disconnected"), UIControlState.Normal); buttonConnection.BackgroundColor = UIColor.Red; labelMeasurement.TextColor = new UIColor(Colors.LIGHT_GRAY); labelUnit.TextColor = new UIColor(Colors.LIGHT_GRAY); } }
/// <summary> /// Builds the header string that is used for the given sensor. /// </summary> /// <returns>The header string from sensor.</returns> /// <param name="ion">Ion.</param> /// <param name="sensor">Sensor.</param> private string GetHeaderStringFromSensor(IION ion, GaugeDeviceSensor sensor) { var device = sensor.device; var serialNumber = device.serialNumber; if (serialNumber.deviceModel == EDeviceModel.P500) { return(serialNumber + " (" + Units.Pressure.IN_HG + "/" + Units.Pressure.PSIG + ")"); } else { return(serialNumber + " (" + ion.preferences.units.DefaultUnitFor(sensor.type) + ")"); } }
private void ShowGaugeDialog(GaugeDeviceSensor sensor) { var ft = FragmentManager.BeginTransaction(); var prev = FragmentManager.FindFragmentByTag("dialog"); if (prev != null) { ft.Remove(prev); } ft.AddToBackStack(null); var frag = new GaugeDeviceControlDialogFragment(sensor.device); frag.Show(ft, "dialog"); }
private void ShowChangeUnitDialog(GaugeDeviceSensor sensor) { var ldb = new ListDialogBuilder(Activity); ldb.SetTitle(Resource.String.pick_unit); foreach (var unit in sensor.supportedUnits) { if (!unit.Equals(sensor.unit)) { ldb.AddItem(unit.ToString(), () => { var device = sensor.device; var p = device.protocol as IGaugeProtocol; device.connection.Write(p.CreateSetUnitCommand(device.IndexOfSensor(sensor) + 1, sensor.type, unit)); }); } } ldb.Show(); }
/// <summary> /// Creates a new sensor measurement row for the database. /// </summary> /// <param name="db">Db.</param> /// <param name="sensor">Sensor.</param> private Task <SensorMeasurementRow> CreateSensorMeasurement(IONDatabase db, GaugeDeviceSensor sensor, DateTime date) { var ret = new SensorMeasurementRow(); // constant checking caused issue for timer when ending a logging session plus it was not used for anything.... //var d = await db.QueryForUsingSerialNumberAsync(sensor.device.serialNumber); var meas = sensor.measurement.ConvertTo(sensor.unit.standardUnit); ret.serialNumber = sensor.device.serialNumber.ToString(); ret.frn_SID = session.SID; ret.sensorIndex = sensor.index; ret.recordedDate = date; ret.measurement = meas.amount; return(Task.FromResult(ret)); }
public SensorDataLogResults(GaugeDeviceSensor sensor, Dictionary <int, List <DataLogMeasurement> > measurementData) { this.sensor = sensor; _measurementData = measurementData; var sd = new DateTime(9999, 1, 1); var ed = new DateTime(1, 1, 1); var su = sensor.unit.standardUnit; var min = su.OfScalar(double.MaxValue); var max = su.OfScalar(double.MinValue); var avg = 0.0; var cnt = 0; foreach (var id in sessionIds) { foreach (var dlm in this[id]) { if (dlm.recordedDate < sd) { sd = dlm.recordedDate; } if (dlm.recordedDate > ed) { ed = dlm.recordedDate; } if (dlm.measurement < min) { min = dlm.measurement; } if (dlm.measurement > max) { max = dlm.measurement; } avg += dlm.measurement.ConvertTo(su).amount; cnt++; } } startDate = sd; endDate = endDate; minimum = min; maximum = max; average = su.OfScalar(avg / cnt); }
private void InvalidateSensor(GaugeDeviceSensor sensor, View container) { var title = container.FindViewById <TextView>(Resource.Id.title); var measurement = container.FindViewById <TextView>(Resource.Id.measurement); var state = container.FindViewById <TextView>(Resource.Id.state); var unit = container.FindViewById <TextView>(Resource.Id.unit); title.Text = sensor.type.GetSensorTypeName(); if (sensor.removed) { measurement.Text = "- - - -"; } else { measurement.Text = sensor.ToFormattedString(false); } state.Visibility = ViewStates.Gone; unit.Text = sensor.measurement.unit.ToString(); }
public void UpdateCell(GaugeDeviceSensor sensor) { slotSensor = sensor; if (slotSensor == null) { ContentView.Hidden = true; BackgroundView.Hidden = true; } else { typeLabel.Text = " " + slotSensor.device.serialNumber.deviceModel.GetTypeString(); if (slotSensor.device.isConnected) { connectionImage.TintColor = UIColor.Green; } else { connectionImage.TintColor = UIColor.Red; } ContentView.Hidden = false; BackgroundView.Hidden = false; if (ion.currentWorkbench.ContainsSensor(sensor)) { workbenchImage.Hidden = false; } else { workbenchImage.Hidden = true; } if (ion.currentAnalyzer.sensorList.Contains(sensor)) { analyzerImage.Hidden = false; } else { analyzerImage.Hidden = true; } } }
public void updatePopup(GaugeDeviceSensor passedSensor) { Console.WriteLine("Analyzer slot index: " + analyzerSlot); sensor = passedSensor; nameLabel.Text = sensor.device.serialNumber.deviceModel.GetTypeString() + ":" + sensor.device.serialNumber.rawSerial.ToUpper(); deviceImage.Image = Devices.DeviceUtil.GetUIImageFromDeviceModel(sensor.device.serialNumber.deviceModel); if (sensor.device.sensorCount == 1) { typeLabel1.Hidden = true; measurementLabel1.Hidden = true; measurementLabel2.Hidden = false; unitLabel1.Hidden = true; divider2.Hidden = true; addWorkbench1.Hidden = true; addAnalyzer1.Hidden = true; measurementLabel2.Text = sensor.measurement.amount.ToString(); } else { typeLabel1.Hidden = false; measurementLabel1.Hidden = false; measurementLabel2.Hidden = false; unitLabel1.Hidden = false; divider2.Hidden = false; addWorkbench1.Hidden = false; addAnalyzer1.Hidden = false; measurementLabel1.Text = sensor.measurement.amount.ToString(); measurementLabel2.Text = sensor.device.sensors[1].measurement.amount.ToString(); } if (sensor.device.sensorCount == 1) { typeLabel2.Text = sensor.type.ToString(); } else { typeLabel1.Text = sensor.device.sensors[0].type.ToString(); typeLabel2.Text = sensor.device.sensors[1].type.ToString(); } sensor.NotifyInvalidated(); }
public void inflateAnalyzer(GaugeDeviceSensor sensor = null) { selectedSensor.sensor.onSensorEvent -= selectedSensor.updateSensor; var window = UIApplication.SharedApplication.KeyWindow; var vc = window.RootViewController as IONPrimaryScreenController; if (fromAnalyzer == -1 && fromAnalyzerLH == false) { //TODO This is wholely dependent upon the flyoutnavigation controller library being used for the menu. Any updates will also affect how the grid view navigates for its sensor NavigationController.PopViewController(true); vc.navigation.GetType().InvokeMember("NavigationItemSelected", System.Reflection.BindingFlags.InvokeMethod | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Static, Type.DefaultBinder, vc.navigation, new object[] { 1 }); } else { fromAnalyzer = -1; fromAnalyzerLH = false; fromWorkbench = false; NavigationController.PopViewController(true); } }
public GaugeDeviceSensorParcelable(GaugeDeviceSensor sensor) { serialNumber = sensor.device.serialNumber; index = sensor.index; }
/// <summary> /// Adds the LH Device sensor from the low or high menu. /// </summary> /// <param name="area">Area.</param> /// <param name="sensor">Sensor.</param> public void addLHDeviceSensor(lowHighSensor area, GaugeDeviceSensor sensor) { ///DON'T ALLOW A USER TO ADD AN EXISTING SENSOR TO THE OPPOSITE SIDE. JUST LET THEM KNOW IT IS ALREADY ON THE ANALYZER ESide side; var exists = ion.currentAnalyzer.GetSideOfSensor(sensor, out side); if ((exists && area.location == "low" && side == ESide.High) || (exists && area.location == "high" && side == ESide.Low)) { UIAlertController fullPopup = UIAlertController.Create(Util.Strings.Analyzer.CANTMOVE, Util.Strings.Analyzer.SENSOREXISTS, UIAlertControllerStyle.Alert); fullPopup.AddAction(UIAlertAction.Create(Util.Strings.OK, UIAlertActionStyle.Default, (action) => { })); PresentViewController(fullPopup, true, null); return; } else { if (area.location == "low" && ion.currentAnalyzer.IsSensorOnSide(sensor, ESide.Low)) { var foundSensor = analyzerSensors.GetSlotFromSensor(sensor); foundSensor.topLabel.BackgroundColor = UIColor.Blue; foundSensor.topLabel.TextColor = UIColor.White; ion.currentAnalyzer.SetManifold(ESide.Low, sensor); lowHighSensors.lowArea.currentSensor = sensor; ion.currentAnalyzer.lowAccessibility = foundSensor.snapArea.AccessibilityIdentifier; area.snapArea.AccessibilityIdentifier = foundSensor.snapArea.AccessibilityIdentifier; } else if (area.location == "high" && ion.currentAnalyzer.IsSensorOnSide(sensor, ESide.High)) { var foundSensor = analyzerSensors.GetSlotFromSensor(sensor); foundSensor.topLabel.BackgroundColor = UIColor.Red; foundSensor.topLabel.TextColor = UIColor.White; ion.currentAnalyzer.SetManifold(ESide.High, sensor); lowHighSensors.highArea.currentSensor = sensor; ion.currentAnalyzer.highAccessibility = foundSensor.snapArea.AccessibilityIdentifier; area.snapArea.AccessibilityIdentifier = foundSensor.snapArea.AccessibilityIdentifier; } else { if (!ion.currentAnalyzer.sensorList.Contains(sensor)) { ion.currentAnalyzer.sensorList.Add(sensor); } var addedIndex = -1; if (area.location == "low") { ion.currentAnalyzer.AddSensorToSide(ESide.Low, sensor); addedIndex = ion.currentAnalyzer.IndexOfSensor(sensor); analyzerSensors.viewList[addedIndex].topLabel.BackgroundColor = UIColor.Blue; ion.currentAnalyzer.SetManifold(ESide.Low, sensor); lowHighSensors.lowArea.currentSensor = sensor; ion.currentAnalyzer.lowAccessibility = addedIndex.ToString(); } else { ion.currentAnalyzer.AddSensorToSide(ESide.High, sensor); addedIndex = ion.currentAnalyzer.IndexOfSensor(sensor); analyzerSensors.viewList[addedIndex].topLabel.BackgroundColor = UIColor.Red; ion.currentAnalyzer.SetManifold(ESide.High, sensor); lowHighSensors.highArea.currentSensor = sensor; ion.currentAnalyzer.highAccessibility = addedIndex.ToString(); } sensor.analyzerArea = Convert.ToInt32(analyzerSensors.viewList[addedIndex].snapArea.AccessibilityIdentifier); sensor.analyzerSlot = addedIndex; analyzerSensors.viewList[addedIndex].topLabel.TextColor = UIColor.White; analyzerSensors.viewList[addedIndex].isManual = false; analyzerSensors.viewList[addedIndex].currentSensor = sensor; analyzerSensors.viewList[addedIndex].updateUI(); area.snapArea.AccessibilityIdentifier = addedIndex.ToString(); area.setLHUI(); } } }
public SensorRecord(GaugeDeviceSensor sensor) { this.sensor = sensor; }
public GaugeDeviceSensorModel(GaugeDeviceSensor sensor) { rawSerial = sensor.device.serialNumber.ToString(); index = sensor.index; }
public RemoteGaugeDeviceSensor(GaugeDeviceSensor sensor) { measurement = sensor.measurement.amount; unit = UnitLookup.GetCode(sensor.unit); sensorIndex = sensor.index; }
private void OnSensorClicked(GaugeDeviceSensor sensor, int position) { ShowGaugeDialog(sensor); }