Skip to content
Snippets Groups Projects
Commit cbceef63 authored by Pierre Minssen's avatar Pierre Minssen
Browse files

suite d ecriture des fonctions de bases

parent 04f7da68
Branches
No related tags found
No related merge requests found
...@@ -19,5 +19,10 @@ ...@@ -19,5 +19,10 @@
</list> </list>
</option> </option>
</inspection_tool> </inspection_tool>
<inspection_tool class="SpellCheckingInspection" enabled="false" level="TYPO" enabled_by_default="false">
<option name="processCode" value="true" />
<option name="processLiterals" value="true" />
<option name="processComments" value="true" />
</inspection_tool>
</profile> </profile>
</component> </component>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.6" project-jdk-type="Python SDK" /> <component name="ProjectRootManager" version="2" project-jdk-name="Python 3.7" project-jdk-type="Python SDK" />
</project> </project>
\ No newline at end of file
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<module type="PYTHON_MODULE" version="4"> <module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager"> <component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" /> <content url="file://$MODULE_DIR$" />
<orderEntry type="jdk" jdkName="Python 3.6" jdkType="Python SDK" /> <orderEntry type="jdk" jdkName="Python 3.7" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="sourceFolder" forTests="false" />
</component> </component>
<component name="TestRunnerService"> <component name="TestRunnerService">
......
...@@ -5,6 +5,18 @@ class Camera: ...@@ -5,6 +5,18 @@ class Camera:
#### ####
####### FONCTIONS COMMANDES D'EXECUTIONS ####### FONCTIONS COMMANDES D'EXECUTIONS
#### ####
@staticmethod
def hex_2_message(x: hex):
"""
:param x: hex of 2 or 4 bits like "0x1234"
:return: string like "0p 0q 0r 0s"
"""
message = ""
for p in x[2:]:
message = message + "0" + p + " "
message.pop()
return message
#CAM_POWER : Power ON/OFF #CAM_POWER : Power ON/OFF
def power_on(self): def power_on(self):
...@@ -17,28 +29,53 @@ class Camera: ...@@ -17,28 +29,53 @@ class Camera:
self.send_payload(payloadtype,payload) self.send_payload(payloadtype,payload)
#CAM_ZOOM : Zoom Control #CAM_ZOOM : Zoom Control
#x from 1 : "0x0000" to 30 : "0x4000"
#TODO def zoom_direct(self, x: hex):
payloadtype = '01 00'
if len(x) != 6: # x n'est pas bon a voir si on check avant
x = "0x0000"
message = self.hex_2_message(x)
payload = "81 01 04 47 " + message + " FF"
self.send_payload(payloadtype, payload)
#CAM_DZOOM #CAM_DZOOM
def digital_zoom_off(self): def digital_zoom_off(self):
payloadtype='01 00' payloadtype='01 00'
payload='81 01 04 06 02 FF' payload='81 01 04 06 02 FF'
self.send_payload(payloadtype,payload) self.send_payload(payloadtype,payload)
def digital_zoom_on(self): def digital_zoom_on(self):
payloadtype='01 00' payloadtype='01 00'
payload="81 01 04 06 03 FF" payload="81 01 04 06 03 FF"
self.send_payload(payloadtype,payload) self.send_payload(payloadtype,payload)
#CAM_Focus : Focus Control #CAM_Focus : Focus Control
# inf = "0x1000" to 1cm = "0xF000"
def focus_direct(self, x: hex):
payloadtype = '01 00'
if len(x) != 6: # x n'est pas bon a voir si on check avant
x = "0x0000"
message = self.hex_2_message(x)
payload = "81 01 04 48 " + message + " FF"
self.send_payload(payloadtype, payload)
def autofocus_on(self):
payloadtype = '01 00'
payload = '81 01 04 38 02 FF'
self.send_payload(payloadtype, payload)
def autofocus_off(self):
payloadtype = '01 00'
payload = '81 01 04 38 03 FF'
self.send_payload(payloadtype, payload)
#TODO
#AF Sensitivity : Auto Focus sensitivity high/low #AF Sensitivity : Auto Focus sensitivity high/low
def autofocus_sensivity_normal(self): def autofocus_sensivity_normal(self):
payloadtype='01 00' payloadtype='01 00'
payload='81 01 04 58 02 FF' payload='81 01 04 58 02 FF'
self.send_payload(payloadtype,payload) self.send_payload(payloadtype,payload)
def autofocus_sensivity_low(self): def autofocus_sensivity_low(self):
payloadtype='01 00' payloadtype='01 00'
payload='81 01 04 58 03 FF' payload='81 01 04 58 03 FF'
...@@ -53,6 +90,7 @@ class Camera: ...@@ -53,6 +90,7 @@ class Camera:
payloadtype='01 00' payloadtype='01 00'
payload='81 01 04 11 00 FF' payload='81 01 04 11 00 FF'
self.send_payload(payloadtype,payload) self.send_payload(payloadtype,payload)
def focus_ir_correction_on(self): def focus_ir_correction_on(self):
payloadtype='01 00' payloadtype='01 00'
payload='81 01 04 11 00 FF' payload='81 01 04 11 00 FF'
...@@ -60,17 +98,26 @@ class Camera: ...@@ -60,17 +98,26 @@ class Camera:
#CAM_ZoomFocus #CAM_ZoomFocus
#TODO def zoom_focus_direct(self, x: hex, y: hex):
payloadtype = '01 00'
if len(x) != 6: # x n'est pas bon a voir si on check avant
x = "0x0000"
if len(y) != 6: # x n'est pas bon a voir si on check avant
y = "0x0000"
message_x = self.hex_2_message(x)
message_y = self.hex_2_message(y)
payload = "81 01 04 47 " + message_x + " " + message_y + " FF"
self.send_payload(payloadtype, payload)
#CAM_WB : White Balance #CAM_WB : White Balance
def wb_auto(self): #Normal Auto def wb_auto(self): #Normal Auto
payloadtype='01 00' payloadtype='01 00'
payload="8x 01 04 35 00 FF" payload="81 01 04 35 00 FF"
def wb_indoor(self): #Indoor Mode def wb_indoor(self): #Indoor Mode
payloadtype='01 00' payloadtype='01 00'
payload="8x 01 04 35 01 FF" payload="81 01 04 35 01 FF"
self.send_payload(payloadtype,payload) self.send_payload(payloadtype,payload)
def wb_outdoor(self): #Outdoor Mode def wb_outdoor(self): #Outdoor Mode
...@@ -101,8 +148,51 @@ class Camera: ...@@ -101,8 +148,51 @@ class Camera:
#TOTERMINER #TOTERMINER
#CAM_RGain and BGain #CAM_RGain and BGain
def rgain_reset(self):
payloadtype = '01 00'
payload = "81 01 04 03 00 FF"
self.send_payload(payloadtype, payload)
#TODO def rgain_up(self):
payloadtype = '01 00'
payload = "81 01 04 03 02 FF"
self.send_payload(payloadtype, payload)
def rgain_up(self):
payloadtype = '01 00'
payload = "81 01 04 03 03 FF"
self.send_payload(payloadtype, payload)
def rgain_direct(self, x: hex):
payloadtype = '01 00'
if len(x) != 4: # x n'est pas bon a voir si on check avant
x = "0x0000"
message = self.hex_2_message(x)
payload = "81 01 04 43 00 00 " + message + " FF"
self.send_payload(payloadtype, payload)
def bgain_reset(self):
payloadtype = '01 00'
payload = "81 01 04 04 00 FF"
self.send_payload(payloadtype, payload)
def bgain_up(self):
payloadtype = '01 00'
payload = "81 01 04 04 02 FF"
self.send_payload(payloadtype, payload)
def bgain_up(self):
payloadtype = '01 00'
payload = "81 01 04 04 03 FF"
self.send_payload(payloadtype, payload)
def bgain_direct(self, x: hex):
payloadtype = '01 00'
if len(x) != 4: # x n'est pas bon a voir si on check avant
x = "0x0000"
message = self.hex_2_message(x)
payload = "81 01 04 44 00 00 " + message + " FF"
self.send_payload(payloadtype, payload)
#CAM_AE : Exposure settings #CAM_AE : Exposure settings
...@@ -143,24 +233,131 @@ class Camera: ...@@ -143,24 +233,131 @@ class Camera:
self.send_payload(payloadtype,payload) self.send_payload(payloadtype,payload)
#CAM_shutter #CAM_shutter
def shutter_reset(self):
payloadtype = '01 00'
payload = "81 01 04 0A 00 FF"
self.send_payload(payloadtype, payload)
def shutter_on(self):
payloadtype = '01 00'
payload = "81 01 04 0A 02 FF"
self.send_payload(payloadtype, payload)
def shutter_off(self):
payloadtype = '01 00'
payload = "81 01 04 0A 03 FF"
self.send_payload(payloadtype, payload)
def shutter_direct(self, x: hex):
payloadtype = '01 00'
if len(x) != 4: # x n'est pas bon a voir si on check avant
x = "0x0000"
message = self.hex_2_message(x)
payload = "81 01 04 4A 00 00 " + message + " FF"
self.send_payload(payloadtype, payload)
#TODO
#CAM_Iris #CAM_Iris
def iris_reset(self):
payloadtype = '01 00'
payload = "81 01 04 0B 00 FF"
self.send_payload(payloadtype, payload)
#TODO def iris_up(self):
payloadtype = '01 00'
payload = "81 01 04 0B 02 FF"
self.send_payload(payloadtype, payload)
def iris_down(self):
payloadtype = '01 00'
payload = "81 01 04 0B 03 FF"
self.send_payload(payloadtype, payload)
def iris_direct(self, x: hex):
payloadtype = '01 00'
if len(x) != 4: # x n'est pas bon a voir si on check avant
x = "0x0000"
message = self.hex_2_message(x)
payload = "81 01 04 4B 00 00 " + message + " FF"
self.send_payload(payloadtype, payload)
#CAM_GAIN #CAM_GAIN
def gain_reset(self):
payloadtype = '01 00'
payload = "81 01 04 0C 00 FF"
self.send_payload(payloadtype, payload)
#TODO def gain_up(self):
payloadtype = '01 00'
payload = "81 01 04 0C 02 FF"
self.send_payload(payloadtype, payload)
def gain_down(self):
payloadtype = '01 00'
payload = "81 01 04 0C 03 FF"
self.send_payload(payloadtype, payload)
def gain_direct(self, x: hex):
payloadtype = '01 00'
if len(x) != 4: # x n'est pas bon a voir si on check avant
x = "0x0000"
message = self.hex_2_message(x)
payload = "81 01 04 4C 00 00 " + message + " FF"
self.send_payload(payloadtype, payload)
# CAM_Bright # CAM_Bright
#TODO def brigth_up(self):
payloadtype = '01 00'
payload = "81 01 04 0D 02 FF"
self.send_payload(payloadtype, payload)
def brigth_down(self):
payloadtype = '01 00'
payload = "81 01 04 0D 03 FF"
self.send_payload(payloadtype, payload)
def brigth_direct(self, x: hex):
payloadtype = '01 00'
if len(x) != 4: # x n'est pas bon a voir si on check avant
x = "0x0000"
message = self.hex_2_message(x)
payload = "81 01 04 4D 00 00 " + message + " FF"
self.send_payload(payloadtype, payload)
# CAM_ExpComp # CAM_ExpComp
def expcomp_reset(self):
payloadtype='01 00'
payload="81 01 04 0E 00 FF"
self.send_payload(payloadtype, payload)
#TODO def expcomp_on(self):
payloadtype = '01 00'
payload="81 01 04 3E 02 FF"
self.send_payload(payloadtype, payload)
def expcomp_off(self):
payloadtype = '01 00'
payload="81 01 04 3E 03 FF"
self.send_payload(payloadtype, payload)
def expcomp_up(self):
payloadtype = '01 00'
payload="81 01 04 0E 02 FF"
self.send_payload(payloadtype, payload)
def expcomp_down(self):
payloadtype = '01 00'
payload="81 01 04 0E 03 FF"
self.send_payload(payloadtype, payload)
def expcomp_direct(self, x: hex):
payloadtype = '01 00'
if len(x) != 4: # x n'est pas bon a voir si on check avant
x = "0x0000"
message = self.hex_2_message(x)
payload = "81 01 04 4E 00 00 " + message + " FF"
self.send_payload(payloadtype, payload)
#CAM_Backlight : Back Light Comp ON/OFF #CAM_Backlight : Back Light Comp ON/OFF
def backlight_on(self): def backlight_on(self):
...@@ -199,6 +396,7 @@ class Camera: ...@@ -199,6 +396,7 @@ class Camera:
payloadtype='01 00' payloadtype='01 00'
payload="81 01 04 37 02 00 FF" payload="81 01 04 37 02 00 FF"
self.send_payload(payloadtype,payload) self.send_payload(payloadtype,payload)
def defog_off(self): def defog_off(self):
payloadtype='01 00' payloadtype='01 00'
payload="81 01 04 37 03 00 FF" payload="81 01 04 37 03 00 FF"
...@@ -206,7 +404,28 @@ class Camera: ...@@ -206,7 +404,28 @@ class Camera:
#CAM_Aperture #CAM_Aperture
#TODO def aperture_reset(self):
payloadtype = '01 00'
payload = "81 01 04 02 FF"
self.send_payload(payloadtype, payload)
def aperture_direct(self, x: hex):
payloadtype = '01 00'
if len(x) != 4: # x n'est pas bon a voir si on check avant
x = "0x0000"
message = self.hex_2_message(x)
payload = "81 01 04 42 00 00 " + message + " FF"
self.send_payload(payloadtype, payload)
def aperture_up(self):
payloadtype = '01 00'
payload = "81 01 04 42 02 02 FF"
self.send_payload(payloadtype, payload)
def aperture_down(self):
payloadtype = '01 00'
payload = "81 01 04 42 02 03 FF"
self.send_payload(payloadtype, payload)
#CAM_HR : High resolution mode #CAM_HR : High resolution mode
...@@ -217,70 +436,76 @@ class Camera: ...@@ -217,70 +436,76 @@ class Camera:
self.send_payload(payloadtype,payload) self.send_payload(payloadtype,payload)
#Pan-tiltDrive
#PAS RELU A PARTIR D'ICI : def pan_tiltDrive_reset(self):
def move_to_absolute_position(self, YCoordinates, ZCoordinates, VV=None, WW=None): payloadtype = '01 00'
payload = "81 01 06 05 FF"
self.send_payload(payloadtype, payload)
def pan_tiltDrive_home(self):
payloadtype = '01 00'
payload = "81 01 06 04 FF"
self.send_payload(payloadtype, payload)
def pan_tiltDrive_up(self):
VV = self.VV
WW = self.WW
payloadtype = '01 00'
payload = "81 01 06 01 " + VV + WW + " 03 01 FF"
self.send_payload(payloadtype, payload)
def pan_tiltDrive_down(self):
VV = self.VV
WW = self.WW
payloadtype = '01 00'
payload = "81 01 06 01 " + VV + WW + " 03 02 FF"
self.send_payload(payloadtype, payload)
def pan_tiltDrive_left(self):
VV = self.VV
WW = self.WW
payloadtype = '01 00'
payload = "81 01 06 01 " + VV + WW + " 01 03 FF"
self.send_payload(payloadtype, payload)
def pan_tiltDrive_right(self):
VV = self.VV
WW = self.WW
payloadtype = '01 00'
payload = "81 01 06 01 " + VV + WW + " 02 03 FF"
self.send_payload(payloadtype, payload)
def pan_tiltDrive_absolute(self, y: hex, z: hex):
""" """
command of absolute position mouvement command of absolute position mouvement
:param YCoordinates: YYYY from to :param y: from DE00 to 2200
:param ZCoordinates: ZZZZ from to :param z: from EE00 to 0400
:param VV:
:param WW:
:return: :return:
""" """
if(VV==None):
VV=self.VV VV=self.VV
if(WW==None):
WW=self.WW WW=self.WW
payloadtype = '01 00' payloadtype = '01 00'
payload = "81 01 06 02" # Absolute position moove payload = "81 01 06 02" # Absolute position moove
payload = payload + VV + WW # add move speed payload = payload + VV + WW # add move speed
for i in [YCoordinates, ZCoordinates]: # add position messagey = self.hex_2_message(y)
for j in i: messagez = self.hex_2_message(z)
payload = payload + " 0" + j payload = payload + messagey + " " + messagez + " FF"
payload = payload + "FF" # end byte #ce code était dans le première boucle, ça me semblait faux. self.send_payload(payloadtype, payload)
self.send_payload(payloadtype,payload)
def zqsd(self, x: str) -> str: # hex
payload = "FF" # message d'erreur à refaire
if x == '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"
if x == 'q':
payload = "81 01 06 03 09 09 0F 0E 0D 0E 00 00 00 00 FF"
if x == 'z':
payload = "81 01 06 03 09 09 0F 0E 0D 0E 00 00 09 0A FF"
if x == 's':
payload = "81 01 06 03 09 09 0F 0E 0D 0E 0F 0F 06 06 FF"
header = self.payload2header(self, payload)
payloadtype = '01 00'
message = payloadtype + header + payload
return message
def zoom(self, n: int) -> str: # hex #faire une version zoom + / zoom -
if n == 0:
payload = "81 01 04 47 00 00 00 00 FF"
if n == 2:
payload = "81 01 04 47 01 06 0A 01 FF"
payloadtype = "01 00"
header = self.payload2header(self, payload)
message = payloadtype + header + payload
return message
def focus(self, b: bool) -> str: def pan_tiltDrive_relavtive(self, y: hex, z: hex):
""" """
Command the focus auto or manual command of relative position mouvement
:param b: bool = 1 : autofocus ; bool = 0 : manualfocus :param y: from DE00 to 2200
:return: commande :param z: from EE00 to 0400
:return:
""" """
# hex #focus2payload(0) = autofocus VV = self.VV
if b: WW = self.WW
payload = "81 01 04 38 02 FF" # autofocus payloadtype = '01 00'
else: payload = "81 01 06 03" # Absolute position moove
payload = "81 01 04 38 03 FF" payload = payload + VV + WW # add move speed
header = self.payload2header(self, payload) messagey = self.hex_2_message(y)
payloadtype = "01 00" messagez = self.hex_2_message(z)
message = payloadtype + header + payload payload = payload + messagey + " " + messagez + " FF"
return message self.send_payload(payloadtype, payload)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment