Page 1 of 1
Custom Ticker not ticking when first starting
Posted: Tue Feb 26, 2013 3:18 am
by dange11
FlowStone 3.0.1, windows 7
I have found that when I use the "Ticker - Custom" they do not tick when I initially strat the program, I have to go in and remove the "On" check mark and then replace it. Once I do that it works fine until I close the program and reopen it. Any thoughts?
Re: Custom Ticker not ticking when first starting
Posted: Tue Feb 26, 2013 7:42 am
by billv
Yeh i came across this a few days ago. It's a simple fix.
Add this line to the code...
output 0,t
Just like i have below with the smilely face.
.
def init
# Time step in secs
@step = 0.1
# Whether the timer has started ticking
@ticking = false
end
def event i,v,t
case i
when 0
if !@ticking && @state
@ticking = true
input 100,nil,t+@step
output 0,t
end
if @state
@step = 0.001 if @step <= 0
output 0
input 100,nil,t+@step
else
@ticking = false
end
end
end
Re: Custom Ticker not ticking when first starting
Posted: Thu Feb 28, 2013 4:36 pm
by dange11
Thank you for the reply, I added the line, to include the smiley face, and the ticker would not initially start ticking until I removed and reinserted the check mark in the on box. I even tried it without the smiley face with no better results

Re: Custom Ticker not ticking when first starting
Posted: Thu Feb 28, 2013 5:48 pm
by MyCo
Try this:
Code: Select all
def init
# Time step in secs
@step = 0.1
# change timer id
@timerID = (@timerID.nil? || !@timerID.integer?) ? 0 : @timerID+1
# Whether the timer has started ticking
@ticking = false
input 200, nil
end
def event(i,v,t)
if (i == 100)
@ticking = @state
if ((@ticking) && (v == @timerID))
output(0)
@step = 0.001 if (@step <= 0)
input(100,@timerID,t+@step)
end
else
if ((!@ticking) && (@state))
@ticking = true
input(100,@timerID,t+@step)
end
end
end
Re: Custom Ticker not ticking when first starting
Posted: Thu Feb 28, 2013 7:21 pm
by trogluddite
dange11 wrote:removed and reinserted the check mark in the on box
That's a clue to the easy way - by doing this you are sending a trigger into the input, causing an event which sets the timer running.
So the simplest way to make sure it automatically starts ticking is to simply put an "After Load" (and "After Duplicate" possibly) connected to the same Ruby input as the on/off checkbox.
That will give it the 'kick' it needs to get running at load time.
Re: Custom Ticker not ticking when first starting
Posted: Fri Mar 01, 2013 3:46 am
by billv
MyCo wrote:Try this:
Ummm.....I'm not getting a result here Myco. It's behaving like the original ticker, waiting
the "step" time before it sends the first trigger. Put in a step value like"1", easier to notice
what i mean.
Re: Custom Ticker not ticking when first starting
Posted: Fri Mar 01, 2013 10:05 am
by Nubeat7
there was also this problem with a time and date module
viewtopic.php?f=3&t=1133 at the end we solved it like this:
Code: Select all
def init
input 100,nil
end
def event i,v,t
output 0
input 100,nil,t+1 #time+1sec
end
in this example it ticks every second (t+1) you just need to calculate the time, the ticker is always running.
Re: Custom Ticker not ticking when first starting
Posted: Fri Mar 01, 2013 3:23 pm
by trogluddite
Yes, if the on/off switch is not required, that is the best way - much less Ruby processing too when all those other variables etc. are removed.