Skip to content

Commit

Permalink
feat(SwimmingPool): support SwimmingPoolIndoor
Browse files Browse the repository at this point in the history
  • Loading branch information
MingboPeng committed Mar 6, 2024
1 parent a795fe8 commit e3d3c51
Show file tree
Hide file tree
Showing 7 changed files with 106 additions and 0 deletions.
Binary file modified doc/Icon/Ironbug.HVAC.afdesign
Binary file not shown.
Binary file added doc/Icon/Ironbug.HVAC/24h/SwimmingPool.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
using System;
using Grasshopper.Kernel;
using Ironbug.Grasshopper.Properties;
using Ironbug.HVAC;

namespace Ironbug.Grasshopper.Component
{
public class Ironbug_SwimmingPoolIndoor : Ironbug_HVACWithParamComponent
{
public Ironbug_SwimmingPoolIndoor()
: base("IB_SwimmingPoolIndoor", "SwimmingPool",
"Description",
"Ironbug", "02:LoopComponents", typeof(IB_SwimmingPoolIndoor_FieldSet))
{
}

public override GH_Exposure Exposure => GH_Exposure.septenary | GH_Exposure.obscure;

protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager)
{
pManager.AddTextParameter("poolSurfaceID", "_poolSrfId", "This is the name of the surface (floor) where the pool is located. Pools are not allowed on any surfaces other than a floor.", GH_ParamAccess.item);
}


protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager pManager)
{
pManager.AddGenericParameter("SwimmingPoolIndoor", "Pool", "TODO..", GH_ParamAccess.item);
}

protected override void SolveInstance(IGH_DataAccess DA)
{
string srfId = string.Empty;
if (!DA.GetData(0, ref srfId)) return;

var obj = new IB_SwimmingPoolIndoor();
obj.SetWaterSufaceID(srfId);

this.SetObjParamsTo(obj);
DA.SetData(0, obj);

}

protected override System.Drawing.Bitmap Icon => Resources.SwimmingPool;

public override Guid ComponentGuid => new Guid("{68E45483-E96D-4864-BB3E-A763DA14143A}");
}
}
10 changes: 10 additions & 0 deletions src/Ironbug.Grasshopper/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/Ironbug.Grasshopper/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -712,4 +712,7 @@
<data name="SetpointMxAir" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\SetpointMxAir.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="SwimmingPool" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\SwimmingPool.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
46 changes: 46 additions & 0 deletions src/Ironbug.HVAC/LoopObjs/IB_SwimmingPoolIndoor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Ironbug.HVAC.BaseClass;
using OpenStudio;

namespace Ironbug.HVAC
{
public class IB_SwimmingPoolIndoor : IB_HVACObject
{
private string _surfaceID { get => this.Get(string.Empty); set => this.Set(value); }
protected override Func<IB_ModelObject> IB_InitSelf => () => new IB_SwimmingPoolIndoor();

private static SwimmingPoolIndoor NewDefaultOpsObj(Model model) => new SwimmingPoolIndoor(model, new Surface(new Point3dVector(new List<Point3d>() { new Point3d(0,0,0), new Point3d(0,1,0), new Point3d(1,0,0)}), model));
public IB_SwimmingPoolIndoor() : base(NewDefaultOpsObj(new Model()))
{
}

public void SetWaterSufaceID(string waterSuface)
{
if (string.IsNullOrEmpty(waterSuface))
throw new ArgumentException("Invalid water surface ID");
_surfaceID = waterSuface;
}

public override HVACComponent ToOS(Model model)
{
var newObj = this.OnNewOpsObj(NewDefaultOpsObj, model);
//var srfs = model.getSurfaces();
//var nn = srfs.Select(_=>_.nameString(true)).ToList();
var srf = model.getSurfaceByName(_surfaceID);
if (srf == null || !srf.is_initialized())
throw new ArgumentException("Failed to find water surface for SwimmingPoolIndoor");

newObj.setSurface(srf.get());
return newObj;
}
}

public sealed class IB_SwimmingPoolIndoor_FieldSet
: IB_FieldSet<IB_SwimmingPoolIndoor_FieldSet, SwimmingPoolIndoor>
{
private IB_SwimmingPoolIndoor_FieldSet() {}

}
}

0 comments on commit e3d3c51

Please sign in to comment.