public void TemporalTemperatureUpdate(TemporalBuilding building, DateTime timeFrom, DateTime timeTo)
 {
     foreach (
         var floor in
             building.Floors.Where(room => room.GetType() == typeof(TemporalFloor)).Cast<TemporalFloor>())
     {
         TemporalTemperatureUpdate(floor, timeFrom, timeTo);
     }
 }
        public void TemporalUpdateAll(TemporalBuilding building, DateTime timeFrom, DateTime timeTo)
        {
            TemporalTemperatureUpdate(building, timeFrom, timeTo);
            TemporalCO2Update(building, timeFrom, timeTo);
            TemporalMotionDetectionUpdate(building, timeFrom, timeTo);
            TemporalLuxUpdate(building, timeFrom, timeTo);
            TemporalLightUpdate(building, timeFrom, timeTo);
            TemporalLightUpdate(building, timeFrom, timeTo);
            TemporalWifiClientUpdate(building, timeFrom, timeTo);
            TemporalOccupantsUpdate(building, timeFrom, timeTo);
            TemporalColdWaterUpdate(building, timeFrom, timeTo);
            TemporalHotWaterUpdate(building, timeFrom, timeTo);
            TemporalVentilationPowerConsumptionUpdate(building, timeFrom, timeTo);
            TemporalHardwarePowerConsumptionUpdate(building, timeFrom, timeTo);
            TemporalLightPowerConsumptionUpdate(building, timeFrom, timeTo);
            TemporalOtherPowerConsumptionUpdate(building, timeFrom, timeTo);
            TemporalTotalPowerConsumptionUpdate(building, timeFrom, timeTo);

        }
 public void TemporalVentilationPowerConsumptionUpdate(TemporalBuilding building, DateTime timeFrom, DateTime timeTo)
 {
     foreach (TemporalFloor floor in building.Floors.Where(floor => floor.GetType() == typeof(TemporalFloor)).Cast<TemporalFloor>())
     {
         TemporalVentilationPowerConsumptionUpdate(floor, timeFrom, timeTo);
     }
 }
 public void TemporalColdWaterUpdate(TemporalBuilding building, DateTime timeFrom, DateTime timeTo)
 {
     foreach (
         TemporalFloor floor in
             building.Floors.Where(floor => floor.GetType() == typeof(TemporalFloor)).Cast<TemporalFloor>())
     {
         TemporalColdWaterUpdate(floor, timeFrom, timeTo);
     }
 }
        public void TemporalOccupantsUpdate(TemporalBuilding building, DateTime timeFrom, DateTime timeTo)
        {
            foreach (
                var floor in
                    building.Floors.Where(room => room.GetType() == typeof(TemporalFloor)).Cast<TemporalFloor>())
            {
                TemporalOccupantsUpdate(floor, timeFrom, timeTo);
            }

            if (building.Endpoints != null && building.Endpoints.SmapEndponts.ContainsValue(SensorType.Occupants))
            {
                TemporalSummary temporalSummary =
                    calcMinMaxMean.CalcSMapMinMaxMean(
                        smapDal.GetHistoricSensorValue(
                            building.Endpoints.SmapEndponts.First(s => s.Value == SensorType.Occupants).Key, timeFrom,
                            timeTo));
                building.AverageOccupants = temporalSummary.MeanValue;
                building.MinObservedOccupants = temporalSummary.MinValue;
                building.MaxObservedOccupants = temporalSummary.MaxValue;
            }
        }
        public string ConvertBuilding(TemporalBuilding building)
        {
            StringBuilder sb = new StringBuilder();
            sb.Append("{");

            sb.Append("\"Name\":\"" + building.Name + "\",");
            sb.Append("\"SurfaceArea\":" + building.SurfaceArea + ",");

            sb.Append("\"NumberOfRooms\":" + JsonConvert.SerializeObject(building.NumberOfSensorRooms) + ",");

            sb.Append("\"AverageTemperature\":" + JsonConvert.SerializeObject(building.AverageTemperature) + ",");
            sb.Append("\"MaxObservedTemperature\":" + JsonConvert.SerializeObject(building.MaxObservedTemperature) + ",");
            sb.Append("\"MinObservedTemperature\":" + JsonConvert.SerializeObject(building.MinObservedTemperature) + ",");
            sb.Append("\"MaxTemperature\":" + JsonConvert.SerializeObject(building.MaxTemperature) + ",");

            sb.Append("\"AverageCO2\":" + JsonConvert.SerializeObject(building.AverageCO2) + ",");
            sb.Append("\"MaxObservedCO2\":" + JsonConvert.SerializeObject(building.MaxObservedCO2) + ",");
            sb.Append("\"MinObservedCO2\":" + JsonConvert.SerializeObject(building.MinObservedCO2) + ",");
            sb.Append("\"MaxCO2\":" + JsonConvert.SerializeObject(building.MaxCO2) + ",");

            sb.Append("\"AverageLight\":" + JsonConvert.SerializeObject(building.AverageLight) + ",");
            sb.Append("\"MaxObservedLight\":" + JsonConvert.SerializeObject(building.MaxObservedLight) + ",");
            sb.Append("\"MinObservedLight\":" + JsonConvert.SerializeObject(building.MinObservedLight) + ",");

            sb.Append("\"AverageLux\":" + JsonConvert.SerializeObject(building.AverageLux) + ",");
            sb.Append("\"MaxObservedLux\":" + JsonConvert.SerializeObject(building.MaxObservedLux) + ",");
            sb.Append("\"MinObservedLux\":" + JsonConvert.SerializeObject(building.MinObservedLux) + ",");
            sb.Append("\"MaxLux\":" + JsonConvert.SerializeObject(building.MaxLux) + ",");

            sb.Append("\"AverageHardwareConsumption\":" +
                      JsonConvert.SerializeObject(building.AverageHardwareConsumption) + ",");
            sb.Append("\"MaxObservedHardwareConsumption\":" +
                      JsonConvert.SerializeObject(building.MaxObservedHardwareConsumption) + ",");
            sb.Append("\"MinObservedHardwareConsumption\":" +
                      JsonConvert.SerializeObject(building.MinObservedHardwareConsumption) + ",");
            sb.Append("\"MaxHardwareConsumption\":" + JsonConvert.SerializeObject(building.MaxHardwareConsumption) + ",");

            sb.Append("\"AverageLightConsumption\":" + JsonConvert.SerializeObject(building.AverageLightConsumption) +
                      ",");
            sb.Append("\"MaxObservedLightConsumption\":" +
                      JsonConvert.SerializeObject(building.MaxObservedLightConsumption) + ",");
            sb.Append("\"MinObservedLightConsumption\":" +
                      JsonConvert.SerializeObject(building.MinObservedLightConsumption) + ",");
            sb.Append("\"MaxLightConsumption\":" + JsonConvert.SerializeObject(building.MaxLightConsumption) + ",");

            sb.Append("\"AverageVentilationConsumption\":" +
                      JsonConvert.SerializeObject(building.AverageVentilationConsumption) + ",");
            sb.Append("\"MaxObservedVentilationConsumption\":" +
                      JsonConvert.SerializeObject(building.MaxObservedVentilationConsumption) + ",");
            sb.Append("\"MinObservedVentilationConsumption\":" +
                      JsonConvert.SerializeObject(building.MinObservedVentilationConsumption) + ",");
            sb.Append("\"MaxVentilationConsumption\":" + JsonConvert.SerializeObject(building.MaxVentilationConsumption) +
                      ",");

            sb.Append("\"AverageOtherConsumption\":" + JsonConvert.SerializeObject(building.AverageOtherConsumption) +
                      ",");
            sb.Append("\"MaxObservedOtherConsumption\":" +
                      JsonConvert.SerializeObject(building.MaxObservedOtherConsumption) + ",");
            sb.Append("\"MinObservedOtherConsumption\":" +
                      JsonConvert.SerializeObject(building.MinObservedOtherConsumption) + ",");
            sb.Append("\"MaxOtherConsumption\":" + JsonConvert.SerializeObject(building.MaxOtherConsumption) + ",");


            sb.Append("\"AverageTotalPowerConsumption\":" +
                      JsonConvert.SerializeObject(building.AverageTotalPowerConsumption) + ",");
            sb.Append("\"MaxObservedTotalPowerConsumption\":" +
                      JsonConvert.SerializeObject(building.MaxObservedTotalPowerConsumption) + ",");
            sb.Append("\"MinObservedTotalPowerConsumption\":" +
                      JsonConvert.SerializeObject(building.MinObservedTotalPowerConsumption) + ",");
            sb.Append("\"MaxTotalPowerConsumption\":" + JsonConvert.SerializeObject(building.MaxTotalPowerConsumption) +
                      ",");

            sb.Append("\"AverageColdWaterConsumption\":" +
                      JsonConvert.SerializeObject(building.AverageColdWaterConsumption) + ",");
            sb.Append("\"MaxObservedColdWaterConsumption\":" +
                      JsonConvert.SerializeObject(building.MaxObservedColdWaterConsumption) + ",");
            sb.Append("\"MinObservedColdWaterConsumption\":" +
                      JsonConvert.SerializeObject(building.MinObservedColdWaterConsumption) + ",");
            sb.Append("\"MaxColdWaterConsumption\":" + JsonConvert.SerializeObject(building.MaxColdWaterConsumption) +
                      ",");

            sb.Append("\"AverageHotWaterConsumption\":" +
                      JsonConvert.SerializeObject(building.AverageHotWaterConsumption) + ",");
            sb.Append("\"MaxObservedHotWaterConsumption\":" +
                      JsonConvert.SerializeObject(building.MaxObservedHotWaterConsumption) + ",");
            sb.Append("\"MinObservedHotWaterConsumption\":" +
                      JsonConvert.SerializeObject(building.MinObservedHotWaterConsumption) + ",");
            sb.Append("\"MaxHotWaterConsumption\":" + JsonConvert.SerializeObject(building.MaxHotWaterConsumption) + ",");

            sb.Append("\"AverageMotion\":" + JsonConvert.SerializeObject(building.AverageMotion) + ",");
            sb.Append("\"MaxObservedMotion\":" + JsonConvert.SerializeObject(building.MaxObservedMotion) + ",");
            sb.Append("\"MinObservedMotion\":" + JsonConvert.SerializeObject(building.MinObservedMotion) + ",");

            sb.Append("\"AverageOccupants\":" + JsonConvert.SerializeObject(building.AverageOccupants) + ",");
            sb.Append("\"MaxObservedOccupants\":" + JsonConvert.SerializeObject(building.MaxObservedOccupants) + ",");
            sb.Append("\"MinObservedOccupants\":" + JsonConvert.SerializeObject(building.MinObservedOccupants) + ",");
            sb.Append("\"MaxOccupants\":" + JsonConvert.SerializeObject(building.MaxOccupants) + ",");

            sb.Append("\"AverageWifiClients\":" + JsonConvert.SerializeObject(building.AverageWifiClients) + ",");
            sb.Append("\"MaxObservedWifiClients\":" + JsonConvert.SerializeObject(building.MaxObservedWifiClients) + ",");
            sb.Append("\"MinObservedWifiClients\":" + JsonConvert.SerializeObject(building.MinObservedWifiClients) + ",");
            sb.Append("\"MaxWifiClients\":" + JsonConvert.SerializeObject(building.MaxWifiClients));
            sb.Append("}");

            return sb.ToString();
        }