Example #1
0
class PTU:

    def __init__(self, host, port, debug=False):
        self.stream = Stream(host, port, testing=debug)

    def connect(self):
        self.stream.connect()

    def send_command(self, command):
        self.stream.send(command)
        self.stream.read_until("*")

    def read_command(self, command, regex):
        self.stream.send(command)
        data = self.stream.read_until("*").decode()
        data = self.stream.read_until("\n").decode()
        match = re.match(regex, data)
        if match:
            return match.group("expected")
        else:
            logger.error("Error parsing regex")

    def pan_angle(self, angle_value=False):
        if type(angle_value) !=  bool:
            self.pan(math.ceil(angle_value/(92.5714/3600)))
        else:
            data = self.pan()
            return data * (92.5714/3600)

    def tilt_angle(self, angle_value=False):
        if type(angle_value) != bool:
            self.tilt(math.ceil(angle_value/(46.2857/3600)))
        else:
            data = self.tilt()
            return data * (46.2857/3600)
Example #2
0
File: ptu.py Project: glhr/flir_ptu
class PTU:
    def __init__(self, host, port, debug=False):
        self.stream = Stream(host, port, testing=debug)

    def connect(self):
        self.stream.connect()

    def send_command(self, command):
        self.stream.send(command)
        self.stream.read_until("\n")

    def read_command(self, command, regex):
        self.stream.send(command)
        data = self.stream.read_until("*").decode()
        # print(data)
        data = self.stream.read_until("\n").decode()
        match = re.match(regex, data)
        # print(data)
        if match:
            return match.group("expected")
        else:
            logger.error("Error parsing regex of")

    def pan_angle(self, angle_value=False):
        if type(angle_value) != bool:
            self.pan(math.ceil(angle_value / (92.5714 / 3600)))
        else:
            data = self.pan()
            return round(float(data) * (92.5714 / 3600), 2)

    def tilt_angle(self, angle_value=False):
        if type(angle_value) != bool:
            self.tilt(math.ceil(angle_value / (46.2857 / 3600)))
        else:
            data = self.tilt()
            return round(float(data) * (46.2857 / 3600), 2)
Example #3
0
File: ptu.py Project: glhr/flir_ptu
 def __init__(self, host, port, debug=False):
     self.stream = Stream(host, port, testing=debug)
Example #4
0
 def __init__(self, host, port, debug=False):
     self.stream = Stream(host, port, testing=debug)