Skip to content
Snippets Groups Projects
Commit 063a82e3 authored by Martin Christoph Hierholzer's avatar Martin Christoph Hierholzer
Browse files

added constructor for ReadBitMask which allows specifying all meta data for inputs and outputs

parent c264277b
No related branches found
No related tags found
No related merge requests found
......@@ -24,16 +24,16 @@ namespace ChimeraTK {
bit[i].replace(ScalarPushInput<int>(this, "bit"+std::to_string(i), "", "The bit "+std::to_string(i)+" of the bit mask"));
}
}
ScalarPushInput<int> bit[NBITS];
};
Input input{this, "input", "The input bits"};
ScalarOutput<int32_t> bitmask{this, "bitmask", "", "Output bit mask."};
void mainLoop() {
while(true) {
// create bit mask
bitmask = 0;
for(size_t i=0; i<NBITS; ++i) {
......@@ -42,7 +42,7 @@ namespace ChimeraTK {
}
}
bitmask.write();
// wait for new input values (at the end, since we want to process the initial values first)
input.readAny();
}
......@@ -54,7 +54,23 @@ namespace ChimeraTK {
template<size_t NBITS>
struct ReadBitMask : public ApplicationModule {
using ApplicationModule::ApplicationModule;
ReadBitMask(EntityOwner *owner, const std::string &name, const std::string &description,
bool eliminateHierarchy=false, const std::unordered_set<std::string> &tags={})
: ApplicationModule(owner, name, description, eliminateHierarchy, tags) {}
ReadBitMask() {}
ReadBitMask( EntityOwner *owner, const std::string &inputName, const std::string &inputDescription,
const std::unordered_set<std::string> &inputTags, const std::array<std::string, NBITS> &outputNames,
const std::array<std::string, NBITS> &outputDescriptions, const std::unordered_set<std::string> &outputTags )
: ApplicationModule(owner, inputName, inputDescription, true)
{
bitmask.setMetaData(inputName, "", inputDescription, inputTags);
output.setEliminateHierarchy();
for(size_t i=0; i<NBITS; ++i) {
output.bit[i].setMetaData(outputNames[i], "", outputDescriptions[i], outputTags);
}
}
/// individual outputs for each bit
struct Output : public VariableGroup {
......@@ -67,22 +83,22 @@ namespace ChimeraTK {
bit[i].replace(ScalarOutput<int>(this, "bit"+std::to_string(i), "", "The bit "+std::to_string(i)+" of the bit mask"));
}
}
ScalarOutput<int> bit[NBITS];
};
Output output{this, "output", "The extracted output bits"};
ScalarPushInput<int32_t> bitmask{this, "bitmask", "", "Input bit mask."};
void mainLoop() {
while(true) {
// decode bit mask
for(size_t i=0; i<NBITS; ++i) {
output.bit[i] = (bitmask & (1 << i)) != 0;
output.bit[i].write(); /// @todo TODO better make a writeAll() for VariableGroups
}
// wait for new input values (at the end, since we want to process the initial values first)
bitmask.read();
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment