Repository navigation
Misc fixes - #11
Merged
Merged
Misc fixes#11
Conversation
- Hub pointer: Initialize() now stores the parent hub once in hub_ and returns DEVICE_COMM_HUB_MISSING if there isn't one. Nothing calls GetParentHub() per frame any more. - Settings lock: a new settingsMutex_ guards exposure, ROI and Mode in their getters, setters and the Mode property handler. - Settings during a sequence: each frame takes a copy of the settings when it starts, so exposure and Mode changes apply from the next frame. The frame interval follows that frame's exposure, and InsertImage gets that frame's width and height. - ROI and snaps while capturing: SetROI and SnapImage both return DEVICE_CAMERA_BUSY_ACQUIRING during a sequence. - Rendering moved out: the frame rendering now lives in GenerateFrame(const FrameSettings &), which doesn't sleep. SnapImage() calls it and then sleeps for the exposure; the sequence thread calls it from RunSequence(). - Capture state: a new std::atomic<bool> capturing_ backs IsCapturing(). The thread clears it after AcqFinished, so snaps and new sequences work after a finite sequence ends on its own. StartSequenceAcquisition cleans up the finished thread before starting a new one. - Stopping: stop now interrupts the exposure wait and throws away the frame in progress. StopSequenceAcquisition() always cleans up the thread. Shutdown() and a new destructor both call it. (Assisted by Claude Code; any errors are mine.)
- SimHub.h: a new mutex mut_ guards the five functions the peripherals
register. Setting a function takes the lock, and each getter holds it
while calling the function. A short comment explains why: a
peripheral's Shutdown() can't return while the camera is still calling
into it.
- All four peripherals: each stores hub_ at the start of Initialize()
and returns DEVICE_COMM_HUB_MISSING if there's no hub. Shutdown()
resets the hub function and clears hub_ only if it was set. In the
shutter and turret this replaces the initialized_ flag, which is gone.
- SimObjectiveTurret.h: state_ is now a std::atomic<long>, with .load()
in the hub functions and OnState. The cast in GetNumberOfPositions()
is fixed to unsigned long.
- SimFocus.h / SimXY.h:
- model_ is now declared last, so it is destroyed first and its slew
thread stops before the members it uses go away. A comment says so.
- if (ProcModel::isAsync) in Initialize() is now if constexpr.
- The constructor's ReciprocalSlewRateSeconds call is wrapped in if
constexpr too.
- ProcessModel.h:
- Halt() and Setpoint(value) now write setpoint_ under mut_.
- Setpoint() compares against the parameter.
- The header comment now says which functions can be called from any
thread and which need outside locking.
(Assisted by Claude Code; any errors are mine.)
Fit in frame at 100x. (Assisted by Claude Code; any errors are mine.)
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.
Thread safety, resource cleanup bugs.
Also make the origin marker 4x smaller so that it fits in the frame at 100x.