Repository navigation
Cookbook of device patterns, lot 2: vendor DLL (ctypes) and multi-axis controller - #25
Merged
Merged
Conversation
A simulated vendor library that behaves like a ctypes.CDLL, the ctypes driver on it, a multi-axis actuator and a 0D detector sharing one handle, an end of move reported by a callback from another thread, load_library and real calls to the C library of the system. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Tdiso1u1ZhikSutj2Qs5Cg
Windows writes /somewhere as \somewhere in the message. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Tdiso1u1ZhikSutj2Qs5Cg
PyMoDAQ only logs an exception raised by a plugin method. The recipes now emit a status (report_errors) before raising it again. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Tdiso1u1ZhikSutj2Qs5Cg
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Tdiso1u1ZhikSutj2Qs5Cg
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Tdiso1u1ZhikSutj2Qs5Cg
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Before: the cookbook (lot 1) showed text protocols (pymeasure, serial, VISA) but nothing for the most common way to drive an instrument: a C library (DLL, shared object) supplied by the manufacturer and called with
ctypes, and no recipe showed several axes of one controller in one plugin.After:
CookbookDll: a multi-axis actuator (X, Y, Z, the library numbers its axes 0 to 2) and a 0D detector that reads the positions. Leave the port toMOCKto run on the simulated library. Axes and detector share one library handle (same controller ID: the first is the master, the others are slaves).MockMotionLibrary(hardware/mock_dll_controller.py) is used exactly like a loadedctypes.CDLL, so the realctypescode of the driver (hardware/dll_controller.py) runs:argtypes/restype, an opaque handle received throughbyref, a structure, integer error codes turned into exceptions with the message of the library, and aCFUNCTYPEcallback kept alive in an attribute.user_condition_to_reach_target). The homing is not polled, somove_doneis called by the slot.load_library(hardware/native_library.py): names per platform, path from a setting or an environment variable,cdeclorstdcall, and an error that lists everything that was tried.hardware/system_library_demo.pycalls the real C library of the system (strlen,frexpwithbyref,qsortwith a Python callback) on Linux, macOS and Windows.hardware/, which the README says.How: tests in
tests/test_cookbook_dll.py(27): loading, the real system library, the simulated library, the driver (callback from another thread, stop, error codes, closed handle), and the plugins with the harness ofpymodaq.utils.plugin_testing(master and slave axes, detector sharing the controller, events of other axes ignored). The call into the system library is exercised on Linux by the shared CI; the Windows and macOS names are written but not run there yet (the shared tests workflow only runs on Ubuntu, the compatibility one also on Windows).check_pluginreports both new plugins ok.No change to PyMoDAQ itself. Builds on the merged lot 1.
Generated by Claude Code