Skip to content

Commit 527afc3

Browse files
committed
Working on SimulationReaderBase
1 parent 3e0338d commit 527afc3

File tree

5 files changed

+480
-25
lines changed

5 files changed

+480
-25
lines changed

src/Modules/Basic/AsyncStreamingTestModule.cc

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include <queue>
2929
#include <future>
3030
#include <Modules/Basic/AsyncStreamingTestModule.h>
31+
#include <Modules/Basic/SimulationReaderBaseModule.h>
3132
#include <Core/Datatypes/Legacy/Bundle/Bundle.h>
3233
#include <Core/Datatypes/DenseMatrix.h>
3334
#include <Core/Datatypes/DenseColumnMatrix.h>
@@ -48,7 +49,7 @@ namespace SCIRun::Modules::Basic
4849
using DataChunk = DenseMatrixHandle;
4950
//TODO: need thread-safe container to share
5051
using DataStream = std::queue<DataChunk>;
51-
52+
5253

5354
class StreamAppender
5455
{
@@ -92,22 +93,22 @@ namespace SCIRun::Modules::Basic
9293
{
9394
if (hasData())
9495
{
95-
//wait for result.
96+
//wait for result.
9697
while (stream().empty())
9798
{
9899
logInfo("__MAIN__ Waiting for data");
99100
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
100101
}
101102

102-
//once data is available, output to ports
103+
//once data is available, output to ports
103104
auto data = stream().front();
104105
{
105106
Guard g(dataMutex.get());
106107
stream().pop();
107108
}
108109

109110
logInfo("__MAIN__ Received data: [{}] outputting matrix.", (*data)(0, 0));
110-
module_->outputAsyncData(module_->bundleOutputs({ "Slice" }, { data }));
111+
module_->sendOutput(module_->OutputSlice, bundleOutputs({ "Slice" }, { data }));
111112

112113
logInfo("__MAIN__ Enqueue execute again");
113114
module_->enqueueExecuteAgain(false);
@@ -149,23 +150,6 @@ void AsyncStreamingTest::execute()
149150
impl_ = std::make_unique<StreamAppender>(this, castMatrix::toDense(input));
150151
impl_->beginPushDataAsync();
151152
}
152-
153-
impl_->waitAndOutputEach();
154-
}
155-
156-
void AsyncStreamingTest::outputAsyncData(BundleHandle data)
157-
{
158-
sendOutput(OutputSlice, data);
159-
}
160153

161-
Core::Datatypes::BundleHandle AsyncStreamingTest::bundleOutputs(std::initializer_list<std::string> names, std::initializer_list<DatatypeHandle> dataList)
162-
{
163-
auto bundle = makeShared<Bundle>();
164-
auto nIter = names.begin();
165-
auto dIter = dataList.begin();
166-
for (; nIter != names.end(); ++nIter, ++dIter)
167-
{
168-
bundle->set(*nIter, *dIter);
169-
}
170-
return bundle;
154+
impl_->waitAndOutputEach();
171155
}

src/Modules/Basic/AsyncStreamingTestModule.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,6 @@ namespace Basic {
5050
OUTPUT_PORT(0, OutputSlice, Bundle);
5151

5252
MODULE_TRAITS_AND_INFO(ModuleFlags::NoAlgoOrUI)
53-
protected:
54-
void outputAsyncData(Core::Datatypes::BundleHandle data);
55-
Core::Datatypes::BundleHandle bundleOutputs(std::initializer_list<std::string> names, std::initializer_list<Core::Datatypes::DatatypeHandle> dataList);
5653
private:
5754
friend class StreamAppender;
5855
std::unique_ptr<class StreamAppender> impl_;

src/Modules/Basic/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ SET(Modules_Basic_SRCS
4040
LoggingTester.cc
4141
CompositeModuleWithStaticPorts.cc
4242
CompositeModuleWithTypedStaticPorts.cc
43+
SimulationReaderBaseModule.cc
4344
)
4445

4546
SET(Modules_Basic_HEADERS
@@ -56,6 +57,7 @@ SET(Modules_Basic_HEADERS
5657
PlaceholderModule.h
5758
CompositeModuleWithStaticPorts.h
5859
CompositeModuleWithTypedStaticPorts.h
60+
SimulationReaderBaseModule.h
5961
share.h
6062
)
6163

0 commit comments

Comments
 (0)