count up timer

637 views
Skip to first unread message

Samuel Thériault

unread,
Mar 16, 2021, 4:16:19 PM3/16/21
to QLab
Hi,

I opened the Count Up timer from the CookBook but there is a compliant error in the Tick script.

finalSeconds seem to be the problem
Impossible to convert "12.0" in number type (my computer is in French so I made a free translations of the error)

Runnung on BigSur.

Any help would be really appreciated. 

Thank you

micpool

unread,
Mar 16, 2021, 7:06:38 PM3/16/21
to QLab
That will be localisation issues, discussed previously here:



Mic


Samuel Thériault

unread,
Mar 16, 2021, 7:17:00 PM3/16/21
to QLab
It was exactly the problem. 

Another question. Would it be possible to start the timer with a defined value. Let say I want to start it with 1h already on the timer and start counting up from there?

Thank you

gar...@compositelight.com

unread,
Mar 23, 2021, 5:28:03 PM3/23/21
to QLab
There are two* things you would need to edit to start the count up from 1 hour.

First:
In the count up example file, the cue "var" in the "timer parts in here" group is where the current time elapsed is stored. This is at the heart of the whole setup, as everything else is either manipulating this value (such as incrementing it by +1 every second) or reading and displaying it.

If you look at that cue when the timer is running you'll notice it changing with each tick of the clock. It's always 1 second ahead of the displayed time. When you run the set/reset cue it contains a network (osc) cue with "/cue/var/name "1". This resets "var" back to 1 (1 second ahead of 0).

When you start the timer, it will count up from whatever number of seconds is in the cue name of "var".

So you will need to set the value (the cue name) of "var" to your new start point, which is 3601 ((60mins x 60secs)+1)

Second:
Separate to this you've got the cue "clock", a text cue that actually displays the time. This gets updated every tick, but initially it'll read 00:00:00. If you want this to show 01:00:00 before the clock starts, you need to set it as such.

* But, both of these changes will be wiped when you run the set/reset group. So rather than editing the two cues directly, you're better off editing those reset cues to do the work for you:
/cue/var/name "3601"
/cue/clock/liveText "01:00:00"

Now when you run the set/reset your timer will jump to 01:00:00, and start from there when cued.

Remember also to edit the action time of the "set" cue at the top of the list to beyond 1hr or it'll jump straight to "Time's up!"

Hope that makes sense, and if it does: Do go back and read Mic's tutorial again to understand the full break down of what's happening. Once you find your feet with AppleScript it's incredibly useful.

Gareth

micpool

unread,
Mar 24, 2021, 1:26:31 PM3/24/21
to QLab
Here's a compact count up timer which works in a different way, that will allow you to easily set the start and end times required.

Screen Shot 2021-03-24 at 16.57.25.png
It doesn't use any cue numbers so the group cue can just be duplicated as many times as you want, for different  start and end times.
The start time is set by  the pre wait of the memo cue, and the end time is set by the post wait of the memo cue. It uses the action elapsed  time of the group cue as the counter (offset by the pre wait time of the memo cue)


tell application id "com.figure53.QLab.4" to tell front workspace
set myQ to las item of (cues whose running is true and q type is "script" as list) --identifies this script cue from the list of active cues
--finds the other cues in the same group as this script cue
set thegroup to parent of myQ
set thesettingscue to first cue of thegroup whose q type is "memo"
set thetextcue to first cue of thegroup whose q type is "text
--sets the timing variables
        set thecount to (pre wait of thesettingscue) + (action elapsed of thegroup)
set theend to post wait of thesettingscue
start thetextcue
         repeat while thecount < (theend - 0.1)
set thecount to (pre wait of thesettingscue) + (action elapsed of thegroup)
set theTimeString to my hrMnSc(thecount)
set the text of thetextcue to theTimeString
delay 0.1
end repeat
--when timer reaches end time
set the text of thetextcue to "TIME'S UP"
delay 3
set text of thetextcue to " "
stop thegroup
end tell

--subroutines to parse seconds to HH:MM:SS format 
on hrMnSc(secs)
tell secs to set {hr, mn, sc} to {it div hours, it mod hours div minutes, it mod hours mod minutes div 1}
return padZero(hr) & ":" & padZero(mn) & ":" & padZero(sc)
end hrMnSc

on padZero(v)
return text -2 thru -1 of ("0" & v)
end padZero


You can also  select any count up group cue and press hotkey 1 to run the reset cue  which will bring the start time for that timer onto the screen. Again, no specific q numbers or names are required.  The script validates that the cue selected is a group cue that only contains 1 text cue, 1 script cue , and 1 memo cue, which in most cases will be  more than enough to identify a valid count up group in this workspace

tell application id "com.figure53.QLab.4" to tell front workspace
set theselected to last item of (selected as list)
--validate
if q type of theselected is not "group" then return
if (count of cues of theselected) is not 3 then return
if (count of (get cues of theselected whose q type is "script")) is not 1 then return
if (count of (get cues of theselected whose q type is "text")) is not 1 then return
if (count of (get cues of theselected whose q type is "memo")) is not 1 then return
set thetextcue to first cue of theselected whose q type is "text"
set text of thetextcue to my hrMnSc(pre wait of (first cue of theselected whose q type is "memo"))
start thetextcue
end tell

on hrMnSc(secs)
tell secs to set {hr, mn, sc} to {it div hours, it mod hours div minutes, it mod hours mod minutes div 1}
return padZero(hr) & ":" & padZero(mn) & ":" & padZero(sc)
end hrMnSc


on padZero(v)
return text -2 thru -1 of ("0" & v)
end padZero

Mic
Count up no q numbers.qlab4.zip

Samuel Thériault

unread,
Mar 31, 2021, 10:29:34 PM3/31/21
to QLab
Wow,

I have nothing else to say than Thank you. Really appreciated.

micpool

unread,
Apr 1, 2021, 1:46:52 PM4/1/21
to QLab
As only a few lines of script were needed to make this a universal timer, that can count up or down and display any message for any length of time, and be copied to other cue list  positions, or workspaces, I've added them!

The attached workspace has a help screen accessed with  Hotkey shift-H   (Just thought of this as a useful addition for complex workspaces)

Each Counter consists of a script cue, a text cue, and a memo cue, contained in a 'start first child and go to next cue'  group
Select a counter group, and press hotkey 1 to display the start time for that counter
When the group cue is started, the counter counts up, or down, from the pre wait time to the post wait time of the memo cue in the group.
When the post wait time is reached the name of the text cue in the group  is displayed, for a duration set by the  post wait time  of the text cue
No cue numbers are required for the operation of the counters, and all the elements needed are contained within the group.
Counter groups can be cut and pasted to different cue list positions or to other workspaces, and times and text set as required from the cue list

Mic
Bidirectional Time Counter.qlab4.zip
Reply all
Reply to author
Forward
0 new messages