/// <summary> /// Parent utility method for generating a sensor reading of float /// type and notifying listeners of the generation for this new /// sensor reading. /// </summary> /// <param name="sensorValue"></param> protected virtual void GenerateFloatSensorReading(float sensorValue) { FloatSensorReading newFloatSensorReading = new FloatSensorReading { sensorValue = sensorValue }; UpdateDetailsInSensorReading(newFloatSensorReading); PublishSensorReading(newFloatSensorReading); }
/// <summary> /// Helper method which creates a base sensor reading object using the specified sensor /// reading data. Used to construct sensor reading objects from database data. /// </summary> /// <param name="sensorArea">Area of where sensor reading was generated.</param> /// <param name="sensorName">Unique identifier of sensor which generated the sensor reading.</param> /// <param name="year">Year (Date) of when sensor reading was generated.</param> /// <param name="month">Month (Date) of when sensor reading was generated.</param> /// <param name="day">Day (Date) of when sensor reading was generated.</param> /// <param name="hours">Hours (Time) of when sensor reading was generated.</param> /// <param name="minutes">Minutes (Time) of when sensor reading was generated.</param> /// <param name="seconds">Seconds (Time) of when sensor reading was generated.</param> /// <param name="sensorValue">Value associated with the sensor reading.</param> /// <param name="sensorType">Sensor type which generated the sensor reading.</param> /// <returns></returns> private BaseSensorReading ConstructSensorReading(string sensorArea, string sensorName, int year, int month, int day, int hours, int minutes, int seconds, float sensorValue, Sensor.Type sensorType) { BaseSensorReading newSensorReading; switch (sensorType) { // Float sensor reading format for light, temperature. case Sensor.Type.Light: case Sensor.Type.Temperature: newSensorReading = new FloatSensorReading { sensorValue = sensorValue, }; break; // Boolean sensor reading format for presence, toggle case Sensor.Type.Presence: case Sensor.Type.Toggle: newSensorReading = new BoolSensorReading { sensorValue = Convert.ToBoolean(sensorValue) }; break; // Base sensor reading format for interaction default: newSensorReading = new BaseSensorReading(); break; } // Set the base attributes for the sensor reading newSensorReading.areaName = sensorArea; newSensorReading.sensorName = sensorName; newSensorReading.sensorType = sensorType; newSensorReading.SetDateTime(year, month, day, hours, minutes, seconds); return(newSensorReading); }