-
Notifications
You must be signed in to change notification settings - Fork 11
SPMMicroscope class and SPM_Scan sub-device #131
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
Open
Slautin
wants to merge
13
commits into
main
Choose a base branch
from
boris_instrument
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
4c432a8
Merge pull request #124 from pycroscopy/main
Slautin 8ff9cc6
Merge pull request #130 from pycroscopy/main
Slautin 047c225
SPMMicroscope_class_basic_setup0
Slautin e612235
SPMMicroscope&Scandevice
Slautin 9db46b4
scan_and_approach
Slautin 3f83731
del_old_scan
Slautin 03e9053
abstract_devices_feedback_scan_stage
Slautin 1024fd3
Merge pull request #144 from pycroscopy/main
Slautin 7f576a2
outcome format correction and finalising abstrations
Slautin c2d2d53
Merge pull request #169 from pycroscopy/main
Slautin 3ae1fba
jupiter_api_blank
Slautin 5fb5061
feat(spm): Jupiter adapter + fixes to run the SPM stack for the first…
Slautin c9fd725
multiple_updates to the jupiter_api scan device
Slautin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
114 changes: 114 additions & 0 deletions
114
asyncroscopy/instruments/scanning_probe_microscope/hardware/spm_approach.py
This file contains hidden or 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,114 @@ | ||
| """ | ||
| SPM APPROACH Tango device. | ||
|
|
||
| Owns the tip approach/retract sequence. Vendor-specific behaviour is | ||
| isolated in the ``_hw_*`` hooks implemented by concrete subclasses | ||
| (APPROACH_Jupiter, etc.). | ||
| """ | ||
|
|
||
| from abc import abstractmethod | ||
|
|
||
| import tango | ||
| from asyncroscopy.instruments.instrument import CombinedMeta | ||
|
|
||
| class SPM_APPROACH(tango.server.Device, metaclass=CombinedMeta): | ||
| """Abstract SPM approach device: tip engage / retract.""" | ||
|
|
||
| # ------------------------------------------------------------------ | ||
| # Attributes | ||
| # ------------------------------------------------------------------ | ||
|
|
||
| approached = tango.server.attribute( | ||
| label="Approached", | ||
| dtype=bool, | ||
| access=tango.AttrWriteType.READ, | ||
| doc="True when the tip is engaged on the surface. Read live from hardware.", | ||
| ) | ||
|
|
||
|
|
||
| # ------------------------------------------------------------------ | ||
| # Initialization | ||
| # ------------------------------------------------------------------ | ||
|
|
||
| def init_device(self) -> None: | ||
| tango.server.Device.init_device(self) | ||
| self.set_state(tango.DevState.ON) | ||
| self.info_stream("SPM APPROACH device initialised") | ||
|
|
||
| # ------------------------------------------------------------------ | ||
| # Attribute read | ||
| # ------------------------------------------------------------------ | ||
|
|
||
| def read_approached(self) -> bool: | ||
| return self._hw_is_approached() | ||
|
|
||
| # ------------------------------------------------------------------ | ||
| # Commands | ||
| # ------------------------------------------------------------------ | ||
|
|
||
| @tango.server.command | ||
| def approach(self) -> None: | ||
| """Engage the tip on the surface. Blocks until engaged.""" | ||
| if self.get_state() == tango.DevState.MOVING: | ||
| tango.Except.throw_exception( | ||
| "ApproachInProgress", | ||
| "An approach or retract is already running; call stop first.", | ||
| "approach()", | ||
| ) | ||
| self.set_state(tango.DevState.MOVING) | ||
| try: | ||
| self._hw_approach() | ||
| finally: | ||
| self.set_state(tango.DevState.ON) | ||
|
|
||
| @tango.server.command | ||
| def retract(self) -> None: | ||
| """Retract the tip from the surface. Blocks until retracted.""" | ||
| if self.get_state() == tango.DevState.MOVING: | ||
| tango.Except.throw_exception( | ||
| "ApproachInProgress", | ||
| "An approach or retract is already running; call stop first.", | ||
| "retract()", | ||
| ) | ||
| self.set_state(tango.DevState.MOVING) | ||
| try: | ||
| self._hw_retract() | ||
| finally: | ||
| self.set_state(tango.DevState.ON) | ||
|
|
||
| @tango.server.command | ||
| def stop(self) -> None: | ||
| """Abort a running approach or retract immediately.""" | ||
| self._hw_stop() | ||
| self.set_state(tango.DevState.ON) | ||
|
|
||
| # ------------------------------------------------------------------ | ||
| # Abstract methods — vendor-specific | ||
| # ------------------------------------------------------------------ | ||
|
|
||
| @abstractmethod | ||
| def _hw_approach(self) -> None: | ||
| """Run the approach sequence; return when the tip is engaged.""" | ||
| pass | ||
|
|
||
| @abstractmethod | ||
| def _hw_retract(self) -> None: | ||
| """Retract the tip; return when clear of the surface.""" | ||
| pass | ||
|
|
||
| @abstractmethod | ||
| def _hw_stop(self) -> None: | ||
| """Abort any running approach/retract motion.""" | ||
| pass | ||
|
|
||
| @abstractmethod | ||
| def _hw_is_approached(self) -> bool: | ||
| """Return True if the tip is currently engaged.""" | ||
| pass | ||
|
|
||
| # ---------------------------------------------------------------------- | ||
| # Server entry point | ||
| # ---------------------------------------------------------------------- | ||
| if __name__ == "__main__": | ||
| SPM_APPROACH.run_server() | ||
|
|
||
140 changes: 140 additions & 0 deletions
140
asyncroscopy/instruments/scanning_probe_microscope/hardware/spm_feedback.py
This file contains hidden or 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,140 @@ | ||
| """ | ||
| SPM FEEDBACK Tango device. | ||
|
|
||
| Owns the Z feedback loop: setpoint, gains, and engage/withdraw. | ||
|
|
||
| Note: the physical meaning of ``setpoint`` depends on the active SPM | ||
| mode (deflection volts in contact, amplitude volts in AC, etc.); this | ||
| device passes the value through without interpreting it. | ||
| """ | ||
|
|
||
| from abc import abstractmethod | ||
| import tango # type: ignore | ||
|
|
||
| from asyncroscopy.instruments.instrument import CombinedMeta | ||
|
|
||
| class SPM_FEEDBACK(tango.server.Device, metaclass=CombinedMeta): | ||
| """Abstract SPM feedback device: Z loop setpoint, gains, engage state.""" | ||
|
|
||
| # ------------------------------------------------------------------ | ||
| # Attributes | ||
| # ------------------------------------------------------------------ | ||
|
|
||
| setpoint = tango.server.attribute( | ||
| label="Setpoint", | ||
| dtype=float, | ||
| access=tango.AttrWriteType.READ_WRITE, | ||
| doc="Z feedback setpoint. Physical meaning depends on the active SPM mode " | ||
| "(deflection in contact, amplitude in AC).", | ||
| ) | ||
|
|
||
| i_gain = tango.server.attribute( | ||
| label="Integral Gain", | ||
| dtype=float, | ||
| access=tango.AttrWriteType.READ_WRITE, | ||
| doc="Integral gain of the Z feedback loop.", | ||
| ) | ||
|
|
||
| feedback_on_bool = tango.server.attribute( | ||
| label="Feedback On", | ||
| dtype=bool, | ||
| access=tango.AttrWriteType.READ, | ||
| doc="True when the Z feedback loop is engaged. Read live from hardware.", | ||
| ) | ||
|
|
||
| # ------------------------------------------------------------------ | ||
| # Initialization | ||
| # ------------------------------------------------------------------ | ||
| def init_device(self) -> None: | ||
| tango.server.Device.init_device(self) | ||
| self._refresh_params() | ||
| self.set_state(tango.DevState.ON) | ||
| self.info_stream("SPM FEEDBACK device initialised") | ||
|
|
||
| # ------------------------------------------------------------------ | ||
| # Internal helpers | ||
| # ------------------------------------------------------------------ | ||
|
|
||
| def _refresh_params(self) -> None: | ||
| """Re-read all feedback parameters from hardware into local fields.""" | ||
| params = self._hw_read_feedback_params() | ||
| self._setpoint: float = params["setpoint"] | ||
| self._i_gain: float = params["i_gain"] | ||
|
|
||
| def _write_param(self, name: str, value) -> None: | ||
| """Push one parameter to hardware, then re-read all (hardware may coerce values).""" | ||
| self._hw_write_feedback_param(name, value) | ||
| self._refresh_params() | ||
|
|
||
| # ------------------------------------------------------------------ | ||
| # Attribute read / write — writes pushed to hardware | ||
| # ------------------------------------------------------------------ | ||
|
|
||
| def read_setpoint(self) -> float: | ||
| return self._setpoint | ||
|
|
||
| def write_setpoint(self, value: float) -> None: | ||
| self._write_param("setpoint", value) | ||
|
|
||
| def read_i_gain(self) -> float: | ||
| return self._i_gain | ||
|
|
||
| def write_i_gain(self, value: float) -> None: | ||
| self._write_param("i_gain", value) | ||
|
|
||
| def read_feedback_on_bool(self) -> bool: | ||
| return self._hw_is_feedback_on() | ||
|
|
||
| # ------------------------------------------------------------------ | ||
| # Commands | ||
| # ------------------------------------------------------------------ | ||
|
|
||
| @tango.server.command | ||
| def feedback_on(self) -> None: | ||
| """Engage the Z feedback loop.""" | ||
| self._hw_feedback_on() | ||
|
|
||
| @tango.server.command | ||
| def feedback_off(self) -> None: | ||
| """Disengage the Z feedback loop.""" | ||
| self._hw_feedback_off() | ||
|
|
||
| @tango.server.command | ||
| def refresh_params(self) -> None: | ||
| """Re-read all feedback parameters from hardware, e.g. after changes in the vendor GUI.""" | ||
| self._refresh_params() | ||
|
|
||
| # ------------------------------------------------------------------ | ||
| # Abstract methods — vendor-specific | ||
| # ------------------------------------------------------------------ | ||
|
Comment on lines
+107
to
+109
Collaborator
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. Similar comment as done on - https://github.com/pycroscopy/asyncroscopy/pull/131/changes#r3691417522 |
||
|
|
||
| @abstractmethod | ||
| def _hw_read_feedback_params(self) -> dict: | ||
| """Read all feedback parameters from hardware. Keys must match attribute names.""" | ||
| pass | ||
|
|
||
| @abstractmethod | ||
| def _hw_write_feedback_param(self, name: str, value) -> None: | ||
| """Push one feedback parameter to hardware.""" | ||
| pass | ||
|
|
||
| @abstractmethod | ||
| def _hw_feedback_on(self) -> None: | ||
| """Engage the Z feedback loop.""" | ||
| pass | ||
|
|
||
| @abstractmethod | ||
| def _hw_feedback_off(self) -> None: | ||
| """Disengage the Z feedback loop.""" | ||
| pass | ||
|
|
||
| @abstractmethod | ||
| def _hw_is_feedback_on(self) -> bool: | ||
| """Return True if the Z feedback loop is currently engaged.""" | ||
| pass | ||
|
|
||
| # ---------------------------------------------------------------------- | ||
| # Server entry point | ||
| # ---------------------------------------------------------------------- | ||
| if __name__ == "__main__": | ||
| SPM_FEEDBACK.run_server() | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Similar comment as done on - https://github.com/pycroscopy/asyncroscopy/pull/131/changes#r3691417522