Commit 9600a5f1 authored by Leander Schulten's avatar Leander Schulten
Browse files

Add dmxProgrammBlock

parent 0af94c01
#include "dmxprogramblock.h"
namespace Modules {
DMXProgramBlock::DMXProgramBlock()
DMXProgramBlock::DMXProgramBlock(std::shared_ptr<Consumer> consumer)
{
prog = new DMXProgram();
addProgramm(prog);
consumer = std::make_shared<DMXConsumer>();
this->consumer = consumer;
prog->setOutputLength(512);
consumer->setInputLength(512);
detail::Connection c(consumer);
c.addTarget(512,prog,0);
addConsumer(std::move(c));
}
void DMXProgramBlock::setDMXConsumer(std::shared_ptr<Consumer> consumer){
this->consumer = consumer;
consumer->setInputLength(512);
removeConsumer([](const detail::Connection&){return true;});
detail::Connection c(consumer);
c.addTarget(512,prog,0);
addConsumer(std::move(c));
}
}
......@@ -3,15 +3,25 @@
#include "programblock.h"
#include "dmxprogram.h"
#include "dmxconsumer.h"
namespace Modules {
/**
* @brief Ein DMXProgramBlock der von Controller ausgeführt werden kann, damit DMXProgramm ausgeführt werden können.
*/
class DMXProgramBlock : public ProgramBlock
{
DMXProgram * prog = nullptr;
std::shared_ptr<DMXConsumer> consumer;
std::shared_ptr<Consumer> consumer;
public:
DMXProgramBlock();
/**
* @brief isLoaded returns true, if a consumer is loaded so that the dmxouput can be shown
* @return true if a consumer exists
*/
bool isLoaded(){return consumer.operator bool();}
void setDMXConsumer(std::shared_ptr<Consumer> consumer);
DMXProgramBlock(std::shared_ptr<Consumer> consumer);
~DMXProgramBlock(){}
};
}
......
......@@ -21,7 +21,7 @@ namespace Modules {
unsigned int startIndex;
};
typedef unsigned int length_t;
const enum SourceType {Filter,Consumer} sourceType;
enum SourceType {Filter,Consumer} sourceType;
std::shared_ptr<InputDataConsumer> source;
template<typename Type>
Connection(std::shared_ptr<Type> source):source(source),sourceType(Filter){
......@@ -146,6 +146,10 @@ namespace Modules {
* @param c
*/
void addConsumer(detail::Connection c);
template<typename F>
void removeConsumer(F f){
std::remove_if(consumer.begin(),consumer.end(),f);
}
public:
ProgramBlock();
ProgramBlock(const QJsonObject&);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment