TimeTables
From Wildix
In new release:
A timetable is an organized list or schedule, usually set out in tabular form, providing information about a series of arranged events: in particular, the time at which it is planned these events will take place.
Contents |
Application timetable
- This application implement timetables behavior, provided by WMS. Application timetable provide only one type of event: call redirection using internal asterisk application “GoTo”. Additionally some applications can be executed before call redirection (f.e. playback or macro).
- A timetable is an organized list or schedule, usually set out in tabular form, providing information about a series of arranged events: in particular, the time at which it is planned these events will take place.
Parameters
Name – name of timetable. Must be defined and timetable with this name must exists.
Options:
- ‘j’ - “jump” - execute jump to priority + 101 if call establish in time period, described by timetable
- ‘i’ - “invert” - invert timetable. Execute jump/actions/goto if call established in time period, NOT described by this timetable.
- ‘d’ - “debug” - provide some extra debug output.
- ‘P(s:t:p)’ – plays soundfile ‘s’ ‘t’ times with pause before replaying ‘p’ seconds. Will play this file before executing jump/goto. At least sound file must be defined. Default value for times = ‘-1’ (infinity), default value for pause – 2 seconds.
- ‘M(macro[,parameters])’ – Execute application Macro with passed parameters before executing jump/goto.
- ’Context|extension|priority’ – where to go if event take place.
Only timetable name must be defined, all other parameters are optional. Some parameters conflicts with other. For example jump to priority+101 will be never done if [context|exten|priority] defined. Instead application will be execute *GoTo(context|exten|priority).
Only ‘P’ or ‘M’ option can be defined in sametime. If both option defined - only last defined option will be executed. If call will be redirected inside macro to somewhere outside of bounds of macro-context – application will finish execution and don’t execute jump/goto.
Application set channel variable ‘TIMETABLESTATE’ to: ‘SUCCESS’ if event take place and ‘FAIL’ otherwise.
Usage Examples
| Timetable: [1] "outoftime" ( free time ) STATE: AUTO | |||||||
| ID | Parent | Weekdays | Days | Month | Time | Year | Enabled |
| 1 | 1 | 1->5 | any | any | 13:00->15:00 | any | Yes |
| 2 | 1 | 6->7 | any | any | any | any | Yes |
| 3 | 1 | 1->5 | any | any | 20:00->9:00 | any | Yes |
This timetable describe a time period when office closed.
- First bar (#id=1) describe time period from Monday to Friday from 13:0 to 15:00 – lunch time in workdays.
- Second bar (#id=2) describe time period from Saturday to Sunday – weekends.
- Third bar (#id=3) describe time period from 8:00 PM to 9:00 AM (The same as from “20:00 to 23:59:59” and from “0:00” to “9:00”) from Monday to Friday – usually all offices closed at this time.
| Timetable: [2] "workhours" (when office open ) STATE: AUTO | |||||||
| ID | Parent | Weekdays | Days | Month | Time | Year | Enabled |
| 1 | 1 | 1->5 | any | any | 9:00->13:00 | any | Yes |
| 2 | 1 | 1->5 | any | any | 13:00->20:00 | any | Yes |
This timetable is inverted timetable for ‘outoftime’. Just describe time period when office open.
Lets continue. We want to realize follow scenario: If user dial to office public line when office closed – PBX play to user sound ‘officeclosed’ infinite times. Otherwise, PBX plays to user sound ‘welcome’ and join user to queue “techsupport”.
[tt-demo0] exten => 1,1,Timetable(outoftime||1000|1) exten => 1,2,Playback(welcome) exten => 1,3,Queue(techsupport) exten => 1000,1,Playback(officeclosed) exten => 1000,2,Wait(2) exten => 1000,3,Goto(1000,1);
Just the same as tt-demo0:
[tt-demo1] exten => 1,1,Timetable(outoftime|P(officeclosed:-1:2)) exten => 1,2,Playback(welcome) exten => 1,3,Queue(techsupport)
Just the same as tt-demo1 but with another timetable:
[tt-demo2] exten => 1,1,Timetable(workhours|iP(officeclosed:-1:2)) ; passed option ‘i' – invert – timetable will ; act as Timetable in tt-demo1 example exten => 1,2,Playback(welcome) exten => 1,3,Queue(techsupport)
Just the same as tt-demo0, again with another timetable and little changed behavior:
[tt-demo3] exten => 1,1,Timetable(workhours||1000,1) exten => 1,2,Playback(officeclosed) exten => 1,3,Goto(1|2) exten => 1000,1,Playback(welcome) exten =>1000,2,Queue(techsupport)
And just a little another example:
[tt-demo4] exten => 1,1,Timetable(workhours|jM(call-to-queue,welcome,techsupport)) exten => 1,2,Playback(officeclosed) exten => 1,3,Goto(1|2) exten => 1,101,Noop
[macro-call-to-queue]
; ${ARG1} – greetings sound
; ${ARG2} – queue name
exten => s,1,Background(${ARG1})
exten => s,2,Queue(${ARG2})
Timetable states
Timetable states used for change processing algorithm of application Timetable.
- In state ‘AUTO’ application timetable will execute jump/goto depending on time period, described by timetable.
- In state ‘ON’ application will always execute jump/goto.
- In state ‘OFF’ application will never execute jump.
Application TimetableState(timetable[|state]) can be used to read/set state of timetable.
- Parameter ‘state’ – one of ‘on’, ‘off’, ‘auto’, ‘next’. Must be defined to set state of timetable. If this parameter not defined – value of channel variable ‘TIMETABLESTATE’ will be set to current state of timetable. With parameter ‘next’ application will increment state of timetable in cyclic way.
Depending on timetable state will be changed also state of device ‘ds/TIME[timetablename]’:
- State = ‘AUTO’ - device state = ‘Available’
- State = ‘ON’ - device state = ‘InUse’
- State = ‘OFF’ - device state = ‘Ringing’
- Note that app_devstate must be loaded to use this functionality.
- See also HINT section for application Features.
Example:
[timetable-states-test-ivr]
exten => 777,1,Answer()
exten => 777,2,Background(tt-ivr) ; Press 1 to set on Press 2 to set off press 3 to set auto mode, press 4 to set next mode
exten => 777,3,WaitExten(60)
exten => 1,1,TimetableState(workhours,ON)
exten => 2,1,TimetableState(workhours,OFF)
exten => 3,1,TimetableState(workhousr,AUTO)
exten => 4,1,TimetableState(workhours,next)
exten => 4,2,SendText("Current state of timetable workhours is: "${TIMETABLESTATE});
exten => i,1,Playback(invalid-choise)
The same behavior as in example implemented in application Features.
Asterisk Cli commands
Timetable destroy [timetable name] – destroy timetable with described name. If timetable name not defined – will destroy all loaded timetables. This timetables will be not destroyed in database, it just unloaded from memory.
Timetable show [timetable name] – dump described timetable to console. If timetable name not defined – will print to console names of all available timetables and it’s current state.
Example
w90*CLI> timetable show |------------------------------------------------------------------------------------------| | Timetable: [1] "outoftime" ( free time ) STATE: AUTO |------------------------------------------------------------------------------------------| |------------------------------------------------------------------------------------------| | Timetable: [2] "workhours" ( Work hours. ) STATE: AUTO |------------------------------------------------------------------------------------------| w90*CLI> timetable show workhours w90*CLI> |------------------------------------------------------------------------------------------| | Timetable: [2] "workhours" ( Work hours. ) STATE: AUTO |------------------------------------------------------------------------------------------| | id | parent | weekdays | days | month | time | year | enabled | |------------------------------------------------------------------------------------------| | 6 | 2 | 1 -> 5 | ANY | ANY | 15: 0: 0 -> 19: 0: 0 | ANY | YES | | | | | | | | | | | 5 | 2 | 1 -> 5 | ANY | ANY | 10: 0: 0 -> 14: 0: 0 | ANY | YES | | | | | | | | | | |------------------------------------------------------------------------------------------|
Timetable reload [timetable name] – destroy described timetable and try to load it again from database. If timetable name not defined will reload all timetables.
Timetable set state [timetable_name] [state] – set state of timetable. Timetable_name and state must be defined. State – one of ‘on’, ‘off’, ‘auto’.
Example:
w90*CLI> timetable show |------------------------------------------------------------------------------------------| | Timetable: [1] "outoftime" ( free time ) STATE: AUTO |------------------------------------------------------------------------------------------| |------------------------------------------------------------------------------------------| | Timetable: [2] "workhours" ( Work hours. ) STATE: AUTO |------------------------------------------------------------------------------------------| w90*CLI> timetable set state fuoriario off Ok, new timetable state ‘OFF’ w90*CLI> timetable set state workhurs off Fail. There are no such timetable: ‘workhurs’ w90*CLI> timetable show |------------------------------------------------------------------------------------------| | Timetable: [1] "outoftime" ( free time ) STATE: OFF |------------------------------------------------------------------------------------------| |------------------------------------------------------------------------------------------| | Timetable: [2] "workhours" ( Work hours. ) STATE: AUTO |------------------------------------------------------------------------------------------|
Timetable check [timetable_name] - check described timetable. Useful for debug. If timetable_name not defined – will check all timetables. Result will be passed to asterisk cli.
Example:
w90*CLI> timetable check outoftime Checking timetable outoftime: Success
W90*CLI> timetable check Checking timetable outoftime: Success Checking timetable workhours: FAIL
For all cli commands realized asterisk internal ‘cli completion’ service, so don’t be afraid and push ‘TAB’ key.
