Grasshopper

algorithmic modeling for Rhino

Question:

I am wondering if there is a way to use a time of my choosing with the DataDam component.

I think 20ms or even shorter is what I am after (this may be asking a lot).

There is probably a method via scripting, but I am far from writing my own with VB or C# as I primarily use native GH methods.

Any advice is welcome,

THanks

Background Below:

The reason I am looking for this is that I am using Firefly's Serial Read which relies on a timer (20ms) and I am using the Serial Write component as well. I have a mechanical switch which sends a "1" when pressed and a "0" when not pressed.  I am using these boolean states to increment a counter which in turn selects a list item... this list item is a string that is sent via the Serial Write.  I have a definition that can detect a state change in the counter and dispatch the current string, but it relies on the DataDam which is too slow to always "catch" the change.

Ultimately what I am trying to avoid is sending the sameString more than one time, which happens when the Timer from Serial Read refreshes every 20ms.  This could probably be dealt with on the Arduino side, but I would like to try to solve this in GH if possible.

The application of this is for a rig I have been building for material testing with ceramic fluids.

Views: 1756

Attachments:

Replies to This Discussion

I think it's possible to not refresh (expire) a component when some event happens but if so it requires knowledge of some obscure parts of the GH SDK.

An alternative that sort of works and is simple to code is to add an intermediate parameter and disable it from a scripting component whenever the data is the same as before.

See the attached definition.

File

Attachments:

Vincente,

Thank you so much... your VB script is doing exactly what I need when I refresh the counter at 20ms.

I had already looked at some of your previous advice here:

http://www.grasshopper3d.com/forum/topics/continuous-streaming-of?c...

which is along the same lines.

Thanks again!

I am really grateful.

The problem is that any component connected to the A output will be calculated again even if you don't assign anything to it.

 

Attached is another version that keeps the last value on the parameter rather than being empty when data is not changing.

Attachments:

I rewrote this VB component in C# and it does not give any errors. The onoff component keep telling me that it has "failed to collect data". Although when I scroll over with my mouse, it does give me the correct value...

I do have to type hint the x input as double to make it work this far. Keeping the x and xo as object does not work at all.

GH_Document doc = owner.OnPingDocument();
Grasshopper.Kernel.GH_Param<Grasshopper.Kernel.Types.GH_String> obj = null;

foreach( IGH_DocumentObject objt in doc.Objects ){
if(objt.NickName.Equals(y, StringComparison.Ordinal)){
obj = (Grasshopper.Kernel.GH_Param<Grasshopper.Kernel.Types.GH_String>) objt;
break;
}
}

if (x != xo) {
xo = x;
obj.ExpireSolution(true);
}
obj.AddVolatileData(new GH_Path(0), 0, xo);
}

// <Custom additional code>

double xo;

 


Would you maybe know what's up?

Jesse

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service