コード例 #1
0
        static private string[] GetElementsStrings(Elements elements)
        {
            var zoneList             = "";
            var zones                = "";
            var buildingSurfaces     = "";
            var fenestrationSurfaces = "";
            var shadingSurfaces      = "";
            var shadingOverhangs     = "";
            var materials            = "";
            var constructions        = "";

            var hvacEquipmentConnections = "";
            var hvacEquipementLists      = "";
            var hvacIdealLoads           = "";

            var lights             = "";
            var peoples            = "";
            var electricEquipments = "";
            var thermostats        = "";

            //Allways checks if the lists are full and writes a message in the idf-File if not
            var building = elements.Building == null ? "!No Building defined\n" : elements.Building.Write();

            if (elements.Zones.Count == 0)
            {
                //throw new ArgumentException("No Zones found");
                zones += "!No Zones defined\n";
            }

            foreach (var zone in elements.Zones)
            {
                //Downcast from NoDuplicate to Zone
                var realZone = (Zone)zone;
                zones += realZone.Write();

                var zc   = new ZoneConnections(realZone);
                var eq   = new EquipmentList(realZone);
                var ilas = new IdealLoadsAirSystem(realZone);

                hvacEquipmentConnections += zc.Write();
                hvacEquipementLists      += eq.Write();
                hvacIdealLoads           += ilas.Write();
            }

            zoneList = elements.ZoneLists.Aggregate(zoneList, (current, zList) => current + zList.Write());

            //handles Surfaces and BuildingSurfaces right now. Should be changed to BuildingSurfaces on the long run...
            if (elements.BuildingSurfaces.Count == 0)
            {
                buildingSurfaces += "!No Surfaces defined\n";
            }
            else
            {
                buildingSurfaces += elements.BuildingSurfaces.Aggregate(buildingSurfaces,
                                                                        (current, surface) => current + surface.Write());
            }

            if (elements.FenestrationSurfaces.Count == 0)
            {
                fenestrationSurfaces += "!No FenestrationSurfaces defined\n";
            }
            else
            {
                fenestrationSurfaces = elements.FenestrationSurfaces.Aggregate(fenestrationSurfaces,
                                                                               (current, fenestrationSurface) => current + fenestrationSurface.Write());
            }

            if (elements.ShadingSurfaces.Count == 0)
            {
                shadingSurfaces += "!No ShadingSurfaces defined\n";
            }
            else
            {
                shadingSurfaces = elements.ShadingSurfaces.Aggregate(shadingSurfaces,
                                                                     (current, shadingSurface) => current + shadingSurface.Write());
            }

            if (elements.ShadingOverhangs.Count == 0)
            {
                shadingOverhangs += "!No ShadingOverhang defined\n";
            }
            else
            {
                shadingOverhangs = elements.ShadingOverhangs.Aggregate(shadingOverhangs,
                                                                       (current, shadingOverhang) => current + shadingOverhang.Write());
            }

            if (elements.Materials.Count == 0)
            {
                materials += "!No Materials defined\n";
            }
            else
            {
                materials = elements.Materials.Aggregate(materials,
                                                         (current, material) => current + material.Write());
            }

            if (elements.Constructions.Count == 0)
            {
                constructions += "!No Constructions defined\n";
            }
            else
            {
                constructions = elements.Constructions.Aggregate(constructions,
                                                                 (current, construction) => current + construction.Write());
            }

            if (elements.Lights.Count == 0)
            {
                lights += "!No Lights defined\n";
            }
            else
            {
                lights = elements.Lights.Aggregate(lights, (current, light) => current + light.Write());
            }

            if (elements.Peoples.Count == 0)
            {
                peoples += "!No People defined\n";
            }
            else
            {
                peoples = elements.Peoples.Aggregate(peoples, (current, people) => current + people.Write());
            }

            if (elements.ElectricEquipments.Count == 0)
            {
                electricEquipments += "!No ElectricEquipment defined\n";
            }
            else
            {
                electricEquipments = elements.ElectricEquipments.Aggregate(electricEquipments, (current, electricEquipment) => current + electricEquipment.Write());
            }

            if (elements.Thermostats.Count == 0)
            {
                thermostats += "!No Thermostats defined\n";
            }
            else
            {
                thermostats = elements.Thermostats.Aggregate(thermostats, (current, thermostat) => current + thermostat.Write());
            }

            string[] lines =
            {
                GetHeadLine("BUILDING") + building,
                GetHeadLine("ZONELIST") + zoneList,
                GetHeadLine("ZONE") + zones,
                GetHeadLine("SURFACE") + buildingSurfaces,
                GetHeadLine("FENESTRATIONSURFACE") + fenestrationSurfaces,
                GetHeadLine("SHADINGSURFACE") + shadingSurfaces,
                GetHeadLine("SHADINHOVERHANG") + shadingOverhangs,
                GetHeadLine("MATERIAL") + materials,
                GetHeadLine("CONSTRUCTION") + constructions,
                GetHeadLine("HVAC:EQUIPMENTCONNECTIONS") + hvacEquipmentConnections,
                GetHeadLine("HVAC:EQUIPMENTLIST") + hvacEquipementLists,
                GetHeadLine("HVAC:IDEALLOADS") + hvacIdealLoads,
                GetHeadLine("LIGHTS") + lights,
                GetHeadLine("PEOPLES") + peoples,
                GetHeadLine("ELECTRICEQUIPMENT") + electricEquipments,
                GetHeadLine("ZONECONTROL:THERMOSTATS") + thermostats
            };
            return(lines);
        }
コード例 #2
0
ファイル: StringCollector.cs プロジェクト: tumcms/DynamoPlus
        private static string[] GetElementsStrings(Elements elements)
        {
            var zoneList = "";
            var zones = "";
            var buildingSurfaces = "";
            var fenestrationSurfaces = "";
            var shadingSurfaces = "";
            var shadingOverhangs = "";
            var materials = "";
            var constructions = "";

            var hvacEquipmentConnections = "";
            var hvacEquipementLists = "";
            var hvacIdealLoads = "";

            //Allways checks if the lists are full and writes a message in the idf-File if not
            var building = elements.Building == null ? "!No Building defined\n" : elements.Building.Write();

            if (elements.Zones.Count == 0)
            {
                //throw new ArgumentException("No Zones found");
                zones += "!No Zones defined\n";
            }

            foreach (var zone in elements.Zones)
            {
                //Downcast from NoDuplicate to Zone
                var realZone = (Zone) zone;
                zones += realZone.Write();

                var zc = new ZoneConnections(realZone);
                var eq = new EquipmentList(realZone);
                var ilas = new IdealLoadsAirSystem(realZone);

                hvacEquipmentConnections += zc.Write();
                hvacEquipementLists += eq.Write();
                hvacIdealLoads += ilas.Write();
            }

            zoneList = elements.ZoneLists.Aggregate(zoneList, (current, zList) => current + zList.Write());

            if (elements.Surfaces.Count == 0)
            {
                buildingSurfaces += "!No Surfaces defined\n";
            }
            else
            {
                buildingSurfaces = elements.Surfaces.Aggregate(buildingSurfaces, (current, surface) => current + surface.Write());
            }

            if (elements.FenestrationSurfaces.Count == 0)
            {
                fenestrationSurfaces += "!No FenestrationSurfaces defined\n";
            }
            else
            {
                fenestrationSurfaces = elements.FenestrationSurfaces.Aggregate(fenestrationSurfaces, (current, fenestrationSurface) => current + fenestrationSurface.Write());
            }

            if (elements.ShadingSurfaces.Count == 0)
            {
                shadingSurfaces += "!No ShadingSurfaces defined\n";
            }
            else
            {
                shadingSurfaces = elements.ShadingSurfaces.Aggregate(shadingSurfaces, (current, shadingSurface) => current + shadingSurface.Write());
            }

            if (elements.ShadingOverhangs.Count == 0)
            {
                shadingOverhangs += "!No ShadingOverhang defined\n";
            }
            else
            {
                shadingOverhangs = elements.ShadingOverhangs.Aggregate(shadingOverhangs, (current, shadingOverhang) => current + shadingOverhang.Write());
            }

            if (elements.Materials.Count == 0)
            {
                materials += "!No Materials defined\n";
            }
            else
            {
                materials = elements.Materials.Aggregate(materials, (current, material) => current + material.Write());
            }

            if (elements.Constructions.Count == 0)
            {
                constructions += "!No Constructions defined\n";
            }
            else
            {
                constructions = elements.Constructions.Aggregate(constructions, (current, construction) => current + construction.Write());
            }

            string[] lines =
            {
                GetHeadLine("BUILDING")+building,
                GetHeadLine("ZONELIST")+zoneList,
                GetHeadLine("ZONE")+zones,
                GetHeadLine("SURFACE")+buildingSurfaces,
                GetHeadLine("FENESTRATIONSURFACE")+fenestrationSurfaces,
                GetHeadLine("SHADINGSURFACE")+shadingSurfaces,
                GetHeadLine("SHADINHOVERHANG")+shadingOverhangs,
                GetHeadLine("MATERIAL")+materials,
                GetHeadLine("CONSTRUCTION")+constructions,
                GetHeadLine("HVAYEQUIPMENTCONNECTIONS")+hvacEquipmentConnections,
                GetHeadLine("HVACEQUIPMENTLIST")+hvacEquipementLists,
                GetHeadLine("HVACIDEALLOADS")+hvacIdealLoads
            };
            return lines;
        }