|
@@ -1,40 +1,50 @@
|
|
|
+//implementation following this protocol : https://www.epiphan.com/userguides/LUMiO12x/Content/UserGuides/PTZ/3-operation/VISCAcommands.htm#InquiryCommands
|
|
|
+
|
|
|
+
|
|
|
// var parameterPath = local.parameters;
|
|
|
// var valuesPath = local.values;
|
|
|
|
|
|
+// var state =
|
|
|
+var inquiry = ['CAM_ZoomPosInq', 'CAM_FocusModeInq', 'CAM_FocusPosInq'];
|
|
|
|
|
|
-function init() {
|
|
|
- //loadFixtures();
|
|
|
- script.log("hello VISCA");
|
|
|
+/////////// HELPERS FUNCTIONS ////////////////
|
|
|
+
|
|
|
+function printArray(name, array){
|
|
|
+ var printHeader = ' '+name+' : ';
|
|
|
+ if (array.length){for(var i=0; i<array.length; i++){printHeader+=array[i] + ' ';}}
|
|
|
+ script.log(printHeader);
|
|
|
}
|
|
|
|
|
|
+/////////// VISCA FUNCTIONS ////////////////
|
|
|
+
|
|
|
function setZoom(ID, position){
|
|
|
+ var header = [1, 4, 71];
|
|
|
+ var posCommand = [];
|
|
|
+ var pos = Math.round(Math.floor(16384 * position));
|
|
|
+ // script.log(pos);
|
|
|
+ posCommand[3]=pos%16;
|
|
|
+ pos = Math.round(Math.floor(pos/16));
|
|
|
+ posCommand[2]=pos%16;
|
|
|
+ pos=Math.round(Math.floor(pos/16));
|
|
|
+ posCommand[1]=pos%16;
|
|
|
+ posCommand[0]=Math.round(Math.floor(pos/16));
|
|
|
+ // local.sendBytes(idHex, 1, 4, 71, posCommand, 255);
|
|
|
+
|
|
|
+ sendCommand(1, header, posCommand);
|
|
|
+}
|
|
|
|
|
|
+function sendCommand(id, header, command){
|
|
|
var idHex = (parseInt("0x80") + ID);
|
|
|
+ printArray('header', header);
|
|
|
+ printArray('command', command);
|
|
|
+ local.sendBytes(idHex, header, command, 255);
|
|
|
+}
|
|
|
|
|
|
+/////////// SCRIPT FUNCTIONS ////////////////
|
|
|
|
|
|
- var pos = Math.round(4000 * position);
|
|
|
- var posString = ""+pos;
|
|
|
- var pad = "0000";
|
|
|
- posString = pad.substring(0, pad.length - posString.length) + posString;
|
|
|
- script.log(posString);
|
|
|
- // script.log(posString.charAt(1));
|
|
|
- var posCommand = [parseInt("0x0"+posString.charAt(0)),
|
|
|
- parseInt("0x0"+posString.charAt(1)),
|
|
|
- parseInt("0x0"+posString.charAt(2)),
|
|
|
- parseInt("0x0"+posString.charAt(3))
|
|
|
- ];
|
|
|
- // script.log(posCommand[0]);
|
|
|
- // script.log(posCommand[1]);
|
|
|
- // script.log(posCommand[2]);
|
|
|
- // script.log(posCommand[3]);
|
|
|
- // var packet = [idHex, , 00, 00, 00, 00, "ff"]
|
|
|
- // local.send(String.fromCharCode.apply(null, posCommand));
|
|
|
- // local.sendBytes(129, 1, 4, 7, 48, 255);
|
|
|
- // local.send()
|
|
|
- local.sendBytes(idHex, 1, 4, 71,
|
|
|
- posCommand, 255);
|
|
|
-
|
|
|
-
|
|
|
+function init() {
|
|
|
+ //loadFixtures();
|
|
|
+ script.log("VISCA module loaded");
|
|
|
}
|
|
|
|
|
|
var buffer=[];
|
|
@@ -78,8 +88,16 @@ function dataReceived(data)
|
|
|
script.log(" > " +data[i]);
|
|
|
}
|
|
|
}
|
|
|
- script.log(msg);
|
|
|
- }
|
|
|
+ script.log(msg);
|
|
|
+ }
|
|
|
+
|
|
|
+ //inquiry answers
|
|
|
+ // if (buffer[1]==80){//0x50){
|
|
|
+ // switch(inquiry){
|
|
|
+ // case 'CAM_ZoomPosInq':
|
|
|
+
|
|
|
+ // }
|
|
|
+ // }
|
|
|
|
|
|
}
|
|
|
bufferIndex = 0;
|