-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add abort api #194
Add abort api #194
Changes from all commits
043029f
23b842a
ad5e86f
aeaa32b
812e5df
bf0ee8b
fdebb69
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -141,6 +141,16 @@ async def calibrate(name: str, data: dict = None): | |
return calibrator.run_calibration_procedure(data) # TODO: or **data? | ||
|
||
|
||
@app.post("/abort") | ||
async def abort(): | ||
app.state.evolver.abort() | ||
# Disable commit also in persistent config in case application needs to restart | ||
config = Evolver.Config.load(app_settings.CONFIG_FILE) | ||
config.enable_control = False | ||
config.enable_commit = False | ||
config.save(app_settings.CONFIG_FILE) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this mean that whilst the user can hit this endpoint to stop the control, they have to use the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think this is a sufficient user interface and have opened #198 to add a "start" endpoint. |
||
|
||
|
||
app.mount("/html", html_app) | ||
|
||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,3 +34,8 @@ def from_brightness(brightness): | |
with self.serial as comm: | ||
comm.communicate(SerialData(addr=self.addr, data=cmd)) | ||
self.committed = inputs | ||
|
||
def off(self): | ||
cmd = [b"0"] * self.slots | ||
with self.serial as comm: | ||
comm.communicate(SerialData(addr=self.addr, data=cmd)) | ||
Comment on lines
+39
to
+41
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This looks like more than just abort code, as mentioned before, couldn't this go in another abstractmethod named, e.g., "reset", "idle", "off", or "init", etc, that then Looks to me like these should be called upon initialization as a way for controlling a baseline on the hardware's physical state. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe the above is what it takes to abort the operation of the device. Do you mean like naming it There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not entirely, but kinda yeah, I meant that we both mentioned in #197 it might be desirable to exec these commands upon initial startup, in which case it's not really an "abort" but more of a ground/rest/init/off state. Technically it's not aborting anything as we have to actually send a commit to command the hardware to some state. Either way, I didn't mean anything complicated just something like the following: class HardwareDriver(...):
@abstractmethod
def init(self, *args, **kwargs): # could be called "reset"
""" Implement to command hardware to its ground/off state. This could be called upon startup/abort."""
...
def abort(self):
self.init() There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually the device abort does send the command directly, no commit required. I'm not sure yet what we will do at startup, but I can definitely rename the device method to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've renamed driver method to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I only meant that it still has to send a command period and not just block subsequent commands. That these hardware methods don't alter the config, they themselves don't "block" future commanding at all etc, and that they are in fact completely oblivious to this concept (at least they should be). They only alter the hardware to some specific state, a state in this instance that is encoded in the semantics of this function name - which isn't "abort".
Agreed, and
At the same time, however, this isn't entirely true due to the significant (1-2s) latency per call and the fact that these are turned off in sequence rather than proposals being |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI I've opened #199 for us to also consider aborting the read.