Skip to content

Commit

Permalink
formatted with black
Browse files Browse the repository at this point in the history
  • Loading branch information
lrlunin committed Apr 25, 2024
1 parent 37a56fe commit a65e542
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 28 deletions.
47 changes: 21 additions & 26 deletions tangods_phymotion/PhyMotionAxis.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,7 @@
import time


_MOVEMENT_UNITS = [
"steps",
"mm",
"inch",
"degree"
]
_MOVEMENT_UNITS = ["steps", "mm", "inch", "degree"]

_PHY_AXIS_STATUS_CODES = [
"Axis busy", # 0
Expand Down Expand Up @@ -185,8 +180,8 @@ class PhyMotionAxis(Device):
"NCC NOC NCC",
"NCC NOC NOC",
"NOC NOC NCC",
"NOC NOC NOC"
],
"NOC NOC NOC",
],
label="limit switch type",
access=AttrWriteType.READ_WRITE,
display_level=DispLevel.EXPERT,
Expand Down Expand Up @@ -217,7 +212,7 @@ class PhyMotionAxis(Device):
"1/64",
"1/128",
"1/256",
],
],
label="step resolution",
access=AttrWriteType.READ_WRITE,
display_level=DispLevel.EXPERT,
Expand All @@ -238,7 +233,7 @@ class PhyMotionAxis(Device):
"rotational",
"linear hw limit",
"linear sw limit",
"linear hw+sw limit"
"linear hw+sw limit",
],
label="type of movement",
access=AttrWriteType.READ_WRITE,
Expand Down Expand Up @@ -279,7 +274,7 @@ def inner(self, value):

def init_device(self):
super().init_device()
self.info_stream("init_device()")
self.info_stream("init_device()")
self.set_state(DevState.INIT)
self.info_stream("module axis: {:d}".format(self.Axis))

Expand All @@ -299,8 +294,8 @@ def init_device(self):
self.read_all_parameters()
# update units and formatting
self.set_display_unit(
unit=_MOVEMENT_UNITS[int(self._all_parameters['P02R'])-1],
steps_per_unit=1/float(self._all_parameters['P03R'])
unit=_MOVEMENT_UNITS[int(self._all_parameters["P02R"]) - 1],
steps_per_unit=1 / float(self._all_parameters["P03R"]),
)

self.set_state(DevState.ON)
Expand Down Expand Up @@ -429,27 +424,27 @@ def write_inverted(self, value):
self._inverted = bool(value)

def read_acceleration(self):
return int(self._all_parameters["P15R"])*float(self._all_parameters["P03R"])
return int(self._all_parameters["P15R"]) * float(self._all_parameters["P03R"])

@update_parameters
def write_acceleration(self, value):
acceleration = int(value/float(self._all_parameters["P03R"]))
acceleration = int(value / float(self._all_parameters["P03R"]))
self.send_cmd("P15S{:d}".format(acceleration))

def read_velocity(self):
return int(self._all_parameters["P14R"])*float(self._all_parameters["P03R"])
return int(self._all_parameters["P14R"]) * float(self._all_parameters["P03R"])

@update_parameters
def write_velocity(self, value):
velocity = int(value/float(self._all_parameters["P03R"]))
velocity = int(value / float(self._all_parameters["P03R"]))
self.send_cmd("P14S{:d}".format(velocity))

def read_homing_velocity(self):
return int(self._all_parameters["P08R"])*float(self._all_parameters["P03R"])
return int(self._all_parameters["P08R"]) * float(self._all_parameters["P03R"])

@update_parameters
def write_homing_velocity(self, value):
velocity = int(value/float(self._all_parameters["P03R"]))
velocity = int(value / float(self._all_parameters["P03R"]))
self.send_cmd("P08S{:d}".format(velocity))

def read_run_current(self):
Expand Down Expand Up @@ -482,11 +477,11 @@ def read_steps_per_unit(self):
@update_parameters
def write_steps_per_unit(self, value):
# inverse of spindle pitch (see manual page 77)
self.send_cmd("P03S{:10.8f}".format(1/value))
self.send_cmd("P03S{:10.8f}".format(1 / value))
self.set_display_unit(
unit=_MOVEMENT_UNITS[int(self._all_parameters['P02R'])-1],
steps_per_unit=value
)
unit=_MOVEMENT_UNITS[int(self._all_parameters["P02R"]) - 1],
steps_per_unit=value,
)

def read_step_resolution(self):
return int(self._all_parameters["P45R"])
Expand Down Expand Up @@ -518,15 +513,15 @@ def write_type_of_movement(self, value):
self.send_cmd("P01S{:d}".format(int(value)))

def read_movement_unit(self):
return int(self._all_parameters["P02R"])-1
return int(self._all_parameters["P02R"]) - 1

@update_parameters
def write_movement_unit(self, value):
self.send_cmd("P02S{:d}".format(int(value) + 1))
self.set_display_unit(
unit=_MOVEMENT_UNITS[value],
steps_per_unit=1/float(self._all_parameters['P03R'])
)
steps_per_unit=1 / float(self._all_parameters["P03R"]),
)

# internal methods
def set_display_unit(self, unit="", steps_per_unit=0):
Expand Down
5 changes: 3 additions & 2 deletions tangods_phymotion/PhyMotionCtrl.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@ def init_device(self):
self.info_stream("Connected to {:s}:{:d}".format(self.Address, self.Port))
self.set_state(DevState.ON)
except Exception:
self.error_stream("Failed to open {:s}:{:d}".format(self.Address,
self.Port))
self.error_stream(
"Failed to open {:s}:{:d}".format(self.Address, self.Port)
)
self.set_state(DevState.FAULT)

def delete_device(self):
Expand Down

0 comments on commit a65e542

Please sign in to comment.