public int GetSensorTypeCount(Sensor.Type sensorType) { if (SensorReadings != null) { if (SensorTypeToSensorNameListMap.ContainsKey(sensorType)) { return(SensorTypeToSensorNameListMap[sensorType].Count); } } return(0); }
public int GetSensorReadingsForSensorTypeCount(Sensor.Type sensorType) { if (SensorReadings != null) { if (SensorTypeToSensorNameListMap.ContainsKey(sensorType)) { int sensorReadingsCount = 0; foreach (string sensorName in SensorTypeToSensorNameListMap[sensorType]) { sensorReadingsCount += SensorNameToSensorReadingsMap[sensorName].Count; } return(sensorReadingsCount); } } return(0); }
/// <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); }
/// <summary> /// Helper method for quantising a sensor readings, within a sample, from a specific sensor. /// </summary> /// <param name="sensorReadings">Sensor readings, from a specific sensor, to be quantised.</param> /// <param name="sensorType">Sensor type associated with the specified sensor readings.</param> /// <param name="previousInputVectorValue">Float which describes the previous input vector value of the specified sensor.</param> /// <returns></returns> private static float QuantiseSensorReadings(List <BaseSensorReading> sensorReadings, Sensor.Type sensorType, float previousInputVectorValue) { float sensorValue = 0f; switch (sensorType) { case Sensor.Type.Temperature: sensorValue = QuantiseMethods.Temperature(sensorReadings); break; case Sensor.Type.Light: sensorValue = QuantiseMethods.Light(sensorReadings); break; case Sensor.Type.Presence: sensorValue = QuantiseMethods.Presence(sensorReadings, previousInputVectorValue); break; case Sensor.Type.Interaction: sensorValue = QuantiseMethods.Interaction(sensorReadings); break; case Sensor.Type.Toggle: sensorValue = QuantiseMethods.Toggle(sensorReadings, previousInputVectorValue); break; default: break; } return(sensorValue); }