Implemented root API v2 routes
This commit is contained in:
parent
5aa783c269
commit
6581612312
27 changed files with 1205 additions and 148 deletions
|
|
@ -14,22 +14,22 @@ class BaseStage(metaclass=ABCMeta):
|
|||
self.lock = StrictLock(timeout=5)
|
||||
|
||||
@abstractmethod
|
||||
def apply_config(self, config: dict):
|
||||
def apply_settings(self, config: dict):
|
||||
"""Update settings from a config dictionary"""
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def read_config(self):
|
||||
def read_settings(self):
|
||||
"""Return the current settings as a dictionary"""
|
||||
pass
|
||||
|
||||
def save_config(self):
|
||||
def save_settings(self):
|
||||
"""(Optional) Save any settings to disk that need to be stored"""
|
||||
return
|
||||
|
||||
@property
|
||||
@abstractmethod
|
||||
def state(self):
|
||||
def status(self):
|
||||
"""The general state dictionary of the board.
|
||||
Should at least contain 'position', and 'board' keys.
|
||||
Note: A None/Null value for 'board' will disable stage
|
||||
|
|
|
|||
|
|
@ -16,9 +16,9 @@ class MockStage(BaseStage):
|
|||
self.axis_names = ["x", "y", "z"] # Assume all sangaboards are 3 axis
|
||||
|
||||
@property
|
||||
def state(self):
|
||||
"""The general state dictionary of the board."""
|
||||
state = {
|
||||
def status(self):
|
||||
"""The general status dictionary of the board."""
|
||||
status = {
|
||||
"position": {
|
||||
"x": self.position[0],
|
||||
"y": self.position[1],
|
||||
|
|
@ -27,9 +27,9 @@ class MockStage(BaseStage):
|
|||
"board": None,
|
||||
"version": "0",
|
||||
}
|
||||
return state
|
||||
return status
|
||||
|
||||
def apply_config(self, config: dict):
|
||||
def apply_settings(self, config: dict):
|
||||
"""Update settings from a config dictionary"""
|
||||
|
||||
# Set backlash. Expects a dictionary with axis labels
|
||||
|
|
@ -38,7 +38,7 @@ class MockStage(BaseStage):
|
|||
backlash = axes_to_array(config["backlash"], ["x", "y", "z"], [0, 0, 0])
|
||||
self.backlash = backlash
|
||||
|
||||
def read_config(self) -> dict:
|
||||
def read_settings(self) -> dict:
|
||||
"""Return the current settings as a dictionary"""
|
||||
blsh = self.backlash.tolist()
|
||||
config = {"backlash": {"x": blsh[0], "y": blsh[1], "z": blsh[2]}}
|
||||
|
|
|
|||
|
|
@ -31,9 +31,9 @@ class SangaStage(BaseStage):
|
|||
self.axis_names = ["x", "y", "z"] # Assume all sangaboards are 3 axis
|
||||
|
||||
@property
|
||||
def state(self):
|
||||
"""The general state dictionary of the board."""
|
||||
state = {
|
||||
def status(self):
|
||||
"""The general status dictionary of the board."""
|
||||
status = {
|
||||
"position": {
|
||||
"x": self.position[0],
|
||||
"y": self.position[1],
|
||||
|
|
@ -42,7 +42,7 @@ class SangaStage(BaseStage):
|
|||
"board": self.board.board,
|
||||
"firmware": self.board.firmware,
|
||||
}
|
||||
return state
|
||||
return status
|
||||
|
||||
@property
|
||||
def n_axes(self):
|
||||
|
|
@ -85,7 +85,7 @@ class SangaStage(BaseStage):
|
|||
else:
|
||||
self._backlash = np.array([int(blsh)] * self.n_axes, dtype=np.int)
|
||||
|
||||
def apply_config(self, config: dict):
|
||||
def apply_settings(self, config: dict):
|
||||
"""Update settings from a config dictionary"""
|
||||
|
||||
# Set backlash. Expects a dictionary with axis labels
|
||||
|
|
@ -94,7 +94,7 @@ class SangaStage(BaseStage):
|
|||
backlash = axes_to_array(config["backlash"], ["x", "y", "z"], [0, 0, 0])
|
||||
self.backlash = backlash
|
||||
|
||||
def read_config(self) -> dict:
|
||||
def read_settings(self) -> dict:
|
||||
"""Return the current settings as a dictionary"""
|
||||
blsh = self.backlash.tolist()
|
||||
config = {"backlash": {"x": blsh[0], "y": blsh[1], "z": blsh[2]}}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue