123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- function init() {
-
- script.log("hello VISCA");
- }
- function setZoom(ID, position){
- var idHex = (parseInt("0x80") + ID);
- var pos = Math.round(4000 * position);
- var posString = ""+pos;
- var pad = "0000";
- posString = pad.substring(0, pad.length - posString.length) + posString;
- script.log(posString);
-
- var posCommand = [parseInt("0x0"+posString.charAt(0)),
- parseInt("0x0"+posString.charAt(1)),
- parseInt("0x0"+posString.charAt(2)),
- parseInt("0x0"+posString.charAt(3))
- ];
-
-
-
-
-
-
-
-
- local.sendBytes(idHex, 1, 4, 71,
- posCommand, 255);
- }
- var buffer=[];
- var bufferIndex = 0 ;
- function dataReceived(data)
- {
-
-
-
-
-
-
-
-
-
- for (var i = 0 ; i<data.length ; i++){
- if (data[i]!=255){
- buffer[bufferIndex]=data[i];
- bufferIndex += 1;
- }
- else{
- if(buffer[0]==144){
- if (buffer[1]==65){script.log("received command");}
- if (buffer[1]==81){script.log("complete command");}
- if (buffer[1]==97){
- var msg = "error :";
- if(buffer[2]==1){msg=msg+"message length";}
- if(buffer[2]==2){msg=msg+"syntax";}
- if(buffer[2]==3){msg=msg+"command buffer full";}
- if(buffer[2]==4){msg=msg+"command cancelled";}
- if(buffer[2]==5){msg=msg+"no socket";}
- if(buffer[2]==65){msg=msg+"command not executable";}
- else{
- msg=msg+"unknow error";
- for(var j=2; j < buffer.length; j++)
- {
- script.log(" > " +data[i]);
- }
- }
- script.log(msg);
- }
- }
- bufferIndex = 0;
- buffer=[];
- }
- }
-
- }
|