JavaScript Query Interface. Acclaim Lighting PHAROS VLC, PHAROS LPC X, PHAROS TPS, PHAROS EXT, PHAROS TPC, PHAROS LPC
Annonce
Annonce
Pharos Designer User Manual
JavaScript Query Interface
The aim of the javascript library is to provide an abstraction to the web technologies used to communicate with the controller and to provide an api which will not change. This allows us to change the way we communicate with the controller without braking compatibility with existing custom web pages.
Usage
To use the javascript library include this line in the head of the html file.
<script src="/default/js/query.js"></script>
The Query object will then exist and queries can then be made by calling the approriate method eg
Query.get_current_time(callback) callback is a function that is called when the server responds to the request. This is required as all the requests made to the controller are asynchronous. The response sent by the controller is given as the first argument of the callback function and is in JSON format.
Authentication
If an api call is made that the current user does not have sufficient privileges to make, the user will be redirected to the page defined by the AuthFormLoginRequiredLocation directive in the main .htaccess file.
API
get_current_time(callback) get_timeline_info(callback)
Returns the current time and the number of milliseconds that the controller has been on.
Returns the name, length, time source and offset for all the timelines in the project.
Returns the position and status of all the timelines.
get_timeline_status(callback) subscribe_timeline_status(callback) get_scene_status(callback) subscribe_scene_status(callback) get_group_status(callback) subscribe_group_status(callback) get_remote_device_status(callback) subscribe_remote_device_status
(callback) get_text_slot(callback) set_text_slot(name, value) get_temperature(callback) get_protocols(callback) get_output(type, key, callback)
Callback is called every time the status of a timeline changes.
Returns the status of all the scenes in the project.
Callback is called every time the status of a scene changes.
Returns the status of all the groups in the project.
Callback is called every time the level of a group changes.
Returns the number and type of the remote devices registered to this controller.
A remote device message is pushed every time the status of a remote device changes.
Returns the name and value for all the text slots in the project.
Sets the text slot with name to value
Returns the temperature readings from the controller (TPC or
LPC X)
Returns the protocols, universe names and universe ids used by this controller.
Returns the current output from a universe. Specify the universe
- 578 -
JavaScript Query Interface park_channel(type, key, num, value) unpark_channel(type, key, num) using the type and key
Parks the channels given by num in the universe specifed by type and key to value, the channel can be a single channel, a range of channels ("1-5") or a set of channels ("1,3,5,7") or any combination of those e.g ("1,3,5-10")
Unparks the channels given by num in the universe specifed by type and key , the channel can be a single channel, a range of channels ("1-5") or a set of channels ("1,3,5,7") or any combination of those e.g ("1,3,5-10") fire_trigger(num, variables, test_ conditions)
Fires the trigger given by num and passes any variables run_command(cmd) subscribe_beacon(callback) toggle_beacon() subscribe_lua(callback) get_system_info(callback) get_lua_variables(var,callback)
Runs the command given by cmd. This can either be parsed by the command line parser, or be a lua command, depending on the settings in designer.
Web interface receives a message whenever the beacon changes.
Toggles whether the beacon is on or not.
Allows you to pass data to the web interface using the push_ to_web()
Returns the system information
Returns the variable/s defined in var. This can be a single string
(e.g. "running") or an array of strings (e.g. ["running", "active",
"myVar"]
Universe Types:
The type is entered as one of the constants below e.g. get_output(DMX,1,callback) l l l l l l l
DMX
PATHPORT
ARTNET
KINET
SACN
DVI
RIO_DMX
Universe Keys:
The Universe key is a JSON object containing the following data: l l l l l l
DMX: {index : 1} or {index : 2}
PATHPORT: {index : num} where num = the universe number
ARTNET: {index : num} where num = the universe number
KINET: {kinet_port : port, kinet_power_supply_num : num} where port is the port number on the power supply and num is the ID number of the power supply
SACN: {index : num} where num = the universe number
RIO_DMX: {remote_device_num : num, remote_device_type : type} where num is the address of the RIO, as set on the address wheel on the front of the RIO and type is one of the the following types: l
RIO80 l l
RIO44
RIO08
- 579 -
Pharos Designer User Manual
Examples
Using Push_to_web()
The Lua Script has the function push_to_web(name,value).
This allows you to send some data to the web interface as a JSON packet push_to_web(name,value) sends {name:value} to the interface.
Within the web interface, use the following Javascript to get the information:
Query.subscribe_lua(function(x){ var NAME = Object.keys(x)[0] // Gets the name from the JSON packet and stores it as a variable var VALUE = x[NAME] // Gets the value from the JSON packet and stores it as a variable
// You will then need to do something with the stored information
})
Fire A Trigger With Multiple Variables
If you have a trigger which is expecting multiple variables, you can add them to the fire_trigger() function as a string:
Query.fire_trigger(1, '"var1", 2, 3, "var4"')
- 580 -
Download
Annonce