Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow for the refresh rate to be specified #16

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion SandWorm/SandWormComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public class SandWorm : GH_Component
public int rightColumns = 0;
public int topRows = 0;
public int bottomRows = 0;
public int tickRate = 20; // In ms
public static Rhino.UnitSystem units = Rhino.RhinoDoc.ActiveDoc.ModelUnitSystem;
public static double unitsMultiplier;

Expand Down Expand Up @@ -62,6 +63,7 @@ protected override void RegisterInputParams(GH_Component.GH_InputParamManager pM
pManager.AddIntegerParameter("RightColumns", "RC", "Number of columns to trim from the right", GH_ParamAccess.item, 0);
pManager.AddIntegerParameter("TopRows", "TR", "Number of rows to trim from the top", GH_ParamAccess.item, 0);
pManager.AddIntegerParameter("BottomRows", "BR", "Number of rows to trim from the bottom", GH_ParamAccess.item, 0);
pManager.AddIntegerParameter("TickRate", "TR", "The time interval, in milliseconds, to update geometry from the Kinect. Set as 0 to disable automatic updates.", GH_ParamAccess.item, tickRate);

pManager[0].Optional = true;
pManager[1].Optional = true;
Expand All @@ -70,6 +72,7 @@ protected override void RegisterInputParams(GH_Component.GH_InputParamManager pM
pManager[4].Optional = true;
pManager[5].Optional = true;
pManager[6].Optional = true;
pManager[7].Optional = true;
}

/// <summary>
Expand Down Expand Up @@ -100,6 +103,7 @@ protected override void SolveInstance(IGH_DataAccess DA)
DA.GetData<int>(4, ref rightColumns);
DA.GetData<int>(5, ref topRows);
DA.GetData<int>(6, ref bottomRows);
DA.GetData<int>(7, ref tickRate);

switch (units.ToString())
{
Expand Down Expand Up @@ -186,7 +190,11 @@ protected override void SolveInstance(IGH_DataAccess DA)
DA.SetDataList(0, outputMesh);
DA.SetDataList(1, output); //debugging
}
base.OnPingDocument().ScheduleSolution(20, new GH_Document.GH_ScheduleDelegate(ScheduleDelegate));

if (tickRate > 0) // Allow users to force manual recalculation
{
base.OnPingDocument().ScheduleSolution(tickRate, new GH_Document.GH_ScheduleDelegate(ScheduleDelegate));
}
}

/// <summary>
Expand Down