From f2085fc412905fff51b476435fac7e1b5b5ee389 Mon Sep 17 00:00:00 2001 From: Matthew Pritchard Date: Mon, 5 Sep 2022 18:06:08 +0100 Subject: [PATCH] #12: Add doctrings for ivar set/getters --- tickit_devices/pmac/pmac.py | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/tickit_devices/pmac/pmac.py b/tickit_devices/pmac/pmac.py index 759d7106..2fd3b5ee 100644 --- a/tickit_devices/pmac/pmac.py +++ b/tickit_devices/pmac/pmac.py @@ -116,6 +116,11 @@ async def m_var(self): @RegexCommand(rb"[iI]([0-9]{1,2})\r?\n?") async def read_system_ivar(self, ivar: int): + """Regex bytestring command that returns the value of a specific system ivar. + + Args: + ivar (int): the ivar to read. + """ value = self.device.system_ivars.get(ivar, None) if value is None: self.device.system_ivars[ivar] = 0 @@ -123,11 +128,23 @@ async def read_system_ivar(self, ivar: int): @RegexCommand(rb"[iI]([0-9]{1,2})=\$?(\d+(?:.\d+)?)\r?\n?") async def write_system_ivar(self, ivar: int, value: float): + """Regex bytestring command that sets the value of a specific system ivar. + + Args: + ivar (int): the ivar to set. + value (float): the value to set the ivar to. + """ self.device.system_ivars[ivar] = value return b"\r" @RegexCommand(rb"[iI]([0-9])([0-9]{2})\r?\n?") async def read_axis_var(self, axis: int, ivar: int): + """Regex bytestring command that returns the value of a specific axis ivar. + + Args: + axis (int): the axis to read ivars from. + ivar (int): the ivar to read. + """ value = self.device.axes[axis].ivars.get(ivar, None) if value is None: self.device.axes[axis].ivars[ivar] = 0 @@ -135,11 +152,23 @@ async def read_axis_var(self, axis: int, ivar: int): @RegexCommand(rb"[iI]([0-9])([0-9]{2})=-?(\d+(?:.\d+)?)\r?\n?") async def write_axis_ivar(self, axis: int, ivar: int, value: float): + """Regex bytestring command that sets the value of a specific axis ivar. + + Args: + axis (int): the axis to set ivars on. + ivar (int): the ivar to set. + value (float): the value to set the ivar to. + """ self.device.axes[axis].ivars[ivar] = value return b"\r" @RegexCommand(rb"[iI]([0-9]{4})\r?\n?") async def read_other_ivar(self, ivar: int): + """Regex bytestring command that returns the value of a specific ivar. + + Args: + ivar (int): the ivar to read. + """ value = self.device.other_ivars.get(ivar, None) if value is None: self.device.other_ivars[ivar] = 0 @@ -147,6 +176,12 @@ async def read_other_ivar(self, ivar: int): @RegexCommand(rb"[iI]([0-9]{4})=-?(\d+(?:\.\d+)?)\r?\n?") async def write_other_var(self, ivar: int, value: float): + """Regex bytestring command that sets the value of a specific ivar. + + Args: + ivar (int): the ivar to set. + value (float): the value to set the ivar to. + """ self.device.other_ivars[ivar] = value return b"\r"