If you have a problem or need to report a bug please email : support@dsprobotics.com
There are 3 sections to this support area:
DOWNLOADS: access to product manuals, support files and drivers
HELP & INFORMATION: tutorials and example files for learning or finding pre-made modules for your projects
USER FORUMS: meet with other users and exchange ideas, you can also get help and assistance here
NEW REGISTRATIONS - please contact us if you wish to register on the forum
Users are reminded of the forum rules they sign up to which prohibits any activity that violates any laws including posting material covered by copyright
Ruby conditional LOOP module: what's wrong with code?
8 posts
• Page 1 of 1
Ruby conditional LOOP module: what's wrong with code?
Dear Colleagues,
please help to figure out problem with Ruby code. I created Ruby-based module, which implements conditional looping, depending on if the 2nd input is true or false. The loop should stop, either if this input becomes 'true', or iterations' number exceeds the preset limit.
The code is meant so as it first of all sends the start trigger right before the loop body starts (str. 7) to the 1st output, but in fact this happens only AFTER the loop finishes, inspite of that the appropriate string is placed before the loop...
And I cannot figure out what's wrong...
Please help. The schematic is attached below.
please help to figure out problem with Ruby code. I created Ruby-based module, which implements conditional looping, depending on if the 2nd input is true or false. The loop should stop, either if this input becomes 'true', or iterations' number exceeds the preset limit.
The code is meant so as it first of all sends the start trigger right before the loop body starts (str. 7) to the 1st output, but in fact this happens only AFTER the loop finishes, inspite of that the appropriate string is placed before the loop...
And I cannot figure out what's wrong...
Please help. The schematic is attached below.
- Attachments
-
- Ruby loop1.fsm
- (608 Bytes) Downloaded 903 times
- keyjslider1
- Posts: 20
- Joined: Tue Mar 13, 2018 2:19 pm
Re: Ruby conditional LOOP module: what's wrong with code?
I opened the schem, will try and get what you want it to do.
Just as a point of interest, does this count to 10,000,000 in about a 10th sec?
That would be freakish
Just as a point of interest, does this count to 10,000,000 in about a 10th sec?
That would be freakish
-
nix - Posts: 817
- Joined: Tue Jul 13, 2010 10:51 am
Re: Ruby conditional LOOP module: what's wrong with code?
nix wrote:I opened the schem, will try and get what you want it to do.
Just as a point of interest, does this count to 10,000,000 in about a 10th sec?
That would be freakish
Not exactly. The scheme - is a Ruby version of conventional LOOP prim, which is present for green, but with different logic: in my scheme I try to implement conditional "loop while" execution, based on the 2nd input, instead of fixed iterations number, featured in standard LOOP primitive. I need this module to read arrays faster, then the sample rate, at that under specific condition (it reads while current value is equal to the previous one, otherwise reading stops).
The breakpoint at 10 million loop cycles in my schematics is not the goal itself and is meant just to make my problem visually noticable: even e.g. 1 mill. or less iterations proved that one wouldn't notice, that the first input value does not come at first, as it was initially conceived (what is obvious from the code) , but instead - arrives only after the full loop is executed up till the end.
Thank you Nix, it could be great if could help what's actually going on wrong, cause I am new to Ruby)
- keyjslider1
- Posts: 20
- Joined: Tue Mar 13, 2018 2:19 pm
Re: Ruby conditional LOOP module: what's wrong with code?
nix wrote:Just as a point of interest, does this count to 10,000,000 in about a 10th sec?
Hi, I'd like to add... I haven't answered your main question eventually... This module outputs triggers from the 3rd out< as long as the iterations go on. The 1st outputs "1" at the start, the 2nd output (the finish-marker) - the same, but works as soon as the 2nd input condition becomes true and the loop stops.
But in this schematic the 3rd output sends, as a sigle-shot, the whole amount of the iterations passed, that happens at the end of the loop and not everytime the loop cycles - just for code testing purposes, so as not to overload Flowstone for redrawing output.
- keyjslider1
- Posts: 20
- Joined: Tue Mar 13, 2018 2:19 pm
Re: Ruby conditional LOOP module: what's wrong with code?
Dear Nix, thank you, I forwarded 2 replies with quotes, 3 days ago, but they still seem to undergo moderation.
In a few words, the point of interest is quite different. The module - is a Ruby recreation of standard green LOOP prim, but with implementation of conditional "loop while/until" logic, which is missing for initial prim.
Thus, the scheme attached is intended to send out triggers (from the 3rd output) in sync with code performing iterations, and then stop, as soon as the true/false condition at the 2nd input meets.
The breakpoint of 10 Mill iterations is such a high, so as to make the issue with the code I am asking about noticebale, otherwise one wouldn't note the time difference between end of looping and the 1st output value arrival time.
In a few words, the point of interest is quite different. The module - is a Ruby recreation of standard green LOOP prim, but with implementation of conditional "loop while/until" logic, which is missing for initial prim.
Thus, the scheme attached is intended to send out triggers (from the 3rd output) in sync with code performing iterations, and then stop, as soon as the true/false condition at the 2nd input meets.
The breakpoint of 10 Mill iterations is such a high, so as to make the issue with the code I am asking about noticebale, otherwise one wouldn't note the time difference between end of looping and the 1st output value arrival time.
- keyjslider1
- Posts: 20
- Joined: Tue Mar 13, 2018 2:19 pm
Re: Ruby conditional LOOP module: what's wrong with code?
It's interesting stuff,
man that's a fast counter.
I understood what the problem is after a bit,
but I can't seem to fix it either.
Truly fast counter, nice one
I can't tell you why ur posts didn't show.
Thanks for the innovation-
hope to see u around
man that's a fast counter.
I understood what the problem is after a bit,
but I can't seem to fix it either.
Truly fast counter, nice one
I can't tell you why ur posts didn't show.
Thanks for the innovation-
hope to see u around
-
nix - Posts: 817
- Joined: Tue Jul 13, 2010 10:51 am
Re: Ruby conditional LOOP module: what's wrong with code?
You try to implement code for traditional top-down list of commands in an event-driven, object oriented language. That won't work.
- A while loop will block any other execution until done.
- Methods return an object, so the next step would be done after returning, but the while loop blocks the (event-)method from returning.
You need another concept for this conditonal looping. I'm not in the state that would allow me to help you with that, but maybe somebody else will.
- A while loop will block any other execution until done.
- Methods return an object, so the next step would be done after returning, but the while loop blocks the (event-)method from returning.
You need another concept for this conditonal looping. I'm not in the state that would allow me to help you with that, but maybe somebody else will.
"There lies the dog buried" (German saying translated literally)
- tulamide
- Posts: 2714
- Joined: Sat Jun 21, 2014 2:48 pm
- Location: Germany
Re: Ruby conditional LOOP module: what's wrong with code?
tulamide wrote:- A while loop will block any other execution until done.
Thanks Tulamide, unfortunately, that's exactly what I thought...
Anyhow the module does the job and I can easily dispense with that start trigger send-out and kill that 1st output.
In reality the iterations will not exceed 100 cycles per hit in my project, thus I expect there will be minor overloading for the whole process...
- keyjslider1
- Posts: 20
- Joined: Tue Mar 13, 2018 2:19 pm
8 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 41 guests