MCPcopy Create free account
hub / github.com/benkuper/Chataigne / handleRoutedModuleValue

Method handleRoutedModuleValue

Source/Module/modules/dmx/DMXModule.cpp:550–619  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

548}
549
550void DMXModule::handleRoutedModuleValue(Controllable* c, RouteParams* p)
551{
552 if (p == nullptr || c == nullptr) return;
553
554 if (DMXRouteParams* rp = dynamic_cast<DMXRouteParams*>(p))
555 {
556 DMXUniverse* u = dynamic_cast<DMXUniverse*>(rp->dmxUniverse->targetContainer.get());
557
558 Parameter* sp = c->type == Controllable::TRIGGER ? nullptr : dynamic_cast<Parameter*>(c);
559
560 bool fullRange = rp->fullRange != nullptr ? rp->fullRange->boolValue() : false;
561
562 DMXByteOrder byteOrder = rp->mode16bit != nullptr ? rp->mode16bit->getValueDataAsEnum<DMXByteOrder>() : DMXByteOrder::BIT8;
563
564 if (sp == nullptr) return;
565
566 switch (c->type)
567 {
568 case Parameter::BOOL:
569 case Parameter::INT:
570 case Parameter::FLOAT:
571 {
572 int value = (sp->hasRange() ? (float)sp->getNormalizedValue() : sp->floatValue()) * (fullRange ? (byteOrder == BIT8 ? 255 : 65535) : 1);
573
574 if (byteOrder == BIT8) sendDMXValue(u, rp->channel->intValue(), value);
575 else send16BitDMXValue(u, rp->channel->intValue(), value, byteOrder);
576 }
577 break;
578
579 /*case Parameter::POINT2D:
580 {
581 Point<float> pp = ((Point2DParameter*)sp)->getPoint();
582 if (fullRange) pp *= byteOrder != BIT8 ? 65535 : 255;
583
584 Array<int> values;
585 values.add((int)pp.x, (int)pp.y);
586
587 if (byteOrder == BIT8) sendDMXValues(u, rp->channel->intValue(), values);
588 else send16BitDMXValues(u, rp->channel->intValue(), values, byteOrder);
589 }
590 break;
591
592 case Parameter::POINT3D:
593 {
594 Vector3D<float> pp = ((Point3DParameter*)sp)->getVector();
595 if (fullRange) pp *= byteOrder != BIT8 ? 65535 : 255;
596
597 Array<int> values;
598 values.add((int)pp.x, (int)pp.y, (int)pp.z);
599
600 if (byteOrder == BIT8) sendDMXValues(u, rp->channel->intValue(), values);
601 else send16BitDMXValues(u, rp->channel->intValue(), values, byteOrder);
602 }
603 break;
604
605 case Parameter::COLOR:
606 {
607 Colour col = ((ColorParameter*)sp)->getColor();

Calls 1

getMethod · 0.45

Tested by

no test coverage detected