Skip to content

Commit

Permalink
Adds "secure" and "set_plate_lock" methods.
Browse files Browse the repository at this point in the history
  • Loading branch information
ChiliJohnson committed Nov 8, 2020
1 parent 4a46a9d commit ca0cec1
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
1 change: 1 addition & 0 deletions asitiger/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class Command:
MOVE = "M"
MOVREL = "R"
RDSTAT = "RS"
SECURE = "SECURE"
SETHOME = "HM"
SPEED = "S"
STATUS = "/"
Expand Down
14 changes: 14 additions & 0 deletions asitiger/secure.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from enum import Enum
from typing import Union


class SecurePosition(Enum):
LOCKED = 0
UNLOCKED = 1

@classmethod
def resolve_value(cls, position: Union["SecurePosition", int, float]):
if isinstance(position, cls):
return position.value

return position
15 changes: 15 additions & 0 deletions asitiger/tigercontroller.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from asitiger.axis import Axis
from asitiger.command import Command
from asitiger.errors import Errors
from asitiger.secure import SecurePosition
from asitiger.serialconnection import SerialConnection
from asitiger.status import AxisStatus, Status, statuses_for_rdstat

Expand Down Expand Up @@ -73,6 +74,13 @@ def enable_axes(self, axes: List[str]):
def disable_axes(self, axes: List[str]):
self.motor_control({axis: "-" for axis in axes})

def set_plate_lock(
self, position: Union[SecurePosition, float], card_address: int = None
):
return self.secure(
{"X": SecurePosition.resolve_value(position)}, card_address=card_address
)

# The methods below map directly onto the Tiger serial API methods

def build(self, card_address: int = None) -> List[str]:
Expand Down Expand Up @@ -112,6 +120,13 @@ def rdstat(self, axes: List[str]) -> List[Union[AxisStatus, Status]]:
response = self.send_command(f"{Command.RDSTAT} {' '.join(axes)}")
return statuses_for_rdstat(response)

def secure(
self, settings: Dict[str, Union[int, float, str]], card_address: int = None,
):
self.send_command(
Command.format(Command.SECURE, settings, card_address=card_address)
)

def set_home(self, axes: Dict[str, Union[str, int]]) -> str:
return self.send_command(
Command.format(Command.SETHOME, coordinates=axes, flag_overrides=["+"])
Expand Down

0 comments on commit ca0cec1

Please sign in to comment.