|
| 1 | +""" |
| 2 | +Scan modifier plugin for {{ project_name }}. |
| 3 | + |
| 4 | +The scan modifier allows you to modify the scan lifecycle and run custom actions before or after the scan hook or replace the scan hook entirely. |
| 5 | +Note that the scan_modifier module must be registered as a plugin in the pyproject.toml file for it to be recognized by the BEC framework and that |
| 6 | +there can only be one scan_modifier plugin registered at a time. If you need to run multiple scan modifiers, you can create a single scan |
| 7 | +modifier plugin that runs multiple actions in sequence with conditional logic to determine which actions to run based on the scan context. |
| 8 | +""" |
| 9 | + |
| 10 | +from bec_server.scan_server.scans.scan_modifier import ScanModifier, scan_hook_impl |
| 11 | + |
| 12 | +{% set project_name_pascal = project_name|replace("_", " ")|title|replace(" ", "") %} |
| 13 | +class {{ project_name_pascal }}ScanModifier(ScanModifier): |
| 14 | + """ |
| 15 | + Scan modifier for {{ project_name }}. |
| 16 | + |
| 17 | + By inheriting from the ScanModifier base class, you get access to currently running scan (self.scan), the devices (self.dev), the scan info (self.scan_info), |
| 18 | + the scan components (self.components) and the scan actions (self.actions). |
| 19 | + """ |
| 20 | + |
| 21 | + def __init__(self, **kwargs): |
| 22 | + """Initialize the scan modifier.""" |
| 23 | + super().__init__(**kwargs) |
| 24 | + |
| 25 | + # Example of running code before the scan stage for a specific scan |
| 26 | + # @scan_hook_impl("stage", "before") |
| 27 | + # def before_stage(self): |
| 28 | + # """Run before the stage hook.""" |
| 29 | + # self.actions.send_client_info("Custom stage logic executed by ScanModifier.") |
| 30 | + # if self.scan_info.scan_name == "example_scan": |
| 31 | + # self.dev.samx.set(20) |
| 32 | + |
| 33 | + |
0 commit comments