Booked Scheduler Community Support
December 14, 2018, 10:49:21 PM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Booked is proud to recommend Shift Capsule in the employee shift scheduling space www.ShiftCapsule.com
 
   Home   Help Login Register  
Pages: [1]
  Print  
Author Topic: Is there any way to use Booked to Trigger Some Automation  (Read 105 times)
quazar0
Newbie
*

Karma: 0
Posts: 3


« on: November 30, 2018, 07:09:00 PM »

I am trying to find a decent way for users to schedule a resource, and for Booked to run a small program at the scheduled start time and the stop time.
Is there anything in Booked that will do that?

As a simple example, lets say the user books room 'A' during 9:00 - 11:00.
And I have a little program that turns on the Wifi in room A.
I would like to have Booked run that little program to turn on the wifi at 9:00, and then turn it off at 11:00.
So how could I do that?
Logged
TechCoder
Hero Member
*****

Karma: 5
Posts: 1588

Need Booked API/App/Plugin? http://bit.ly/23EutBO


WWW
« Reply #1 on: November 30, 2018, 11:11:38 PM »

Various ways to go about this....... - mostly depends on your current program as well as your comfort level in OOPHP (which Booked is mostly written in).

I would first look at the current way to do scheduled reminders (see the documentation...) and modify off of that a bit.

If that puzzles you, then I would consider a PostReservation plugin to write some data that your current program can read and process.  This is a bit more 'elegant' way to do things and my most likely way to go - depending on the 'automation' part of the program.

Given no other way, I would write a 'stand-alone' program that reads the current database for the reservations and 'wakes up' the automation program.  A bit 'hackish', but certainly would work.

We write programs for clients like this quite often (though to date we haven't interfaced directly with some 'turn on WiFi' sort of thing) - we can certainly interface with anything that has a method of controlling it via software! Smiley

Should you need help in writing your interface, let us know.  We are the premier providers of add-on software for Booked and have several plugins, etc. available on our website (https://CashFlowProducts.com).  You can make a direct request for quote on our helpdesk as well - https://CashFlowProducts.com/helpdesk
Logged
quazar0
Newbie
*

Karma: 0
Posts: 3


« Reply #2 on: December 03, 2018, 04:49:13 PM »

Thanks.  Using a method like the reminders would be easy enough.  But I was hoping for Booked to trigger it directly, instead of writing something that will have to continuously poll the database.  My experience with systems that require polling shows that it can be problematic; though that depends on the environment.
Logged
TechCoder
Hero Member
*****

Karma: 5
Posts: 1588

Need Booked API/App/Plugin? http://bit.ly/23EutBO


WWW
« Reply #3 on: December 03, 2018, 05:18:15 PM »

I'd be really interested in how you think such a system will work......

How would you (with experience with systems that require polling) imagine Booked (or anything) would automatically trigger some program at a pre-determined (start of event in this case) time - without polling........Huh?

A CRON job can certainly run, but the program will have to poll the database to see if it is time to run - whether it is like the scheduled reminders (which would be much like a direct look in the database program that you'd write yourself) or one that writes to your own program data (as I explained in my answer before).

Without 'polling' just how could the system (any system...) know it is time to do something?Huh

At any rate I'm always interested in learning something new - or writing working programs based on the (this year!) 40 years of programming experience I already have, so if you need some help - let me know (though the helpdesk I can get you an estimate on the work).
Logged
quazar0
Newbie
*

Karma: 0
Posts: 3


« Reply #4 on: December 06, 2018, 02:17:22 AM »

In the past I have used a thread that sleeps until the configured time to perform the action (e.g. in Java, there is the Timer https://docs.oracle.com/javase/7/docs/api/java/util/Timer.html).  Usually I have had some main process, which reads the database once, and determines which action is needed the soonest; and it creates a Timer thread to wake up at that time and do the needed work.
And if some entry is added to the database that necessitates an action that is needed sooner than the current Timer thread, then the main process cancels the current Timer and creates a new one.
So, most of the time (depending on how busy the system is) the Timer thread is sleeping (so minimal wasted CPU, if any), no need for the continuous polling.

And if there is some requirement that makes it impossible to have the Timer thread in the main process (e.g the main process that handles database updates runs the transaction and exits), then you can run the Timer thread in its own process (sort of a timer-manager process) and have the main process just send a HUP signal to the timer-manager process when a new record is written to the proper table in the database; and that timer-manager will query the database to determine if a new Timer is needed.
A named semaphore (on Linux) can also be used in place of the HUP signal, if there is no way for the main process to know the PID of the timer-manager process, but both processes can use the same pre-configured name for the semaphore.
Though polling may be better in this case, if there are many more DB updates than there are actionable events, since polling would query the database less.
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.20 | SMF © 2006-2007, Simple Machines Valid XHTML 1.0! Valid CSS!