-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
652d30a
commit 9da5154
Showing
8 changed files
with
61 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,7 @@ | ||
# -*- coding: utf-8 -*- | ||
from __future__ import annotations | ||
|
||
from typing import Optional | ||
|
||
from pioreactor.automations import events | ||
from pioreactor.background_jobs.subjobs import BackgroundSubJob | ||
|
||
|
||
DISALLOWED_AUTOMATION_NAMES = { | ||
"config", | ||
} | ||
|
||
|
||
class BaseAutomationJob(BackgroundSubJob): | ||
automation_name = "base_automation_job" | ||
|
||
def __init__(self, unit: str, experiment: str) -> None: | ||
super(BaseAutomationJob, self).__init__(unit, experiment) | ||
|
||
if self.automation_name in DISALLOWED_AUTOMATION_NAMES: | ||
raise NameError(f"{self.automation_name} is not allowed.") | ||
|
||
self.add_to_published_settings( | ||
"latest_event", | ||
{ | ||
"datatype": "AutomationEvent", | ||
"settable": False, | ||
}, | ||
) | ||
|
||
def on_init_to_ready(self) -> None: | ||
self.start_passive_listeners() | ||
|
||
def execute(self) -> Optional[events.AutomationEvent]: | ||
""" | ||
Overwrite in subclass | ||
""" | ||
return events.NoEvent() | ||
from . import dosing | ||
from . import events | ||
from . import led | ||
from . import temperature |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# -*- coding: utf-8 -*- | ||
from __future__ import annotations | ||
|
||
from typing import Optional | ||
|
||
from pioreactor.automations import events | ||
from pioreactor.background_jobs.subjobs import BackgroundSubJob | ||
|
||
|
||
DISALLOWED_AUTOMATION_NAMES = { | ||
"config", | ||
} | ||
|
||
|
||
class AutomationJob(BackgroundSubJob): | ||
automation_name = "automation_job" | ||
|
||
def __init__(self, unit: str, experiment: str) -> None: | ||
super(AutomationJob, self).__init__(unit, experiment) | ||
|
||
if self.automation_name in DISALLOWED_AUTOMATION_NAMES: | ||
raise NameError(f"{self.automation_name} is not allowed.") | ||
|
||
self.add_to_published_settings( | ||
"latest_event", | ||
{ | ||
"datatype": "AutomationEvent", | ||
"settable": False, | ||
}, | ||
) | ||
|
||
def on_init_to_ready(self) -> None: | ||
self.start_passive_listeners() | ||
|
||
def execute(self) -> Optional[events.AutomationEvent]: | ||
""" | ||
Overwrite in subclass | ||
""" | ||
return events.NoEvent() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters