JavaScript Query Examples. Acclaim Lighting PHAROS VLC, PHAROS LPC X, PHAROS TPS, PHAROS EXT, PHAROS TPC, PHAROS LPC
Werbung
Werbung
JavaScript Query Examples
JavaScript Query Examples
In the examples below, we will query the controller for the required information and display the returned object in the browser's console before displaying the relevant information in a popup.
In the examples, the callback functions have been defined at the time that the query is made, but these can be defined separately, as below: function getTimeRespone(t){ alert(datetime);
}
Query.get_current_time(getTimeResponse)
Function get_current_ time(callback)
Example Response
{"data":{
"datetime":"03 Feb 2016 22:41:20",
"uptime":208171
},"request":"current_time"} get_timeline_ info(callback)
{"data":{
"response":[
{
"length":"P00H01M00.00s",
"name":"Timeline 1",
"num":1,
"timeOffset":"P00H00M00.00s",
"timeSource":{
"type":"internal"
}
},
{
"length":"P00H00M10.00s",
"name":"Timeline 2",
"num":2,
"timeOffset":"P00H00M00.00s",
"timeSource":{
"bus":0,
"timeFormat":"Unknown",
"type":"Timecode"
}
JavaScript
Query.get_current_time( function(t){ console.log(t); alert(t.datetime); alert(t.uptime);
});
Query.get_timeline_info( function(t){ console.log(t); //
Logging the incoming object var output = ""; //
Creating a variable to put information in for (var i = 0; i <
Object.keys
(t.response).length; i++) { // Iterate over the object to extract information output += t.response
[i].num + " - "
+ t.response[i]
["name"] + "\n";
// Add number and name to the output variable
}; alert(output); //
Display the output variable
}
);
- 581 -
Pharos Designer User Manual get_timeline_ status(callback)
}
]
},"request":"timeline_info"}
{"data":{
"timelines":[
{
"active":false,
"group":"",
"name":"Timeline 1",
"num":1,
"position":0,
"released":false
},
{
"active":false,
"group":"",
"name":"Timeline 2",
"num":2,
"position":0,
"released":false
},
{
"active":false,
"group":"",
"name":"Timeline 3",
"num":3,
"position":0,
"released":false
}
] get_timeline_ status(timeline
,callback)
},"request":"timeline"}
{"data":{
"timelines":[
{
"active":false,
"group":"",
"name":"Timeline 1",
- 582 -
Query.get_timeline_status( function(t){ console.log(t); var output = ""; //
Creating a variable to put information in for (var i = 0; i <
Object.keys
(t.timelines).length; i++) { // Iterate over the object to extract information if (t.timelines
[i].active) { // only add active timelines output += t.timelines
[i].num + " - "
+ t.timelines[i]
["name"] + "\n";
// Add number and name to the output variable
};
});
}; alert(output); //
Display the output variable
Query.get_timeline_status
console.log(t); var output = ""; //
Creating a variable to put information in for (var i = 0; i <
]
}
"num":1,
"position":0,
"released":false
},"request":"timeline"} subscribe_ timeline_status
(callback)
{"broadcast":"timeline",
"data":{
"active":{
"force_poll":false,
"halted":false,
"onstage":true,
"running":true
},
"num":1,
"position":60,
"released":false
}
}
{"data":{ get_scene_ status(callback)
"scenes":[
{
"active": true,
"name":"Scene 1",
"num":1,
"onstage":true,
- 583 -
JavaScript Query Examples
Object.keys
(t.timelines).length; i++) { // Iterate over the object to extract information if (t.timelines
[i].active) { // only add active timelines output += t.timelines
[i].num + " - "
+ t.timelines[i]
["name"] + "\n";
// Add number and name to the output variable
};
}; alert(output); //
Display the output variable
});
Query.subscribe_timeline_
status(function(r){ console.log(r); alert("TL" + r.num + " changed");
})
Query.get_scene_status( console.log(t) var output = "" //
Creating a variable to put information in for (var i = 0; i <
Object.keys
(t.scenes).length; i++)
{ // Iterate over the
Pharos Designer User Manual subscribe_ scene_status
(callback)
"released": false
},
{
},
{
"active": false,
"name":"Scene 3",
"num":3,
"onstage": false,
"released": false
}
]
},"request":"scene"}
{"broadcast":"scene",
"data":{
"active": true,
"num":1,
"onstage": true,
"released": false
}
}
"active": true,
"name":"Scene 2",
"num":2,
"onstage": false,
"released": false get_group_ status(callback)
{"data":{
"groups":[
{
"level":100,
"name":"All Fixtures",
"num":0
},
{
- 584 object to extract information output += t.scenes
[i].num + " - " + t.scenes[i]["name"]
+ "\n" // Add number and name to the output variable
});
}; alert(output) //
Display the output variable
Query.subscribe_scene_
status(function(r){ console.log(r) if (r.onstage){ alert("Scene " + r.num + " started")
} else { alert("Scene " + r.num + " released")
}
})
Query.get_group_status( function(t){ console.log(t) var output = "" //
Creating a variable to put information in for (var i = 0; i <
Object.keys
(t.groups).length; i++)
{ // Iterate over the object to extract information
JavaScript Query Examples subscribe_ group_status
(callback) get_remote_ device_status
(callback)
"level":100,
"name":"All LED - RGB 8 bit",
"num":0
}
]
},"request":"group"}
{"broadcast":"group",
"data":{
"level":40,
"name":"All LED - RGB 8 bit",
"num":0
}
}
{"data":{
"remote_devices":[
{
"num":1,
"online":false,
"serial":"",
"type":"RIO 80"
},
{
},
{
}
"num":1,
"online":true,
"serial":"",
"type":"BPS"
"num":2,
"online":true,
"serial":"",
"type":"BPS" output += t.groups
[i].num + " - " + t.groups[i]["name"]+
" - " + t.groups
[i].level + "\n" //
Add number and name to the output variable
}; alert(output) //
Display the output variable
});
Query.subscribe_group_
status(function(r){ console.log(r); alert(r["name"] + " set to " + r.level + "%");
})
Query.get_remote_device_
console.log(t) var output = "Remote
Devices: \n" for (var i = 0; i <
Object.keys(t.remote_
devices).length; i++) {
}; output += t.remote_
devices[i]["type"] +
" " + t.remote_
devices[i]["num"] +
":" + t.remote_
devices[i]["serial"]
+ "\n" alert(output);
});
- 585 -
Pharos Designer User Manual subscribe_ remote_device_ status(callback) get_text_slot
(callback) set_text_slot
(name, value)
]
},"request":"remote_device"}
{"broadcast":"remote_device",
"data":{
"num":1,
"online":true,
"serial":"011050",
"type":"RIO 80"
}
}
{"data":{
"text_slots":[
{
"name":"text1","value":"Hello"
},
{
"name":"text2","value":"World"
}
]
},"request":"text_slot"}
No Response get_temperature
(callback)
{"data":{
"temp":{
}
"ambient_temp":24.75
Query.subscribe_remote_
device_status(function(r) console.log(r) alert(r["type"] + "
" + r.num +
"online")
} else { alert(r["type"] + "
" + r.num +
"offline")
}
})
Query.get_text_slot( function(t){ console.log(t); var output = ""; //
Creating a variable to put information in for (var i = 0; i <
Object.keys(t.text_
slots).length; i++) {
// Iterate over the object to extract information output +=t.text_
slots[i]["name"]+ "
- " + t.text_slots
[i]["value"] + "\n";
// Add number and name to the output variable
}; alert(output); //
Display the output variable
});
Query.set_text_slot("text1","Test") // Sets the value of the text slot
"Text1" to "Test"
Query.get_temperature( function(h){ console.log(h); alert(h.temp.ambient_
temp);
- 586 -
get_protocols
(callback) get_output(id, callback)
},"request":"temperature"}
{"data":{
"outputs":[
{
"name":"Art-Net",
"type":4,
"universes":[
{
"id":1,
"name":"1"
},
{
"id":2,
"name":"2"
},
]
}
]
},"request":"protocol"}
{"data":{
"channels":[
"0",
"128",
"255",
"50",
" ", -- This is an unpatched channel
... 512 entries in total
" "
]
},"request":"output"}
No Response park_channel
(type, key, num, value) unpark_channel
(type, key,
No Response
});
JavaScript Query Examples
Query.get_protocols( console.log(t) var output ="" for (var i = 0; i <
Object.keys
(t.outputs).length; i++) { output += t.outputs
[i]["name"] + " in use\n"
}; alert(output);
});
Query.get_output(2, function(t){ console.log(t); alert("Channel 1 = " + t.channels[0]);
});
Query.park_channel(DMX,
{index:1},1,128) // Set channel 12 on DMX Universe
1 to 128.
Query.park_channel(DMX,
{index:1},"1-10,15",50) //
Set channels 1-10 and 15 to 50.
Query.unpark_channel(DMX,
{index:1},12) // Release
- 587 -
Pharos Designer User Manual num) fire_trigger
(num, variables, test_conditions) run_command
(cmd)
To use this function, go
Project > Web
Interface in
Designer and check "Parse command line submissions as
Lua commands" subscribe_ beacon(callback) get_system_info
()
No Response
No Response
{"broadcast":"beacon",
}
"data":{
}
"on":true toggle_beacon() No Response subscribe_lua() {name:value} -- As specified in push_ to_web() function
{"data":{
"cf_card_size_kb":1957112,
"controller_number":1,
"date":"11 Apr 2016",
"firmware_version":
{"major":2,"minor":1,"point":0},
"hardware_type":"LPC", park of channel 12 on
DMX universe 1.
Query.fire_trigger(1) //
Fire trigger 1
Query.fire_trigger
(2,"255,255,128,0",true)
// Fire trigger 2, injecting 4 variables
(255,255,128,0) and testing the conditions of the trigger.
Query.run_command('get_ timeline(1):start()') //
Run a Lua script on the controller.
Note:
The Script must be contained within quotation marks (' or ").
Query.subscribe_beacon
(function(r){ console.log(r); var output = ""; if (r.on){ alert("Beacon On")
}else{ alert("Beacon Off")
}
})
Query.toggle_beacon() //
The beacon on the controller will be toggled
Query.subscribe_lua
(function(x){ console.log(x); alert(Object.keys(x)[0]
+ " = " + x[0]);
})
Query.get_system_info
(function(x){ console.log(x); alert(Object.keys(x)[0]
+ " = " + x[Object.keys
(x)[0]]);
})
- 588 -
JavaScript Query Examples
"network_interface":{
"gateway":"0.0.0.0",
"ip_address":"172.30.2.243",
"subnet_mask":"255.255.0.0"
},
"project":{
"author":"",
"name":"",
"upload_date":"2016-04-11T15:12:53",
"uuid":"{f21f3181-7b71-4f45-bdf3d96db0e9e7b4}"
},
"serial_number":"0100992",
"sunrise":"06:58:00",
"sunset":"19:05:00",
"time":"15:12:55"
},"request":"system"} get_lua_vari-
{"data":{ ables(var, callback)
"count":96,
"count2":64
},"request":"lua"}
Query.get_lua_variables
(["count","count2"], function(x){ console.log(x)
})
- 589 -
Herunterladen
Werbung