flexPTP-test/FlexPtpController.py
András Wiesner cdbec108cb GUI...
2026-04-27 21:47:57 +02:00

55 lines
1.9 KiB
Python

from DeviceInterface import DeviceInterface
class FlexPtpController:
def __init__(self, di: DeviceInterface) -> None:
self.__di = di
pass
def reset_flexptp(self) -> None:
self.__di.execute_command("ptp reset")
def start_e2e_udp(self) -> None:
self.__di.execute_command("ptp profile preset default")
def start_p2p_udp(self) -> None:
self.__di.execute_command("ptp profile preset defp2p")
def start_e2e_l2(self) -> None:
self.__di.execute_command("ptp profile preset default")
self.__di.execute_command("ptp transport 802.3")
self.reset_flexptp()
def start_p2p_l2(self) -> None:
self.__di.execute_command("ptp profile preset defp2p")
self.__di.execute_command("ptp transport 802.3")
self.reset_flexptp()
def start_gPTP(self) -> None:
self.__di.execute_command("ptp profile preset gPTP")
def start_by_id(self, id: str) -> None:
id = id.replace("_", "").upper()
if id == "E2EL4":
self.start_e2e_udp()
elif id == "E2EL2":
self.start_e2e_l2()
elif id == "P2PL4":
self.start_p2p_udp()
elif id == "P2PL2":
self.start_p2p_l2()
elif id == "GPTP":
self.start_gPTP()
def set_priority(self, priority1: int, priority2: int) -> None:
self.__di.execute_command("ptp priority {:d} {:d}".format(priority1, priority2))
def set_domain(self, domain: int) -> None:
self.__di.execute_command("ptp domain {:d}".format(domain))
def disable_all_logging(self) -> None:
logging_types = [ "def", "corr", "ts", "info", "locked", "bmca" ]
for lt in logging_types:
self.__di.execute_command("ptp log " + lt + " off", expect_results=False)
def set_servo_offset(self, offset: int) -> None:
self.__di.execute_command("ptp servo offset {:d}".format(offset))