/// <summary> /// Adds the sensor detail to the detail map /// </summary> /// <param name="add">Address of bluetooth device with this detail</param> /// <param name="det">The sensor detail object</param> private void addSensorDetail(string add, SensorDetail det) { if (sensorDetailMap.ContainsKey(add)) { sensorDetailMap[add] = det; } else { sensorDetailMap.Add(add, det); } }
/// <summary> /// Resets the data in the sensorDetail object /// </summary> public void resetData() { _currentDetail = new SensorDetail(); _currentDetail.DeviceDetails = new DeviceDetails(); _currentDetail.PowerDetails = new PowerDetails(); _currentDetail.PhysiologicalDetails = new PhysiologicalSensorDetails(); _currentDetail.EnvironmentalDetails = new EnvironmentalSensorDetails(); // Setting the device details and main fields for the sensor detail object setDeviceDetails(); }
public IEnumerable <Tuple <IMTSOutMessageEvent, DeviceDetails> > GetMtsOutMessageEvent(DeviceConfigRequestBase requestBase, DeviceDetails deviceDetails) { var mtsOutMessages = new List <Tuple <IMTSOutMessageEvent, DeviceDetails> >(); var otaConfigDetails = new Dictionary <int, OtaConfigDetail>(4); _loggingService.Info("Recieved Switches Message for Device " + deviceDetails.DeviceType, "SwitchesMessageEventBuilder.GetMtsOutMessageEvent"); var requestMessage = _dataPopulator.GetRequestModel <DeviceConfigSwitchesRequest>(requestBase); if (requestMessage.SingleStateSwitches != null && requestMessage.SingleStateSwitches.Any()) { foreach (var singleSwitch in requestMessage.SingleStateSwitches) { var otaInputConfigDetail = new OtaConfigDetail(); otaInputConfigDetail.InputConfig = string.IsNullOrEmpty(singleSwitch.SwitchActiveState) ? (InputConfigType?)null : _dataPopulator.GetEventEnumValue <InputConfigType>(singleSwitch.SwitchActiveState); otaInputConfigDetail.MonitoringCondition = string.IsNullOrEmpty(singleSwitch.SwitchMonitoringStatus) ? (DigitalInputMonitoringConditions?)null : _dataPopulator.GetEventEnumValue <DigitalInputMonitoringConditions>(singleSwitch.SwitchMonitoringStatus); otaInputConfigDetail.InputDesc = singleSwitch.SwitchName; otaInputConfigDetail.InputDelay = new TimeSpan(0, 0, 0, 0, (int)Math.Round(singleSwitch.SwitchSensitivity * 1000)); otaConfigDetails.Add(singleSwitch.SwitchNumber, otaInputConfigDetail); } var mtsMessageEvent = _dataPopulator.ConstructMtsEvent <SendOtaConfigurationEvent>(deviceDetails); mtsMessageEvent.Input1 = otaConfigDetails.ContainsKey(1) ? otaConfigDetails[1] : new OtaConfigDetail(); mtsMessageEvent.Input2 = otaConfigDetails.ContainsKey(2) ? otaConfigDetails[2] : new OtaConfigDetail(); mtsMessageEvent.Input3 = otaConfigDetails.ContainsKey(3) ? otaConfigDetails[3] : new OtaConfigDetail(); mtsMessageEvent.Input4 = otaConfigDetails.ContainsKey(4) ? otaConfigDetails[4] : new OtaConfigDetail(); var dvcDetails = ConstructorHelpers.GetDeviceConfigMsg(deviceDetails, "SingleStateSwitch1", "SingleStateSwitch2", "SingleStateSwitch3", "SingleStateSwitch4"); mtsOutMessages.Add(new Tuple <IMTSOutMessageEvent, DeviceDetails>(mtsMessageEvent, dvcDetails)); } var sensorDetails = new Dictionary <int, SensorDetail>(3); if (requestMessage.DualStateSwitches != null && requestMessage.DualStateSwitches.Any()) { var mtsMessageEvent = _dataPopulator.ConstructMtsEvent <ConfigureSensorsEvent>(deviceDetails); foreach (var dualSwitch in requestMessage.DualStateSwitches) { var sensorDetail = new SensorDetail(); sensorDetail.HasPosPolarity = false; sensorDetail.IgnReqired = false; sensorDetail.HystHalfSec = dualSwitch.SwitchSensitivity * 2; sensorDetail.Enabled = dualSwitch.SwitchEnabled; sensorDetails.Add(dualSwitch.SwitchNumber, sensorDetail); } mtsMessageEvent.Sensor1 = sensorDetails.ContainsKey(5) ? sensorDetails[5] : null; mtsMessageEvent.Sensor2 = sensorDetails.ContainsKey(6) ? sensorDetails[6] : null; mtsMessageEvent.Sensor3 = sensorDetails.ContainsKey(7) ? sensorDetails[7] : null; var dvcDetails = ConstructorHelpers.GetDeviceConfigMsg(deviceDetails, "MTSDualStateSwitch5", "MTSDualStateSwitch6", "MTSDualStateSwitch7"); mtsOutMessages.Add(new Tuple <IMTSOutMessageEvent, DeviceDetails>(mtsMessageEvent, dvcDetails)); } _loggingService.Info("Switches Message Event Construction for Device Type " + deviceDetails.DeviceType + " completed !!" + JsonConvert.SerializeObject(requestMessage), "SwitchesMessageEventBuilder.GetMtsOutMessageEvent"); return(mtsOutMessages); }
/// <summary> /// Updates the sensorDetail object with the given byte data /// </summary> /// <param name="data">Data.</param> public void updateData(byte[] data) { SensorParser parser = GetParser(data); try { _currentDetail = parser.getSensorDetail(); } catch (Exception e) { // An invalid tag was found in the data, ignore this round of values Debug.WriteLine("Invalid data. Not updating the detail object"); } }
public override void OnReceive(Context context, Intent intent) { Bundle intentBundle = intent.Extras; string action = intent.Action; if (intentBundle != null) { // Values string address, dataXML = ""; SensorDetail det = null; Log.Debug(TAG, "Update Received"); address = intentBundle.GetString(AppUtil.ADDRESS_KEY); dataXML = intentBundle.GetString(AppUtil.DETAIL_KEY); // deserializing the data xml XmlSerializer serializer = new XmlSerializer(typeof(SensorDetail)); StringReader stringReader = new StringReader(dataXML); XmlTextReader xmlReader = new XmlTextReader(stringReader); det = (SensorDetail)serializer.Deserialize(xmlReader); xmlReader.Close(); stringReader.Close(); DateTime readTime = DateTime.MinValue; if (intentBundle.ContainsKey(AppUtil.TIME_KEY)) { string timeString = intentBundle.GetString(AppUtil.TIME_KEY); DateTime.TryParse(timeString, out readTime); } // Creating event args SensorEventArgs arg = new SensorEventArgs(address, det, readTime); try { OnSensorReading(this, arg); } catch (NullReferenceException e) { // This exception occurs when nothign is subscribed to this event, it can be safely ignored Log.Debug(TAG, "Nothing is subscribed to the event"); } } }
/// <summary> /// Initializes a new instance of the <see cref="T:WatchTower.Droid.SensorEventArgs"/> class. /// </summary> /// <param name="add">Address of device.</param> /// <param name="det">Sensor detail for this device</param> /// <param name="isConnect">If set to <c>true</c> the device is connected</param> public SensorEventArgs(string add, SensorDetail det) { address = add; detail = det; }
/// <summary> /// Initializes a new instance of the <see cref="T:WatchTower.Droid.SensorEventArgs"/> class. /// </summary> /// <param name="add">Address of device.</param> /// <param name="det">Sensor detail for this device</param> public SensorEventArgs(string add, SensorDetail det) { address = add; detail = det; readingTime = DateTime.MinValue; }
/// <summary> /// Initializes a new instance of the <see cref="T:WatchTower.Droid.SensorEventArgs"/> class. /// </summary> /// <param name="add">Address of device.</param> /// <param name="det">Sensor detail for this device</param> /// <param name="readTime">The time the reading was taken</param> public SensorEventArgs(string add, SensorDetail det, DateTime readTime) { address = add; detail = det; readingTime = readTime; }
public POCParser(byte[] data, SensorDetail det) : base(data, det) { }
/// <summary> /// Constructor. /// </summary> /// <param name="data">Data.</param> public SensorParser(byte[] data, SensorDetail det) { detail = det; sensorData = data; }
public ZephyrHeartRateParser(byte[] data, SensorDetail det) : base(data, det) { }
public HexoskinParser(byte[] data, SensorDetail det) : base(data, det) { }