Ejemplo n.º 1
0
        private ActionResult ProcessSearchResult(byte deviceID, DateTime when, SensorDataResult searchResult)
        {
            if (!searchResult.IsFound)
            {
                return(NotFound($"Data for sensor {deviceID} was not found for the specified date time {when}."));
            }

            SensorDataResponse response = new SensorDataResponse
            {
                DeviceID     = deviceID,
                Average      = searchResult.Average,
                SensorValues = searchResult.SensorValues
            };

            return(Ok(response));
        }
Ejemplo n.º 2
0
        public void Update()
        {
            HidDeviceData data = sensor.Read(2);

            if (data.Status == HidDeviceData.ReadStatus.Success)
            {
                int    size = Marshal.SizeOf(this.sensorResult);
                IntPtr ptr  = Marshal.AllocHGlobal(size);
                Marshal.Copy(data.Data, 0, ptr, size);
                this.sensorResult = (SensorDataResult)Marshal.PtrToStructure(ptr, sensorResult.GetType());
                Marshal.FreeHGlobal(ptr);
                failure = false;
            }
            else
            {
                failure           = true;
                sensorResult.temp = 0;
            }
        }
Ejemplo n.º 3
0
 public TempSensor(HidDevice sensor)
 {
     this.sensor       = sensor;
     this.sensorResult = new SensorDataResult();
     Update();
 }