Skip to content

Convert DAQ from NIDAQ.jl to DAQmx.jl#46

Merged
kalidke merged 14 commits intomainfrom
convert-nidaqmx
Mar 5, 2026
Merged

Convert DAQ from NIDAQ.jl to DAQmx.jl#46
kalidke merged 14 commits intomainfrom
convert-nidaqmx

Conversation

@kalidke
Copy link
Copy Markdown
Member

@kalidke kalidke commented Mar 5, 2026

Summary

  • Convert DAQ dependency from old NIDAQ.jl to DAQmx.jl (renamed to avoid copyright issues)
  • Refactor export system using Reexport.jl to simplify MicroscopeControl.jl from ~80 lines to ~30
  • Add [sources] for DAQmx since it's not in General registry (requires Julia 1.11+)
  • Fix camera image permutation to (H, W, N) convention, ThorCam mono mode, Makie deprecations
  • Add AbstractSystem interface and error handling for laser/DAQ modules

Test plan

  • Pkg.test() passes with simulated devices
  • Verify using MicroscopeControl loads cleanly with Reexport
  • Confirm DAQmx resolves from GitHub URL via [sources]

🤖 Generated with Claude Code

kalidke and others added 14 commits January 29, 2026 13:05
- Add AbstractSystem and AbstractSystemState types to instrument.jl
- Export get_state, set_state for system interface
- Fix armcamera duplicate method in ThorCamCSC (remove default argument)
- Fix CrystaLaser constructor: handle missing NI-DAQ gracefully
- Fix VortranLaser constructor: handle missing NI-DAQ gracefully
- Both laser constructors now use try-catch and validate device list

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Constructor now validates device index before accessing
- All interface methods check for empty channels before use
- Warnings instead of crashes when hardware unavailable

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- VortranLaser: wrap all DAQ operations in try-catch, check channel counts
- CrystaLaser: wrap all DAQ operations in try-catch, check for empty channels
- Shutdown now completes gracefully even when hardware unavailable

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add permutedims after reshape in all camera getdata/getlastframe functions
  to convert from row-major C buffer to column-major Julia (H, W) arrays
- Fix array allocations to use (H, W, N) instead of (W, H, N)
- Add HDF5 metadata (dimension_order, dimension_labels, memory_layout)
  to make convention explicit for downstream readers
- Document convention in CLAUDE.md

Cameras fixed: DCAM4, SimCamera, ThorCamCSC, ThorCamDCx

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Replace the deprecated NIDAQ.jl package (v0.6) with the locally developed
NIDAQmx.jl package which provides better type safety, error handling, and
a more complete API.

Key changes:
- Update Project.toml dependencies (NIDAQ -> NIDAQmx)
- Update channelfunctions to use NIDAQmx API (ai_channels, ao_channels, etc.)
- Update taskfunctions to use typed task constructors (AITask, AOTask, etc.)
- Enhance createtask() to query device voltage ranges for compatibility
- Update setvoltage/readvoltage to use write_scalar/read_scalar with auto_start
- Add separate method signatures for AOTask/DOTask and AITask/DITask
- Update all consumer modules (CrystaLaser, VortranLaser, TransmissionDaq)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- ThorCam DCX: Use IS_CM_MONO8 instead of RGBA8 for grayscale camera
- ThorCam DCX: Change buffer type from Cchar to UInt8 for proper 0-255 range
- Fix Makie deprecation: resolution -> size in all GUI files
- Fix camera display permutation: (H,W) data needs permutedims for Makie
- Add exposure time tolerance check to avoid spurious warnings
- Update CLAUDE.md with image()/heatmap() display documentation

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Replace manual export propagation with Reexport.jl for cleaner module
structure. MicroscopeControl.jl reduced from 79 to 31 lines by removing
50+ manual exports and 15+ using statements.

Changes:
- Add Reexport.jl dependency
- HardwareInterfaces.jl: @reexport all interface modules
- HardwareImplementations.jl: @reexport all implementation modules
- MicroscopeControl.jl: @reexport both layers, remove manual exports

Adding new hardware now requires edits in only one place instead of three.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Package was renamed upstream.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Brings in Reexport.jl to simplify export propagation from submodules.
Resolved conflict: keep DAQmx (not old NIDAQ) + add Reexport dep.
Fixed CI checkout action back to v6.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Move NIDAQcard include before TCubeLaserControl since it depends on it.
Restore DAQmx to Project.toml after it was removed during manifest cleanup.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
DAQmx.jl is not in General registry, so [sources] is needed.
[sources] requires Julia 1.11+.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
When the live display window is closed, abort the camera and invoke an
optional on_close callback. This lets callers (e.g. MicroscopeAdapt)
hook in additional cleanup like turning off lasers and updating GUI.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@kalidke kalidke merged commit 28cc6ea into main Mar 5, 2026
0 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant