diff --git a/doc/HVAC_GHTemplates/03_Other/Availability Manager with Probe.gh b/doc/HVAC_GHTemplates/03_Other/Availability Manager with Probe.gh new file mode 100644 index 00000000..f586476e Binary files /dev/null and b/doc/HVAC_GHTemplates/03_Other/Availability Manager with Probe.gh differ diff --git a/doc/Icon/Ironbug.HVAC.afdesign b/doc/Icon/Ironbug.HVAC.afdesign index fb227d52..d6e39a47 100644 Binary files a/doc/Icon/Ironbug.HVAC.afdesign and b/doc/Icon/Ironbug.HVAC.afdesign differ diff --git a/src/Ironbug.Grasshopper/Classes/Helper.cs b/src/Ironbug.Grasshopper/Classes/Helper.cs index 9da0a395..ec778bc6 100644 --- a/src/Ironbug.Grasshopper/Classes/Helper.cs +++ b/src/Ironbug.Grasshopper/Classes/Helper.cs @@ -39,8 +39,15 @@ public static string GetRoomName(object HBObj) } else if (HBObj is GH_ObjectWrapper wrapper) { - // LBT Room + var pyObj = wrapper.Value; + if (pyObj is Ironbug.HVAC.BaseClass.IB_ThermalZone ibZone) + { + ibZone.CustomAttributes.TryGetValue(Ironbug.HVAC.BaseClass.IB_ThermalZone_FieldSet.Value.Name, out var ibName); + return ibName?.ToString(); + } + + // LBT Room var isPythonObj = pyObj.GetType().ToString().StartsWith("IronPython."); if (!isPythonObj) throw new System.ArgumentException("Invalid Room object!"); diff --git a/src/Ironbug.Grasshopper/Component/Ironbug/AvailabilityManagers/Ironbug_AvailabilityManagerDifferentialThermostat.cs b/src/Ironbug.Grasshopper/Component/Ironbug/AvailabilityManagers/Ironbug_AvailabilityManagerDifferentialThermostat.cs new file mode 100644 index 00000000..5ec7407c --- /dev/null +++ b/src/Ironbug.Grasshopper/Component/Ironbug/AvailabilityManagers/Ironbug_AvailabilityManagerDifferentialThermostat.cs @@ -0,0 +1,53 @@ +using System; +using Grasshopper.Kernel; +using Ironbug.HVAC; +using Ironbug.HVAC.AvailabilityManager; + +namespace Ironbug.Grasshopper.Component +{ + public class Ironbug_AvailabilityManagerDifferentialThermostat : Ironbug_HVACWithParamComponent + { + public Ironbug_AvailabilityManagerDifferentialThermostat() + : base("IB_AvailabilityManagerDifferentialThermostat", "AM_Diff", + "Description", + "Ironbug", "05:SetpointManager & AvailabilityManager", typeof(IB_AvailabilityManagerDifferentialThermostat_FieldSet)) + { + } + + public override GH_Exposure Exposure => GH_Exposure.secondary; + + protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager) + { + pManager.AddGenericParameter("Cold Probe", "_coldProbe", $"Add a IB_NodeProbe (cold) to a loop first, and then connect the probe to here for availability manager to use.", GH_ParamAccess.item); + pManager.AddGenericParameter("Hot Probe", "_hotProbe", "Add a IB_NodeProbe (hot) to a loop first, and then connect the probe to here for availability manager to use.", GH_ParamAccess.item); + } + + + protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager pManager) + { + pManager.AddGenericParameter("AvailabilityManager", "AM", "TODO..", GH_ParamAccess.item); + } + + protected override void SolveInstance(IGH_DataAccess DA) + { + IB_NodeProbe cold = null; + IB_NodeProbe hot = null; + if (!DA.GetData(0, ref cold)) return; + if (!DA.GetData(0, ref hot)) return; + + var coldID = cold.GetTrackingID(); + var hotID = hot.GetTrackingID(); + + var obj = new IB_AvailabilityManagerDifferentialThermostat(); + obj.SetSensorNode(coldID, hotID); + + this.SetObjParamsTo(obj); + DA.SetData(0, obj); + + } + + protected override System.Drawing.Bitmap Icon => Properties.Resources.AM_Dif; + + public override Guid ComponentGuid => new Guid("F1E8995C-953F-44BF-88DD-076B1F8CBC73"); + } +} \ No newline at end of file diff --git a/src/Ironbug.Grasshopper/Component/Ironbug/AvailabilityManagers/Ironbug_AvailabilityManagerHighTemperatureTurnOff.cs b/src/Ironbug.Grasshopper/Component/Ironbug/AvailabilityManagers/Ironbug_AvailabilityManagerHighTemperatureTurnOff.cs new file mode 100644 index 00000000..2b08d24d --- /dev/null +++ b/src/Ironbug.Grasshopper/Component/Ironbug/AvailabilityManagers/Ironbug_AvailabilityManagerHighTemperatureTurnOff.cs @@ -0,0 +1,48 @@ +using System; +using Grasshopper.Kernel; +using Ironbug.HVAC; +using Ironbug.HVAC.AvailabilityManager; + +namespace Ironbug.Grasshopper.Component +{ + public class Ironbug_AvailabilityManagerHighTemperatureTurnOff : Ironbug_HVACWithParamComponent + { + public Ironbug_AvailabilityManagerHighTemperatureTurnOff() + : base("IB_AvailabilityManagerHighTemperatureTurnOff", "AM_HighOff", + "Description", + "Ironbug", "05:SetpointManager & AvailabilityManager", typeof(IB_AvailabilityManagerHighTemperatureTurnOff_FieldSet)) + { + } + + public override GH_Exposure Exposure => GH_Exposure.secondary | GH_Exposure.obscure; + + protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager) + { + pManager.AddGenericParameter("Sensor Probe", "_probe", "Add a IB_NodeProbe to a loop first, and then connect the probe to here for availability manager to use.", GH_ParamAccess.item); + } + + + protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager pManager) + { + pManager.AddGenericParameter("AvailabilityManager", "AM", "TODO..", GH_ParamAccess.item); + } + + protected override void SolveInstance(IGH_DataAccess DA) + { + IB_NodeProbe probe = null; + if (!DA.GetData(0, ref probe)) return; + + var nodeID = probe.GetTrackingID(); + var obj = new IB_AvailabilityManagerHighTemperatureTurnOff(); + obj.SetSensorNode(nodeID); + + this.SetObjParamsTo(obj); + DA.SetData(0, obj); + + } + + protected override System.Drawing.Bitmap Icon => Properties.Resources.AM_Off; + + public override Guid ComponentGuid => new Guid("3C8F8AEF-426B-43BD-AFDB-397BC8B000FB"); + } +} \ No newline at end of file diff --git a/src/Ironbug.Grasshopper/Component/Ironbug/AvailabilityManagers/Ironbug_AvailabilityManagerHighTemperatureTurnOn.cs b/src/Ironbug.Grasshopper/Component/Ironbug/AvailabilityManagers/Ironbug_AvailabilityManagerHighTemperatureTurnOn.cs new file mode 100644 index 00000000..e5c67bb4 --- /dev/null +++ b/src/Ironbug.Grasshopper/Component/Ironbug/AvailabilityManagers/Ironbug_AvailabilityManagerHighTemperatureTurnOn.cs @@ -0,0 +1,48 @@ +using System; +using Grasshopper.Kernel; +using Ironbug.HVAC; +using Ironbug.HVAC.AvailabilityManager; + +namespace Ironbug.Grasshopper.Component +{ + public class Ironbug_AvailabilityManagerHighTemperatureTurnOn : Ironbug_HVACWithParamComponent + { + public Ironbug_AvailabilityManagerHighTemperatureTurnOn() + : base("IB_AvailabilityManagerHighTemperatureTurnOn", "AM_HighOn", + "Description", + "Ironbug", "05:SetpointManager & AvailabilityManager", typeof(IB_AvailabilityManagerHighTemperatureTurnOn_FieldSet)) + { + } + + public override GH_Exposure Exposure => GH_Exposure.secondary | GH_Exposure.obscure; + + protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager) + { + pManager.AddGenericParameter("Sensor Probe", "_probe", "Add a IB_NodeProbe to a loop first, and then connect the probe to here for availability manager to use.", GH_ParamAccess.item); + } + + + protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager pManager) + { + pManager.AddGenericParameter("AvailabilityManager", "AM", "TODO..", GH_ParamAccess.item); + } + + protected override void SolveInstance(IGH_DataAccess DA) + { + IB_NodeProbe probe = null; + if (!DA.GetData(0, ref probe)) return; + + var nodeID = probe.GetTrackingID(); + var obj = new IB_AvailabilityManagerHighTemperatureTurnOn(); + obj.SetSensorNode(nodeID); + + this.SetObjParamsTo(obj); + DA.SetData(0, obj); + + } + + protected override System.Drawing.Bitmap Icon => Properties.Resources.AM_On; + + public override Guid ComponentGuid => new Guid("6FEFF3D5-F37B-4989-8FC9-16545DADA803"); + } +} \ No newline at end of file diff --git a/src/Ironbug.Grasshopper/Component/Ironbug/AvailabilityManagers/Ironbug_AvailabilityManagerHybridVentilation.cs b/src/Ironbug.Grasshopper/Component/Ironbug/AvailabilityManagers/Ironbug_AvailabilityManagerHybridVentilation.cs index abb3e11f..695084d5 100644 --- a/src/Ironbug.Grasshopper/Component/Ironbug/AvailabilityManagers/Ironbug_AvailabilityManagerHybridVentilation.cs +++ b/src/Ironbug.Grasshopper/Component/Ironbug/AvailabilityManagers/Ironbug_AvailabilityManagerHybridVentilation.cs @@ -13,11 +13,11 @@ public Ironbug_AvailabilityManagerHybridVentilation() { } - public override GH_Exposure Exposure => GH_Exposure.secondary; + public override GH_Exposure Exposure => GH_Exposure.secondary | GH_Exposure.obscure; protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager) { - pManager.AddTextParameter("controlZone", "_ctrlZone", "A controlled zone served by the air loop defined. The air conditions in this zone are used to determine if natural ventilation should be provided.", GH_ParamAccess.item); + pManager.AddGenericParameter("controlZone", "_ctrlZone", "A controlled zone served by the air loop defined. The air conditions in this zone are used to determine if natural ventilation should be provided.", GH_ParamAccess.item); pManager[0].Optional = true; } diff --git a/src/Ironbug.Grasshopper/Component/Ironbug/AvailabilityManagers/Ironbug_AvailabilityManagerList.cs b/src/Ironbug.Grasshopper/Component/Ironbug/AvailabilityManagers/Ironbug_AvailabilityManagerList.cs new file mode 100644 index 00000000..3745a7fe --- /dev/null +++ b/src/Ironbug.Grasshopper/Component/Ironbug/AvailabilityManagers/Ironbug_AvailabilityManagerList.cs @@ -0,0 +1,48 @@ +using System; +using System.Collections.Generic; +using Grasshopper.Kernel; +using Ironbug.HVAC.BaseClass; + +namespace Ironbug.Grasshopper.Component +{ + public class Ironbug_Ironbug_AvailabilityManagerList : Ironbug_Component + { + + public override GH_Exposure Exposure => GH_Exposure.secondary; + + public Ironbug_Ironbug_AvailabilityManagerList() + : base("IB_AvailabilityManagerList", "AMList", + "Use AvailabilityManagerList if you have more than one availability managers (from highest precedence to lowest) for one loop", + "Ironbug", "05:SetpointManager & AvailabilityManager") + { + } + + protected override void RegisterInputParams(GH_InputParamManager pManager) + { + pManager.AddGenericParameter("Availability managers", "managers", "A list of availability managers (from highest precedence to lowest) that will be grouped.", GH_ParamAccess.list); + pManager[0].Optional = true; + } + + protected override void RegisterOutputParams(GH_OutputParamManager pManager) + { + pManager.AddGenericParameter("AvailabilityManagerList", "AMList", "A list of availability managers that will be added to each loop. Connect to loop's AvailabilityManager", GH_ParamAccess.item); + pManager[0].DataMapping = GH_DataMapping.Flatten; + } + + protected override void SolveInstance(IGH_DataAccess DA) + { + var managers = new List(); + DA.GetDataList(0, managers); + + var group = new IB_AvailabilityManagerList(); + group.SetManagers(managers); + DA.SetData(0, group); + } + + protected override System.Drawing.Bitmap Icon => Properties.Resources.AM_Group; + + public override Guid ComponentGuid => new Guid("6E86EBFB-28E6-45F7-BDB4-7FDA4D560354"); + } + + +} \ No newline at end of file diff --git a/src/Ironbug.Grasshopper/Component/Ironbug/AvailabilityManagers/Ironbug_AvailabilityManagerLowTemperatureTurnOff.cs b/src/Ironbug.Grasshopper/Component/Ironbug/AvailabilityManagers/Ironbug_AvailabilityManagerLowTemperatureTurnOff.cs new file mode 100644 index 00000000..5e6f70f9 --- /dev/null +++ b/src/Ironbug.Grasshopper/Component/Ironbug/AvailabilityManagers/Ironbug_AvailabilityManagerLowTemperatureTurnOff.cs @@ -0,0 +1,48 @@ +using System; +using Grasshopper.Kernel; +using Ironbug.HVAC; +using Ironbug.HVAC.AvailabilityManager; + +namespace Ironbug.Grasshopper.Component +{ + public class Ironbug_AvailabilityManagerLowTemperatureTurnOff : Ironbug_HVACWithParamComponent + { + public Ironbug_AvailabilityManagerLowTemperatureTurnOff() + : base("IB_AvailabilityManagerLowTemperatureTurnOff", "AM_LowOff", + "Description", + "Ironbug", "05:SetpointManager & AvailabilityManager", typeof(IB_AvailabilityManagerLowTemperatureTurnOff_FieldSet)) + { + } + + public override GH_Exposure Exposure => GH_Exposure.secondary | GH_Exposure.obscure; + + protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager) + { + pManager.AddGenericParameter("Sensor Probe", "_probe", "Add a IB_NodeProbe to a loop first, and then connect the probe to here for availability manager to use.", GH_ParamAccess.item); + } + + + protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager pManager) + { + pManager.AddGenericParameter("AvailabilityManager", "AM", "TODO..", GH_ParamAccess.item); + } + + protected override void SolveInstance(IGH_DataAccess DA) + { + IB_NodeProbe probe = null; + if (!DA.GetData(0, ref probe)) return; + + var nodeID = probe.GetTrackingID(); + var obj = new IB_AvailabilityManagerLowTemperatureTurnOff(); + obj.SetSensorNode(nodeID); + + this.SetObjParamsTo(obj); + DA.SetData(0, obj); + + } + + protected override System.Drawing.Bitmap Icon => Properties.Resources.AM_Off; + + public override Guid ComponentGuid => new Guid("D5717D6F-B3B3-4AD5-B32C-2F8460AC76F0"); + } +} \ No newline at end of file diff --git a/src/Ironbug.Grasshopper/Component/Ironbug/AvailabilityManagers/Ironbug_AvailabilityManagerLowTemperatureTurnOn.cs b/src/Ironbug.Grasshopper/Component/Ironbug/AvailabilityManagers/Ironbug_AvailabilityManagerLowTemperatureTurnOn.cs new file mode 100644 index 00000000..17c3c530 --- /dev/null +++ b/src/Ironbug.Grasshopper/Component/Ironbug/AvailabilityManagers/Ironbug_AvailabilityManagerLowTemperatureTurnOn.cs @@ -0,0 +1,48 @@ +using System; +using Grasshopper.Kernel; +using Ironbug.HVAC; +using Ironbug.HVAC.AvailabilityManager; + +namespace Ironbug.Grasshopper.Component +{ + public class Ironbug_AvailabilityManagerLowTemperatureTurnOn : Ironbug_HVACWithParamComponent + { + public Ironbug_AvailabilityManagerLowTemperatureTurnOn() + : base("IB_AvailabilityManagerLowTemperatureTurnOn", "AM_LowOn", + "Description", + "Ironbug", "05:SetpointManager & AvailabilityManager", typeof(IB_AvailabilityManagerLowTemperatureTurnOn_FieldSet)) + { + } + + public override GH_Exposure Exposure => GH_Exposure.secondary | GH_Exposure.obscure; + + protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager) + { + pManager.AddGenericParameter("Sensor Probe", "_probe", "Add a IB_NodeProbe to a loop first, and then connect the probe to here for availability manager to use.", GH_ParamAccess.item); + } + + + protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager pManager) + { + pManager.AddGenericParameter("AvailabilityManager", "AM", "TODO..", GH_ParamAccess.item); + } + + protected override void SolveInstance(IGH_DataAccess DA) + { + IB_NodeProbe probe = null; + if (!DA.GetData(0, ref probe)) return; + + var nodeID = probe.GetTrackingID(); + var obj = new IB_AvailabilityManagerLowTemperatureTurnOn(); + obj.SetSensorNode(nodeID); + + this.SetObjParamsTo(obj); + DA.SetData(0, obj); + + } + + protected override System.Drawing.Bitmap Icon => Properties.Resources.AM_On; + + public override Guid ComponentGuid => new Guid("C9A99554-BF69-48C2-A77A-418319D7DEFA"); + } +} \ No newline at end of file diff --git a/src/Ironbug.Grasshopper/Component/Ironbug/AvailabilityManagers/Ironbug_AvailabilityManagerNightVentilation.cs b/src/Ironbug.Grasshopper/Component/Ironbug/AvailabilityManagers/Ironbug_AvailabilityManagerNightVentilation.cs index 6f57138b..17f5c1cb 100644 --- a/src/Ironbug.Grasshopper/Component/Ironbug/AvailabilityManagers/Ironbug_AvailabilityManagerNightVentilation.cs +++ b/src/Ironbug.Grasshopper/Component/Ironbug/AvailabilityManagers/Ironbug_AvailabilityManagerNightVentilation.cs @@ -17,7 +17,7 @@ public Ironbug_AvailabilityManagerNightVentilation() protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager) { - pManager.AddTextParameter("controlZone", "_ctrlZone", "A controlled zone served by the air loop defined. The air conditions in this zone are used to determine if natural ventilation should be provided.", GH_ParamAccess.item); + pManager.AddGenericParameter("controlZone", "_ctrlZone", "A controlled zone served by the air loop defined. The air conditions in this zone are used to determine if natural ventilation should be provided.", GH_ParamAccess.item); pManager[0].Optional = true; } diff --git a/src/Ironbug.Grasshopper/Component/Ironbug/AvailabilityManagers/Ironbug_AvailabilityManagerOptimumStart.cs b/src/Ironbug.Grasshopper/Component/Ironbug/AvailabilityManagers/Ironbug_AvailabilityManagerOptimumStart.cs new file mode 100644 index 00000000..5748a902 --- /dev/null +++ b/src/Ironbug.Grasshopper/Component/Ironbug/AvailabilityManagers/Ironbug_AvailabilityManagerOptimumStart.cs @@ -0,0 +1,47 @@ +using System; +using Grasshopper.Kernel; +using Ironbug.HVAC.AvailabilityManager; + +namespace Ironbug.Grasshopper.Component +{ + public class Ironbug_AvailabilityManagerOptimumStart : Ironbug_HVACWithParamComponent + { + public Ironbug_AvailabilityManagerOptimumStart() + : base("IB_AvailabilityManagerOptimumStart", "AM_OptimumStart", + "Description", + "Ironbug", "05:SetpointManager & AvailabilityManager", typeof(IB_AvailabilityManagerOptimumStart_FieldSet)) + { + } + + public override GH_Exposure Exposure => GH_Exposure.secondary; + + protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager) + { + pManager.AddGenericParameter("controlZone", "_ctrlZone", "A controlled zone served by the air loop defined. The air conditions in this zone are used to determine if natural ventilation should be provided.", GH_ParamAccess.item); + pManager[0].Optional = true; + } + + + protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager pManager) + { + pManager.AddGenericParameter("AvailabilityManager", "AM", "TODO..", GH_ParamAccess.item); + } + + protected override void SolveInstance(IGH_DataAccess DA) + { + object zone = null; + if (!DA.GetData(0, ref zone)) return; + + var zoneName = Helper.GetRoomName(zone); + var obj = new IB_AvailabilityManagerOptimumStart(); + obj.SetControlZone(zoneName); + this.SetObjParamsTo(obj); + DA.SetData(0, obj); + + } + + protected override System.Drawing.Bitmap Icon => Properties.Resources.AM_Opt; + + public override Guid ComponentGuid => new Guid("FF1B3CB5-54F7-4EB7-BE62-4DFC0BFCB6ED"); + } +} \ No newline at end of file diff --git a/src/Ironbug.Grasshopper/Component/Ironbug/Ironbug_FanConstantVolume.cs b/src/Ironbug.Grasshopper/Component/Ironbug/Ironbug_FanConstantVolume.cs index b34eb84a..2b5c793d 100644 --- a/src/Ironbug.Grasshopper/Component/Ironbug/Ironbug_FanConstantVolume.cs +++ b/src/Ironbug.Grasshopper/Component/Ironbug/Ironbug_FanConstantVolume.cs @@ -15,9 +15,9 @@ public Ironbug_FanConstantVolume() } - public override GH_Exposure Exposure => GH_Exposure.tertiary; + public override GH_Exposure Exposure => GH_Exposure.tertiary | GH_Exposure.obscure; + - protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager) { } diff --git a/src/Ironbug.Grasshopper/Component/Ironbug/Ironbug_FanSystemModel.cs b/src/Ironbug.Grasshopper/Component/Ironbug/Ironbug_FanSystemModel.cs index baeb97ee..b10516ba 100644 --- a/src/Ironbug.Grasshopper/Component/Ironbug/Ironbug_FanSystemModel.cs +++ b/src/Ironbug.Grasshopper/Component/Ironbug/Ironbug_FanSystemModel.cs @@ -15,7 +15,7 @@ public Ironbug_FanSystemModel() { } - public override GH_Exposure Exposure => GH_Exposure.tertiary | GH_Exposure.obscure; + public override GH_Exposure Exposure => GH_Exposure.tertiary; protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager) diff --git a/src/Ironbug.Grasshopper/Component/Ironbug/Ironbug_FanVariableVolume.cs b/src/Ironbug.Grasshopper/Component/Ironbug/Ironbug_FanVariableVolume.cs index c3ed5b67..9b8a397e 100644 --- a/src/Ironbug.Grasshopper/Component/Ironbug/Ironbug_FanVariableVolume.cs +++ b/src/Ironbug.Grasshopper/Component/Ironbug/Ironbug_FanVariableVolume.cs @@ -20,7 +20,7 @@ protected override void RegisterInputParams(GH_Component.GH_InputParamManager pM } - public override GH_Exposure Exposure => GH_Exposure.tertiary; + public override GH_Exposure Exposure => GH_Exposure.tertiary | GH_Exposure.obscure; diff --git a/src/Ironbug.Grasshopper/Component/Ironbug/SetpointManagers/Ironbug_SetpointManagerScheduledDualSetpoint.cs b/src/Ironbug.Grasshopper/Component/Ironbug/SetpointManagers/Ironbug_SetpointManagerScheduledDualSetpoint.cs index 01d612c3..7913b49d 100644 --- a/src/Ironbug.Grasshopper/Component/Ironbug/SetpointManagers/Ironbug_SetpointManagerScheduledDualSetpoint.cs +++ b/src/Ironbug.Grasshopper/Component/Ironbug/SetpointManagers/Ironbug_SetpointManagerScheduledDualSetpoint.cs @@ -19,8 +19,8 @@ public Ironbug_SetpointManagerScheduledDualSetpoint() protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager) { - pManager.AddNumberParameter("HighTemperature", "_hiT", "High SetpointTemperature", GH_ParamAccess.item, 21.1); - pManager.AddNumberParameter("LowTemperature", "_lowT", "Low SetpointTemperature", GH_ParamAccess.item, 12.7778); + pManager.AddNumberParameter("HighTemperature", "_hiT", "High SetpointTemperature in C to create a constant schedule", GH_ParamAccess.item, 21.1); + pManager.AddNumberParameter("LowTemperature", "_lowT", "Low SetpointTemperature in C to create a constant schedule", GH_ParamAccess.item, 12.7778); } protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager pManager) diff --git a/src/Ironbug.Grasshopper/Component/Ironbug/SetpointManagers/Ironbug_SetpointManagerSingleZoneCooling.cs b/src/Ironbug.Grasshopper/Component/Ironbug/SetpointManagers/Ironbug_SetpointManagerSingleZoneCooling.cs index 233364ef..92c7958e 100644 --- a/src/Ironbug.Grasshopper/Component/Ironbug/SetpointManagers/Ironbug_SetpointManagerSingleZoneCooling.cs +++ b/src/Ironbug.Grasshopper/Component/Ironbug/SetpointManagers/Ironbug_SetpointManagerSingleZoneCooling.cs @@ -1,6 +1,7 @@ using Grasshopper.Kernel; using System; using System.Collections.Generic; +using System.Linq; namespace Ironbug.Grasshopper.Component.Ironbug { @@ -31,13 +32,15 @@ protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager protected override void SolveInstance(IGH_DataAccess DA) { - var zones = new List(); - DA.GetDataList(0, zones); - var zone = (HVAC.BaseClass.IB_ThermalZone)null; - if (zones.Count == 0) return; + List zones = null; + + if (!DA.GetDataList(0, zones) || zones?.FirstOrDefault() == null) + { + this.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Invalid control zone."); + return; + } + var zone = zones.FirstOrDefault(); - if (zones.Count > 1) this.AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "This is a setpointManager for the single zone, you have more than one zone as input. So it takes the first zone as the control zone."); - zone = zones[0]; var obj = new HVAC.IB_SetpointManagerSingleZoneCooling(zone); diff --git a/src/Ironbug.Grasshopper/Component/Ironbug/SetpointManagers/Ironbug_SetpointManagerSingleZoneHeating.cs b/src/Ironbug.Grasshopper/Component/Ironbug/SetpointManagers/Ironbug_SetpointManagerSingleZoneHeating.cs index 191b0972..ab0cb23e 100644 --- a/src/Ironbug.Grasshopper/Component/Ironbug/SetpointManagers/Ironbug_SetpointManagerSingleZoneHeating.cs +++ b/src/Ironbug.Grasshopper/Component/Ironbug/SetpointManagers/Ironbug_SetpointManagerSingleZoneHeating.cs @@ -1,6 +1,7 @@ using Grasshopper.Kernel; using System; using System.Collections.Generic; +using System.Linq; namespace Ironbug.Grasshopper.Component.Ironbug { @@ -31,15 +32,16 @@ protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager protected override void SolveInstance(IGH_DataAccess DA) { - var zones = new List(); - DA.GetDataList(0, zones); - var zone = (HVAC.BaseClass.IB_ThermalZone)null; - if (zones.Count == 0) return; + List zones = null; - if (zones.Count > 1) this.AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "This is a setpointManager for the single zone, you have more than one zone as input. So it takes the first zone as the control zone."); - zone = zones[0]; - var obj = new HVAC.IB_SetpointManagerSingleZoneHeating(zone); + if (!DA.GetDataList(0, zones) || zones?.FirstOrDefault() == null) + { + this.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Invalid control zone."); + return; + } + var zone = zones.FirstOrDefault(); + var obj = new HVAC.IB_SetpointManagerSingleZoneHeating(zone); this.SetObjParamsTo(obj); DA.SetData(0, obj); diff --git a/src/Ironbug.Grasshopper/Component/Ironbug/SetpointManagers/Ironbug_SetpointManagerSingleZoneHumidityMaximum.cs b/src/Ironbug.Grasshopper/Component/Ironbug/SetpointManagers/Ironbug_SetpointManagerSingleZoneHumidityMaximum.cs index b2f5e510..c0cf4ea5 100644 --- a/src/Ironbug.Grasshopper/Component/Ironbug/SetpointManagers/Ironbug_SetpointManagerSingleZoneHumidityMaximum.cs +++ b/src/Ironbug.Grasshopper/Component/Ironbug/SetpointManagers/Ironbug_SetpointManagerSingleZoneHumidityMaximum.cs @@ -1,6 +1,7 @@ using Grasshopper.Kernel; using System; using System.Collections.Generic; +using System.Linq; namespace Ironbug.Grasshopper.Component.Ironbug { @@ -20,7 +21,7 @@ public Ironbug_SetpointManagerSingleZoneHumidityMaximum() protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager) { - pManager.AddGenericParameter("ControlZone", "_Ctrlzone", "ControlZone", GH_ParamAccess.list); + pManager.AddGenericParameter("ControlZone", "_Ctrlzone", EPDoc.SetpointManagerSingleZoneHumidityMaximum.Field_ControlZoneAirNodeName, GH_ParamAccess.list); pManager[0].DataMapping = GH_DataMapping.Flatten; } @@ -31,13 +32,14 @@ protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager protected override void SolveInstance(IGH_DataAccess DA) { - var zones = new List(); - DA.GetDataList(0, zones); - var zone = (HVAC.BaseClass.IB_ThermalZone)null; - if (zones.Count == 0) return; - - if (zones.Count > 1) this.AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "This is the setpointManager for the single zone, you have more than one zone as input. So it takes the first zone as the control zone."); - zone = zones[0]; + List zones = null; + + if (!DA.GetDataList(0, zones) || zones?.FirstOrDefault() == null) + { + this.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Invalid control zone."); + return; + } + var zone = zones.FirstOrDefault(); var obj = new HVAC.IB_SetpointManagerSingleZoneHumidityMaximum(zone); diff --git a/src/Ironbug.Grasshopper/Component/Ironbug/SetpointManagers/Ironbug_SetpointManagerSingleZoneHumidityMinimum.cs b/src/Ironbug.Grasshopper/Component/Ironbug/SetpointManagers/Ironbug_SetpointManagerSingleZoneHumidityMinimum.cs index 20cc6fe5..4c3ac774 100644 --- a/src/Ironbug.Grasshopper/Component/Ironbug/SetpointManagers/Ironbug_SetpointManagerSingleZoneHumidityMinimum.cs +++ b/src/Ironbug.Grasshopper/Component/Ironbug/SetpointManagers/Ironbug_SetpointManagerSingleZoneHumidityMinimum.cs @@ -1,6 +1,7 @@ using Grasshopper.Kernel; using System; using System.Collections.Generic; +using System.Linq; namespace Ironbug.Grasshopper.Component.Ironbug { @@ -20,7 +21,7 @@ public Ironbug_SetpointManagerSingleZoneHumidityMinimum() protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager) { - pManager.AddGenericParameter("ControlZone", "_Ctrlzone", "ControlZone", GH_ParamAccess.list); + pManager.AddGenericParameter("ControlZone", "_Ctrlzone", EPDoc.SetpointManagerSingleZoneHumidityMinimum.Field_ControlZoneAirNodeName, GH_ParamAccess.list); pManager[0].DataMapping = GH_DataMapping.Flatten; } @@ -31,13 +32,14 @@ protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager protected override void SolveInstance(IGH_DataAccess DA) { - var zones = new List(); - DA.GetDataList(0, zones); - var zone = (HVAC.BaseClass.IB_ThermalZone)null; - if (zones.Count == 0) return; - - if (zones.Count > 1) this.AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "This is the setpointManager for the single zone, you have more than one zone as input. So it takes the first zone as the control zone."); - zone = zones[0]; + List zones = null; + + if (!DA.GetDataList(0, zones) || zones?.FirstOrDefault() == null) + { + this.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Invalid control zone."); + return; + } + var zone = zones.FirstOrDefault(); var obj = new HVAC.IB_SetpointManagerSingleZoneHumidityMinimum(zone); diff --git a/src/Ironbug.Grasshopper/Component/Ironbug/SetpointManagers/Ironbug_SetpointManagerSingleZoneReheat.cs b/src/Ironbug.Grasshopper/Component/Ironbug/SetpointManagers/Ironbug_SetpointManagerSingleZoneReheat.cs index 5e368080..f8f635c9 100644 --- a/src/Ironbug.Grasshopper/Component/Ironbug/SetpointManagers/Ironbug_SetpointManagerSingleZoneReheat.cs +++ b/src/Ironbug.Grasshopper/Component/Ironbug/SetpointManagers/Ironbug_SetpointManagerSingleZoneReheat.cs @@ -1,6 +1,7 @@ using Grasshopper.Kernel; using System; using System.Collections.Generic; +using System.Linq; namespace Ironbug.Grasshopper.Component.Ironbug { @@ -35,16 +36,15 @@ protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager protected override void SolveInstance(IGH_DataAccess DA) { - var zones = new List(); - DA.GetDataList(0, zones); - var zone = (HVAC.BaseClass.IB_ThermalZone)null; - if (zones.Count == 0) return; + List zones = null; + + if (!DA.GetDataList(0, zones) || zones?.FirstOrDefault() == null) + { + this.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Invalid control zone."); + return; + } + var zone = zones.FirstOrDefault(); - if (zones.Count > 1) this.AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "This is the setpointManager for single zone, you have more than one zone as input. So it takes the first zone as the control zone."); - zone = zones[0]; - if (zone == null) - throw new ArgumentException("Input zone is null"); - var obj = new HVAC.IB_SetpointManagerSingleZoneReheat(zone); double minT = 10; double maxT = 50; diff --git a/src/Ironbug.Grasshopper/Properties/Resources.Designer.cs b/src/Ironbug.Grasshopper/Properties/Resources.Designer.cs index 69809fcc..5cb224e3 100644 --- a/src/Ironbug.Grasshopper/Properties/Resources.Designer.cs +++ b/src/Ironbug.Grasshopper/Properties/Resources.Designer.cs @@ -140,6 +140,26 @@ internal static System.Drawing.Bitmap AM_24 { } } + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap AM_Dif { + get { + object obj = ResourceManager.GetObject("AM_Dif", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap AM_Group { + get { + object obj = ResourceManager.GetObject("AM_Group", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// @@ -190,6 +210,16 @@ internal static System.Drawing.Bitmap AM_On { } } + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap AM_Opt { + get { + object obj = ResourceManager.GetObject("AM_Opt", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// diff --git a/src/Ironbug.Grasshopper/Properties/Resources.resx b/src/Ironbug.Grasshopper/Properties/Resources.resx index b23dcabe..535c8a0d 100644 --- a/src/Ironbug.Grasshopper/Properties/Resources.resx +++ b/src/Ironbug.Grasshopper/Properties/Resources.resx @@ -670,4 +670,13 @@ ..\Resources\FanSysModel.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\AM_Dif.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\AM_Opt.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\AM_Group.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + \ No newline at end of file diff --git a/src/Ironbug.Grasshopper/Resources/AM_Dif.png b/src/Ironbug.Grasshopper/Resources/AM_Dif.png new file mode 100644 index 00000000..290bc346 Binary files /dev/null and b/src/Ironbug.Grasshopper/Resources/AM_Dif.png differ diff --git a/src/Ironbug.Grasshopper/Resources/AM_Group.png b/src/Ironbug.Grasshopper/Resources/AM_Group.png new file mode 100644 index 00000000..56f3d9c9 Binary files /dev/null and b/src/Ironbug.Grasshopper/Resources/AM_Group.png differ diff --git a/src/Ironbug.Grasshopper/Resources/AM_Opt.png b/src/Ironbug.Grasshopper/Resources/AM_Opt.png new file mode 100644 index 00000000..c8570be8 Binary files /dev/null and b/src/Ironbug.Grasshopper/Resources/AM_Opt.png differ diff --git a/src/Ironbug.HVAC/AvailabilityManagers/IB_AvailabilityManagerDifferentialThermostat.cs b/src/Ironbug.HVAC/AvailabilityManagers/IB_AvailabilityManagerDifferentialThermostat.cs new file mode 100644 index 00000000..66dde1f5 --- /dev/null +++ b/src/Ironbug.HVAC/AvailabilityManagers/IB_AvailabilityManagerDifferentialThermostat.cs @@ -0,0 +1,59 @@ +using Ironbug.HVAC.BaseClass; +using OpenStudio; +using System; + +namespace Ironbug.HVAC.AvailabilityManager +{ + public class IB_AvailabilityManagerDifferentialThermostat : IB_AvailabilityManager + { + private string _nodeCID { get => this.Get(string.Empty); set => this.Set(value); } + private string _nodeHID { get => this.Get(string.Empty); set => this.Set(value); } + public static IB_AvailabilityManagerDifferentialThermostat_FieldSet FieldSet => IB_AvailabilityManagerDifferentialThermostat_FieldSet.Value; + protected override Func IB_InitSelf => () => new IB_AvailabilityManagerDifferentialThermostat(); + + private static AvailabilityManagerDifferentialThermostat NewDefaultOpsObj(Model model) => new AvailabilityManagerDifferentialThermostat(model); + public IB_AvailabilityManagerDifferentialThermostat() : base(NewDefaultOpsObj(new Model())) + { + } + + public void SetSensorNode(string coldProbeTrackingID, string hotProbeTrackingID) + { + if (string.IsNullOrEmpty(coldProbeTrackingID) || string.IsNullOrEmpty(hotProbeTrackingID)) + throw new ArgumentException("Invalid probe tracking ID"); + _nodeCID = coldProbeTrackingID; + _nodeHID = hotProbeTrackingID; + } + + public override OpenStudio.AvailabilityManager ToOS(Model model) + { + var obj = base.OnNewOpsObj(NewDefaultOpsObj, model); + + // this will be executed after all loops (nodes) are saved + Func func = () => + { + var nodeC = model.GetNodeByTrackingID(_nodeCID); + var nodeH = model.GetNodeByTrackingID(_nodeHID); + if (nodeC == null || nodeH == null) + return false; + + return obj.setColdNode(nodeC) && obj.setHotNode(nodeH); + + }; + + IB_Utility.DelayAddSensorNode(func); + + return obj; + } + + + } + + public sealed class IB_AvailabilityManagerDifferentialThermostat_FieldSet + : IB_FieldSet + { + private IB_AvailabilityManagerDifferentialThermostat_FieldSet() { } + + } + + +} diff --git a/src/Ironbug.HVAC/AvailabilityManagers/IB_AvailabilityManagerHighTemperatureTurnOff.cs b/src/Ironbug.HVAC/AvailabilityManagers/IB_AvailabilityManagerHighTemperatureTurnOff.cs new file mode 100644 index 00000000..40ae3f73 --- /dev/null +++ b/src/Ironbug.HVAC/AvailabilityManagers/IB_AvailabilityManagerHighTemperatureTurnOff.cs @@ -0,0 +1,56 @@ +using Ironbug.HVAC.BaseClass; +using OpenStudio; +using System; + +namespace Ironbug.HVAC.AvailabilityManager +{ + public class IB_AvailabilityManagerHighTemperatureTurnOff : IB_AvailabilityManager + { + private string _nodeID { get => this.Get(string.Empty); set => this.Set(value); } + public static IB_AvailabilityManagerHighTemperatureTurnOff_FieldSet FieldSet => IB_AvailabilityManagerHighTemperatureTurnOff_FieldSet.Value; + protected override Func IB_InitSelf => () => new IB_AvailabilityManagerHighTemperatureTurnOff(); + + private static AvailabilityManagerHighTemperatureTurnOff NewDefaultOpsObj(Model model) => new AvailabilityManagerHighTemperatureTurnOff(model); + public IB_AvailabilityManagerHighTemperatureTurnOff() : base(NewDefaultOpsObj(new Model())) + { + } + + public void SetSensorNode(string probeTrackingID) + { + if (string.IsNullOrEmpty(probeTrackingID)) + throw new ArgumentException("Invalid probe tracking ID"); + _nodeID = probeTrackingID; + } + + public override OpenStudio.AvailabilityManager ToOS(Model model) + { + var obj = base.OnNewOpsObj(NewDefaultOpsObj, model); + + // this will be executed after all loops (nodes) are saved + Func func = () => + { + var node = model.GetNodeByTrackingID(_nodeID); + if (node == null) + return false; + + return obj.setSensorNode(node); + + }; + + IB_Utility.DelayAddSensorNode(func); + + return obj; + } + + + } + + public sealed class IB_AvailabilityManagerHighTemperatureTurnOff_FieldSet + : IB_FieldSet + { + private IB_AvailabilityManagerHighTemperatureTurnOff_FieldSet() { } + + } + + +} diff --git a/src/Ironbug.HVAC/AvailabilityManagers/IB_AvailabilityManagerHighTemperatureTurnOn.cs b/src/Ironbug.HVAC/AvailabilityManagers/IB_AvailabilityManagerHighTemperatureTurnOn.cs new file mode 100644 index 00000000..87fa2896 --- /dev/null +++ b/src/Ironbug.HVAC/AvailabilityManagers/IB_AvailabilityManagerHighTemperatureTurnOn.cs @@ -0,0 +1,56 @@ +using Ironbug.HVAC.BaseClass; +using OpenStudio; +using System; + +namespace Ironbug.HVAC.AvailabilityManager +{ + public class IB_AvailabilityManagerHighTemperatureTurnOn : IB_AvailabilityManager + { + private string _nodeID { get => this.Get(string.Empty); set => this.Set(value); } + public static IB_AvailabilityManagerHighTemperatureTurnOn_FieldSet FieldSet => IB_AvailabilityManagerHighTemperatureTurnOn_FieldSet.Value; + protected override Func IB_InitSelf => () => new IB_AvailabilityManagerHighTemperatureTurnOn(); + + private static AvailabilityManagerHighTemperatureTurnOn NewDefaultOpsObj(Model model) => new AvailabilityManagerHighTemperatureTurnOn(model); + public IB_AvailabilityManagerHighTemperatureTurnOn() : base(NewDefaultOpsObj(new Model())) + { + } + + public void SetSensorNode(string probeTrackingID) + { + if (string.IsNullOrEmpty(probeTrackingID)) + throw new ArgumentException("Invalid probe tracking ID"); + _nodeID = probeTrackingID; + } + + public override OpenStudio.AvailabilityManager ToOS(Model model) + { + var obj = base.OnNewOpsObj(NewDefaultOpsObj, model); + + // this will be executed after all loops (nodes) are saved + Func func = () => + { + var node = model.GetNodeByTrackingID(_nodeID); + if (node == null) + return false; + + return obj.setSensorNode(node); + + }; + + IB_Utility.DelayAddSensorNode(func); + + return obj; + } + + + } + + public sealed class IB_AvailabilityManagerHighTemperatureTurnOn_FieldSet + : IB_FieldSet + { + private IB_AvailabilityManagerHighTemperatureTurnOn_FieldSet() { } + + } + + +} diff --git a/src/Ironbug.HVAC/AvailabilityManagers/IB_AvailabilityManagerHybridVentilation.cs b/src/Ironbug.HVAC/AvailabilityManagers/IB_AvailabilityManagerHybridVentilation.cs index afc31338..202eb579 100644 --- a/src/Ironbug.HVAC/AvailabilityManagers/IB_AvailabilityManagerHybridVentilation.cs +++ b/src/Ironbug.HVAC/AvailabilityManagers/IB_AvailabilityManagerHybridVentilation.cs @@ -25,24 +25,22 @@ public void SetControlZone(string controlZoneName) public override OpenStudio.AvailabilityManager ToOS(Model model) { var obj = base.OnNewOpsObj(NewDefaultOpsObj, model); - var zone = GetThermalZone(model, _controlZoneName); - if (zone != null) - obj.setControlledZone(zone); + // this will be executed after all loops (nodes) are saved + Func func = () => + { + var zone = model.GetThermalZone(_controlZoneName); + if (zone == null) + return false; - return obj; - } + return obj.setControlledZone(zone); - private static ThermalZone GetThermalZone(Model model, string name) - { - ThermalZone newZone = null; - if (string.IsNullOrEmpty(name)) - return newZone; + }; - var optionalZone = model.getThermalZoneByName(name); - if (optionalZone.is_initialized()) newZone = optionalZone.get(); - return newZone; + IB_Utility.DelayAddSensorNode(func); + return obj; } + } public sealed class IB_AvailabilityManagerHybridVentilation_FieldSet diff --git a/src/Ironbug.HVAC/AvailabilityManagers/IB_AvailabilityManagerList.cs b/src/Ironbug.HVAC/AvailabilityManagers/IB_AvailabilityManagerList.cs new file mode 100644 index 00000000..38d622d3 --- /dev/null +++ b/src/Ironbug.HVAC/AvailabilityManagers/IB_AvailabilityManagerList.cs @@ -0,0 +1,52 @@ +using OpenStudio; +using System; +using System.Collections.Generic; + +namespace Ironbug.HVAC.BaseClass +{ + public class IB_AvailabilityManagerList: IB_AvailabilityManager + { + + public List Mangers + { + get => this.TryGetList(); + set => this.Set(value); + } + + protected override Func IB_InitSelf => () => new IB_AvailabilityManagerList(); + + + public IB_AvailabilityManagerList() : base(new Node(new Model())) + { + } + + public void SetManagers(List mangers) + { + this.Mangers = mangers; + } + + + public OpenStudio.AvailabilityManagerVector ToAMVector(Model model) + { + var vec = new OpenStudio.AvailabilityManagerVector(); + foreach (var item in Mangers) + { + vec.Add(item.ToOS(model)); + } + return vec; + } + + public override OpenStudio.AvailabilityManager ToOS(Model model) + { + throw new NotImplementedException(); + } + + public override string ToString() + { + var s = $"{this.Mangers.Count} managers"; + return s; + } + } + + +} diff --git a/src/Ironbug.HVAC/AvailabilityManagers/IB_AvailabilityManagerLowTemperatureTurnOff.cs b/src/Ironbug.HVAC/AvailabilityManagers/IB_AvailabilityManagerLowTemperatureTurnOff.cs new file mode 100644 index 00000000..5d99bcec --- /dev/null +++ b/src/Ironbug.HVAC/AvailabilityManagers/IB_AvailabilityManagerLowTemperatureTurnOff.cs @@ -0,0 +1,56 @@ +using Ironbug.HVAC.BaseClass; +using OpenStudio; +using System; + +namespace Ironbug.HVAC.AvailabilityManager +{ + public class IB_AvailabilityManagerLowTemperatureTurnOff : IB_AvailabilityManager + { + private string _nodeID { get => this.Get(string.Empty); set => this.Set(value); } + public static IB_AvailabilityManagerLowTemperatureTurnOff_FieldSet FieldSet => IB_AvailabilityManagerLowTemperatureTurnOff_FieldSet.Value; + protected override Func IB_InitSelf => () => new IB_AvailabilityManagerLowTemperatureTurnOff(); + + private static AvailabilityManagerLowTemperatureTurnOff NewDefaultOpsObj(Model model) => new AvailabilityManagerLowTemperatureTurnOff(model); + public IB_AvailabilityManagerLowTemperatureTurnOff() : base(NewDefaultOpsObj(new Model())) + { + } + + public void SetSensorNode(string probeTrackingID) + { + if (string.IsNullOrEmpty(probeTrackingID)) + throw new ArgumentException("Invalid probe tracking ID"); + _nodeID = probeTrackingID; + } + + public override OpenStudio.AvailabilityManager ToOS(Model model) + { + var obj = base.OnNewOpsObj(NewDefaultOpsObj, model); + + // this will be executed after all loops (nodes) are saved + Func func = () => + { + var node = model.GetNodeByTrackingID(_nodeID); + if (node == null) + return false; + + return obj.setSensorNode(node); + + }; + + IB_Utility.DelayAddSensorNode(func); + + return obj; + } + + + } + + public sealed class IB_AvailabilityManagerLowTemperatureTurnOff_FieldSet + : IB_FieldSet + { + private IB_AvailabilityManagerLowTemperatureTurnOff_FieldSet() { } + + } + + +} diff --git a/src/Ironbug.HVAC/AvailabilityManagers/IB_AvailabilityManagerLowTemperatureTurnOn.cs b/src/Ironbug.HVAC/AvailabilityManagers/IB_AvailabilityManagerLowTemperatureTurnOn.cs new file mode 100644 index 00000000..f0cc0e97 --- /dev/null +++ b/src/Ironbug.HVAC/AvailabilityManagers/IB_AvailabilityManagerLowTemperatureTurnOn.cs @@ -0,0 +1,56 @@ +using Ironbug.HVAC.BaseClass; +using OpenStudio; +using System; + +namespace Ironbug.HVAC.AvailabilityManager +{ + public class IB_AvailabilityManagerLowTemperatureTurnOn : IB_AvailabilityManager + { + private string _nodeID { get => this.Get(string.Empty); set => this.Set(value); } + public static IB_AvailabilityManagerLowTemperatureTurnOn_FieldSet FieldSet => IB_AvailabilityManagerLowTemperatureTurnOn_FieldSet.Value; + protected override Func IB_InitSelf => () => new IB_AvailabilityManagerLowTemperatureTurnOn(); + + private static AvailabilityManagerLowTemperatureTurnOn NewDefaultOpsObj(Model model) => new AvailabilityManagerLowTemperatureTurnOn(model); + public IB_AvailabilityManagerLowTemperatureTurnOn() : base(NewDefaultOpsObj(new Model())) + { + } + + public void SetSensorNode(string probeTrackingID) + { + if (string.IsNullOrEmpty(probeTrackingID)) + throw new ArgumentException("Invalid probe tracking ID"); + _nodeID = probeTrackingID; + } + + public override OpenStudio.AvailabilityManager ToOS(Model model) + { + var obj = base.OnNewOpsObj(NewDefaultOpsObj, model); + + // this will be executed after all loops (nodes) are saved + Func func = () => + { + var node = model.GetNodeByTrackingID(_nodeID); + if (node == null) + return false; + + return obj.setSensorNode(node); + + }; + + IB_Utility.DelayAddSensorNode(func); + + return obj; + } + + + } + + public sealed class IB_AvailabilityManagerLowTemperatureTurnOn_FieldSet + : IB_FieldSet + { + private IB_AvailabilityManagerLowTemperatureTurnOn_FieldSet() { } + + } + + +} diff --git a/src/Ironbug.HVAC/AvailabilityManagers/IB_AvailabilityManagerNightVentilation.cs b/src/Ironbug.HVAC/AvailabilityManagers/IB_AvailabilityManagerNightVentilation.cs index 0a10b4e4..dc5ec7b1 100644 --- a/src/Ironbug.HVAC/AvailabilityManagers/IB_AvailabilityManagerNightVentilation.cs +++ b/src/Ironbug.HVAC/AvailabilityManagers/IB_AvailabilityManagerNightVentilation.cs @@ -25,24 +25,22 @@ public void SetControlZone(string controlZoneName) public override OpenStudio.AvailabilityManager ToOS(Model model) { var obj = base.OnNewOpsObj(NewDefaultOpsObj, model); - var zone = GetThermalZone(model, _controlZoneName); - if (zone != null) - obj.setControlZone(zone); + // this will be executed after all loops (nodes) are saved + Func func = () => + { + var zone = model.GetThermalZone(_controlZoneName); + if (zone == null) + return false; - return obj; - } + return obj.setControlZone(zone); - private static ThermalZone GetThermalZone(Model model, string name) - { - ThermalZone newZone = null; - if (string.IsNullOrEmpty(name)) - return newZone; + }; - var optionalZone = model.getThermalZoneByName(name); - if (optionalZone.is_initialized()) newZone = optionalZone.get(); - return newZone; + IB_Utility.DelayAddSensorNode(func); + return obj; } + } public sealed class IB_AvailabilityManagerNightVentilation_FieldSet diff --git a/src/Ironbug.HVAC/AvailabilityManagers/IB_AvailabilityManagerOptimumStart.cs b/src/Ironbug.HVAC/AvailabilityManagers/IB_AvailabilityManagerOptimumStart.cs new file mode 100644 index 00000000..67d30421 --- /dev/null +++ b/src/Ironbug.HVAC/AvailabilityManagers/IB_AvailabilityManagerOptimumStart.cs @@ -0,0 +1,57 @@ +using Ironbug.HVAC.BaseClass; +using OpenStudio; +using System; + +namespace Ironbug.HVAC.AvailabilityManager +{ + public class IB_AvailabilityManagerOptimumStart : IB_AvailabilityManager + { + private string _controlZoneName { get => this.Get(string.Empty); set => this.Set(value); } + public static IB_AvailabilityManagerOptimumStart_FieldSet FieldSet => IB_AvailabilityManagerOptimumStart_FieldSet.Value; + protected override Func IB_InitSelf => () => new IB_AvailabilityManagerOptimumStart(); + + private static AvailabilityManagerOptimumStart NewDefaultOpsObj(Model model) => new AvailabilityManagerOptimumStart(model); + public IB_AvailabilityManagerOptimumStart() : base(NewDefaultOpsObj(new Model())) + { + } + + public void SetControlZone(string controlZoneName) + { + if (string.IsNullOrEmpty(controlZoneName)) + return; + _controlZoneName = controlZoneName; + } + + public override OpenStudio.AvailabilityManager ToOS(Model model) + { + var obj = base.OnNewOpsObj(NewDefaultOpsObj, model); + + // this will be executed after all loops (nodes) are saved + Func func = () => + { + var zone = model.GetThermalZone(_controlZoneName); + if (zone == null) + return false; + + return obj.setControlZone(zone); + + }; + + IB_Utility.DelayAddSensorNode(func); + + + return obj; + } + + + } + + public sealed class IB_AvailabilityManagerOptimumStart_FieldSet + : IB_FieldSet + { + private IB_AvailabilityManagerOptimumStart_FieldSet() { } + + } + + +} diff --git a/src/Ironbug.HVAC/BaseClass/IB_Loop.cs b/src/Ironbug.HVAC/BaseClass/IB_Loop.cs index 9aca3188..b4d47864 100644 --- a/src/Ironbug.HVAC/BaseClass/IB_Loop.cs +++ b/src/Ironbug.HVAC/BaseClass/IB_Loop.cs @@ -146,6 +146,7 @@ IB_HVACObject FindPreComponent(IEnumerable Coms, IB_HVACObject cu } } + protected bool AddNodeProbe(Node startingNode, IEnumerable Components) { var components = Components.Where(_ => !(_ is IB_SetpointManager)); @@ -170,7 +171,10 @@ protected bool AddNodeProbe(Node startingNode, IEnumerable Compon { startingNode.SetCustomAttributes(item.CustomAttributes); startingNode.SetOutputVariables(item.CustomOutputVariables); - + + // node can be shared within model for availability manager's sensor input + OpsIDMapper.TryAdd(item.GetTrackingID(), startingNode.handle()); + added++; } return true; @@ -183,6 +187,10 @@ protected bool AddNodeProbe(Node startingNode, IEnumerable Compon var item = probes.First(); startingNode.SetCustomAttributes(item.CustomAttributes); startingNode.SetOutputVariables(item.CustomOutputVariables); + + // node can be shared within model for availability manager's sensor input + OpsIDMapper.TryAdd(item.GetTrackingID(), startingNode.handle()); + added = 1; remainingProbes = probes.Skip(1); @@ -230,6 +238,10 @@ protected bool AddNodeProbe(Node startingNode, IEnumerable Compon var nd = nodeWithProbe.get(); nd.SetCustomAttributes(item.CustomAttributes); nd.SetOutputVariables(item.CustomOutputVariables); + + // node can be shared within model for availability manager's sensor input + OpsIDMapper.TryAdd(item.GetTrackingID(), nd.handle()); + //var ndName = nd.nameString(); //AddOutputVariablesToModel(item.CustomOutputVariables, nd, model); added++; diff --git a/src/Ironbug.HVAC/BaseClass/IB_ModelObject.cs b/src/Ironbug.HVAC/BaseClass/IB_ModelObject.cs index 7d3110da..0d29f425 100644 --- a/src/Ironbug.HVAC/BaseClass/IB_ModelObject.cs +++ b/src/Ironbug.HVAC/BaseClass/IB_ModelObject.cs @@ -5,7 +5,6 @@ using Ironbug.Core; using System.Runtime.Serialization; using System.Runtime.CompilerServices; -using Ironbug.HVAC.Schedules; namespace Ironbug.HVAC.BaseClass { @@ -265,7 +264,10 @@ public void SetFieldValue(IB_Field field, object value) } else if (value is IB_AvailabilityManager am) { - realValue = new AvailabilityManagerVector(new[] { am.ToOS(this.GhostOSObject.model()) }.ToList()); + if (am is IB_AvailabilityManagerList amList) + realValue = amList.ToAMVector(this.GhostOSObject.model()); + else + realValue = new AvailabilityManagerVector(new[] { am.ToOS(this.GhostOSObject.model()) }.ToList()); } this.CustomAttributes.TryAdd(field, value); diff --git a/src/Ironbug.HVAC/Extensions/OpsIDMapper.cs b/src/Ironbug.HVAC/Extensions/OpsIDMapper.cs index 8f0820eb..a4e83493 100644 --- a/src/Ironbug.HVAC/Extensions/OpsIDMapper.cs +++ b/src/Ironbug.HVAC/Extensions/OpsIDMapper.cs @@ -4,6 +4,13 @@ namespace Ironbug.HVAC { + /// + /// Cache OpenStudio object Handle IDs along with Ironbug tracking IDs. + /// Only the following types of objects are cached: + /// - IIB_DualLoopObj + /// - IB_ScheduleRuleset + /// _ IB_NodeProbe (OpenStudio.Node) + /// internal static class OpsIDMapper { private static Dictionary _mapper; diff --git a/src/Ironbug.HVAC/IB_HVACSystem.cs b/src/Ironbug.HVAC/IB_HVACSystem.cs index d9e73f03..159c3774 100644 --- a/src/Ironbug.HVAC/IB_HVACSystem.cs +++ b/src/Ironbug.HVAC/IB_HVACSystem.cs @@ -158,195 +158,22 @@ public static bool SaveHVAC(string osmPath, string hvacJsonFilePath) public bool SaveHVAC(string osmFile) { - OpsIDMapper.StartRecording(); - - var airLoops = this.AirLoops; - var plantLoops = this.PlantLoops; - var vrfs = this.VariableRefrigerantFlows; - - //here means editing current existing file - if (!string.IsNullOrEmpty( this._existFile)) + if (!string.IsNullOrEmpty(this._existFile)) { if (this._existFile != osmFile) { throw new ArgumentException("File path is different than osm file contains existing loops!\nPlease input the existing osm file path."); } - //osmFile = this._existFile; - } - - //get Model from file if exists - var model = GetOrNewModel(osmFile); - - //Add outdoor air temperature output variable - var outT = new OpenStudio.OutputVariable("Site Outdoor Air Drybulb Temperature", model); - outT.setReportingFrequency("Hourly"); - - //add loops - //added plantLoops first, as the controllerWaterCoil of CoilCoolingWater or CoilHeatingWater only exists after the coil is added to PlantLoop - // add Condenser water loop before chilled water loop so that the chiller's condenser type can be set to WaterCooled - //var condenserLps = plantLoops.OfType(); - //foreach (var cdPlant in condenserLps) - //{ - // cdPlant.ToOS(model); - //} - //var theRestLps = plantLoops.Where(_ => !(_ is IB_CondenserPlantLoop)); - foreach (var plant in plantLoops) - { - plant.ToOS(model); - } - //don't add airloop before the plantLoops - foreach (var airLoop in airLoops) - { - airLoop.ToOS(model); - } - - - - foreach (var vrf in vrfs) - { - vrf.ToOS(model); + //osmFile = hvac._existFile; } - CheckInternalSourceConstruction(model); - var tol = model.getOutputControlReportingTolerances(); - tol.setToleranceforTimeCoolingSetpointNotMet(1.11); - tol.setToleranceforTimeHeatingSetpointNotMet(1.11); - - //save workflow - var osw = Path.Combine(Path.GetDirectoryName(osmFile), Path.GetFileNameWithoutExtension(osmFile), "workflow.osw"); - var wf = model.workflowJSON(); - wf.setSeedFile(OpenStudio.OpenStudioUtilitiesCore.toPath(Path.Combine("..", Path.GetFileName(osmFile)))); - wf.saveAs(OpenStudio.OpenStudioUtilitiesCore.toPath(osw)); - if (!File.Exists(osw)) - throw new ArgumentException($"Failed to create workflowJSON file: {osw}"); - - - //save osm file - return model.Save(osmFile); - - } - - public static OpenStudio.Model GetOrNewModel(string opsFilePath) - { - OpenStudio.Model model = null; - var f= new FileInfo(opsFilePath); - - if (f.Exists && - f.Length > 0 && - f.Extension.ToLower().Equals(".osm")) - { - //var osmPath = opsModelFilePath.ToPath(); - //CheckIfOldVersion(osmPath); - - // works - var vt = new OpenStudio.VersionTranslator(); - vt.setAllowNewerVersions(false); - var optionalModel = vt.loadModel(OpenStudio.OpenStudioUtilitiesCore.toPath(opsFilePath)); - - if (optionalModel.is_initialized()) - { - //var warnings = vTranslator.warnings().Select(_ => _.logMessage()).ToList(); - var errors = vt.errors().Select(_ => _.logMessage()).ToList(); - if (errors.Any()) - throw new ArgumentException($"Failed to load OpenStudio Model from {opsFilePath} because the following errors:{Environment.NewLine}{string.Join(Environment.NewLine, errors)}"); - - model = optionalModel.get(); - - } - else - throw new ArgumentException($"Failed to load OpenStudio Model from {opsFilePath}"); - - if (!model.isValid()) - throw new ArgumentException($"Found an invalid OpenStudio Model from {opsFilePath}"); - - } - else - { - model = new OpenStudio.Model(); - } - return model; - } - - //This is due to how HB sets up the this type of construction - private static void CheckInternalSourceConstruction(OpenStudio.Model model) - { - var tempM_o = model.getMaterialByName("INTERNAL SOURCE"); - if (tempM_o.isNull()) return; - var tempM = tempM_o.get(); - var handle = tempM.handle().__str__(); - - var tempCName = string.Empty; - - foreach (var item in tempM.sources()) - { - if (item.to_Construction().isNull()) continue; - - var tempC = item.to_Construction().get(); - tempCName = tempC.nameString(); - var mLayers = tempC.layers(); - - var newLayers = new OpenStudio.MaterialVector(mLayers); - var index = newLayers.ToList().FindIndex(_ => _.nameString() == "INTERNAL SOURCE"); - newLayers.RemoveAt(index); - - //create ConstructionWithInternalSource - var opC = new OpenStudio.ConstructionWithInternalSource(model); - opC.setName(tempCName); - opC.setLayers(newLayers); - opC.setSourcePresentAfterLayerNumber(index); - var opC_rev = opC.reverseConstructionWithInternalSource(); - var opCname = opC.nameString(); - - //assign to surfaces and their adjacent surfaces - var surfacesWithConstr = tempC.sources().Where(_ => _.to_Surface().is_initialized()).Select(_ => _.to_Surface().get()); - foreach (var srf in surfacesWithConstr) - { - srf.setConstruction(opC); - if (srf.adjacentSurface().is_initialized()) - { - srf.adjacentSurface().get().setConstruction(opC_rev); - } - } - - //in case that construction is set to default construction set - var defconstrs = tempC.sources().Where(_=> _.to_DefaultSurfaceConstructions().is_initialized()).Select(_ => _.to_DefaultSurfaceConstructions().get()); - //var names = defconstrs.SelectMany(_ => _.children().Select(c => c.nameString())); - foreach (var defcon in defconstrs) - { - if (defcon.wallConstruction().is_initialized()) - { - if (defcon.wallConstruction().get().nameString() == tempCName) - { - defcon.setWallConstruction(opC); - } - - } - - if (defcon.floorConstruction().is_initialized()) - { - if (defcon.floorConstruction().get().nameString() == tempCName) - { - defcon.setFloorConstruction(opC); - } - } - - if (defcon.roofCeilingConstruction().is_initialized()) - { - if (defcon.roofCeilingConstruction().get().nameString() == tempCName) - { - defcon.setRoofCeilingConstruction(opC); - } - } - - - } - tempC.remove(); - } - + return IB_Utility.SaveHVAC(this, osmFile); } + + public override string ToString() { var info = new List(); diff --git a/src/Ironbug.HVAC/IB_Utility.cs b/src/Ironbug.HVAC/IB_Utility.cs new file mode 100644 index 00000000..d8e6e22f --- /dev/null +++ b/src/Ironbug.HVAC/IB_Utility.cs @@ -0,0 +1,232 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; + +namespace Ironbug.HVAC +{ + public class IB_Utility + { + private static List> _delaiedAMFuncs; + + /// + /// Collect Funcs that need to be executed after all loops are saved. + /// + /// + public static void DelayAddSensorNode(Func func) + { + // This can only be called when saving the HVAC system to the OpenStudio model. + if (_delaiedAMFuncs == null) + return; + + _delaiedAMFuncs.Add(func); + } + + private static void ExecuteDelayedFuns() + { + if (_delaiedAMFuncs == null) + return; + foreach (var f in _delaiedAMFuncs) + { + if (!(f?.Invoke()).GetValueOrDefault()) + throw new ArgumentException("Failed to set availability manager's node"); + } + + // clear + _delaiedAMFuncs = null; + } + + private static void StartSaving() + { + OpsIDMapper.StartRecording(); + + _delaiedAMFuncs = new(); + } + + + + public static bool SaveHVAC(IB_HVACSystem hvac, string osmFile) + { + StartSaving(); + + var airLoops = hvac.AirLoops; + var plantLoops = hvac.PlantLoops; + var vrfs = hvac.VariableRefrigerantFlows; + + + //get Model from file if exists + var model = GetOrNewModel(osmFile); + + //Add outdoor air temperature output variable + var outT = new OpenStudio.OutputVariable("Site Outdoor Air Drybulb Temperature", model); + outT.setReportingFrequency("Hourly"); + + //add loops + //added plantLoops first, as the controllerWaterCoil of CoilCoolingWater or CoilHeatingWater only exists after the coil is added to PlantLoop + // add Condenser water loop before chilled water loop so that the chiller's condenser type can be set to WaterCooled + //var condenserLps = plantLoops.OfType(); + //foreach (var cdPlant in condenserLps) + //{ + // cdPlant.ToOS(model); + //} + //var theRestLps = plantLoops.Where(_ => !(_ is IB_CondenserPlantLoop)); + foreach (var plant in plantLoops) + { + plant.ToOS(model); + } + //don't add airloop before the plantLoops + foreach (var airLoop in airLoops) + { + airLoop.ToOS(model); + } + + foreach (var vrf in vrfs) + { + vrf.ToOS(model); + } + + // set availability manager's sensor nodes after all loops are saved + ExecuteDelayedFuns(); + + + CheckInternalSourceConstruction(model); + var tol = model.getOutputControlReportingTolerances(); + tol.setToleranceforTimeCoolingSetpointNotMet(1.11); + tol.setToleranceforTimeHeatingSetpointNotMet(1.11); + + //save workflow + var osw = Path.Combine(Path.GetDirectoryName(osmFile), Path.GetFileNameWithoutExtension(osmFile), "workflow.osw"); + var wf = model.workflowJSON(); + wf.setSeedFile(OpenStudio.OpenStudioUtilitiesCore.toPath(Path.Combine("..", Path.GetFileName(osmFile)))); + wf.saveAs(OpenStudio.OpenStudioUtilitiesCore.toPath(osw)); + if (!File.Exists(osw)) + throw new ArgumentException($"Failed to create workflowJSON file: {osw}"); + + + //save osm file + return model.Save(osmFile); + } + + public static OpenStudio.Model GetOrNewModel(string opsFilePath) + { + OpenStudio.Model model = null; + var f = new FileInfo(opsFilePath); + + if (f.Exists && + f.Length > 0 && + f.Extension.ToLower().Equals(".osm")) + { + //var osmPath = opsModelFilePath.ToPath(); + //CheckIfOldVersion(osmPath); + + // works + var vt = new OpenStudio.VersionTranslator(); + vt.setAllowNewerVersions(false); + var optionalModel = vt.loadModel(OpenStudio.OpenStudioUtilitiesCore.toPath(opsFilePath)); + + if (optionalModel.is_initialized()) + { + //var warnings = vTranslator.warnings().Select(_ => _.logMessage()).ToList(); + var errors = vt.errors().Select(_ => _.logMessage()).ToList(); + if (errors.Any()) + throw new ArgumentException($"Failed to load OpenStudio Model from {opsFilePath} because the following errors:{Environment.NewLine}{string.Join(Environment.NewLine, errors)}"); + + model = optionalModel.get(); + + } + else + throw new ArgumentException($"Failed to load OpenStudio Model from {opsFilePath}"); + + if (!model.isValid()) + throw new ArgumentException($"Found an invalid OpenStudio Model from {opsFilePath}"); + + } + else + { + model = new OpenStudio.Model(); + } + return model; + } + + + //This is due to how HB sets up the this type of construction + private static void CheckInternalSourceConstruction(OpenStudio.Model model) + { + var tempM_o = model.getMaterialByName("INTERNAL SOURCE"); + if (tempM_o.isNull()) return; + var tempM = tempM_o.get(); + var handle = tempM.handle().__str__(); + + var tempCName = string.Empty; + + foreach (var item in tempM.sources()) + { + if (item.to_Construction().isNull()) continue; + + var tempC = item.to_Construction().get(); + tempCName = tempC.nameString(); + var mLayers = tempC.layers(); + + var newLayers = new OpenStudio.MaterialVector(mLayers); + var index = newLayers.ToList().FindIndex(_ => _.nameString() == "INTERNAL SOURCE"); + newLayers.RemoveAt(index); + + //create ConstructionWithInternalSource + var opC = new OpenStudio.ConstructionWithInternalSource(model); + opC.setName(tempCName); + opC.setLayers(newLayers); + opC.setSourcePresentAfterLayerNumber(index); + var opC_rev = opC.reverseConstructionWithInternalSource(); + var opCname = opC.nameString(); + + //assign to surfaces and their adjacent surfaces + var surfacesWithConstr = tempC.sources().Where(_ => _.to_Surface().is_initialized()).Select(_ => _.to_Surface().get()); + foreach (var srf in surfacesWithConstr) + { + srf.setConstruction(opC); + if (srf.adjacentSurface().is_initialized()) + { + srf.adjacentSurface().get().setConstruction(opC_rev); + } + } + + //in case that construction is set to default construction set + var defconstrs = tempC.sources().Where(_ => _.to_DefaultSurfaceConstructions().is_initialized()).Select(_ => _.to_DefaultSurfaceConstructions().get()); + //var names = defconstrs.SelectMany(_ => _.children().Select(c => c.nameString())); + foreach (var defcon in defconstrs) + { + if (defcon.wallConstruction().is_initialized()) + { + if (defcon.wallConstruction().get().nameString() == tempCName) + { + defcon.setWallConstruction(opC); + } + + } + + if (defcon.floorConstruction().is_initialized()) + { + if (defcon.floorConstruction().get().nameString() == tempCName) + { + defcon.setFloorConstruction(opC); + } + } + + if (defcon.roofCeilingConstruction().is_initialized()) + { + if (defcon.roofCeilingConstruction().get().nameString() == tempCName) + { + defcon.setRoofCeilingConstruction(opC); + } + } + + + } + tempC.remove(); + } + + + } + + } +} diff --git a/src/Ironbug.HVAC/LoopObjs/IB_NodeProbe.cs b/src/Ironbug.HVAC/LoopObjs/IB_NodeProbe.cs index a8fad462..df342395 100644 --- a/src/Ironbug.HVAC/LoopObjs/IB_NodeProbe.cs +++ b/src/Ironbug.HVAC/LoopObjs/IB_NodeProbe.cs @@ -14,16 +14,16 @@ public IB_NodeProbe() : base(NewDefaultOpsObj(new Model())) { } - //This will never be called, check IB_Loop.AddNodeProbe(); + public override HVACComponent ToOS(Model model) { - return base.OnNewOpsObj(NewDefaultOpsObj, model); + throw new NotImplementedException("This will never be called, check IB_Loop.AddNodeProbe()"); } - //This will never be called, check IB_Loop.AddNodeProbe(); + public override bool AddToNode(Node node) { - return true; + throw new NotImplementedException("This will never be called, check IB_Loop.AddNodeProbe()"); } public override string ToString() => "NodeProbe"; diff --git a/src/Ironbug.HVAC/LoopObjs/IB_OutdoorAirSystem.cs b/src/Ironbug.HVAC/LoopObjs/IB_OutdoorAirSystem.cs index ed24dda3..8180a1a9 100644 --- a/src/Ironbug.HVAC/LoopObjs/IB_OutdoorAirSystem.cs +++ b/src/Ironbug.HVAC/LoopObjs/IB_OutdoorAirSystem.cs @@ -198,6 +198,8 @@ protected bool AddNodeProbe(IEnumerable Components, IEnumerable Components, IEnumerable Components, IEnumerable(this T component, Model model) where T: ModelObject { var type = component.GetType(); @@ -247,7 +274,10 @@ public static List SetCustomAttributes(this ModelObject component, BaseC } else if (value is BaseClass.IB_AvailabilityManager am) { - value = new AvailabilityManagerVector(new[] { am.ToOS(md) }.ToList()); + if (am is BaseClass.IB_AvailabilityManagerList amList) + value = amList.ToAMVector(md); + else + value = new AvailabilityManagerVector(new[] { am.ToOS(md) }.ToList()); } var invokeResult = component.SetFieldValue(field, value);