| 119 | } |
| 120 | |
| 121 | void HyperHdrInstance::start() |
| 122 | { |
| 123 | _log = Logger::getInstance(QString("HYPERHDR%1").arg(_instIndex)); |
| 124 | |
| 125 | if (_signalTerminate) |
| 126 | { |
| 127 | Warning(_log, "Signal terminate detected. Skipping start of the instance"); |
| 128 | return; |
| 129 | } |
| 130 | |
| 131 | Info(_log, "Starting the instance"); |
| 132 | |
| 133 | _instanceConfig = std::unique_ptr<InstanceConfig>(new InstanceConfig(false, _instIndex, this)); |
| 134 | _componentController = std::unique_ptr<ComponentController>(new ComponentController(this, _disableOnStartup)); |
| 135 | connect(_componentController.get(), &ComponentController::SignalComponentStateChanged, this, &HyperHdrInstance::SignalComponentStateChanged); |
| 136 | _ledString = LedString::createLedString(getSetting(settings::type::LEDS).array(), LedString::createColorOrder(getSetting(settings::type::DEVICE).object())); |
| 137 | _muxer = std::unique_ptr<Muxer>(new Muxer(_instIndex, static_cast<int>(_ledString.leds().size()), this)); |
| 138 | _imageProcessor = std::unique_ptr<ImageToLedManager>(new ImageToLedManager(_ledString, this)); |
| 139 | connect(_muxer.get(), &Muxer::SignalPrioritiesChanged, this, &HyperHdrInstance::SignalPrioritiesChanged); |
| 140 | connect(_muxer.get(), &Muxer::SignalVisiblePriorityChanged, this, &HyperHdrInstance::SignalVisiblePriorityChanged); |
| 141 | connect(_muxer.get(), &Muxer::SignalVisibleComponentChanged, this, &HyperHdrInstance::SignalVisibleComponentChanged); |
| 142 | _ledColorCalibration = std::unique_ptr<LedCalibration>(new LedCalibration(_instIndex, static_cast<int>(_ledString.leds().size()), getSetting(settings::type::COLOR).object())); |
| 143 | _ledGridSize = LedString::getLedLayoutGridSize(getSetting(settings::type::LEDS).array()); |
| 144 | _currentLedColors = std::vector<ColorRgb>(_ledString.leds().size(), ColorRgb::BLACK); |
| 145 | |
| 146 | Info(_log, "Led strip RGB order is: %s", QSTRING_CSTR(LedString::colorOrderToString(_ledString.colorOrder))); |
| 147 | |
| 148 | connect(_instanceConfig.get(), &InstanceConfig::SignalInstanceSettingsChanged, this, &HyperHdrInstance::SignalInstanceSettingsChanged); |
| 149 | |
| 150 | if (!_ledColorCalibration->verifyAdjustments()) |
| 151 | { |
| 152 | Warning(_log, "At least one led has no color calibration, please add all leds from your led layout to an 'LED index' field!"); |
| 153 | } |
| 154 | |
| 155 | // handle hwLedCount |
| 156 | _hwLedCount = qMax(getSetting(settings::type::DEVICE).object()["hardwareLedCount"].toInt(1), getLedCount()); |
| 157 | |
| 158 | connect(this, &HyperHdrInstance::SignalVisiblePriorityChanged, this, &HyperHdrInstance::update); |
| 159 | connect(this, &HyperHdrInstance::SignalVisiblePriorityChanged, this, &HyperHdrInstance::handlePriorityChangedLedDevice); |
| 160 | connect(this, &HyperHdrInstance::SignalVisibleComponentChanged, this, &HyperHdrInstance::handleVisibleComponentChanged); |
| 161 | |
| 162 | // listen for settings updates of this instance (LEDS & COLOR) |
| 163 | connect(_instanceConfig.get(), &InstanceConfig::SignalInstanceSettingsChanged, this, &HyperHdrInstance::handleSettingsUpdate); |
| 164 | |
| 165 | // initialize LED-devices |
| 166 | QJsonObject ledDevice = getSetting(settings::type::DEVICE).object(); |
| 167 | ledDevice["currentLedCount"] = _hwLedCount; // Inject led count info |
| 168 | |
| 169 | // smoothing |
| 170 | _smoothing = std::unique_ptr<Smoothing>(new Smoothing(getSetting(settings::type::SMOOTHING), this)); |
| 171 | connect(this, &HyperHdrInstance::SignalInstanceSettingsChanged, _smoothing.get(), &Smoothing::handleSettingsUpdate); |
| 172 | connect(this, &HyperHdrInstance::SignalSmoothingClockTick, _smoothing.get(), &Smoothing::SignalMasterClockTick, Qt::DirectConnection); |
| 173 | |
| 174 | _ledDeviceWrapper = std::unique_ptr<LedDeviceWrapper>(new LedDeviceWrapper(this)); |
| 175 | connect(this, &HyperHdrInstance::SignalRequestComponent, _ledDeviceWrapper.get(), &LedDeviceWrapper::handleComponentState); |
| 176 | _ledDeviceWrapper->createLedDevice(ledDevice, _smoothing->GetSuggestedInterval(), _disableOnStartup); |
| 177 | |
| 178 | // create the effect engine; needs to be initialized after smoothing! |
nothing calls this directly
no test coverage detected