From f66b4345d1cdb3bebed74dfa11e8e4aa51bb17c8 Mon Sep 17 00:00:00 2001
From: amalcor <amalio.coron@student-cs.Fr>
Date: Wed, 28 Nov 2018 14:36:32 +0100
Subject: [PATCH] =?UTF-8?q?recup=C3=A9ration=20du=20code=20du=20PC=20dista?=
 =?UTF-8?q?nt?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 cam commandes.py | 169 +++++++++++++++++++++++++++--------------------
 1 file changed, 98 insertions(+), 71 deletions(-)

diff --git a/cam commandes.py b/cam commandes.py
index ce0f916..7d5d8b2 100644
--- a/cam commandes.py	
+++ b/cam commandes.py	
@@ -1,6 +1,6 @@
 import socket
 sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) # UDP
-sequence_number=520
+sequence_number=1360
 
 UDP_IP = "192.168.0.100"
 UDP_PORT = 52381
@@ -8,84 +8,111 @@ VV =  "10 " # Pan speed setting between 01 and 18 in normal speed, up to 0x7E in
 WW = "10 " # Tilt speed 
 POS_1=["0A00","FB00"]
 POS_2=["F700","FB00"]
-#sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
 payload = ""
 header=""
 message=""
+commande = ""
 
-while True:
-    command = input('Indique ta commande : pos1, pos2, reset \n')
-    if(command == "pos1"):
-        payload = "81 01 06 02 " #Movetoabsoluteposition in POS
-        payload = payload + VV + WW #add move speed
-        for i in POS_1: #add position
-            for j in i:
-                payload = payload + "0" + j +" "
-        payload = payload + "FF " #end byte
-        header = "01 00 " # Payload type : 0100 for a command, 0110 for and inquiry, 0200 for a control command and 0120 for a device setting command
-        header = header + "00 "
-        #header = header + ('0'*(4-len(hex(len(payload.replace(' ',''))//2))) +hex(len(payload.replace(' ',''))//2))
-        header=header + '0F '
-        header = header + ('0'*(8-len(str(sequence_number)))+str(sequence_number)) 
-        message = header + payload
-        sock.sendto(bytes.fromhex(message.replace(' ','')),(UDP_IP,UDP_PORT))
-        print("salle1" + message)
-        sequence_number=sequence_number+1
-    if(command=="pos2"):
-        payload = "81 01 06 02 " #Movetoabsoluteposition in POS
-        payload = payload + VV + WW #add move speed
-        for i in POS_2: #add position
-            for j in i:
-                payload = payload + "0" + j +" "
-        payload = payload + "FF " #end byte
-        header = "01 00 " # Payload type : 0100 for a command, 0110 for and inquiry, 0200 for a control command and 0120 for a device setting command
-        header = header + "00 "
-        #header = header + ('0'*(4-len(hex(len(payload.replace(' ',''))//2))) +hex(len(payload.replace(' ',''))//2))
-        header=header + '0F '
-        header = header + ('0'*(8-len(str(sequence_number)))+str(sequence_number)) 
-        message = header + payload
-        sock.sendto(bytes.fromhex(message.replace(' ','')),(UDP_IP,UDP_PORT))
-        print("salle2 " + message)
-        sequence_number=sequence_number+1
-    if(command=="reset"):
-        payload = "01 " #Movetoabsoluteposition in POS
-        payload = payload + "FF " #end byte
+while commande != "reset":
+    command = input('Indique ta commande : pos1, pos2, movetuyau, manualfocus, \n focustuyau, autofocus, zoom0, zoom2 \n')
+    if command in ["pos1", "pos2", "reset"]:
         
-        header = "02 00 " # Payload type : 0100 for a command, 0110 for and inquiry, 0200 for a control command and 0120 for a device setting command
+        if(command == "pos2"):
+            payload = "81 01 06 02 " #Movetoabsoluteposition in POS
+            payload = payload + VV + WW #add move speed
+            for i in POS_1: #add position
+                for j in i:
+                    payload = payload + "0" + j +" "
+            payload = payload + "FF " #end byte
+            header = "01 00 " # Payload type : 0100 for a command, 0110 for and inquiry, 0200 for a control command and 0120 for a device setting command
+            header = header + "00 "
+            #header = header + ('0'*(4-len(hex(len(payload.replace(' ',''))//2))) +hex(len(payload.replace(' ',''))//2))
+            header=header + '0F '
+            header = header + ('0'*(8-len(str(sequence_number)))+str(sequence_number)) 
+            message = header + payload
+            sock.sendto(bytes.fromhex(message.replace(' ','')),(UDP_IP,UDP_PORT))
+            print("salle2" + message)
+            sequence_number = sequence_number+1
+        if(command=="pos1"):
+            payload = "81 01 06 02 " #Movetoabsoluteposition in POS
+            payload = payload + VV + WW #add move speed
+            for i in POS_2: #add position
+                for j in i:
+                    payload = payload + "0" + j +" "
+            payload = payload + "FF " #end byte
+            header = "01 00 " # Payload type : 0100 for a command, 0110 for and inquiry, 0200 for a control command and 0120 for a device setting command
+            header = header + "00 "
+            #header = header + ('0'*(4-len(hex(len(payload.replace(' ',''))//2))) +hex(len(payload.replace(' ',''))//2))
+            header=header + '0F '
+            header = header + ('0'*(8-len(str(sequence_number)))+str(sequence_number)) 
+            message = header + payload
+            sock.sendto(bytes.fromhex(message.replace(' ','')),(UDP_IP,UDP_PORT))
+            print("salle1 " + message)
+            sequence_number=sequence_number+1
+        # if(command=="reset"):
+        #     payload = "01 " #Movetoabsoluteposition in POS
+        #     payload = payload + "FF " #end byte
+        #     
+        #     header = "02 00 " # Payload type : 0100 for a command, 0110 for and inquiry, 0200 for a control command and 0120 for a device setting command
+        #     
+        #     #header = header + ('0'*(4-len(hex(len(payload.replace(' ',''))//2))) +hex(len(payload.replace(' ',''))//2))
+        #     header=header + '01 '
+        #     header = header + "00 00 00 00"
+        #     message = header + payload
+        #     
+        #     sock.sendto(bytes.fromhex(message.replace(' ','')),(UDP_IP,UDP_PORT))
+        #     print("reset " + message)
+        #     sequence_number = sequence_number+1
+    else:
+        if(command=='moveleft_c'):
+            payload = "81 01 06 01 18 17 01 03 FF"
+            header = "10 00 00 09"
+        if(command =='moveright_c'):
+            payload = "81 01 06 01 18 17 02 03 FF"
+            header = "10 00 00 09"
+        if(command == 'stop'):
+            payload = "81 01 06 01 00 00 03 03 FF"
+            header = "10 00 00 09"
+        if(command=='d'):
+            # payload = "81 01 06 03 VV WW 0Y 0Y 0Y 0Y 00 00 00 00 FF     YYYY de DE00 à 2200 center 0000
+            payload = "81 01 06 03 09 09 00 01 02 02 00 00 00 00 FF"     
+            header = "01 00 00 0F"
+        if(command =='q'):
+            payload = "81 01 06 03 09 09 0F 0E 0D 0E 00 00 00 00 FF"
+            header = "01 00 00 0F"
+        if(command =='z'):
+            payload = "81 01 06 03 09 09 0F 0E 0D 0E 0 00 00 00 FF"
+            header = "01 00 0q
+            q
+            dezo 0 0F"
+        if(command =='s'):
+            payload = "81 01 06 03 09 09 0F 0E 0D 0E 00 00 00 00 FF"
+            header = "01 00 00 0F"
+        if(command=="zoom0"):
+            payload="81 01 04 47 00 00 00 00 FF"
+            header = "01 00 00 09"
+        if(command=="zoom2"):
+            payload="81 01 04 47 01 06 0A 01 FF"
+            header = "01 00 00 09"
+        if(command=="focustuyau"): #6m
+            payload="81 01 04 48 04 00 00 00 FF"
+            header = "01 00 00 09"
+        if(command=="manualfocus"):
+            payload="81 01 04 38 03 FF"
+            header = "01 00 00 06"
+        if(command=="autofocus"):
+            payload="81 01 04 38 02 FF"
+            header = "01 00 00 06"
+        if(command=="movetuyau"):
+            payload="81 01 06 02 10 10 01 02 00 00 0F 0E 0C 00 FF"
+            header = "01 00 00 0F"
         
-        #header = header + ('0'*(4-len(hex(len(payload.replace(' ',''))//2))) +hex(len(payload.replace(' ',''))//2))
-        header=header + '01 '
-        header = header + "00 00 00 00"
-        message = header + payload
-        
-        sock.sendto(bytes.fromhex(message.replace(' ','')),(UDP_IP,UDP_PORT))
-        print("reset " + message)
-        sequence_number=1
-""""if(command=='moveleft'):
-        payload = "81 01 06 01 03 03 01 03 FF"
-        header = "10 00 00 09"
-        header = header + ('0'*(8-len(str(sequence_number)))+str(sequence_number)) 
-        message = header + payload
-        sock.sendto(bytes.fromhex(message.replace(' ','')),(UDP_IP,UDP_PORT))
-        print("Moveleft : " + message)
-    if(command =='moveright'):
-        payload = "81 01 06 01 03 03 02 03 FF"
-        header = "10 00 00 09"
         header = header + ('0'*(8-len(str(sequence_number)))+str(sequence_number)) 
         message = header + payload
         sock.sendto(bytes.fromhex(message.replace(' ','')),(UDP_IP,UDP_PORT))
-        print("Moveleft : " + message)"""
+        print("fait "+ command)
+        sequence_number = sequence_number + 1
+    print(sequence_number)
         
-""" if(command=="zoom0"):
-        payload="81 01 04 47 00 00 00 00 FF"
-    if(command=="zoom2"):
-        payload="81 01 04 47 01 06 0A 01 FF"
-    if(command=="focustuyau"): #6m
-        payload="81 01 04 48 04 00 00 00 FF"
-    if(command=="manualfocus"):
-        payload="81 01 04 38 03 FF"
-    if(command=="autofocus"):
-        payload="81 01 04 38 02 FF"
-    if(command=="movetuyau"):
-        payload="81 01 06 02 10 10 01 02 00 00 0F 0E 0C 00 ff"""
+            
     
\ No newline at end of file
-- 
GitLab