Support

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

How "draw" method is executed from Stack in FlowStone/Ruby?

For general discussion related FlowStone

How "draw" method is executed from Stack in FlowStone/Ruby?

Postby Nowhk » Wed Jan 27, 2016 12:33 pm

For the last time ever (I really need to catch this): I need to understand how Ruby stack "draw" method when I call it, because I don't get how it is executed with the logic I have now, and 90% of graphics I want to make fail due to this dubt I'm not able to get.

Pretty basic example:

Code: Select all
def setParameters
   @watchs+="p1 "      
end

def getCoordinates
   @watchs+="c1 "
end

def draw i,v
   watch "watcher_b", @watchs+"d1 "
end

def event i,v
   if(i=="trigger1")
      @watchs=""
      @watchs+="e1 "
      setParameters
      getCoordinates
      @watchs+="e2 "
      redraw 0   
      @watchs+="e3 "
   elsif(i=="trigger2")
      @watchs+="e4 "
      setParameters
      redraw 0      
      @watchs+="e5 "
   end
   
   watch "watcher_a", @watchs
end

Ruby Redraw Stack.fsm
(492 Bytes) Downloaded 956 times

Open the schematic and trigger with the button. What I'd aspect from it, its that the output is:

e1 p1 c1 e2 d1 e3 e4 p1 d1 e5

Instead its:

e1 p1 c1 e2 e3 e4 p1 e5
without any "redrawing" between methods called in event. Seems that it first processes all the "events" method inside Ruby event, than add "redraw" method to the stack, to be called at some point (later?).

Well, this is the part I miss: what's this "some point"? Is it scheduled random? Is it "as soon as possible" following a Redraw ticks? (so if I'm lucky and the tick is between e2 and e3, I'll get a redraw?)

Can you help me to understand this? :lol:
Nowhk
 
Posts: 275
Joined: Mon Oct 27, 2014 6:45 pm

Re: How "draw" method is executed from Stack in FlowStone/Ru

Postby Tronic » Wed Jan 27, 2016 9:59 pm

Try this, this show some redraw strangness....
Ruby Redraw Stack_strangness.fsm
(1.39 KiB) Downloaded 994 times
Tronic
 
Posts: 539
Joined: Wed Dec 21, 2011 12:59 pm

Re: How "draw" method is executed from Stack in FlowStone/Ru

Postby Nowhk » Thu Jan 28, 2016 2:47 pm

Tronic wrote:Try this, this show some redraw strangness....
Ruby Redraw Stack_strangness.fsm

Yes, additional ones! But it doesn't reply to my question :lol:
Nowhk
 
Posts: 275
Joined: Mon Oct 27, 2014 6:45 pm

Re: How "draw" method is executed from Stack in FlowStone/Ru

Postby tulamide » Thu Jan 28, 2016 3:41 pm

The layer of execution is just as important. Where does the drawing happen on the hierarchy? Is a called method an instance method or a class method (everything you define is aninstance method, while, for example, redraw is a class method (read about it in the user guide, chapter 8)?

I've made a few simple changes that will help you understand the hierarchy of events better.
Attachments
Ruby Redraw Stack[tula].fsm
(513 Bytes) Downloaded 1010 times
"There lies the dog buried" (German saying translated literally)
tulamide
 
Posts: 2714
Joined: Sat Jun 21, 2014 2:48 pm
Location: Germany

Re: How "draw" method is executed from Stack in FlowStone/Ru

Postby Nowhk » Fri Feb 26, 2016 4:13 pm

tulamide wrote:The layer of execution is just as important. Where does the drawing happen on the hierarchy? Is a called method an instance method or a class method (everything you define is aninstance method, while, for example, redraw is a class method (read about it in the user guide, chapter 8)?

I've made a few simple changes that will help you understand the hierarchy of events better.

Hi dude, totally forgot about this topic! Now I've found the same problem, so it's time to reup and understand better this "ruby" hierarchy. I've looks at the Chapter 8, but I see nothing about instance/class method (which is a classic concept of object oriented programming).

Where is wrote that redraw is a class method (and it is executed after instance method)?
Nowhk
 
Posts: 275
Joined: Mon Oct 27, 2014 6:45 pm

Re: How "draw" method is executed from Stack in FlowStone/Ru

Postby tulamide » Fri Feb 26, 2016 7:46 pm

Nowhk wrote:
tulamide wrote:The layer of execution is just as important. Where does the drawing happen on the hierarchy? Is a called method an instance method or a class method (everything you define is aninstance method, while, for example, redraw is a class method (read about it in the user guide, chapter 8)?

I've made a few simple changes that will help you understand the hierarchy of events better.

Hi dude, totally forgot about this topic! Now I've found the same problem, so it's time to reup and understand better this "ruby" hierarchy. I've looks at the Chapter 8, but I see nothing about instance/class method (which is a classic concept of object oriented programming).

Where is wrote that redraw is a class method (and it is executed after instance method)?

I meant to read in chapter 8 about 'redraw'. Chapter 8 explains how Flowstone integrates Ruby. If you want to know how Ruby (it's the only real OOP language to date ;) ) itself works, which is what you try to understand, you have to google for interesting Ruby tutorials.
"There lies the dog buried" (German saying translated literally)
tulamide
 
Posts: 2714
Joined: Sat Jun 21, 2014 2:48 pm
Location: Germany

Re: How "draw" method is executed from Stack in FlowStone/Ru

Postby TheOm » Sat Feb 27, 2016 7:03 am

tulamide wrote:redraw is a class method

That's wrong, redraw is an instance method (Check it with self.methods and self.class.methods)
RubyEdit doesn't have any class methods.
TheOm
 
Posts: 103
Joined: Tue Jan 28, 2014 7:35 pm
Location: Germany

Re: How "draw" method is executed from Stack in FlowStone/Ru

Postby tulamide » Sat Feb 27, 2016 7:48 am

TheOm wrote:
tulamide wrote:redraw is a class method

That's wrong, redraw is an instance method (Check it with self.methods and self.class.methods)
RubyEdit doesn't have any class methods.

Thanks for correcting that!
"There lies the dog buried" (German saying translated literally)
tulamide
 
Posts: 2714
Joined: Sat Jun 21, 2014 2:48 pm
Location: Germany

Re: How "draw" method is executed from Stack in FlowStone/Ru

Postby Nowhk » Sat Feb 27, 2016 8:31 am

TheOm wrote:
tulamide wrote:redraw is a class method

That's wrong, redraw is an instance method (Check it with self.methods and self.class.methods)
RubyEdit doesn't have any class methods.

Uhm, I'm confused. So why redraw (thus draw method) is executed after the event method finished (and not at the point I invoke it)? Will ruby prevent many drawing settings a timeout?
Nowhk
 
Posts: 275
Joined: Mon Oct 27, 2014 6:45 pm

Re: How "draw" method is executed from Stack in FlowStone/Ru

Postby Tronic » Sat Feb 27, 2016 10:23 pm

because in fact it is handled by C ++ side,
and in any case it is taken in mind that all RubyEdit modules are operated in turn by a class not exposed to us
and are executed in a Fiber method execution.
Tronic
 
Posts: 539
Joined: Wed Dec 21, 2011 12:59 pm

Next

Return to General

Who is online

Users browsing this forum: No registered users and 48 guests