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 Issue: Draw and Init
12 posts
• Page 1 of 2 • 1, 2
Ruby Issue: Draw and Init
If a view is connected to the Ruby editor, when starting the schematic (and probably any exports also) the 'draw' method is called before the init method. A simple test will convince you, see attachment.
In my spline class example 2, I can resolve the issue by calling init from within the draw method, which should convince everyone who wasn't from the attached test.
This renders 'init' pretty much useless. Luckily, you can also initialize by just placing the initializing code at the very beginning of the Ruby editor, without defining an init method. No need to call init from the draw method then.
Thought you should be aware of it!
In my spline class example 2, I can resolve the issue by calling init from within the draw method, which should convince everyone who wasn't from the attached test.
This renders 'init' pretty much useless. Luckily, you can also initialize by just placing the initializing code at the very beginning of the Ruby editor, without defining an init method. No need to call init from the draw method then.
Thought you should be aware of it!
- Attachments
-
- order_issue.fsm
- shows that 'draw' is called first when opening this schematic
- (360 Bytes) Downloaded 719 times
"There lies the dog buried" (German saying translated literally)
- tulamide
- Posts: 2714
- Joined: Sat Jun 21, 2014 2:48 pm
- Location: Germany
Re: Ruby Issue: Draw and Init
Thanks for pointing this out and giving a solution.
I have noticed that too, it is rather odd and doesn't make much sense!
I have noticed that too, it is rather odd and doesn't make much sense!
- Exo
- Posts: 426
- Joined: Wed Aug 04, 2010 8:58 pm
- Location: UK
Re: Ruby Issue: Draw and Init? not true
Your test is not very correct, look at this:
The problem that you have with your class Spline is that you must always load the modules that contain the classes, before any other modules, otherwise your class when the module invokes it, does not yet exist in memory.
The problem that you have with your class Spline is that you must always load the modules that contain the classes, before any other modules, otherwise your class when the module invokes it, does not yet exist in memory.
- Tronic
- Posts: 539
- Joined: Wed Dec 21, 2011 12:59 pm
Re: Ruby Issue: Draw and Init? not true
Tronic wrote:Your test is not very correct, look at this:
The problem that you have with your class Spline is that you must always load the modules that contain the classes, before any other modules, otherwise your class when the module invokes it, does not yet exist in memory.
I'm sorry, but you're not true. See, the watch method only gets triggered when the method it's in is also triggered. That's why you get the impression of a regular order, since after the first draw, the order is correct (draw, init, draw). The spline class is an expansion of the ruby edit class, any access to the class forces ruby to build it if not yet existant. That's why you have no issues at all when initializing at the very beginning of the editor, without creating an 'init' method.
My schematic on the other hand raises an error whenever one of the methods gets called, whatever is the first. No Spline Class involved at all!
See the attached schematic without your 'afterload' prim. (draw gets called 3x, init 1x)
- Attachments
-
- order_issue_not_true_issue.fsm
- (417 Bytes) Downloaded 732 times
"There lies the dog buried" (German saying translated literally)
- tulamide
- Posts: 2714
- Joined: Sat Jun 21, 2014 2:48 pm
- Location: Germany
Re: Ruby Issue: Draw and Init
Unfortunately I can not agree to your idea,
because if the method "Init" was not the first to be triggered,
would not be initialized the variable with which you observe the results,
you're considering the number of trig happened, but the method "draw" shows a longer time,
compared to that reported by the method "init",
so for me the order of execution is correct.
because if the method "Init" was not the first to be triggered,
would not be initialized the variable with which you observe the results,
you're considering the number of trig happened, but the method "draw" shows a longer time,
compared to that reported by the method "init",
so for me the order of execution is correct.
- Tronic
- Posts: 539
- Joined: Wed Dec 21, 2011 12:59 pm
Re: Ruby Issue: Draw and Init
Tronic wrote:...so for me the order of execution is correct.
That's exactly what I said in my last post. You get the impression, because after the first 'draw' call, the order indeed is correct. There's just the issue that draw gets called a first time before 'init'
Here's another schematic, and if this one doesn't convince you, I don't know what else.
Make sure Flowstone is not running, then open it with the schematic. After load, just click on the trigger button and be surprised
- Attachments
-
- order_issue 2.fsm
- (436 Bytes) Downloaded 765 times
"There lies the dog buried" (German saying translated literally)
- tulamide
- Posts: 2714
- Joined: Sat Jun 21, 2014 2:48 pm
- Location: Germany
Re: Ruby Issue: Draw and Init
Sorry, but not...
trig order still
Method:
1) init
2) event
3) draw
try to switch OFF the module and retrig....
surprise....
trig order still
Method:
1) init
2) event
3) draw
try to switch OFF the module and retrig....
surprise....
- Tronic
- Posts: 539
- Joined: Wed Dec 21, 2011 12:59 pm
Re: Ruby Issue: Draw and Init
Tronic wrote:Sorry, but not...
trig order still
Method:
1) init
2) event
3) draw
try to switch OFF the module and retrig....
surprise....
Tronic, I see you misunderstand the whole issue. We talk past each other. Of course, it works after retrig. That's what I am saying the whole time! You don't even need to switch it off, just enter something in the editor, for example a space anywhere and retrigger. But the issue is not that it works afterwards, the issue is that, as you can clearly see in the last schematic I posted, 'init' doesn't get called, while 'draw' is called - at the very first time.
I don't know how I could explain it in another way so that it might get clearer.
"There lies the dog buried" (German saying translated literally)
- tulamide
- Posts: 2714
- Joined: Sat Jun 21, 2014 2:48 pm
- Location: Germany
Re: Ruby Issue: Draw and Init
your preview test is not correct, it every time reset the variable when you trig the module,
because method init is called only the first time, so the variable @a_init is lost(is reset) in your case.
because method init is called only the first time, so the variable @a_init is lost(is reset) in your case.
- Tronic
- Posts: 539
- Joined: Wed Dec 21, 2011 12:59 pm
Re: Ruby Issue: Draw and Init
Tronic wrote:your preview test is not correct, it every time reset the variable when you trig the module,
because method init is called only the first time, so the variable @a_init is lost(is reset) in your case.
Wrong again, I don't trig the module, I trig the event method. Also, your thought would also reset @a_draw
But I'll leave it as it is. I've done my best.
"There lies the dog buried" (German saying translated literally)
- tulamide
- Posts: 2714
- Joined: Sat Jun 21, 2014 2:48 pm
- Location: Germany
12 posts
• Page 1 of 2 • 1, 2
Who is online
Users browsing this forum: No registered users and 77 guests