Ejemplo n.º 1
0
        public SensorNode(ISensor sensor, PersistentSettings settings, 
            UnitManager unitManager)
            : base()
        {
            this.sensor = sensor;
              this.settings = settings;
              this.unitManager = unitManager;
              switch (sensor.SensorType) {
            case SensorType.Voltage: format = "{0:F3} V"; break;
            case SensorType.Clock: format = "{0:F0} MHz"; break;
            case SensorType.Load: format = "{0:F1} %"; break;
            case SensorType.Temperature: format = "{0:F1} °C"; break;
            case SensorType.Fan: format = "{0:F0} RPM"; break;
            case SensorType.Flow: format = "{0:F0} L/h"; break;
            case SensorType.Control: format = "{0:F1} %"; break;
            case SensorType.Level: format = "{0:F1} %"; break;
            case SensorType.Power: format = "{0:F1} W"; break;
            case SensorType.Data: format = "{0:F1} GB"; break;
            case SensorType.Factor: format = "{0:F3}"; break;
            case SensorType.DataRate: format = "{0:bf}/s"; break;
              }

              bool hidden = settings.GetValue(new Identifier(sensor.Identifier,
            "hidden").ToString(), sensor.IsDefaultHidden);
              base.IsVisible = !hidden;

              this.Plot = settings.GetValue(new Identifier(sensor.Identifier,
            "plot").ToString(), false);
        }
Ejemplo n.º 2
0
        public override void RemoveInfo(ISensor sensor)
        {
            if (!(sensor is WiFiSensor))
            {
                if (sensor != null)
                {
                    throw new SensorDifferentException("Not able to calculate distance between differents Sensor");
                }
                throw new NullReferenceException();
            }
            var wiFisensor = (WiFiSensor) sensor;

            double bestproximity=0.0;
            double tmpproximity;
            WiFiNetworkSet networkSet=null;
            if (Datasets.Count == 1) throw new SensorDatasetException("Sensor "+ Id.ToString() + "has one only Dataset. It does not make sense to remove it.");
            foreach (var dataset in Datasets)
                if ((tmpproximity = dataset.GetDistance(wiFisensor.Datasets.First())) > bestproximity)
                {
                    bestproximity = tmpproximity;
                    networkSet = dataset;
                }
            Datasets.Remove(networkSet);
            networkSet.Sensor = null;
        }
Ejemplo n.º 3
0
		/// <summary>
		/// Initializes a new instance of the <see cref="CyrusBuilt.MonoPi.Devices.Access.OpenerDevice"/>
		/// class with the relay, sensor, and the sensor state that indicates
		/// that the opener has opened.
		/// </summary>
		/// <param name="relay">
		/// The relay that controls the opener.
		/// </param>
		/// <param name="sensor">
		/// The reading the state of the opener.
		/// </param>
		/// <param name="openState">
		/// The sensor state that indicates the opener has opened.
		/// </param>
		public OpenerDevice(IRelay relay, ISensor sensor, SensorState openState)
			: base() {
			this._relay = relay;
			this._sensor = sensor;
			this._openState = openState;
			this._sensor.StateChanged += this.OnSensorStateChanged;
		}
        private static Camera Translate(this Camera camera, ISensor sensor, double moveFactor, double zoomFactor, double rotationFactor, double tiltFactor)
        {
            var x = sensor.Translation.X;
            var y = -sensor.Translation.Z;
            var move = sensor.Translation.Length;
            var zoom = sensor.Translation.Y;
            var rotation = -Math.Sign(sensor.Rotation.Y) * sensor.Rotation.Angle;
            var tilt = sensor.Rotation.X;

            //Rotate
            var rotation1 = rotation * rotationFactor;
            var rotation2 = rotation1 < 0 && camera.Heading < 0.1 ? 359.5 : rotation1;
            var camera1 = camera.Rotate(rotation2, 0);

            //Zoom
            var deltaAltitude = zoom * camera1.Location.Z * zoomFactor;
            var camera2 = camera1.Elevate(deltaAltitude);

            //Move
            var azimuth1 = Math.Atan(y / x) / Math.PI * 180;
            var azimuth2 = x > 0 ? 90 - azimuth1 : x < 0 ? 270 - azimuth1 : y >= 0 ? 0 : 180;
            var azimuth3 = (azimuth2 + camera2.Heading) % 360;
            var point1 = camera2.Location;
            var point2 = GeometryEngine.GeodesicMove(point1, point1.Z * move * moveFactor, LinearUnits.Meters, azimuth3);
            var point3 = new MapPoint(point2.X, point2.Y, point1.Z + deltaAltitude);
            var camera3 = camera2.SetLocation(point3);

            //Tilt
            var pitch1 = camera3.Pitch + tilt * tiltFactor;
            var pitch2 = pitch1 < 0 ? 0 : (pitch1 > 180 ? 180 : pitch1);
            var camera4 = camera3.SetPitch(pitch2);

            return camera4;
        }
Ejemplo n.º 5
0
        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;

              if (!float.TryParse(settings.GetValue(
              new Identifier(identifier, "value").ToString(), "0"),
            NumberStyles.Float, CultureInfo.InvariantCulture,
            out this.softwareValue))
              {
            this.softwareValue = 0;
              }
              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;
              }
        }
 public IoTHub(ISensor[] sensors, int sampleRateMilliseconds = 2000)
 {
     this.sensors = sensors;
     this.sampleRateMilliseconds = sampleRateMilliseconds;
     StartMeasuringAsync();
    
 }
Ejemplo n.º 7
0
 public Parameter(ParameterDescription description, ISensor sensor)
 {
     this.sensor = sensor;
       this.description = description;
       this.isDefault = true;
       this.value = description.DefaultValue;
 }
Ejemplo n.º 8
0
        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;
              }
        }
    private void HardwareSensorAdded(ISensor data) {
      Sensor sensor = new Sensor(data);
      activeInstances.Add(sensor);

      try {
        Instrumentation.Publish(sensor);
      } catch (Exception) { }
    }
        private static async void Update(this SceneView sceneView, ISensor sensor, double moveFactor, double zoomFactor, double rotationFactor, double tiltFactor)
        {
            if (sceneView?.Camera == null)
                return;

            var camera = sceneView.Camera.Translate(sensor, moveFactor, zoomFactor, rotationFactor, tiltFactor);
            await sceneView.SetViewAsync(camera, TimeSpan.MinValue);
        }
Ejemplo n.º 11
0
 public void VisitSensor(ISensor sensor)
 {
     if (sensor.SensorType == SensorType.Temperature)
     {
         Logger.Warn($"{sensor.Identifier} : {sensor.Name} : {sensor.Value}");
         Console.WriteLine($"{sensor.Identifier} : {sensor.Name} : {sensor.Value}");
     }
 }
Ejemplo n.º 12
0
        public Service(string displayName, Server parentServer, ISensor sensor)
        {
            ParentServer = parentServer;
            DisplayName = displayName;

            this.sensor = sensor;

            LastCheckDurations = new Queue<TimeSpan>(10);
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Registers a hardware sensor with the sensor engine, ensuring that it is
        /// updated as the game runs.
        /// </summary>
        /// <param name="sensor">The hardware sensor to register.</param>
        public void Register(ISensor sensor)
        {
            if (sensor == null)
            {
                throw new ArgumentNullException(nameof(sensor));
            }

            _sensors.Add(sensor);
        }
Ejemplo n.º 14
0
    private void SensorAdded(ISensor sensor) {
      if (sensors == null)
        return;

      for (int i = 0; i < sensors.Length; i++) {
        if (sensor.Identifier.ToString() == identifiers[i])
          sensors[i] = sensor;
      }
    }
Ejemplo n.º 15
0
    private void SensorRemoved(ISensor sensor) {
      if (sensors == null)
        return;

      for (int i = 0; i < sensors.Length; i++) {
        if (sensor == sensors[i])
          sensors[i] = null;
      }
    }
Ejemplo n.º 16
0
        public String GetCurrentData(ISensor baseSensor, out int samples)
        {
            Sensor<BrainData> sensor = (Sensor<BrainData>)baseSensor;

            BrainData[] data = sensor.GetData(255);
            samples = data.Length;

            return String.Format("{0:0.000}", data.Last().signal);
        }
Ejemplo n.º 17
0
        public String GetCurrentData(ISensor baseSensor, out int samples)
        {
            Sensor<EyeData> sensor = (Sensor<EyeData>)baseSensor;

            EyeData[] data = sensor.GetData(255);
            samples = data.Length;

            return String.Format("{0:0.000}", data.Last().left.eyePos.X);
        }
 private void InsertSorted(Node node, ISensor sensor) {
   int i = 0;
   while (i < node.Nodes.Count &&
     ((SensorNode)node.Nodes[i]).Sensor.Index < sensor.Index)
     i++;
   SensorNode sensorNode = new SensorNode(sensor, settings, unitManager);
   sensorNode.PlotSelectionChanged += SensorPlotSelectionChanged;
   node.Nodes.Insert(i, sensorNode);
 }
Ejemplo n.º 19
0
	  public static void Main(string[] args)
	  {
	    object sensorLock = new object();
	    bool run = true;
	    ISensor[] sensor = new ISensor[4];
	    for (int i = 0; i < 4; i++)
	    {
	      sensor[i] = null;
	    }
	    using (SensorListner listner = new SensorListner())
	    {
	      listner.SensorAttached += delegate(ISensor obj)
	      {
	        lock (sensorLock)
	        {
	          if (obj != null)
	          {
	            sensor[(int) obj.Port] = obj;
	            Console.WriteLine(obj.GetSensorName() + " attached on " + obj.Port);
	          }
	        }
	      };
	      listner.SensorDetached += delegate(SensorPort obj)
	      {
	        lock (sensorLock)
	        {
	          Console.WriteLine(sensor[(int) obj] + " detached from " + obj);
	          sensor[(int) obj] = null;
	        }
	      };
	      ButtonEvents buts = new ButtonEvents();
	      buts.EscapePressed += delegate
	      {
	        run = false;
	      };
	      while (run)
	      {

	        lock (sensorLock)
	        {

	          /*for (int i = 0; i < sensor.Length; i++) {
						if (sensor[i] != null) {
							typeLabel [i].Text = sensor[i].GetSensorName ();
							modeLabel [i].Text = sensor[i].SelectedMode ();
							valueLabel[i].Text = sensor[i].ReadAsString ();
						} else {
							typeLabel [i].Text = "Not connected";
							modeLabel [i].Text = "-";
							valueLabel [i].Text = "-";
						}
					}*/
	        }
	        System.Threading.Thread.Sleep(1000);
	      }
	    }
	  }
Ejemplo n.º 20
0
        public String GetCurrentData(ISensor baseSensor, out int samples)
        {
            Sensor<float> sensor = (Sensor<float>)baseSensor;

            float[] data = sensor.GetData(255);
            samples = data.Length;

            return String.Format("{0:0.000}", data.Last());
        }
Ejemplo n.º 21
0
        public OHMSensor(ISensor sensor, DataType dataType, string label, bool round = false)
        {
            _sensor = sensor;

            DataType = dataType;
            Append = dataType.GetAppend();
            Label = label;
            Round = round;
        }
Ejemplo n.º 22
0
        /// <summary>
        /// Deregisters a hardware sensor from the sensor engine, ensuring that it is
        /// no longer updated as the game runs.
        /// </summary>
        /// <param name="sensor">The hardware sensor to deregister.</param>
        public void Deregister(ISensor sensor)
        {
            if (sensor == null)
            {
                throw new ArgumentNullException(nameof(sensor));
            }

            _sensors.Remove(sensor);
        }
Ejemplo n.º 23
0
		public static ISensor[] GetSensorArray()
		{
			SensorPort[] ports = new SensorPort[]{ SensorPort.In1, SensorPort.In2, SensorPort.In3, SensorPort.In4 };
			ISensor[] sensors = new ISensor[ports.Length];
			for(int i = 0; i < ports.Length; i++)
			{
				sensors[i] = GetSensor(ports[i]);
			}
			return sensors;
		}
Ejemplo n.º 24
0
    public Sensor(ISensor sensor) {
      Name = sensor.Name;
      Index = sensor.Index;

      SensorType = sensor.SensorType.ToString();
      Identifier = sensor.Identifier.ToString();
      Parent = sensor.Hardware.Identifier.ToString();

      this.sensor = sensor;
    }
Ejemplo n.º 25
0
        public Service(string serviceRecordName, Server parentServer)
        {
            var record = ServiceFileRecordRegistry.GetServiceFileRecord(serviceRecordName);

            ParentServer = parentServer;
            DisplayName = record.DisplayName;

            sensor = SensorFactory.BuildSensor(record);

            LastCheckDurations = new Queue<TimeSpan>(10);
        }
        public async Task DisplayBmp280(ISensor sensor)
        {
            var component = sensor as BMP280;

            if (matrix == null) { return; }
            while (true)
            {
                var message = $"{Math.Round(component.Temperature.DegreesCelsius, 1)}C , {Math.Round(component.Pressure.Hectopascals, 1)}hPa";
                Display(message);  // Display temp on matrix
                await Task.Delay(1000);
            }
        }
 /// <summary>
 /// Azure IoT Suite Simulated Device schema
 /// </summary>
 /// <param name="deviceId"></param>
 /// <param name="measureName"></param>
 /// <param name="sensorUnit"></param>
 public SensorIoTHub(ISensor sensor, string deviceID)
 {
     this.Sensor = sensor;
     this.component = sensor as IComponent;
     // Only Device ID is not hard-coded, the rest of the Device Properties are hard-coded below, and the DeviceInfo message is sent to the IoT Hub to update
     var loc = ConfigurationManager.DeviceLocations.Find(x => x.UniqueRPiDeviceID.Contains(deviceID.ToUpperInvariant()));
     if (loc == null)
     {
         // just defaults to 1 Epping Road
         loc = new ConfigurationManager.DeviceLocation("F4D9C1B3-F68C-47B6-8894-855E3D78CF4C", "rpi01", "HostName=FaisterRemote.azure-devices.net;DeviceId=rpi01;SharedAccessKey=JvGy9y1z6GlZFywrdAbFGw==", -33.796875, 151.138428);  // Microsoft Sydney, 1 Epping Road, North Ryde, NSW 2113, Australia
     }
     this.DeviceId = loc.DeviceID;
 }
Ejemplo n.º 28
0
		public void DetachSensor ()
		{
			if (isDummy) 
			{
				sensor = new DummySensor (sensor.Port);
			} 
			else 
			{
				this.sensor = new NoSensor(sensor.Port);
			}
			updateMode = true;
			updateName = true;
		}
Ejemplo n.º 29
0
        public Control(ISensor sensor, float minSoftwareValue,
      float maxSoftwareValue, int defaultPolicy, int defaultLevel)
        {
            this.identifier = new Identifier(sensor.Identifier, "control");
              this.minSoftwareValue = minSoftwareValue;
              this.maxSoftwareValue = maxSoftwareValue;
              this.defaultPolicy = defaultPolicy;
              this.defaultLevel = defaultLevel;

              this.softwareValue = 0;
              int mode = 0;
              this.mode = (ControlMode)mode;
        }
Ejemplo n.º 30
0
		public SensorModel(MonoBrickFirmware.Sensors.SensorPort port, bool isDummy)
		{
			Port = port.ToString();
			this.isDummy = isDummy;
			if (isDummy) 
			{
				sensor = new DummySensor(port);
			} 
			else 
			{
				sensor = new NoSensor (port);
			}
		}
Ejemplo n.º 31
0
 private static void sensorRemoved(ISensor sensor)
 {
     Log.Info("GPU sensor removed: " + sensor.Name);
     //gpu.findSensors();
     reset.Set();
 }
Ejemplo n.º 32
0
 public void Remove(ISensor sensor)
 {
     Remove(sensor, true);
 }
 public BloodPressureIndicator(ISensor sensor) : base(sensor)
 {
     Name         = "Показатель кровяного давления";
     MeasureUnits = "мм рт. ст.";
 }
Ejemplo n.º 34
0
        /// <summary>
        /// Retrieve the filename for this particular sensor
        /// </summary>
        /// <param name="sensor"></param>
        /// <returns></returns>
        private string GetFilename(ISensor sensor)
        {
            string fn = Path.Combine(_csv_folder_path, sensor.Identity.ToString() + ".csv");

            return(fn);
        }
Ejemplo n.º 35
0
 public void VisitSensor(ISensor sensor)
 {
     sensor.ResetMin();
     sensor.ResetMax();
 }
Ejemplo n.º 36
0
 void ISensorEvents.OnEvent(ISensor sensor, Guid eventID, ISensorDataReport newData)
 {
 }
Ejemplo n.º 37
0
 public SkinTemperatureIndicator(ISensor sensor) : base(sensor)
 {
     Name         = "Показатель температуры кожи";
     MeasureUnits = "C";
 }
Ejemplo n.º 38
0
 /// <summary>
 /// Creates a plotted point
 /// </summary>
 internal BaseContact(ISensor detectedBy, PointF position) : base(detectedBy, position)
 {
     DetectedBy = detectedBy;
     LastUpdate = TimeStamp;
 }
Ejemplo n.º 39
0
        public SensorNotifyIcon(SystemTray sensorSystemTray, ISensor sensor,
                                bool balloonTip)
        {
            this.sensor     = sensor;
            this.notifyIcon = new NotifyIcon();

            Color defaultColor = Color.Black;

            if (sensor.SensorType == SensorType.Load)
            {
                defaultColor = Color.FromArgb(0xff, 0x70, 0x8c, 0xf1);
            }
            Color = Config.Get(new Identifier(sensor.Identifier,
                                              "traycolor").ToString(), defaultColor);

            this.pen  = new Pen(Color.FromArgb(96, Color.Black));
            this.font = SystemFonts.MessageBoxFont;

            ContextMenuStrip  contextMenuStrip = new ContextMenuStrip();
            ToolStripMenuItem hideShowItem     = new ToolStripMenuItem("Hide/Show");

            hideShowItem.Click += delegate(object obj, EventArgs args) {
                sensorSystemTray.SendHideShowCommand();
            };
            contextMenuStrip.Items.Add(hideShowItem);
            contextMenuStrip.Items.Add(new ToolStripSeparator());
            ToolStripMenuItem removeItem = new ToolStripMenuItem("Remove Sensor");

            removeItem.Click += delegate(object obj, EventArgs args) {
                sensorSystemTray.Remove(this.sensor);
            };
            contextMenuStrip.Items.Add(removeItem);
            ToolStripMenuItem colorItem = new ToolStripMenuItem("Change Color...");

            colorItem.Click += delegate(object obj, EventArgs args) {
                ColorDialog dialog = new ColorDialog();
                dialog.Color = Color;
                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    Color = dialog.Color;
                    Config.Set(new Identifier(sensor.Identifier,
                                              "traycolor").ToString(), Color);
                }
            };
            contextMenuStrip.Items.Add(colorItem);
            contextMenuStrip.Items.Add(new ToolStripSeparator());
            ToolStripMenuItem exitItem = new ToolStripMenuItem("Exit");

            exitItem.Click += delegate(object obj, EventArgs args) {
                sensorSystemTray.SendExitCommand();
            };
            contextMenuStrip.Items.Add(exitItem);
            this.notifyIcon.ContextMenuStrip = contextMenuStrip;
            this.notifyIcon.DoubleClick     += delegate(object obj, EventArgs args) {
                sensorSystemTray.SendHideShowCommand();
            };

            this.bitmap   = new Bitmap(16, 16, PixelFormat.Format32bppArgb);
            this.graphics = Graphics.FromImage(this.bitmap);

            if (Environment.OSVersion.Version.Major > 5)
            {
                this.graphics.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
                this.graphics.SmoothingMode     = SmoothingMode.HighQuality;
            }
        }
Ejemplo n.º 40
0
        public SensorNotifyIcon(SystemTray sensorSystemTray, ISensor sensor,
                                bool balloonTip, PersistentSettings settings)
        {
            this.sensor     = sensor;
            this.notifyIcon = new NotifyIcon();

            Color defaultColor = Color.Black;

            if (sensor.SensorType == SensorType.Load ||
                sensor.SensorType == SensorType.Control ||
                sensor.SensorType == SensorType.Level)
            {
                defaultColor = Color.FromArgb(0xff, 0x70, 0x8c, 0xf1);
            }
            Color = settings.GetValue(new Identifier(sensor.Identifier,
                                                     "traycolor").ToString(), defaultColor);

            this.pen  = new Pen(Color.FromArgb(96, Color.Black));
            this.font = SystemFonts.MessageBoxFont;

            ContextMenu contextMenu  = new ContextMenu();
            MenuItem    hideShowItem = new MenuItem("Hide/Show");

            hideShowItem.Click += delegate(object obj, EventArgs args) {
                sensorSystemTray.SendHideShowCommand();
            };
            contextMenu.MenuItems.Add(hideShowItem);
            contextMenu.MenuItems.Add(new MenuItem("-"));
            MenuItem removeItem = new MenuItem("Remove Sensor");

            removeItem.Click += delegate(object obj, EventArgs args) {
                sensorSystemTray.Remove(this.sensor);
            };
            contextMenu.MenuItems.Add(removeItem);
            MenuItem colorItem = new MenuItem("Change Color...");

            colorItem.Click += delegate(object obj, EventArgs args) {
                ColorDialog dialog = new ColorDialog();
                dialog.Color = Color;
                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    Color = dialog.Color;
                    settings.SetValue(new Identifier(sensor.Identifier,
                                                     "traycolor").ToString(), Color);
                }
            };
            contextMenu.MenuItems.Add(colorItem);
            contextMenu.MenuItems.Add(new MenuItem("-"));
            MenuItem exitItem = new MenuItem("Exit");

            exitItem.Click += delegate(object obj, EventArgs args) {
                sensorSystemTray.SendExitCommand();
            };
            contextMenu.MenuItems.Add(exitItem);
            this.notifyIcon.ContextMenu  = contextMenu;
            this.notifyIcon.DoubleClick += delegate(object obj, EventArgs args) {
                sensorSystemTray.SendHideShowCommand();
            };

            // get the default dpi to create an icon with the correct size
            float dpiX, dpiY;

            using (Bitmap b = new Bitmap(1, 1, PixelFormat.Format32bppArgb)) {
                dpiX = b.HorizontalResolution;
                dpiY = b.VerticalResolution;
            }

            // adjust the size of the icon to current dpi (default is 16x16 at 96 dpi)
            int width  = (int)Math.Round(16 * dpiX / 96);
            int height = (int)Math.Round(16 * dpiY / 96);

            // make sure it does never get smaller than 16x16
            width  = width < 16 ? 16: width;
            height = height < 16 ? 16: height;

            this.bitmap   = new Bitmap(width, height, PixelFormat.Format32bppArgb);
            this.graphics = Graphics.FromImage(this.bitmap);

            if (Environment.OSVersion.Version.Major > 5)
            {
                this.graphics.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
                this.graphics.SmoothingMode     = SmoothingMode.HighQuality;
            }
        }
 public void VisitSensor(ISensor sensor)
 {
 }
Ejemplo n.º 42
0
 private void HardwareSensorRemoved(ISensor sensor)
 {
     RevokeInstance(sensor.Identifier.ToString());
 }
Ejemplo n.º 43
0
 private static void sensorAdded(ISensor sensor)
 {
     Log.Info("GPU Sensor added: " + sensor.Name);
     //gpu.findSensors();
     reset.Set();
 }
Ejemplo n.º 44
0
 public override object Visit(ISensor entity, IModule data)
 {
     data.Sensors.Remove(entity);
     return(null);
 }
Ejemplo n.º 45
0
        public SensorDataCollection RetrieveData(ISensor sensor, DateTime?start_date = null, DateTime?end_date = null, bool fetch_exceptions = false)
        {
            var data = new SensorDataCollection();

            data.StartDate  = start_date ?? DateTime.MinValue;
            data.EndDate    = end_date ?? DateTime.MaxValue;
            data.Data       = new List <SensorData>();
            data.Exceptions = new List <SensorException>();

            // Check to see if this sensor filename exists
            string fn = GetFilename(sensor);

            if (File.Exists(fn))
            {
                // Construct a new CSVReader and be careful about this
                using (var csv = new CSVReader(fn, ',', '\"', false)) {
                    foreach (string[] line in csv)
                    {
                        if (line != null && line.Length >= 2)
                        {
                            DateTime t = DateTime.MinValue;
                            Decimal  val;

                            // Load the measurement time if present
                            int ms = 0;
                            if (line.Length >= 3)
                            {
                                int.TryParse(line[2], out ms);
                            }

                            // Save values
                            if (DateTime.TryParse(line[0], out t) && Decimal.TryParse(line[1], out val))
                            {
                                // Only load the specific timeframe
                                if (t < data.StartDate || t > data.EndDate)
                                {
                                    continue;
                                }

                                // Load the exception if asked
                                if (fetch_exceptions)
                                {
                                    if (line.Length >= 3)
                                    {
                                        SensorException e = new SensorException()
                                        {
                                            Description   = line[2],
                                            ExceptionTime = t
                                        };
                                        data.Exceptions.Add(e);
                                    }
                                }

                                // Load the sensor data
                                SensorData sd = new SensorData()
                                {
                                    Time             = t,
                                    Value            = val,
                                    CollectionTimeMs = ms
                                };
                                data.Data.Add(sd);
                            }
                        }
                    }
                }
            }

            // Mark for lazy loading
            return(data);
        }
Ejemplo n.º 46
0
 public Alarm(ISensor sensor)
 {
     this.sensor  = sensor;
     this.AlarmOn = AlarmOn;
 }
 public Alarm(ISensor sensor)
 {
     _sensor = sensor;
 }
Ejemplo n.º 48
0
 public bool CanProcess(ISensor sensor) => sensor is CylinderSensor;
Ejemplo n.º 49
0
 /// <summary>
 /// Delete all data for this sensor
 /// </summary>
 /// <param name="sensor"></param>
 public void DeleteSensorData(ISensor sensor)
 {
 }
Ejemplo n.º 50
0
 public void OnSensorEnter(ISensor pSensor, SensorState state)
 {
     Windows7.Sensors.SensorManager.OnSensorEnter(pSensor, state);
 }
Ejemplo n.º 51
0
 public GraphItemInComboBox(ISensor sensor)
 {
     this.Sensor = sensor;
 }
Ejemplo n.º 52
0
 public ItemVm(ISensor sensor)
 {
     baseItem = sensor as ItemBase;
 }
Ejemplo n.º 53
0
 /// <summary>
 /// Append one item of data
 /// </summary>
 /// <param name="sensor"></param>
 /// <param name="data_to_save"></param>
 public void AppendData(ISensor sensor, SensorException exception_to_save)
 {
 }
Ejemplo n.º 54
0
        /// <summary>
        /// Gets all routes that use the given sensor
        /// </summary>
        private IEnumerable <IRoute> GetRoutesUsingSensor(ISensor sensor)
        {
            var module = sensor.Module;

            return(module == null?Enumerable.Empty <IRoute>() : module.Routes.Where(sensor.IsUsedBy));
        }
Ejemplo n.º 55
0
 public SensorValueProvider(ISensor sensor)
 {
     Sensor = sensor;
 }
Ejemplo n.º 56
0
 public ItemVM(ISensor sensor)
 {
     test = sensor as ItemBase;
 }
Ejemplo n.º 57
0
 public ReadTemperatureCommand(ISensor sensor)
 {
     _sensor = sensor;
 }
Ejemplo n.º 58
0
 public void VisitSensor(ISensor sensor)
 {
     handler(sensor);
 }
Ejemplo n.º 59
0
 public SkinMoistureIndicator(ISensor sensor) : base(sensor)
 {
     Name         = "Показатель влажности кожи";
     MeasureUnits = "Отн. ед.";
 }
 public AlarmController(ILogger <AlarmController> logger, ISensor sensor)
 {
     this.logger = logger;
     this.sensor = sensor;
 }