-
Notifications
You must be signed in to change notification settings - Fork 3
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
Refactor UI blocks and use multithreaded scheduler #149
Conversation
ee22108
to
841eee4
Compare
841eee4
to
8a8cfb3
Compare
8a8cfb3
to
57bdc1a
Compare
f11c5b0
to
7b70854
Compare
7b70854
to
384f485
Compare
Fixes issues with emscripten GET/SET, i.e. initial dashboard retrieval, and subscribe/unsubscribe (query parameters got lost).
Remove special treatment for remote sources, make it a regular GR block. TODO: - readd remote flowgraph handling - readd adding new sources from the UI (wait for messages?)
RestClient's tasks continue running when the RestClient is destroyed, the callback then accessed the already deleted "this". Move the shared data to a shared_ptr, to ensure it's still valid when appending data to it.
Make sure that destroyed while waiting in processOne(), there isn't a deadlock where both mutex destruction and processOne block each other.
82d97fa
to
4468bcf
Compare
struct MathNode : public gr::Block<MathNode<T>> { | ||
gr::PortIn<T> in1{}; | ||
gr::PortIn<T> in2{}; | ||
struct Arithmetic : public gr::Block<Arithmetic<T>> { |
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.
generally OK for this PR but we should move all of these isolated block implementation to the GR 4.0 repo and also make them conform and check the corresponding items in summary issue EPIC: List of GR 3.10 blocks & Others to be ported to GR 4.0
@@ -40,31 +39,35 @@ struct SineSource : public gr::Block<SineSource<T>, gr::BlockingIO<true>> { | |||
} | |||
|
|||
~SineSource() { | |||
std::unique_lock guard(mutex); |
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.
Should be replaced and synchronised with EPIC: List of GR 3.10 blocks & Others to be ported to GR 4.0. Also there is already a sine and cosine source in GR 4.0.
@drslebedev maybe you could comment/document the usage and check this if this conforms to the functionality in GR 3.X.
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.
Here is the example of SignalGenerator
which can generate sine wave (this is the default signal type), note that ClockSource
is required sa input to SignalGenerator
:
constexpr std::uint32_t n_samples = 200;
constexpr float sample_rate = 1000.f;
Graph testGraph;
auto &clockSrc = testGraph.emplaceBlock<gr::basic::ClockSource<float>>({ { "sample_rate", sample_rate }, { "n_samples_max", n_samples }, { "name", "ClockSource" } });
auto &signalGen = testGraph.emplaceBlock<SignalGenerator<float>>({ { "sample_rate", sample_rate }, { "name", "SignalGenerator" } });
testGraph.connect<"out">(clockSrc).to<"in">(signalGen);
testGraph.connect<"out">(signalGen).to<"in">(sink);
scheduler::Simple sched{ std::move(testGraph) };
sched.runAndWait();
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.
Looks OK for me from a code-only perspective. Many of the non-UI blocks (and those not dependent on OpenCMW) should become part of the GR 4.0 block-lib. This reduces the duplicate work/documentation/testing. See the EPIC: List of GR 3.10 blocks & Others to be ported to GR 4.0 for details.
Can IMO be merged if @drslebedev and/or @wirew0rm had another chance to functionally cross-check.
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.
I added an example of Sine wave generator in the comment to this PR.
The rest looks fine to me and PR can be merged, just keeping in mind in the next iteration to use blocks from GR4.0 where possible.
Convert the UI blocks RemoteDataSource, SineSource and Arithmetic into "plain" GR blocks that could be moved out of opendigitizer later. This temporarily removes the the remote flowgraph handling for RemoteSource, which will be re-added later.
Also use a multithreaded scheduler, and stop and delete the old graph/scheduler once a new one is set (this required some fixes in RemoteSource and SineSource to avoid freezes/crashes on destruction).
Bump opencmw-cpp to include some fixes for RestClientEmscripten (GET/SUBSCRIBE).