[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: requesting advice about creating a business model sim.

Shashank Date

10/31/2004 12:51:00 AM

Chuck Brotman wrote:
> A more specific question: Does anyone have any clever ideas (or design
> patterns, etc.) for keeping a simulation-time clock and dispatching the
> appropriate metods/objects on each tick?

I am not sure that I have a "clever" idea, but I can point to similar
threads in the past. See ruby-talk #43139 and #41919:

http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-...
http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-...

I can also share with you a little insight I got while playing with GUI
frameworks in Ruby. Most (I dare say all) GUI frameworks will have a
Timer class which is easy to use and will accomplish what you want.

I have used the one in wxRuby (http://rubyforge.org/projec...)
and it works perfectly. Like so:

#... instantiate
@timer = Wx::Timer.new(self, :timer.id)
evt_timer(:timer.id) {on_timer}
#...

def on_timer
#
# take action
#
end

#... use
@timer.start(@delay)

@timer.stop
#...

Does this sound like what you want? I will gladly share the real code
(which is more complex) if you are interested.

Thanks,
-- Shashank
1 Answer

Chuck Brotman

10/31/2004 2:36:00 AM

0

Shashank,

Thanks for replying and for the thread pointers. I'm not sure if the code
snippets are exactly what I need or not, since I'm not sure exactly what I
need. But, I would be interested to see the code you offered. Thanks for
providing me with a place to start! Also, can you recomend any
Framework(s)? I have no experience with tthem...

Thanks again,

Chuck


"Shashank Date" <sdate@everestkc.net> wrote in message
news:418436F2.4000105@everestkc.net...
> Chuck Brotman wrote:
>> A more specific question: Does anyone have any clever ideas (or
>> design patterns, etc.) for keeping a simulation-time clock and
>> dispatching the appropriate metods/objects on each tick?
>
> I am not sure that I have a "clever" idea, but I can point to similar
> threads in the past. See ruby-talk #43139 and #41919:
>
> http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-...
> http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-...
>
> I can also share with you a little insight I got while playing with GUI
> frameworks in Ruby. Most (I dare say all) GUI frameworks will have a
> Timer class which is easy to use and will accomplish what you want.
>
> I have used the one in wxRuby (http://rubyforge.org/projec...) and
> it works perfectly. Like so:
>
> #... instantiate
> @timer = Wx::Timer.new(self, :timer.id)
> evt_timer(:timer.id) {on_timer}
> #...
>
> def on_timer
> #
> # take action
> #
> end
>
> #... use
> @timer.start(@delay)
>
> @timer.stop
> #...
>
> Does this sound like what you want? I will gladly share the real code
> (which is more complex) if you are interested.
>
> Thanks,
> -- Shashank