public Sensor(string name, int index, bool defaultHidden, SensorType sensorType, Hardware hardware, ParameterDescription[] parameterDescriptions, ISettings settings) { this.index = index; this.defaultHidden = defaultHidden; this.sensorType = sensorType; this.hardware = hardware; Parameter[] parameters = new Parameter[parameterDescriptions == null ? 0 : parameterDescriptions.Length]; for (int i = 0; i < parameters.Length; i++ ) parameters[i] = new Parameter(parameterDescriptions[i], this, settings); this.parameters = parameters; this.settings = settings; this.defaultName = name; this.name = settings.GetValue( new Identifier(Identifier, "name").ToString(), name); GetSensorValuesFromSettings(); hardware.Closing += delegate(IHardware h) { SetSensorValuesToSettings(); }; }
private static void SimulateDeviceDataTransmission(SensorType type, string topic, string deviceId) { int value = Random.Next(1, Math.Min(120, 100 + (_count/25))); if (value%13 == 0) { value = value/2; } else if (value%17 == 0) { value = value*2; } var payload = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject( new SensorData { Value = value.ToString(), DeviceId = deviceId, Type = type })); Client.Publish(topic, payload, MqttMsgBase.QOS_LEVEL_AT_MOST_ONCE, true); }
public Sensor(string name, int index, SensorType sensorType, Hardware hardware, ParameterDescription[] parameterDescriptions, ISettings settings) : this(name, index, false, sensorType, hardware, parameterDescriptions, settings) { }
public GradientChanger(SensorManager sensorManager, SensorType sensorType, AbsoluteLayout layout) { this._sensorManager = sensorManager; this._sensorType = sensorType; _layout = layout; this.StartListening(); }
private static string GetUnit(SensorType type, byte scale) { var tankCapacityUnits = new[] { "l", "cbm", "gal" }; var distanceUnits = new [] { "m", "cm", "ft" }; switch (type) { case SensorType.Temperature: return(scale == 1 ? "°F" : "°C"); case SensorType.General: return (scale == 1 ? "" : "%"); case SensorType.Luminance: return(scale == 1 ? "lux" : "%"); case SensorType.Power: return(scale == 1 ? "BTU/h" : "W"); case SensorType.RelativeHumidity: return("%"); case SensorType.Velocity: return(scale == 1 ? "mph" : "m/s"); case SensorType.Direction: return(""); case SensorType.AtmosphericPressure: return(scale == 1 ? "inHg" : "kPa"); case SensorType.BarometricPressure: return(scale == 1 ? "inHg" : "kPa"); case SensorType.SolarRadiation: return("W/m2"); case SensorType.DewPoint: return(scale == 1 ? "in/h" : "mm/h"); case SensorType.RainRate: return(scale == 1 ? "F" : "C"); case SensorType.TideLevel: return(scale == 1 ? "ft" : "m"); case SensorType.Weight: return(scale == 1 ? "lb" : "kg"); case SensorType.Voltage: return(scale == 1 ? "mV" : "V"); case SensorType.Current: return(scale == 1 ? "mA" : "A"); case SensorType.CO2: return("ppm"); case SensorType.AirFlow: return(scale == 1 ? "cfm" : "m3/h"); case SensorType.TankCapacity: return(tankCapacityUnits[scale]); case SensorType.Distance: return(distanceUnits[scale]); default: return string.Empty; } }
public TypeNode(SensorType sensorType) : base() { this.sensorType = sensorType; switch (sensorType) { case SensorType.Voltage: this.Image = Utilities.EmbeddedResources.GetImage("voltage.png"); this.Text = "电压"; break; case SensorType.Clock: this.Image = Utilities.EmbeddedResources.GetImage("clock.png"); this.Text = "频率"; break; case SensorType.Load: this.Image = Utilities.EmbeddedResources.GetImage("load.png"); this.Text = "负载"; break; case SensorType.Temperature: this.Image = Utilities.EmbeddedResources.GetImage("temperature.png"); this.Text = "温度"; break; case SensorType.Fan: this.Image = Utilities.EmbeddedResources.GetImage("fan.png"); this.Text = "风扇"; break; case SensorType.Flow: this.Image = Utilities.EmbeddedResources.GetImage("flow.png"); this.Text = "Flows"; break; case SensorType.Control: this.Image = Utilities.EmbeddedResources.GetImage("control.png"); this.Text = "控制台"; break; case SensorType.TinyFanControl: this.Image = Utilities.EmbeddedResources.GetImage("control.png"); this.Text = "控制台"; break; case SensorType.Level: this.Image = Utilities.EmbeddedResources.GetImage("level.png"); this.Text = "Levels"; break; case SensorType.Power: this.Image = Utilities.EmbeddedResources.GetImage("power.png"); this.Text = "功率"; break; case SensorType.Data: this.Image = Utilities.EmbeddedResources.GetImage("data.png"); this.Text = "Data"; break; case SensorType.Factor: this.Image = Utilities.EmbeddedResources.GetImage("factor.png"); this.Text = "Factors"; break; } NodeAdded += new NodeEventHandler(TypeNode_NodeAdded); NodeRemoved += new NodeEventHandler(TypeNode_NodeRemoved); }
public Control(ISensor sensor, ISettings settings, float minSoftwareValue, float maxSoftwareValue) { this.identifier = new Identifier(sensor.Identifier, "control"); this.settings = settings; this.minSoftwareValue = minSoftwareValue; this.maxSoftwareValue = maxSoftwareValue; //fan add this.sensorType = sensor.SensorType; float softValue = 0; if (!float.TryParse(settings.GetValue( new Identifier(identifier, "value").ToString(), "-a"), NumberStyles.Float, CultureInfo.InvariantCulture, out softValue)){ this.softwareValue = 0; if (this.sensorType.Equals(SensorType.TinyFanControl)) this.SoftwareValue = 50; //init value(when .config was not exist) } else this.softwareValue = softValue; int mode; if (!int.TryParse(settings.GetValue( new Identifier(identifier, "mode").ToString(), ((int)ControlMode.Default).ToString(CultureInfo.InvariantCulture)), NumberStyles.Integer, CultureInfo.InvariantCulture, out mode)) { this.mode = ControlMode.Default; } else { this.mode = (ControlMode)mode; } int fanMode; if (!int.TryParse(settings.GetValue( new Identifier(identifier, "fanMode").ToString(), ((int)FanMode.Pin4).ToString(CultureInfo.InvariantCulture)), NumberStyles.Integer, CultureInfo.InvariantCulture, out fanMode)) { this.fanMode = FanMode.Pin4; } else { this.fanMode = (FanMode)fanMode; } int fanFollow;//again if (!int.TryParse(settings.GetValue( new Identifier(identifier, "fanFollow").ToString(), ((int)FanFollow.NONE).ToString(CultureInfo.InvariantCulture)), NumberStyles.Integer, CultureInfo.InvariantCulture, out fanFollow)) { this.fanFollow = FanFollow.NONE; } else { this.fanFollow = (FanFollow)fanFollow; } }
public VideoStream CreateVideoStream(SensorType sensorType) { if (!this.isValid) return null; if (!VideoStreams_Cache.ContainsKey(sensorType)) VideoStreams_Cache[sensorType] = VideoStream.Private_Create(this, sensorType); return VideoStreams_Cache[sensorType]; }
public AndroidSensorListener(SensorType sensorType, SensorDelay sensorDelay, Action<SensorStatus> sensorAccuracyChangedCallback, Action<SensorEvent> sensorValueChangedCallback) { _sensorType = sensorType; _sensorDelay = sensorDelay; _sensorAccuracyChangedCallback = sensorAccuracyChangedCallback; _sensorValueChangedCallback = sensorValueChangedCallback; _listening = false; }
public CollisionSensor(CollisionBox linkedCollisionBox, SensorType sensorType, int sensorDepth) : base(0, 0, Vector2.Zero, Color.Blue) { this.linkedCollisionBox = linkedCollisionBox; this.sensorType = sensorType; this.sensorDepth = sensorDepth; SetSensorDetails(); }
private void UpdateValue(Device sd, ZibaseDll.ZiBase.SensorInfo si, SensorType st) { DeviceValue dv = null; var q = sd.Values.Where(x => x.ValueType == st); if (q.Any()) { dv = q.First(); dv.Value = si.sHTMLValue; if (st == SensorType.ENERGY_KW || st == SensorType.ENERGY_KWH) { String[] splitted = si.sValue.Split(new char[] { ' ' }); if (splitted.Length == 2) { float val = Convert.ToSingle(dv.Value,System.Globalization.CultureInfo.InvariantCulture); // Convert.ToInt32(splitted[0]); //val /= 1000.0F; dv.DisplayValue = val + " " + splitted[1]; } } else dv.DisplayValue = si.sValue; } else { dv = new DeviceValue {Value = si.sHTMLValue, ValueType = st}; if (st == SensorType.ENERGY_KW || st == SensorType.ENERGY_KWH) { String[] splitted = si.sValue.Split(new char[] { ' ' }); if (splitted.Length == 2) { //float val = Convert.ToInt32(splitted[0]); //val /= 1000.0F; float val = Convert.ToSingle(dv.Value, System.Globalization.CultureInfo.InvariantCulture); // Convert.ToInt32(splitted[0]); dv.DisplayValue = val + " " + splitted[1]; } } else dv.DisplayValue = si.sValue; sd.Values.Add(dv); } // if no HSDevice associated,look for the current device in HS // IOMisc contains the ID followed by the SensorType if (dv.HSDevice == null) { var q2 = HSDevice.Where(x => x.iomisc.Contains(si.sID) && x.iomisc.Contains(st.ToString())); if (q2.Any()) { dv.AlreadyInHS = true; dv.HSDevice = q2.First(); } } dv.DwValue = si.dwValue; dv.HSUpdate(); }
public MySensorsPresentationMessage(int nodeId, int sensorId, SensorType sensorType, bool ack, string payload) { this.DateTimeOffset = DateTimeOffset.Now; this.NodeId = nodeId; this.SensorId = sensorId; this.SensorType = sensorType; this.Ack = ack; this.Payload = payload; }
public Sensor(string name, int index, SensorType sensorType, Hardware hardware, Parameter[] parameterDescriptions) { Index = index; SensorType = sensorType; Parameters = parameterDescriptions; Name = name; Identifier = $"{hardware.Identifier}/{SensorType}/{Index}"; }
/// <summary> /// Initializes a new instance of the <see cref="SensorParametersInternal"/> class. /// </summary> /// <param name="sensorName">The name to use for this sensor.</param> /// <param name="sensorType">The type of sensor these parameters will create.</param> internal SensorParametersInternal(string sensorName, SensorType sensorType) : base(sensorName, "fake_type") { SensorType = sensorType; if (DefaultTags != null && DefaultTags.Length != 0) { Tags = DefaultTags; } }
public static string End(SensorType type) { #if UNITY_ANDROID return(jc.CallStatic <string>(end, (int)type)); #else Debug.LogError("Non-Android is not supported"); return("Non-Android is not supported"); #endif }
public static float Get(SensorType type, int index) { #if UNITY_ANDROID return(jc.CallStatic <float>(get, (int)type, index)); #else Debug.LogError("Non-Android is not supported"); return(-1f); #endif }
private byte[] SetupCommand(SensorPort sensorPort, ConnectionType conn, SensorType type, byte mode) { lock (setupLock) { sensorData [(int)sensorPort] = (byte)conn; sensorData [(int)sensorPort + NumberOfSensorPorts] = (byte)type; sensorData [(int)sensorPort + 2 * NumberOfSensorPorts] = mode; return(sensorData); } }
public static bool IsRunning(SensorType type) { #if UNITY_ANDROID return(jc.CallStatic <bool>(checkRunning)); #else Debug.LogError("Non-Android is not supported"); return(false); #endif }
public DialogSensor(Sensor sensor) { this.sensor = sensor; this.SensorTypes = SensorDescriptor.SensorTypes; SensorType type = this.sensor.SensorType; this.IsLoop = (type != SensorType.Series); if (type == SensorType.Loop) { type = SensorType.Series; } this.SelectedSensorType = this.SensorTypes.First(t => t.Value == type); this.SeriesData = (type == SensorType.Series) ? this.sensor.Data : Sensor.DefaultSeriesData; int min = Sensor.DefaultRandomMinInterval; int max = Sensor.DefaultRandomMaxInterval; if (type == SensorType.Random) { SensorPoint point; if (Sensor.TryParsePoint(this.sensor.Data, 32, out point)) { min = point.Tick; max = point.Value; } } this.RandomMin = min.ToString(Properties.Resources.Culture); this.RandomMax = max.ToString(Properties.Resources.Culture); if (type == SensorType.Manual) { string text = this.sensor.Data; int value; if (string.IsNullOrEmpty(text) || !int.TryParse(text, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out value)) { value = 0; } this.ManualInitialValue = Constant.Normalize(value, this.sensor.BitWidth).ToString("X", CultureInfo.InvariantCulture); } else { this.ManualInitialValue = "0"; } this.DataContext = this; this.InitializeComponent(); this.bitWidth.ItemsSource = PinDescriptor.BitWidthRange; this.bitWidth.SelectedItem = this.sensor.BitWidth; this.side.ItemsSource = PinDescriptor.PinSideRange; this.side.SelectedItem = PinDescriptor.PinSideDescriptor(this.sensor.PinSide); this.notation.Text = this.sensor.Notation; this.note.Text = this.sensor.Note; }
async Task StartHoloLensMediaFrameSourceGroups() { #if ENABLE_WINMD_SUPPORT // Plugin doesn't work in the Unity editor myText.text = "Initializing MediaFrameSourceGroups..."; // PV Debug.Log("HoloLensForCVUnity.ArUcoDetection.StartHoloLensMediaFrameSourceGroup: Setting up sensor frame streamer"); _sensorType = (SensorType)sensorTypePv; _sensorFrameStreamerPv = new SensorFrameStreamer(); _sensorFrameStreamerPv.Enable(_sensorType); // Spatial perception Debug.Log("HoloLensForCVUnity.ArUcoDetection.StartHoloLensMediaFrameSourceGroup: Setting up spatial perception"); _spatialPerception = new SpatialPerception(); // Enable media frame source groups // PV Debug.Log("HoloLensForCVUnity.ArUcoDetection.StartHoloLensMediaFrameSourceGroup: Setting up the media frame source group"); _pvMediaFrameSourceGroup = new MediaFrameSourceGroup( MediaFrameSourceGroupType.PhotoVideoCamera, _spatialPerception, _sensorFrameStreamerPv); _pvMediaFrameSourceGroup.Enable(_sensorType); // Start media frame source groups myText.text = "Starting MediaFrameSourceGroups..."; // Photo video Debug.Log("HoloLensForCVUnity.ArUcoDetection.StartHoloLensMediaFrameSourceGroup: Starting the media frame source group"); await _pvMediaFrameSourceGroup.StartAsync(); _mediaFrameSourceGroupsStarted = true; myText.text = "MediaFrameSourceGroups started..."; // Initialize the Unity coordinate system // Get pointer to Unity's spatial coordinate system // https://github.com/qian256/HoloLensARToolKit/blob/master/ARToolKitUWP-Unity/Scripts/ARUWPVideo.cs try { _unityCoordinateSystem = Marshal.GetObjectForIUnknown(WorldManager.GetNativeISpatialCoordinateSystemPtr()) as SpatialCoordinateSystem; } catch (Exception) { Debug.Log("ArUcoDetectionHoloLensUnity.ArUcoMarkerDetection: Could not get pointer to Unity spatial coordinate system."); throw; } // Initialize the aruco marker detector with parameters _arUcoMarkerTracker = new ArUcoMarkerTracker( markerSize, (int)arUcoDictionaryName, _unityCoordinateSystem); #endif }
private void AddSensor(string name, int index, bool defaultHidden, SensorType sensorType, GetSensorValue getValue) { var sensor = new NVMeSensor(name, index, defaultHidden, sensorType, this, _settings, getValue) { Value = 0 }; ActivateSensor(sensor); _sensors.Add(sensor); }
public void UnitedValueToBarSensorValue_Null_Test() { const SensorType sensorType = SensorType.BooleanSensor; var unitedValue = _sensorValuesFactory.BuildUnitedSensorValue(sensorType); var barSensorValue = unitedValue.Convert(); Assert.Null(barSensorValue); }
public async Task <Sensor> GetByBoxIdAndTypeAsync(string boxId, SensorType type) { var table = _client.GetTableClient(_tableName); await table.CreateIfNotExistsAsync(); var sensorTypeString = type.ToString("G"); var entityPages = table.QueryAsync <TableEntity>(x => x.PartitionKey == boxId && x.RowKey == sensorTypeString); return((await entityPages.AsPages().FirstOrDefaultAsync())?.Values.Select(SensorMapper.Map).FirstOrDefault()); }
public NewSensorDynamicParameterCategory(SensorType type, NewSensorDestinationType destinationType, AlternateParameterSet alternateSet) { parameterSets = new Lazy <ParameterSetDescriptor[]>(GetParameterSets); Type = type; DestinationType = destinationType; this.alternateSet = alternateSet; }
public static string Start(SensorType type) { #if UNITY_ANDROID && !UNITY_EDITOR return(jc.CallStatic <string>(start, (int)type)); #else Debug.LogWarning("Non-Android is not supported"); return("Non-Android is not supported"); #endif }
public void SensorValueToSensorDataEntityConverter_WithoutComment_Test(SensorType sensorType, string comment) { var sensorValue = _sensorValuesFactory.BuildSensorValue(sensorType); sensorValue.Comment = comment; var data = sensorValue.Convert(_productName, _timeCollected, TransactionType.Unknown); Assert.Equal(GetSensorDataStringValue(sensorValue), data.StringValue); }
void RegisterListeners(SensorType sensorType) { var sensorManager = (SensorManager)GetSystemService(Context.SensorService); var sensor = sensorManager.GetDefaultSensor(sensorType); //get faster why not, nearly fast already and when //sensor gets messed up it will be better sensorManager.RegisterListener(this, sensor, SensorDelay.Normal); Console.WriteLine("Sensor listener registered of type: " + sensorType); }
public VirtualSensor(string name, int index, SensorType sensorType, Hardware.Hardware hardware, ISettings settings) : base(name, index, false, sensorType, hardware, null, settings) { val = new ValueString(settings.GetValue(new Identifier(Identifier, "valuestring").ToString(), "0"), SharedData.AllSensors); SetSensorType(sensorType); skip = 0; int.TryParse(settings.GetValue(new Identifier(Identifier, "skip").ToString(), "0"), out skip); skipCount = skip; // Force initial update }
/// <summary> /// 构造函数 /// </summary> /// <param name="SenorVersion">传感器种类</param> /// <param name="FrequencySampling">采用频率,默认250Hz</param> /// <param name="FilterSampling">截断频率,默认4,即15Hz</param> /// <param name="AmountSampling">要采集的数据个数,默认0,即无穷个</param> public OPTO49152Connector(SensorType SenorVersion, int FrequencySampling = 250, int FilterSampling = 4, int AmountSampling = 0) { sensorVersion = SenorVersion; sampleFrequency = FrequencySampling; frequencyFilter = FilterSampling; sampleCount = AmountSampling; listenCancelSource = new CancellationTokenSource(); listenFromOPTOTask = new Task(() => ListenFromOPTOFunction(listenCancelSource.Token)); }
public void Remove(IActorStateModel actor, SensorType sensor) { _storages[sensor].Remove(actor); if (_lifetimeSubscriptions.ContainsKey(actor)) { _lifetimeSubscriptions[actor].Dispose(); _lifetimeSubscriptions.Remove(actor); } }
public EmbeddedControllerSource(string name, SensorType type, ushort register, byte size, float factor = 1.0f, uint blank = uint.MaxValue) { Name = name; Register = register; Size = size; Type = type; Factor = factor; Blank = blank; }
public NewSensorDynamicParameterCategory(SensorType type, NewSensorDestinationType destinationType, Func <PSCmdlet> makeCmdlet = null, Action <dynamic, Dictionary <string, object> > valueFromPipeline = null) { parameterSets = new Lazy <ParameterSetDescriptor[]>(GetParameterSets); Type = type; DestinationType = destinationType; this.makeCmdlet = makeCmdlet; this.valueFromPipeline = valueFromPipeline; }
// GPU // For clock 1 means core, 2 means memory, 3 means shader // For Load 4 means memory and 1 means core. private float GetGpuInfo(int core, SensorType sensor) { // Making sure we are open if (!opened) { return(0); } // Making sure we don't get a bad number if (sensor == SensorType.Clock) { if (core > 3) { return(0); } } if (sensor == SensorType.Load) { if (core > 4) { return(0); } } float value = 0; computer.GPUEnabled = true; for (int i = 0; core > 0; i++) { // Find the right hardware if ((computer.Hardware[i].HardwareType != HardwareType.GpuNvidia) && (computer.Hardware[i].HardwareType != HardwareType.GpuAti)) { continue; } for (int j = 0; j < computer.Hardware[i].Sensors.Length; j++) { // Find right sensor. if (computer.Hardware[i].Sensors[j].SensorType != sensor) { continue; } value = (float)(computer.Hardware[i].Sensors[j].Value); core -= 1; if (core == 0) { // Returning here computer.GPUEnabled = false; return(value); } } } computer.GPUEnabled = false; return(0); }
private float GetCPUInfo(int core, SensorType sensor) { // Making sure we are open if (!opened) { return(0); } // Making sure we have a legit value // Plus 1 to represent package. int totalCore = GetCpuCores(); //if (core > (totalCore + 1)) //{ // return 0; //} // Wrong type of sensor if ((sensor != SensorType.Temperature) && (sensor != SensorType.Load) && (sensor != SensorType.Clock)) { return(0); } float value = 100; computer.CPUEnabled = true; for (int i = 0; core > 0; i++) { // Find the right hardware if (computer.Hardware[i].HardwareType != HardwareType.CPU) { continue; } for (int j = 0; j < computer.Hardware[i].Sensors.Length; j++) { // Find right sensor. if (computer.Hardware[i].Sensors[j].SensorType != sensor) { continue; } value = (float)(computer.Hardware[i].Sensors[j].Value); core -= 1; if (core == 0) { // Returning here computer.CPUEnabled = false; return(value); } } } computer.CPUEnabled = false; return(0); }
/// <summary> /// Initializes a new instance of the <see cref="SmartAttribute"/> class. /// </summary> /// <param name="identifier">The SMART identifier of the attribute.</param> /// <param name="name">The name of the attribute.</param> /// <param name="rawValueConversion">A delegate for converting the raw byte /// array into a value (or null to use the attribute value).</param> /// <param name="sensorType">Type of the sensor or null if no sensor is to /// be created.</param> /// <param name="sensorChannel">If there exists more than one attribute with /// the same sensor channel and type, then a sensor is created only for the /// first attribute.</param> /// <param name="defaultHiddenSensor">True to hide the sensor initially.</param> public SmartAttribute(byte identifier, string name, RawValueConversion rawValueConversion, SensorType? sensorType, int sensorChannel, bool defaultHiddenSensor = false) { this.Identifier = identifier; this.Name = name; this.rawValueConversion = rawValueConversion; this.SensorType = sensorType; this.SensorChannel = sensorChannel; this.DefaultHiddenSensor = defaultHiddenSensor; }
public Sensors(Context context, SensorType type, Action <string> onsensorchanged, Action <string> acc) { this.context = context; this.onsensorchanged = onsensorchanged; this.onAccuracyChanged = acc; this.type = type; _senMan = (SensorManager)context.GetSystemService(Context.SensorService); Sensor sen = _senMan.GetDefaultSensor(type); _senMan.RegisterListener(this, sen, Android.Hardware.SensorDelay.Normal); }
public SensorData() { // The initial type doesn't matter since the abstract base // class will never be instantiated. type = SensorType.Acceleration; Enabled = Defaults.Sensor.Enabled; Name = ""; Solid = null; // "transform" is initialized in its own constructor. //Transform = Matrix.Identity; }
public Sensor(SensorType kind, double outputStart, double outputEnd, double range, double coefficient, int y, int digits = 3) { this.kind = kind; this.outputStart = outputStart; this.outputEnd = outputEnd; this.range = range; this.coefficient = coefficient; this._readValue = outputStart; this.digits = digits; this.b = y; }
public TypeNode(SensorType sensorType) : base() { this.sensorType = sensorType; switch (sensorType) { case SensorType.Voltage: this.Text = "voltages"; break; case SensorType.Clock: this.Text = "clocks"; break; case SensorType.Load: this.Text = "load"; break; case SensorType.Temperature: this.Text = "temperatures"; break; case SensorType.Fan: this.Text = "fans"; break; case SensorType.Flow: this.Text = "flows"; break; case SensorType.Control: this.Text = "controls"; break; case SensorType.Level: this.Text = "levels"; break; case SensorType.Power: this.Text = "powers"; break; case SensorType.Data: this.Text = "data"; break; case SensorType.Factor: this.Text = "factors"; break; } NodeAdded += new NodeEventHandler(TypeNode_NodeAdded); NodeRemoved += new NodeEventHandler(TypeNode_NodeRemoved); }
public async Task AddSensorValueTest(SensorType type) { var sensorValue = _sensorValuesFactory.BuildSensorValue(type); _monitoringCore.AddSensorValue(sensorValue); await FullSensorValueTestAsync(sensorValue, _valuesCache.GetValues, _databaseAdapterManager.DatabaseAdapter.GetOneValueSensorValue, _databaseAdapterManager.DatabaseAdapter.GetSensorInfo); }
public static bool IsPureCounterSensorType(SensorType type) { if (type == SensorType.ESM) { return(true); } else { return(false); } }
public void SetVisible(SensorType sensorType, bool visible) { foreach (TypeNode node in typeNodes) { if (node.SensorType == sensorType) { node.IsVisible = visible; UpdateNode(node); } } }
internal SensorMultiLevelReport(Node node, byte[] payload) : base(node) { if (payload == null) throw new ArgumentNullException(nameof(payload)); if (payload.Length < 3) throw new ReponseFormatException($"The response was not in the expected format. {GetType().Name}: Payload: {BitConverter.ToString(payload)}"); Type = (SensorType)payload[0]; Value = PayloadConverter.ToFloat(payload.Skip(1).ToArray(), out Scale); Unit = GetUnit(Type, Scale); }
public SensorInfoImpl(int aId, string aName, SensorType aSensorType, SensorSide aSide, double aShift) { if (string.IsNullOrEmpty(aName)) { throw new ArgumentNullException("aName"); } id = aId; name = aName; sType = aSensorType; side = aSide; shift = aShift; }
public object GetImageArray(Bitmap bmp, SensorType sensorType, LumaConversionMode conversionMode) { this.imageWidth = bmp.Width; this.imageHeight = bmp.Height; if (sensorType == SensorType.Monochrome) return NativeHelpers.GetMonochromePixelsFromBitmap(bmp, conversionMode); else if (sensorType == SensorType.Color) return NativeHelpers.GetColourPixelsFromBitmap(bmp); else throw new NotSupportedException(string.Format("Sensor type {0} is not currently supported.", sensorType)); }
/// <summary> /// Initializes a new instance of the <see cref="SmartAttribute"/> class. /// </summary> /// <param name="identifier">The SMART identifier of the attribute.</param> /// <param name="name">The name of the attribute.</param> /// <param name="rawValueConversion">A delegate for converting the raw byte /// array into a value (or null to use the attribute value).</param> /// <param name="sensorType">Type of the sensor or null if no sensor is to /// be created.</param> /// <param name="sensorChannel">If there exists more than one attribute with /// the same sensor channel and type, then a sensor is created only for the /// first attribute.</param> /// <param name="defaultHiddenSensor">True to hide the sensor initially.</param> /// <param name="parameterDescriptions">Description for the parameters of the sensor /// (or null).</param> public SmartAttribute(byte identifier, string name, RawValueConversion rawValueConversion, SensorType? sensorType, int sensorChannel, bool defaultHiddenSensor = false, ParameterDescription[] parameterDescriptions = null) { this.Identifier = identifier; this.Name = name; this.rawValueConversion = rawValueConversion; this.SensorType = sensorType; this.SensorChannel = sensorChannel; this.DefaultHiddenSensor = defaultHiddenSensor; this.ParameterDescriptions = parameterDescriptions; }
public void SetImageArray(object imageArray, int imageWidth, int imageHeight, SensorType sensorType) { this.imageArray = imageArray; this.imageWidth = imageWidth; this.imageHeight = imageHeight; this.sensorType = sensorType; objPixelArray = null; intPixelArray = null; intColourPixelArray = null; objColourPixelArray = null; if (sensorType == SensorType.Monochrome) { if (imageArray is int[,]) { intPixelArray = (int[,])imageArray; isColumnMajor = intPixelArray.GetLength(0) == imageWidth; isRowMajor = intPixelArray.GetLength(0) == imageHeight; return; } else if (imageArray is object[,]) { objPixelArray = (object[,])imageArray; isColumnMajor = objPixelArray.GetLength(0) == imageWidth; isRowMajor = objPixelArray.GetLength(0) == imageHeight; return; } } else { // Color sensor type is represented as 3-dimentional array that can be either: [3, height, width], [width, height, 3] if (imageArray is int[, ,]) { intColourPixelArray = (int[, ,])imageArray; isColumnMajor = intColourPixelArray.GetLength(0) == imageWidth; isRowMajor = intColourPixelArray.GetLength(0) == 3; return; } else if (imageArray is object[, ,]) { objColourPixelArray = (object[, ,])imageArray; isColumnMajor = objColourPixelArray.GetLength(0) == imageWidth; isRowMajor = objColourPixelArray.GetLength(0) == 3; return; } } throw new ArgumentException(); }
/// <summary> /// Gets the sensor type and mode. /// </summary> /// <param name="type">Type.</param> /// <param name="mode">Mode.</param> protected void GetTypeAndMode(out SensorType type, out SensorMode mode){ if(!isInitialized) Initialize(); var command = new Command(2,0,200,true); command.Append(ByteCodes.InputDevice); command.Append(InputSubCodes.GetTypeMode); command.Append(this.DaisyChainLayer); command.Append(this.Port); command.Append((byte)0, VariableScope.Global); command.Append((byte)1, VariableScope.Global); var reply = Connection.SendAndReceive(command); Error.CheckForError(reply,200); type = (SensorType) reply.GetByte(3); mode = (SensorMode) reply.GetByte(4); }
public Sensor(string name, int index, bool defaultHidden, SensorType sensorType, Hardware hardware, ParameterDescription[] parameterDescriptions) { this.index = index; this.defaultHidden = defaultHidden; this.sensorType = sensorType; this.hardware = hardware; Parameter[] parameters = new Parameter[parameterDescriptions == null ? 0 : parameterDescriptions.Length]; for (int i = 0; i < parameters.Length; i++ ) parameters[i] = new Parameter(parameterDescriptions[i], this); this.parameters = parameters; this.defaultName = name; this.name = name; }
internal static Location GenerateLocation(SensorType sensorType, int seed) { IList<Sensor> list = new List<Sensor>(); switch (sensorType) { case SensorType.All: list.Add(WiFiSensorHelper.GetASensor(seed)); list.Add(WiFiConnectedSensorHelper.GetASensor()); break; case SensorType.WiFiConnected: list.Add(WiFiConnectedSensorHelper.GetASensor()); break; case SensorType.WiFi: list.Add(WiFiSensorHelper.GetASensor(seed)); break; } return new Location(list); }
/// <summary> /// Initialized the decoder class, will fill all elements if the format is properly recognised /// </summary> /// <param name="rawData">The raw ANT packet to process</param> public DataDecoder(byte[] rawData) { rawPacket = rawData; dataLength = rawPacket[1]; //if standard packet (first byte of data is the channel id) if (dataLength == 9 || dataLength == 14) { int sensorType = rawData[4] & 0xE0; //11100000 mask sensorType = sensorType >> 5; //set the extended message parameters if ((dataLength == 14) && (rawData[12] == 0x80)) { isExtendedMessage = true; deviceID = GetDeviceID(rawData[13], rawData[14]); } else { isExtendedMessage = false; } switch (sensorType) { case 2: sensor = SensorType.Accelerometer; break; case 4: sensor = SensorType.Temperature; break; case 3: sensor = SensorType.Button; break; default: sensor = SensorType.Unknown; break; } ProcessData(); } }
public List<ISensor> filter(SensorType requestedSensorType) { var requestedSensors = new List<ISensor>(); var cpus = _computer.Hardware.ToList().Select(hardware => hardware.HardwareType == HardwareType.CPU); foreach (var hardware in _computer.Hardware) { if (hardware.HardwareType != HardwareType.CPU) continue; hardware.Update(); var cpuSensors = hardware.Sensors; foreach (var sensor in cpuSensors) { if (sensor.SensorType == requestedSensorType) { requestedSensors.Add(sensor); } } } return requestedSensors; }
/// <summary> /// Set sensor's type and mode. /// </summary> /// /// <param name="sensor">Sensor to set type of.</param> /// <param name="type">Sensor's type.</param> /// <param name="mode">Sensor's mode.</param> /// /// <returns>Returns <b>true</b> if command was executed successfully or <b>false</b> otherwise.</returns> /// public bool SetSensorMode( Sensor sensor, SensorType type, SensorMode mode ) { return SetSensorMode( sensor, type, mode, true ); }
TtlSensor CreateTtlSensor(SensorType sensorType, String name, Channel channel, float sampleRate, bool queueData) { TtlSensor sensor; switch (sensorType) { //case SensorType.Brain: // sensor = new BrainSensor(new BrainSensor.Processor(), name, channel, sampleRate, queueData); // break; case SensorType.Bvp: sensor = new BvpSensor(new BvpSensor.Processor(), name, channel, sampleRate, queueData); break; case SensorType.Gsr: sensor = new GsrSensor(new GsrSensor.Processor(), name, channel, sampleRate, queueData); break; case SensorType.Heart: sensor = new HeartSensor(new HeartSensor.Processor(), name, channel, sampleRate, queueData); break; case SensorType.Muscle: sensor = new MuscleSensor(new MuscleSensor.Processor(), name, channel, sampleRate, queueData); break; case SensorType.Strain: sensor = new StrainSensor(new StrainSensor.Processor(), name, channel, sampleRate, queueData); break; case SensorType.Temperature: sensor = new TempSensor(new TempSensor.Processor(), name, channel, sampleRate, queueData); break; case SensorType.Raw: sensor = new RawSensor(new RawSensor.Processor(), name, channel, sampleRate, queueData); break; default: sensor = null; Debug.Assert(false); break; } return sensor; }
public void GetSensorState(SensorPort port, out SensorType type, out SensorMode mode, out int raw, out int normalized, out int scaled) { mre.Reset(); GetInputState(port); if (!mre.WaitOne(1000, false)) throw new NxtTimeout(); if (nError > 0) throw new InvalidResult(); if (result[4] != 1) throw new InvalidResult(); type = (SensorType)result[6]; mode = (SensorMode)result[7]; raw = Buffer2Word(result, 8); normalized = Buffer2Word(result, 10); scaled = Buffer2Word(result, 12); }
public void SetInputMode(SensorPort nPort, SensorType nType, SensorMode nMode) { byte[] data = new byte[5]; data[0] = 0x80; data[1] = 0x05; data[2] = (byte)nPort; data[3] = (byte)nType; data[4] = (byte)nMode; Tx(data); }
/* public void StartChannels() { session.StartChannels(); channelsStarted = true; return; } public void StopChannels() { channelsStarted = false; session.StopChannels(); return; } */ public TtlSensor CreateSensor(ITtlEncoder encoder, SensorType type, Channel channel, String name, bool queueData) { if (sessionThreadControl.InvokeRequired) { Func<ITtlEncoder, SensorType, Channel, String, bool, TtlSensor> func = new Func<ITtlEncoder, SensorType, Channel, String, bool, TtlSensor>(CreateSensor); return (TtlSensor)sessionThreadControl.Invoke(func, encoder, type, channel, name, queueData); } //Find the encoder TTLEncoder ttlEncoder = GetEncoder(encoder); //Get the first available channel handle on the encoder int channelHandle = -1; //passing in -1 means AddChannel() will just return the first available channel ttlEncoder.AddChannel((TTLAPI_CHANNELS)channel, ref channelHandle); float sampleRate = session.get_NominalSampleRate(channelHandle); TtlSensor sensor = CreateTtlSensor(type, name, channel, sampleRate, queueData); channelHandleToSensor.Add(channelHandle, sensor); sensor.Started += new SensorEventHandler(sensor_Started); sensor.Stopped += new SensorEventHandler(sensor_Stopped); return sensor; }
public Sensor(string name, int index, SensorType sensorType, Hardware hardware, ISettings settings) : this(name, index, sensorType, hardware, null, settings) { }
// void cfg_OnUserUpdateControledDevices(List<DeviceAssociation> ControledDevices) // { // // ZBClass class2 = new ZBClass(); // // class2.header = class2.GetBytesFromString("ZSIG"); // // class2.command = 11; // // class2.alphacommand = class2.GetBytesFromString("SendCmd"); // // class2.label_base = class2.GetBytesFromString(""); // // class2.command_text = class2.GetBytesFromString(""); // // class2.serial = 0; // // class2.param1 = 1; // // class2.param2 = 22; // // class2.param3 = 0; // // class2.param4 = 0; // // byte[] rBuff = null; // // byte[] bytes = class2.GetBytes(); // // ZibaseDll.ZBClass zb = new ZibaseDll.ZBClass(); // // zb.UDPDataTransmit(bytes, ref rBuff, "192.168.0.210", 0xc34f); // // m_Config.ControledDevices = ControledDevices; // //m_ControledDevices = ControledDevices; // try // { // Util.SerializeToXml(m_Config, ConfigFilePath); // } // catch (Exception ex) // { // HsObjet.getInstance().WriteLog("Error", ex.Message); // } // // } void cfg_OnUserAddDevice(char hc, int dc, string DeviceName, SensorType st) { Scheduler.Classes.DeviceClass dev = HsObjet.getInstance().NewDeviceEx(DeviceName); dev.dc = dc.ToString(); dev.hc = hc.ToString(); dev.@interface = HSPI.PlugInName; dev.iomisc = DeviceName + " " + st.ToString() + " zibase_sensor"; dev.misc = 0x10; //status only var q = m_SensorDataManager.SensorList.Where(x => x.ID == DeviceName); if (q.Any()) { Device AddedDevice = q.First(); var AddedDeviceValue = AddedDevice.Values.First(x => x.ValueType == st); if (AddedDeviceValue != null) { AddedDeviceValue.AlreadyInHS = true; AddedDeviceValue.HSDevice = dev; AddedDeviceValue.HSUpdate(); } } m_SensorDataManager.HSDevice.Add(dev); }
/// <summary> /// Set sensor's type and mode. /// </summary> /// /// <param name="sensor">Sensor to set type of.</param> /// <param name="type">Sensor's type.</param> /// <param name="mode">Sensor's mode.</param> /// <param name="waitReply">Wait reply from NXT (safer option) or not (faster option).</param> /// /// <returns>Returns <b>true</b> if command was executed successfully or <b>false</b> otherwise.</returns> /// public bool SetSensorMode( Sensor sensor, SensorType type, SensorMode mode, bool waitReply ) { byte[] command = new byte[5]; // prepare message command[0] = (byte) ( ( waitReply ) ? NXTCommandType.DirectCommand : NXTCommandType.DirectCommandWithoutReply ); command[1] = (byte) NXTDirectCommand.SetInputMode; command[2] = (byte) sensor; command[3] = (byte) type; command[4] = (byte) mode; return SendCommand( command, new byte[3] ); }