-
Notifications
You must be signed in to change notification settings - Fork 2
Mike/add fits writer #101
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
Merged
Merged
Mike/add fits writer #101
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
f0bc395
add asyc FITS writer
mikelangmayr 75e7d37
add frame output factory, make frame output configurable, hook up fra…
mikelangmayr ff314e0
remove unused is_camera_mode flag
mikelangmayr 5997770
make default SINGLE exposure mode override-able
mikelangmayr 91f6da9
make ExposureMode::expose optional
mikelangmayr 4a5a63a
Merge branch 'camera-2.0' into mike/add-fits-writer
mikelangmayr 881004e
Reset stop_ in open() and reject queue_size==0 in FitsWriter
mikelangmayr 973a2a6
temporary fits writer
a33ea1e
slight changes
f4466b4
move FITS cadence decision outside the FITS writer
mikelangmayr 4b792ec
Merge branch 'mike/add-fits-writer' of github.com:CaltechOpticalObser…
mikelangmayr 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
Submodule hispec_tracking_camera
updated
7 files
| +1,117 −0 | config/hispecatc.acf | |
| +30 −0 | config/hispecatc.cfg | |
| +184 −12 | hispec_tracking_camera_exposure_modes.cpp | |
| +6 −6 | hispec_tracking_camera_exposure_modes.h | |
| +362 −304 | hispec_tracking_camera_instrument.cpp | |
| +19 −23 | hispec_tracking_camera_instrument.h | |
| +27 −0 | hispecatc.cfg |
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
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
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
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
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
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
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
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
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,36 @@ | ||
| /** | ||
| * @file cadence_gate.cpp | ||
| * @brief FrameOutput decorator that rate-limits frames to a wrapped output | ||
| */ | ||
|
|
||
| #include "cadence_gate.h" | ||
| #include "common.h" | ||
|
|
||
| #include <utility> | ||
|
|
||
| namespace Camera { | ||
|
|
||
| CadenceGate::CadenceGate(std::unique_ptr<FrameOutput> inner, uint32_t write_interval_ms) | ||
| : inner_(std::move(inner)), | ||
| interval_(std::chrono::milliseconds(write_interval_ms)) { | ||
| } | ||
|
|
||
| long CadenceGate::open() { | ||
| return inner_->open(); | ||
| } | ||
|
|
||
| long CadenceGate::write(const char* data, size_t size, const FrameMetadata& meta) { | ||
| const auto now = std::chrono::steady_clock::now(); | ||
| if (now - last_forwarded_ < interval_) { | ||
| n_skipped_.fetch_add(1, std::memory_order_relaxed); | ||
| return NO_ERROR; | ||
| } | ||
| last_forwarded_ = now; | ||
| return inner_->write(data, size, meta); | ||
| } | ||
|
|
||
| void CadenceGate::close() { | ||
| inner_->close(); | ||
| } | ||
|
|
||
| } |
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,46 @@ | ||
| /** | ||
| * @file cadence_gate.h | ||
| * @brief FrameOutput decorator that rate-limits frames to a wrapped output | ||
| * | ||
| * Forwards a frame only when at least write_interval_ms has elapsed since the | ||
| * last forwarded frame; otherwise the frame is dropped. Keeps the cadence | ||
| * policy out of the concrete writers, which then just do their I/O. | ||
| */ | ||
| #pragma once | ||
|
|
||
| #include "frame_output.h" | ||
|
|
||
| #include <atomic> | ||
| #include <chrono> | ||
| #include <cstdint> | ||
| #include <memory> | ||
|
|
||
| namespace Camera { | ||
|
|
||
| /// FrameOutput that thins frames by minimum interval before delegating | ||
| class CadenceGate : public FrameOutput { | ||
| public: | ||
| CadenceGate(std::unique_ptr<FrameOutput> inner, uint32_t write_interval_ms); | ||
| ~CadenceGate() override = default; | ||
|
|
||
| CadenceGate(const CadenceGate&) = delete; | ||
| CadenceGate& operator=(const CadenceGate&) = delete; | ||
|
|
||
| long open() override; | ||
| long write(const char* data, size_t size, const FrameMetadata& meta) override; | ||
| void close() override; | ||
|
|
||
| uint64_t frames_skipped() const { return n_skipped_.load(); } | ||
|
|
||
| private: | ||
| std::unique_ptr<FrameOutput> inner_; | ||
| std::chrono::milliseconds interval_; | ||
|
|
||
| // Only touched on the producer thread | ||
| std::chrono::steady_clock::time_point last_forwarded_{ | ||
| std::chrono::steady_clock::time_point::min()}; | ||
|
|
||
| std::atomic<uint64_t> n_skipped_{0}; | ||
| }; | ||
|
|
||
| } |
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.
If I ask for an exposure mode that doesn't exist then this will silently give me some other mode.
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.
@astronomerdave It allows each instrument to have a default exposure mode.