added more smp >API< functions
This commit is contained in:
@@ -9,7 +9,7 @@ from backend.recorder_adapters import telnetlib, TelnetAdapter
|
||||
HOST = "172.22.246.207" # Test SMP MZ
|
||||
|
||||
USER = "admin"
|
||||
PW = "123mzsmpx"
|
||||
PW = "123mzsmp"
|
||||
|
||||
|
||||
class SMP(TelnetAdapter):
|
||||
@@ -249,7 +249,7 @@ class SMP(TelnetAdapter):
|
||||
File related stuff not implemented. (-> use sftp)
|
||||
"""
|
||||
|
||||
def set_input(self, input_num:int, channel_num:int):
|
||||
def set_input(self, input_num: int, channel_num: int):
|
||||
"""
|
||||
Switches input # (1 to 5) to output channel (1=A [input 1 and 2], 2=B [input 3, 4 and 5])
|
||||
:param input_num:
|
||||
@@ -258,10 +258,130 @@ class SMP(TelnetAdapter):
|
||||
"""
|
||||
if input_num not in range(1,6):
|
||||
raise Exception("input_num must be a value between 1 and 5!")
|
||||
if channel_num not in range(1,3):
|
||||
raise Exception("input_num must be a value between 1 and 2!")
|
||||
self.tn.write("{}*{}!\n".format(input_num, channel_num))
|
||||
return TelnetAdapter.get_response_str(self.tn.read_until_non_empty_line())
|
||||
|
||||
def get_input(self, channel_num: int):
|
||||
if channel_num not in range(1,2):
|
||||
raise Exception("input_num must be a value between 1 and 2!")
|
||||
self.tn.write("{}!\n".format(channel_num))
|
||||
return TelnetAdapter.get_response_str(self.tn.read_until_non_empty_line())
|
||||
|
||||
def set_input_format(self, input_num: int, input_format: int):
|
||||
"""
|
||||
Sets the input to the format, where the input_format parameter may be:
|
||||
1 = YUVp / HDTV (default)
|
||||
2 = YUVi
|
||||
3 = Composite
|
||||
:param input_num:
|
||||
:param input_format:
|
||||
:return:
|
||||
"""
|
||||
if input_num not in range(1,6):
|
||||
raise Exception("input_num must be a value between 1 and 5!")
|
||||
if input_format not in range(1,4):
|
||||
raise Exception("input_num must be a value between 1 and 3!")
|
||||
self.tn.write("{}*{}\\\n".format(input_num, input_format))
|
||||
return TelnetAdapter.get_response_str(self.tn.read_until_non_empty_line())
|
||||
|
||||
def get_input_format(self, input_num: int):
|
||||
if input_num not in range(1,6):
|
||||
raise Exception("input_num must be a value between 1 and 5!")
|
||||
self.tn.write("{}\\\n".format(input_num))
|
||||
return TelnetAdapter.get_response_str(self.tn.read_until_non_empty_line())
|
||||
|
||||
def set_input_name(self, input_num: int, input_name: str):
|
||||
if input_num not in range(1,6):
|
||||
raise Exception("input_num must be a value between 1 and 5!")
|
||||
if len(input_name) > 16:
|
||||
raise Exception("input_name must be not longer than 16 chars")
|
||||
try:
|
||||
input_name.encode('ascii')
|
||||
except UnicodeDecodeError:
|
||||
raise Exception("input_name must only contain ascii characters")
|
||||
self.tn.write("{}{},{}NI\n".format(self.esc_char, input_num, input_name))
|
||||
return TelnetAdapter.get_response_str(self.tn.read_until_non_empty_line())
|
||||
|
||||
def get_input_name(self, input_num: int):
|
||||
if input_num not in range(1,6):
|
||||
raise Exception("input_num must be a value between 1 and 5!")
|
||||
self.tn.write("{}{}NI\n".format(self.esc_char, input_num))
|
||||
return TelnetAdapter.get_response_str(self.tn.read_until_non_empty_line())
|
||||
|
||||
def get_input_selction_per_channel(self):
|
||||
self.tn.write("32I\n")
|
||||
return TelnetAdapter.get_response_str(self.tn.read_until_non_empty_line())
|
||||
|
||||
"""
|
||||
Input configuration part skipped
|
||||
"""
|
||||
|
||||
def stop_recording(self):
|
||||
self.tn.write("{}Y0RCDR\n".format(self.esc_char))
|
||||
return TelnetAdapter.get_response_str(self.tn.read_until_non_empty_line())
|
||||
|
||||
def start_recording(self):
|
||||
self.tn.write("{}Y1RCDR\n".format(self.esc_char))
|
||||
return TelnetAdapter.get_response_str(self.tn.read_until_non_empty_line())
|
||||
|
||||
def pause_recording(self):
|
||||
self.tn.write("{}Y2RCDR\n".format(self.esc_char))
|
||||
return TelnetAdapter.get_response_str(self.tn.read_until_non_empty_line())
|
||||
|
||||
def get_recording_status(self):
|
||||
"""
|
||||
Status may be one of:
|
||||
0=stop
|
||||
1=record
|
||||
2=pause
|
||||
:return: status
|
||||
"""
|
||||
self.tn.write("{}YRCDR\n".format(self.esc_char))
|
||||
return TelnetAdapter.get_response_str(self.tn.read_until_non_empty_line())
|
||||
|
||||
def extent_recording_time(self, extension_time: int):
|
||||
"""
|
||||
Extends a scheduled recording by extension_time minutes
|
||||
:param extension_time: must be an int from 0 to 99
|
||||
:return:
|
||||
"""
|
||||
if extension_time not in range(0,100):
|
||||
raise Exception("extension_time must be a value between 0 and 99!")
|
||||
self.tn.write("{}E{}RCDR\n".format(self.esc_char, extension_time))
|
||||
return TelnetAdapter.get_response_str(self.tn.read_until_non_empty_line())
|
||||
|
||||
def add_chapter_marker(self):
|
||||
self.tn.write("{}BRCDR\n".format(self.esc_char))
|
||||
return TelnetAdapter.get_response_str(self.tn.read_until_non_empty_line())
|
||||
|
||||
def swap_channel_positions(self):
|
||||
self.tn.write("%\n")
|
||||
return TelnetAdapter.get_response_str(self.tn.read_until_non_empty_line())
|
||||
|
||||
def get_recording_status_text(self):
|
||||
self.tn.write("I\n")
|
||||
return TelnetAdapter.get_response_str(self.tn.read_until_non_empty_line())
|
||||
|
||||
def get_elapsed_recording_time(self):
|
||||
self.tn.write("35I\n")
|
||||
return TelnetAdapter.get_response_str(self.tn.read_until_non_empty_line())
|
||||
|
||||
def get_remaining_recording_time(self):
|
||||
self.tn.write("36I\n")
|
||||
return TelnetAdapter.get_response_str(self.tn.read_until_non_empty_line())
|
||||
|
||||
def get_recording_destination(self):
|
||||
self.tn.write("37I\n")
|
||||
return TelnetAdapter.get_response_str(self.tn.read_until_non_empty_line())
|
||||
|
||||
"""
|
||||
Metadata part skipped
|
||||
"""
|
||||
|
||||
def recall_user_preset(self, channel_number, preset_number):
|
||||
pass # TODO
|
||||
|
||||
|
||||
smp = SMP(HOST, PW)
|
||||
@@ -286,3 +406,7 @@ print(smp.get_file_transfer_config())
|
||||
|
||||
print(smp.set_front_panel_lock(0))
|
||||
print(smp.get_front_panel_lock())
|
||||
|
||||
print(smp.get_input_name(1))
|
||||
print(smp.get_input_selction_per_channel())
|
||||
print(smp.get_recording_status())
|
||||
|
||||
Reference in New Issue
Block a user