/// <summary> /// Queries the localized string for the given sensor property. /// </summary> /// <returns>The localized string.</returns> /// <param name="sensorPropety">Sensor propety.</param> /// <param name="context">Context.</param> public static string GetLocalizedString(this ISensorProperty sensorProperty, Context context) { if (sensorProperty is AlternateUnitSensorProperty) { return(context.GetString(Resource.String.workbench_alt)); } else if (sensorProperty is HoldSensorProperty) { return(context.GetString(Resource.String.workbench_hold)); } else if (sensorProperty is MinSensorProperty) { return(context.GetString(Resource.String.workbench_min)); } else if (sensorProperty is MaxSensorProperty) { return(context.GetString(Resource.String.workbench_max)); } else if (sensorProperty is PTChartSensorProperty) { return(context.GetString(Resource.String.workbench_ptchart)); } else if (sensorProperty is RateOfChangeSensorProperty) { return(context.GetString(Resource.String.workbench_roc)); } else if (sensorProperty is SuperheatSubcoolSensorProperty) { return(context.GetString(Resource.String.workbench_shsc)); } else { return(context.GetString(Resource.String.na)); } }
/// <summary> /// Called when a sensor property is clicked in the analyzer view. Note: either the low or high side may be clicked /// </summary> /// <param name="manifold">Manifold.</param> /// <param name="sensorProperty">Sensor property.</param> private void OnSensorPropertyClicked(Manifold manifold, ISensorProperty sensorProperty) { var sensor = sensorProperty.sensor; if (sensorProperty is AlternateUnitSensorProperty) { var asp = sensorProperty as AlternateUnitSensorProperty; UnitDialog.Create(Activity, sensor.supportedUnits, (obj, u) => { asp.unit = u; }).Show(); } else if (sensorProperty is PTChartSensorProperty) { ViewInPtChartActivity(manifold, sensorProperty); } else if (sensorProperty is SuperheatSubcoolSensorProperty) { ViewInSuperheatSubcoolActivity(manifold, sensorProperty); } else if (sensorProperty is RateOfChangeSensorProperty) { var ps = manifold.primarySensor as GaugeDeviceSensor; if (ps != null && !ps.device.isConnected) { Toast.MakeText(Activity, Resource.String.devices_error_connect_for_roc, ToastLength.Long).Show(); } else { var i = new Intent(Activity, typeof(RoCActivity)); i.PutExtra(RoCActivity.EXTRA_MANIFOLD, new AnalyzerManifoldParcelable(analyzer.lowSideManifold == manifold)); StartActivity(i); } } }
private void ViewInPtChartActivity(Manifold manifold, ISensorProperty sensorProperty) { var side = Analyzer.ESide.Low; if (!analyzer.GetSideOfManifold(manifold, out side)) { Error(GetString(Resource.String.analyzer_error_failed_to_launch_ptchart_missing_manifold)); return; } var i = new Intent(Activity, typeof(PTChartActivity)); i.SetAction(Intent.ActionPick); i.PutExtra(PTChartActivity.EXTRA_LOCK_FLUID, true); i.PutExtra(PTChartActivity.EXTRA_FLUID_NAME, manifold.ptChart.fluid.name); i.PutExtra(PTChartActivity.EXTRA_FLUID_STATE, (int)analyzer.SideAsFluidState(side)); i.PutExtra(PTChartActivity.EXTRA_ANALYZER_MANIFOLD, (int)side); if (ion is RemoteION) { StartActivity(i); } else { StartActivityForResult(i, REQUEST_SHOW_PTCHART); } }
public AlarmSensor(ISensorProperty sensor, ISensorsSetings settings) { ctrl = settings; this.sensor = sensor; sensor.SensorAction += OnSensorAction; }
private void NotifySensorPropertyClicked(Manifold manifold, ISensorProperty sp) { if (onSensorPropertyClicked != null) { onSensorPropertyClicked(manifold, sp); } }
private IRecord CreateSensorPropertyRecord(Manifold m, ISensorProperty sp) { if (sp is PTChartSensorProperty) { var p = sp as PTChartSensorProperty; return(new PTSensorPropertyRecord(m, p)); } else if (sp is SuperheatSubcoolSensorProperty) { return(new SHSCSensorPropertyRecord(m, sp as SuperheatSubcoolSensorProperty)); } else if (sp is RateOfChangeSensorProperty) { return(new ROCSensorPropertyRecord(m, sp as RateOfChangeSensorProperty)); } else if (sp is TimerSensorProperty) { return(new TimerSensorPropertyRecord(m, sp as TimerSensorProperty)); } else if (sp is SecondarySensorProperty) { return(new SecondarySensorPropertyRecord(m, sp as SecondarySensorProperty)); } else { return(new SimpleSensorPropertyRecord(m, sp)); } }
private void AddNewAlarmSensor(ISensorProperty s) { RigEx.WriteLineColors($"sensor detected: {s.Name} => {s.Dictionary.Keys.Last().ToString()}".AddTimeStamp(), ConsoleColor.DarkGray); var alarmsensor = new AlarmSensor(s, ctrl); alarmsensor.AlarmAction += OnAlarmAction; alarmsensor.StopMiningAction += OnStopMiningAction; ctrl.GetAlarmdata.AddifNew(alarmsensor); }
// Implemented for ISubviewParser public bool Write(ISensorProperty sp, BinaryWriter writer) { try { var alt = (AlternateUnitSensorProperty)sp; writer.Write(UnitLookup.GetCode(alt.unit)); return(true); } catch (Exception e) { Log.E(this, "Failed to write.", e); return(false); } }
private void OnSensorPropertyChanged(ISensorProperty sensorProperty) { if (sensorProperty is SuperheatSubcoolSensorProperty) { HandleSuperheatSubcoolSensorPropertyChanged(sensorProperty as SuperheatSubcoolSensorProperty); } else { HandlePTChartSensorPropertyChanged(sensorProperty as PTChartSensorProperty); } }
private void OnSensorPropertyChanged(ISensorProperty sensorProperty) { //var device = (initialRecord.manifold.primarySensor as GaugeDeviceSensor)?.device; var device = (initialRecord.sensor as GaugeDeviceSensor)?.device; if (device != null && device.isConnected && !isUpdating) { Console.WriteLine("Sensor change and graph was not updating so starting roc settings update started"); updateCellGraph(); } }
private void WriteSensorProperty(ISensorProperty property, BinaryWriter writer) { var name = property.GetType(); writer.Write(name.Name); if (property is AlternateUnitSensorProperty) { var sp = property as AlternateUnitSensorProperty; writer.Write(UnitLookup.GetCode(sp.unit)); } }
private void OnSensorPropertyChanged(ISensorProperty sensorProperty) { if (!isConnected && !isUpdating) { if (plotView != null) { plotView.Hidden = true; } isUpdating = true; updateCellGraph(); } }
// Implemented for ISubviewParser public bool Write(ISensorProperty sp, BinaryWriter writer) { try { var roc = (RateOfChangeSensorProperty)sp; writer.Write((int)roc.flags); return(true); } catch (Exception e) { Log.E(this, "Failed to write.", e); return(false); } }
/// <summary> /// Inserts the sensor property into the given index within the manifold. /// </summary> /// <returns><c>true</c>, if sensor property was inserted, <c>false</c> otherwise.</returns> /// <param name="">.</param> public bool InsertSensorProperty(ISensorProperty sensorProperty, int index) { if (HasSensorPropertyOfType(sensorProperty.GetType())) { return(false); } else { sensorProperties.Insert(index, sensorProperty); NotifyOfEvent(new SensorEvent(SensorEvent.EType.LinkedSensorAdded, this, index)); return(true); } }
/// <summary> /// Inserts the sensor property into the given index within the manifold. /// </summary> /// <returns><c>true</c>, if sensor property was inserted, <c>false</c> otherwise.</returns> /// <param name="">.</param> public bool InsertSensorProperty(ISensorProperty sensorProperty, int index) { if (HasSensorPropertyOfType(sensorProperty.GetType())) { return(false); } else { sensorProperties.Insert(index, sensorProperty); NotifyOfEvent(ManifoldEvent.EType.SensorPropertyAdded, index); return(true); } }
public override bool Equals(object obj) { if (this == obj) { return(true); } if (this == null || obj == null) { return(false); } ISensorProperty c = obj as ISensorProperty; return(Name == c?.Name && HwType == c.HwType && dictionary.Count == c.Dictionary.Count && !dictionary.Except(c.Dictionary).Any()); }
private void OnSensorPropertyChanged(ISensorProperty sensorProperty) { if (!isUpdating) { isUpdating = true; DoUpdateCell(); } if (!isConnected) { if (plotView != null) { plotView.Hidden = true; labelMeasurement.Hidden = true; } updateCellGraph(); } }
private async void DoUpdateRocCell(ISensorProperty property) { if (!(property is RateOfChangeSensorProperty)) { return; } await Task.Delay(TimeSpan.FromMilliseconds(2)); var rocproperty = property as RateOfChangeSensorProperty; var roc = rocproperty.GetPrimaryAverageRateOfChange(); var abs = Math.Abs(roc.magnitude); var range = (rocproperty.sensor.maxMeasurement - rocproperty.sensor.minMeasurement) / 10; if (abs > range.magnitude) { rocReading.Text = ">" + SensorUtils.ToFormattedString(rocproperty.sensor.type, range, false) + " " + roc.unit.ToString() + "/min"; } else { rocReading.Text = SensorUtils.ToFormattedString(rocproperty.sensor.type, roc.unit.OfScalar(abs), false) + " " + roc.unit.ToString() + "/min"; } if (roc.magnitude == 0) { rocImage.Image = null; rocReading.Text = Strings.Workbench.Viewer.ROC_STABLE; isUpdating = false; } else { if (roc.magnitude < 0) { rocImage.Image = UIImage.FromBundle("ic_arrow_trend_down"); } else { rocImage.Image = UIImage.FromBundle("ic_arrow_trend_up"); } await Task.Delay(TimeSpan.FromMilliseconds(500)); DoUpdateRocCell(rocproperty); } }
private void WriteSensorProperty(ISensorProperty sp, BinaryWriter writer) { var ms = new MemoryStream(); using (var bw = new BinaryWriter(ms)) { try { var code = lookup[sp.GetType().Name]; var parser = parsers[code]; bw.Write((int)code); if (parser.Write(sp, bw)) { bw.Flush(); writer.Write(ms.ToArray()); } } catch (Exception e) { Log.E(this, "Failed to write sensor property {" + sp.GetType().Name + "} to writer", e); } } }
/// <summary> /// Queries the localizes string abreviation for the given sensor property. /// </summary> /// <returns>The localized string abreviation.</returns> /// <param name="sensorProperty">Sensor property.</param> /// <param name="context">Context.</param> public static string GetLocalizedStringAbreviation(this ISensorProperty sensorProperty, Context context) { if (sensorProperty is AlternateUnitSensorProperty) { return(context.GetString(Resource.String.workbench_alt_abrv)); } else if (sensorProperty is HoldSensorProperty) { return(context.GetString(Resource.String.workbench_hold_abrv)); } else if (sensorProperty is MinSensorProperty) { return(context.GetString(Resource.String.workbench_min_abrv)); } else if (sensorProperty is MaxSensorProperty) { return(context.GetString(Resource.String.workbench_max_abrv)); } else if (sensorProperty is PTChartSensorProperty) { return(context.GetString(Resource.String.fluid_pt_abrv)); } else if (sensorProperty is RateOfChangeSensorProperty) { return(context.GetString(Resource.String.workbench_roc_abrv)); } else if (sensorProperty is SuperheatSubcoolSensorProperty) { return(context.GetString(Resource.String.workbench_shsc_abrv)); } else if (sensorProperty is TimerSensorProperty) { return(context.GetString(Resource.String.workbench_timer_abrv)); } else { return(context.GetString(Resource.String.na)); } }
/// <summary> /// Adds the sensor property to the manifold if the manifold does not already have a /// sensor property of the given type. /// </summary> /// <param name="sensorProperty">Sensor property.</param> /// <returns>True if the property was added, false if the manifold already has the property.</returns> public bool AddSensorProperty(ISensorProperty sensorProperty) { if (HasSensorPropertyOfType(sensorProperty.GetType())) { return(false); } else { if (sensorProperty is SecondarySensorProperty) { sensorProperties.Insert(0, sensorProperty); NotifyOfEvent(new SensorEvent(SensorEvent.EType.SensorPropertyAdded, this, 0)); return(true); } else { sensorProperties.Add(sensorProperty); NotifyOfEvent(SensorEvent.EType.SensorPropertyAdded); return(true); } } }
private void OnOnSensorPropertyClicked(Manifold manifold, ISensorProperty sensorProperty) { var sensor = sensorProperty.sensor; if (sensorProperty is AlternateUnitSensorProperty) { var asp = sensorProperty as AlternateUnitSensorProperty; UnitDialog.Create(Activity, sensor.supportedUnits, (obj, u) => { asp.unit = u; }).Show(); } else if (sensorProperty is PTChartSensorProperty) { var i = new Intent(Activity, typeof(PTChartActivity)); i.SetAction(Intent.ActionPick); i.PutExtra(PTChartActivity.EXTRA_WORKBENCH_MANIFOLD, workbench.IndexOf(manifold)); if (ion is RemoteION) { StartActivity(i); } else { StartActivityForResult(i, REQUEST_SHOW_PTCHART); } } else if (sensorProperty is SuperheatSubcoolSensorProperty) { var i = new Intent(Activity, typeof(SuperheatSubcoolActivity)); i.SetAction(Intent.ActionPick); i.PutExtra(SuperheatSubcoolActivity.EXTRA_WORKBENCH_MANIFOLD, workbench.IndexOf(manifold)); i.PutExtra(SuperheatSubcoolActivity.EXTRA_FLUID_NAME, manifold.ptChart.fluid.name); i.PutExtra(SuperheatSubcoolActivity.EXTRA_FLUID_STATE, (int)manifold.ptChart.state); if (ion is RemoteION) { StartActivity(i); } else { StartActivityForResult(i, REQUEST_SHOW_SUPERHEAT_SUBCOOL); } } else if (sensorProperty is RateOfChangeSensorProperty) { var ps = manifold.primarySensor as GaugeDeviceSensor; if (ps != null && !ps.device.isConnected) { Toast.MakeText(Activity, Resource.String.devices_error_connect_for_roc, ToastLength.Long).Show(); } else { var i = new Intent(Activity, typeof(RoCActivity)); i.PutExtra(RoCActivity.EXTRA_MANIFOLD, new WorkbenchManifoldParcelable(workbench.IndexOf(manifold))); StartActivity(i); } } }
public static string GetCodeFromSensorProperty(ISensorProperty sp) { var type = sp.GetType(); if (typeof(AlternateUnitSensorProperty).Equals(type)) { return("Alternate"); } else if (typeof(PTChartSensorProperty).Equals(type)) { return("Pressure"); } else if (typeof(MinSensorProperty).Equals(type)) { return("Minimum"); } else if (typeof(MaxSensorProperty).Equals(type)) { return("Maximum"); } else if (typeof(HoldSensorProperty).Equals(type)) { return("Hold"); } else if (typeof(RateOfChangeSensorProperty).Equals(type)) { return("Rate"); } else if (typeof(SuperheatSubcoolSensorProperty).Equals(type)) { return("Superheat"); } else { // Log.D(typeof(RemoteAnalyzerLH).Name, "Cannot find code for sensor property: " + sp.GetType().Name + ". Returning null."); return(null); } }
private void OnSensorPropertyChanged(ISensorProperty sensorProperty) { //if (record.manifold.secondarySensor != null) { if (record.sensor.linkedSensor != null) { //labelMeasurement.Text = record.manifold.secondarySensor.measurement.amount.ToString("N") + " " + record.manifold.secondarySensor.unit; labelMeasurement.Text = record.sensor.linkedSensor.measurement.amount.ToString("N") + " " + record.sensor.linkedSensor.unit; //if (record.manifold.secondarySensor.type == ESensorType.Temperature){ if (record.sensor.linkedSensor.type == ESensorType.Temperature) { labelTitle.Text = "TEMP"; } else { labelTitle.Text = "PRESS"; } } else { labelMeasurement.Text = "Not Linked"; labelTitle.Text = "Linked"; } }
public static int CodeFromSensorProperty(ISensorProperty sp) { if (sp is PTChartSensorProperty) { return(CODE_SP_PT); } else if (sp is SuperheatSubcoolSensorProperty) { return(CODE_SP_SHSC); } else if (sp is MinSensorProperty) { return(CODE_SP_MIN); } else if (sp is MaxSensorProperty) { return(CODE_SP_MAX); } else if (sp is HoldSensorProperty) { return(CODE_SP_HOLD); // } else if (sp is RateOfChangeSensorProperty) { // return CODE_SP_ROC; } else if (sp is TimerSensorProperty) { return(CODE_SP_TIMER); } else if (sp is SecondarySensorProperty) { return(CODE_SP_SECONDARY); } else { return(-1); } }
/// <summary> /// Adds the sensor property to the manifold if the manifold does not already have a /// sensor property of the given type. /// </summary> /// <param name="sensorProperty">Sensor property.</param> /// <returns>True if the property was added, false if the manifold already has the property.</returns> public bool AddSensorProperty(ISensorProperty sensorProperty) { if (HasSensorPropertyOfType(sensorProperty.GetType())) { return(false); } else { if (sensorProperty is SecondarySensorProperty) { sensorProperties.Insert(0, sensorProperty); NotifyOfEvent(ManifoldEvent.EType.SensorPropertyAdded, 0); return(true); } else { sensorProperties.Add(sensorProperty); NotifyOfEvent(ManifoldEvent.EType.SensorPropertyAdded, sensorProperties.Count - 1); return(true); } } }
/// <summary> /// Removes the given sensor property from the manifold. /// </summary> /// <param name="sensorProperty">Sensor property.</param> public void RemoveSensorProperty(ISensorProperty sensorProperty) { RemoveSensorPropertyAt(sensorProperties.IndexOf(sensorProperty)); }
/// <summary> /// Views the in superheat subcool activity. /// </summary> /// <param name="">.</param> private void ViewInSuperheatSubcoolActivity(Manifold manifold, ISensorProperty sensorProperty) { var side = Analyzer.ESide.Low; if (!analyzer.GetSideOfManifold(manifold, out side)) { Error(GetString(Resource.String.analyzer_error_failed_to_launch_shsc_missing_manifold)); return; } // If the manifold does not have a secondary sensor, then we will need to query whether or not the analyzer has // space to accept the returned sensor. If it does not, then we cannot open the activity safely. if (manifold.secondarySensor == null && !analyzer.CanAddSensorToSide(side)) { var adb = new IONAlertDialog(Activity, Resource.String.error); adb.SetMessage(string.Format(GetString(Resource.String.analyzer_error_failed_to_launch_shsc_analyzer_full_1sarg), side.ToLocalizedString(Activity))); adb.SetNegativeButton(Resource.String.ok, (obj, args) => { var dialog = obj as Android.App.Dialog; dialog.Dismiss(); }); adb.Show(); return; } var sensor = sensorProperty.sensor; var i = new Intent(Activity, typeof(SuperheatSubcoolActivity)); i.SetAction(Intent.ActionPick); i.PutExtra(SuperheatSubcoolActivity.EXTRA_LOCK_FLUID, true); i.PutExtra(SuperheatSubcoolActivity.EXTRA_FLUID_NAME, manifold.ptChart.fluid.name); i.PutExtra(SuperheatSubcoolActivity.EXTRA_FLUID_STATE, (int)analyzer.SideAsFluidState(side)); switch (sensor.type) { case ESensorType.Pressure: i.PutExtra(SuperheatSubcoolActivity.EXTRA_ANALYZER_MANIFOLD, (int)side); if (ion is RemoteION) { StartActivity(i); } else { StartActivityForResult(i, EncodeSuperheatSubcoolRequest(side)); } break; case ESensorType.Temperature: i.PutExtra(SuperheatSubcoolActivity.EXTRA_ANALYZER_MANIFOLD, (int)side); if (ion is RemoteION) { StartActivity(i); } else { StartActivityForResult(i, EncodeSuperheatSubcoolRequest(side)); } break; default: var msg = string.Format(GetString(Resource.String.analyzer_error_invalid_sensor_type), sensor.type.GetTypeString()); L.E(this, msg); Alert(msg); break; } }
private void OnSensorPropertyChanged(ISensorProperty sensorProperty) { HandleSuperheatSubcoolSensorPropertyChanged(sensorProperty as TargetSuperheatSubcoolProperty); }
// Implemented for ISubviewParser public bool Write(ISensorProperty sp, BinaryWriter writer) { return(true); }