Scheduling events from UCI

Discussions of Q-SYS hardware and software.

Moderators: Cameron Shoffner, Christian Cook, Kirk Fyvie, Martin Barbour, Fred Thomke, Gary Evans_QSC, Chris Brouelette

Wed May 31, 2017 5:31 pm

  • Just wondering if anyone can help with a little issue:

    I want to be able to schedule an event from within a UCI - present a drop down picker for times/dates and then be able to trigger an action (either preset recall or directly interface with a named component).

    I can do that with QSys Administrator really easily - set up some snapshots, call them at a date and time of my choosing - but can items be added to the core's scheduler programatically?

    One of the tasks I want to automate is ensuring rooms are correctly powered down at the conclusion of an event - when AV staff may have left site before an event concludes. So I want (on a case by case basis) for the AV staff member when they are turning everything on to be able to "enable" turning off the room at 18:45 for example (45 minutes after the function concludes that day). The AV staff member does not have access to Qsys Administrator. As there is no fixed end time - its a corporate event venue - the lazy solution would be to have everything turn off each night at 1:30am... but I would really prefer to do case-by-case scheduling.

    I could program a timer script I suppose that when "enabled" takes the time selected, subtracts the current time and then starts a timer - that feels a little clunky to me - and I am unsure what qsys's drift is like when it comes to the timer over extended periods (8+hrs). I am also already using timer for a number of other functions within my projector control script - and if I am reading the manual correctly I can only have 1 timer per control script which just starts to make the design a bit messy - adding additional blocks and wiring them instead of being able to nest it nicely inside the script I already have where it can directly access all the controls I want to access.
    mac.calder
    Rookie
     
    Posts: 12
    Joined: Thu May 05, 2016 8:46 pm

Wed May 31, 2017 6:04 pm

Wed May 31, 2017 6:32 pm

  • Yeah - I could - but I was hoping there was a feature where I could declare an object, set an event time and then use an eventhandler. I could see 2 basic ways of handling the issue in a script - (excuse the pseudo-code)

    Code: Select all
    timer = Timer.new()

    trigtime = {hour=12,min=15} 'actually grab values from wherever... but 12:15 for now

    timer:Start(60)

    timer.EventHandler = function ()
      now = os.date("*t")
      if now["hour"] == trigtime["hour"] && now["min"] == trigtime["min] then
          do stuff
       end
    end



    or

    Code: Select all
    timer=Timer.new()
    now = os.date("*t)
    trigtime = os.time({year = now["year"], month = now["month"], day = now["day"], hour=12, minute=15}) 'actually grab values from wherever... but 12:15 for now
    now = os.time()

    timer:Start(trigtime-now)

    timer.EventHandler = function ()
     Do Stuff Here

    end



    However the limitation of one timer per control script means that this timer would need to be part of it's own object (as I am already using the timer object), which means that all the controls I want to interact with either need to be exposed as Named Controls or as pins... And there is already a scheduler running on the core, so it would be really nice to just be able to interact with that instead of reinventing the wheel.
    mac.calder
    Rookie
     
    Posts: 12
    Joined: Thu May 05, 2016 8:46 pm

Wed May 31, 2017 10:05 pm

  • I'm not sure of the limitation on timers you speak of. Just declare multiple timers.

    IE.

    timer1 = Timer.New()
    timer2 = TImer.New()

    timer1:Start(60)
    timer2:Start(120)

    etc.

    What would be nice if we could add events to the administrator command schedule, and I'm note sure if there is a way to do this.
    Callum Brieske
    Rookie
     
    Posts: 23
    Joined: Thu May 07, 2015 4:00 am

Thu Jun 01, 2017 4:52 am

  • The Timer object is used to create delays or trigger events after a defined elapsed time. It should be used instead of Lua’s native delay and time functions. There is no limit to the number of timers you create within a single script (within reason). Each Timer must be named when created which is then the means by which you manipulate each specific timer. The Timer:Start method is used to start the timer and set the delay time. When the delay time has elapsed, the function specified in Timer.EventHandler is called. By default, Timer repeats when it has elapsed. Timer.Stop is used to stop the timer. Each Control Script has a single Timer.


    Had not read the first underlined bit - because when I skimmed, I saw the last underlined bit and must have grabbed the wrong end of the stick. I still want to be able to use the command schedule if possible though.
    mac.calder
    Rookie
     
    Posts: 12
    Joined: Thu May 05, 2016 8:46 pm



Return to Q-SYS Support




Information
  • Users browsing this forum: No registered users and 3 guests
cron