Commit 10757bd8 authored by Leander Schulten's avatar Leander Schulten
Browse files

Update DMXConsumer so that the consumer can be used in ProgramBlocks. Use...

Update DMXConsumer so that the consumer can be used in ProgramBlocks. Use DMXConsumer data in Driver and DriverDummy
parent 74ab2ea2
......@@ -6,6 +6,7 @@
#include "dmxchannelfilter.h"
#include <QDir>
#include <cstring>
#include "programms/dmxconsumer.h"
#ifdef Q_OS_WIN
#include <windows.h>
#endif
......@@ -64,6 +65,7 @@ namespace Driver {
std::memset(values,0,size);
DMXChannelFilter::initValues(values,size);
Programm::fill(values,size,time);
Modules::DMXConsumer::fillWithDMXConsumer(values,size);
DMXChannelFilter::filterValues(values,size);
});
......
......@@ -219,8 +219,10 @@ int main(int argc, char *argv[])
/*DriverDummy driver;
driver.setSetValuesCallback([](unsigned char* values, int size, double time){
std::memset(values,0,size);
DMXChannelFilter::initValues(values,size);
Programm::fill(values,size,time);
Modules::DMXConsumer::fillWithDMXConsumer(values,size);
DMXChannelFilter::filterValues(values,size);
});
driver.setWaitTime(std::chrono::seconds(5));
......
......@@ -2,24 +2,31 @@
namespace Modules {
DMXConsumer::DMXConsumer()
DMXConsumer::DMXConsumer():startDMXChannel(0,512,0)
{
properties.push_back(&startDMXChannel);
startDMXChannel.setName("start DMX Channel");
startDMXChannel.setDescription("The address of the first position in the output array.");
}
void DMXConsumer::setInputLength(unsigned int size){
channel.resize(size,-1);
TypedConsumer::setInputLength(size);
}
void DMXConsumer::start(){}
void DMXConsumer::start(){
running = true;
}
void DMXConsumer::stop(){
running = false;
}
void DMXConsumer::show(){
brightness_t * b = input;
for(auto i = channel.cbegin();i!=channel.cend();++i,++b){
if(*i>0){
//dmxData[*i] = *b;
//TODO;
// all the logic is done in fillWithDMXConsumer, because we are not the driver and the driver gets the data from us
}
void DMXConsumer::fillWithDMXConsumer(unsigned char *data, size_t length){
for(const auto & i : IDBase<DMXConsumer>::getAllIDBases()){
if(i->running){
for (int a = 0; a < std::min(static_cast<int>(length)-i->startDMXChannel.getValue(),static_cast<int>(i->getInputLength()));++a) {
data[i->startDMXChannel.getValue() + a] = i->input[a];
}
}
}
}
......
......@@ -3,19 +3,30 @@
#include "consumer.hpp"
#include <vector>
#include "idbase.h"
namespace Modules {
class DMXConsumer : public Modules::TypedConsumer<brightness_t>
/**
* @brief Der DMXConsumer macht es möglich, in Moduleprogrammen dmx channel anzusprechen. Diese Daten werden dann in driver.cpp hier abgeholt und vom alten treiber angezeigt
*/
class DMXConsumer : public Modules::TypedConsumer<brightness_t>, public IDBase<DMXConsumer>
{
std::vector<short> channel;
NumericProperty<int> startDMXChannel;
bool running = false;
public:
/**
* @brief fillWithDMXConsumer füllt den data array mit den dmx daten aus dem DMXConsumern
* @param data der daten array der an die DMX Geräte geht
* @param length Die länge des Arrays
*/
static void fillWithDMXConsumer(unsigned char * data, size_t length);
public:
DMXConsumer();
virtual void setInputLength(unsigned int) override;
virtual void start()override;
virtual void show() override;
virtual void stop() override;
virtual void doStep(time_diff_t)override{}
const std::vector<short> & getChannelAssoziatfion()const{return channel;}
virtual const char * getName()const override{return "DMXConsumer";}
};
......
......@@ -6,6 +6,7 @@
#include <QJsonObject>
#include <QJsonArray>
#include "audio/audiocapturemanager.h"
#include "dmxconsumer.h"
namespace Modules {
......@@ -74,6 +75,10 @@ typedef Modules::Program* (*CreateProgramm)(unsigned int index);
}
}
});
// add the DMXConsumer for the old driver
consumer.emplace("DMXConsumer","With the DMXConsumer class you can write to the DMX Channels",-1,[](){
return new DMXConsumer;
});
}
void ModuleManager::loadModules(const QJsonObject & o){
......
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