Beispiel #1
0
        public static BHR.SimulationResult FromTAS(this TSD.BuildingData tsdData, BHR.ProfileResultUnit unitType, BHR.ProfileResultType resultType, int hour, int day)
        {
            TSD.tsdBuildingArray? buildingType = resultType.ToTASBuildingType();
            if(buildingType == null)
            {
                BH.Engine.Base.Compute.RecordError("That Result Type is not valid for Building results - please choose a different result type");
                return null;
            }

            List<double> results = new List<double>();
            switch(unitType)
            {
                case BHR.ProfileResultUnit.Yearly:
                    object yearRes = tsdData.GetAnnualBuildingResult((int)buildingType.Value);
                    results = ToDoubleList(yearRes);
                    break;
                case BHR.ProfileResultUnit.Daily:
                    if (day < 1 || day > 365)
                    {
                        BH.Engine.Base.Compute.RecordError("Please set a day between 1 and 365 inclusive");
                        return null;
                    }
                    object dayRes = tsdData.GetDailyBuildingResult(day, (int)buildingType.Value);
                    results = ToDoubleList(dayRes);
                    break;
                case BHR.ProfileResultUnit.Hourly:
                    if(hour < 1 || hour > 24)
                    {
                        BH.Engine.Base.Compute.RecordError("Please set an hour between 1 and 24 inclusive");
                        return null;
                    }
                    results.Add(tsdData.GetHourlyBuildingResult(hour, (int)buildingType.Value));
                    break;
                default:
                    BH.Engine.Base.Compute.RecordError("That unit type is not valid for pulling results from TAS TSD. Please select a different result unit type");
                    return null;
            }

            BHR.SimulationResult result = new BHR.SimulationResult();
            result.SimulationResultType = BHR.SimulationResultType.BuildingResult;
            result.SimulationResults.Add(new BHR.ProfileResult { Name = tsdData.name, Type = resultType, Unit = unitType, Results = results });

            return result;
        }