Browse Source

added methods

advanced options through write register
eLandon 4 years ago
parent
commit
eef938ed5f
2 changed files with 64 additions and 3 deletions
  1. 34 2
      Visca.js
  2. 30 1
      module.json

+ 34 - 2
Visca.js

@@ -8,7 +8,7 @@ var ZoomPos = script.addFloatParameter("Zoom Position", "", 0., 0., 1.);
 var ZoomPosLastUpdate = script.addFloatParameter("Zoom update", "", 0.);
 
 // var state = 
-var inquiry = ['CAM_ZoomPosInq', 'CAM_FocusModeInq', 'CAM_FocusPosInq'];
+var inquiry = ['CAM_ZoomPosInq', 'CAM_FocusModeInq', 'CAM_FocusPosInq', 'CAM_ReplyIntervalTimeInq'];
 var camID = 1;
 var waitTaskComplete = 0 ;
 var currentInquiry = '';
@@ -62,7 +62,7 @@ function sendInquiry(id, inquiryName){
 	if (currentInquiry == ''){ //no inquiry running;
 		currentInquiry = inquiryName ;
 		if(inquiryName == 'CAM_ZoomPosInq'){ command = [9, 4, 71];}
-
+		if(inquiryName == 'CAM_ReplyIntervalTimeInq'){ command = [9, 4, 106];}
 		sendCommand(camID, command);
 	}
 	else{script.log("inquiry running");}
@@ -110,6 +110,24 @@ function setZoomPositionInTime(ID, position, time){
 	// sendHeaderCommand(camID, header, speedCmd);
 }
 
+function setZoomPositionInTime_TL(ID, position, time){
+	
+	var tl_time = root.sequences.keys.currentTime.get();
+	
+	//update zoom position and time targets
+	ZoomPos_target = root.sequences.keys.zoom.automation.getValueAtPosition(tl_time+time) ;
+	ZoomTime_target = util.getTime()+time;
+
+	//activate callback
+	ZoomAuto = true ;
+
+	//deduce appropriate speed
+	// var speedCmd = speed < 0 ?  48 : 32;
+	// speedCmd = speed == 0 ? 0 : speedCmd ;
+	// speedCmd += Math.abs(speed);
+	// sendHeaderCommand(camID, header, speedCmd);
+}
+
 function updateZoomPosition() {
 	
 	if (ZoomAuto){		
@@ -226,9 +244,23 @@ function dataReceived(data)
 						ZoomPos.set(position/16384.);
 						ZoomPosLastUpdate.set(util.getTime());
 					}
+					if(currentInquiry == 'CAM_ReplyIntervalTimeInq'){
+						var position = buffer[4]*16 + buffer[5];
+						// printArray("zoom position :", buffer);
+						// script.log(position);
+						ZoomPos.set(position/16384.);
+						ZoomPosLastUpdate.set(util.getTime());
+					}
 					//free inquiry slot
 					currentInquiry = '';
 				}
+				else if(buffer[1] == 7 && buffer[2] == 4 && buffer[3]==105){
+					var position = buffer[6]*4096 + buffer[7]*256 + buffer[8]*16 + buffer[9];
+						// printArray("zoom position :", buffer);
+						// script.log(position);
+						ZoomPos.set(position/16384.);
+						ZoomPosLastUpdate.set(util.getTime());
+				}
 				else{printArray("unknown answer :", buffer);}
 			}
 			bufferIndex = 0;

+ 30 - 1
module.json

@@ -65,7 +65,8 @@
 						"CAM_ZoomPosInq":"CAM_ZoomPosInq",
 						"CAM_FocusModeInq":"CAM_FocusModeInq",
 						"CAM_FocusPosInq":"CAM_FocusPosInq",
-
+						"CAM_FocusPosInq":"CAM_FocusPosInq",
+						"CAM_ReplyIntervalTimeInq": "CAM_ReplyIntervalTimeInq"
 					}
 				}
 			}
@@ -136,6 +137,34 @@
 					"useForMapping": true
 				}
 			}
+		},
+		"ZoomPositionInTime_TL": {
+			"menu": "",
+			"callback": "setZoomPositionInTime_TL",
+			"parameters": {
+				"ID" : {
+					"type": "Integer",
+					"default":1,
+					"min": 1,
+					"max": 7,
+					"useForMapping": true
+				},
+				"Position" : {
+					"type": "Float",
+					"default":0,
+					"min": 0.,
+					"max": 1.,
+					"useForMapping": true
+				},
+				"offset" : {
+					"type": "Float",
+					"default":0,
+					"min": 0.,
+					"max": 1000,
+					"useForMapping": true
+				}
+				
+			}
 		}
 	}
 }