Exemplo n.º 1
0
        public OwDeviceDto[] ToDto(IOwDevice[] devices)
        {
            var tmp = new OwDeviceDto[devices.Length];

            for (var i = 0; i < devices.Length; i++)
            {
                tmp[i] = ToDto(devices[i]);
            }

            return(tmp.ToArray());
        }
Exemplo n.º 2
0
        private static OwDeviceDetailsModel ToDetailsModel(OwDeviceDto device)
        {
            var measurements = new KeyValuePair <string, string> [device.MeasuredValues.Length];

            for (var i = 0; i < device.MeasuredValues.Length; i++)
            {
                measurements[i] = new KeyValuePair <string, string>(device.MeasuredValues[i].Key, device.MeasuredValues[i].Value.ToString());
            }

            var tmp = new OwDeviceDetailsModel
            {
                Id          = device.Id,
                Description = device.Description,
                LastRead    = device.LastRead,
                Values      = measurements
            };

            return(tmp);
        }
Exemplo n.º 3
0
        public OwDeviceDto ToDto(IOwDevice device)
        {
            var deviceValues = Enumerable.Empty <KeyValuePair <string, object> >().ToArray();

            try
            {
                deviceValues = device.ReadDeviceValues();
            }
            catch (Exception e)
            {
                _logger.LogWarning("Error when reading value of device {0}: {1}", device.DeviceId, e.Message);
            }

            var tmp = new OwDeviceDto
            {
                Id             = device.DeviceId,
                Description    = device.Description,
                MeasuredValues = deviceValues,
                LastRead       = DateTime.Now
            };

            return(tmp);
        }