Skip to content

Commit

Permalink
#12: Add doctrings for ivar set/getters
Browse files Browse the repository at this point in the history
  • Loading branch information
MattPrit committed Sep 5, 2022
1 parent 06d79cb commit f2085fc
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions tickit_devices/pmac/pmac.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,37 +116,72 @@ 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
return f"{self.device.system_ivars[ivar]}\r".encode()

@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
return f"{self.device.axes[axis].ivars[ivar]}\r".encode()

@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
return f"{self.device.other_ivars[ivar]}\r".encode()

@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"

Expand Down

0 comments on commit f2085fc

Please sign in to comment.