Skip to content

naneos.partector.partector2_pro

Partector2Pro

Bases: PartectorBluePrint

Source code in src/naneos/partector/partector2_pro.py
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
class Partector2Pro(PartectorBluePrint):
    def __init__(
        self,
        serial_number: Optional[int] = None,
        port: Optional[str] = None,
        verb_freq: int = 6,
        hw_version: str = "P2pro",
        gain_test_active: bool = True,
        output_pulse_diagnostics: bool = True,
    ) -> None:
        self._GAIN_TEST_ACTIVE = gain_test_active
        self._OUTPUT_PULSE_DIAGNOSTICS = output_pulse_diagnostics
        super().__init__(serial_number, port, verb_freq, hw_version)

    def _init_serial_data_structure(self) -> None:
        """This gets passed here and is set in the set_verbose_freq method."""
        self.device_type = NaneosDeviceDataPoint.DEV_TYPE_P2PRO

    def _set_verbose_freq(self, freq: int) -> None:
        if freq == 0:
            self._write_line("X0000!")
        elif freq in [1, 2, 3]:  # std p2 mode
            if self._fw >= 311:
                self._data_structure = PARTECTOR2_DATA_STRUCTURE_V320

                self._write_line("M0000!")  # deactivates size dist mode
                self._write_line("A0002!")  # activates antispikes

                if self._OUTPUT_PULSE_DIAGNOSTICS:
                    self._write_line("opd01!")
                    self._data_structure.update(
                        PARTECTOR2_OUTPUT_PULSE_DIAGNOSTIC_ADDITIONAL_DATA_STRUCTURE
                    )
                else:
                    self._write_line("opd00!")

                if self._GAIN_TEST_ACTIVE:
                    self._write_line("h2001!")  # activates harmonics output
                    self._write_line("e1100!")  # strength of gain test signal
                    self._data_structure.update(PARTECTOR2_GAIN_TEST_ADDITIONAL_DATA_STRUCTURE)
                else:
                    self._write_line("h2000!")  # deactivates harmonics output
                    self._write_line("e0000!")  # deactivates gain test signal

                self._write_line(f"X000{freq}!")  # set verbose freq

            else:
                raise RuntimeError("Firmware too old for P2 pro mode. Minimum FW is 311.")
        elif freq == 6:  # p2 pro mode
            if self._fw >= 336:
                self._data_structure = PARTECTOR2_PRO_DATA_STRUCTURE_V336
            else:
                self._data_structure = PARTECTOR2_PRO_DATA_STRUCTURE_V311

            self._write_line("X0006!")  # activates verbose mode
            self._write_line("M0004!")  # activates size dist mode
            self._write_line("A0002!")  # activates the antispikes

            if self._OUTPUT_PULSE_DIAGNOSTICS:
                self._write_line("opd01!")
                self._data_structure.update(
                    PARTECTOR2_OUTPUT_PULSE_DIAGNOSTIC_ADDITIONAL_DATA_STRUCTURE
                )
            else:
                self._write_line("opd00!")

            if self._GAIN_TEST_ACTIVE:
                self._write_line("h2001!")  # activates harmonics output
                self._write_line("e1100!")  # strength of gain test signal
                self._data_structure.update(PARTECTOR2_GAIN_TEST_ADDITIONAL_DATA_STRUCTURE)
            else:
                self._write_line("h2000!")  # deactivates harmonics output
                self._write_line("e0000!")  # deactivates gain test signal