Page 1 of 5

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

Posted: Wed Jan 27, 2016 12:33 pm
by Nowhk
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 1018 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:

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

Posted: Wed Jan 27, 2016 9:59 pm
by Tronic
Try this, this show some redraw strangness....
Ruby Redraw Stack_strangness.fsm
(1.39 KiB) Downloaded 1068 times

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

Posted: Thu Jan 28, 2016 2:47 pm
by Nowhk
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:

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

Posted: Thu Jan 28, 2016 3:41 pm
by tulamide
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.

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

Posted: Fri Feb 26, 2016 4:13 pm
by Nowhk
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)?

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

Posted: Fri Feb 26, 2016 7:46 pm
by tulamide
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.

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

Posted: Sat Feb 27, 2016 7:03 am
by TheOm
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.

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

Posted: Sat Feb 27, 2016 7:48 am
by tulamide
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!

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

Posted: Sat Feb 27, 2016 8:31 am
by Nowhk
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?

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

Posted: Sat Feb 27, 2016 10:23 pm
by Tronic
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.