| 304 | } |
| 305 | |
| 306 | bool HyperHdrManager::startInstance(quint8 inst, QObject* caller, int tan, bool disableOnStartup) |
| 307 | { |
| 308 | if (_instanceTable->instanceExist(inst)) |
| 309 | { |
| 310 | if (!_runningInstances.contains(inst) && !_startingInstances.contains(inst)) |
| 311 | { |
| 312 | QThread* hyperhdrThread = new QThread(); |
| 313 | hyperhdrThread->setObjectName("HyperHdrThread"); |
| 314 | |
| 315 | auto hyperhdr = std::shared_ptr<HyperHdrInstance>( |
| 316 | new HyperHdrInstance(inst, |
| 317 | disableOnStartup, |
| 318 | _instanceTable->getNamebyIndex(inst)), |
| 319 | [](HyperHdrInstance* oldInstance) { |
| 320 | THREAD_REMOVER(QString("HyperHDR instance at index = %1").arg(oldInstance->getInstanceIndex()), |
| 321 | oldInstance->thread(), oldInstance); |
| 322 | } |
| 323 | ); |
| 324 | |
| 325 | hyperhdr->moveToThread(hyperhdrThread); |
| 326 | |
| 327 | connect(hyperhdrThread, &QThread::started, hyperhdr.get(), &HyperHdrInstance::start); |
| 328 | connect(hyperhdr.get(), &HyperHdrInstance::SignalInstanceJustStarted, this, &HyperHdrManager::handleInstanceJustStarted); |
| 329 | connect(hyperhdr.get(), &HyperHdrInstance::SignalInstancePauseChanged, this, &HyperHdrManager::SignalInstancePauseChanged); |
| 330 | connect(hyperhdr.get(), &HyperHdrInstance::SignalInstanceSettingsChanged, this, &HyperHdrManager::SignalSettingsChanged); |
| 331 | connect(hyperhdr.get(), &HyperHdrInstance::SignalRequestComponent, this, &HyperHdrManager::SignalCompStateChangeRequest); |
| 332 | connect(this, &HyperHdrManager::SignalSetNewComponentStateToAllInstances, hyperhdr.get(), &HyperHdrInstance::setNewComponentState); |
| 333 | |
| 334 | _startingInstances.insert(inst, hyperhdr); |
| 335 | |
| 336 | hyperhdrThread->start(); |
| 337 | |
| 338 | _instanceTable->setLastUse(inst); |
| 339 | _instanceTable->setEnable(inst, true); |
| 340 | |
| 341 | if (!_pendingRequests.contains(inst) && caller != nullptr) |
| 342 | { |
| 343 | PendingRequests newDef{ caller, tan }; |
| 344 | _pendingRequests[inst] = newDef; |
| 345 | } |
| 346 | |
| 347 | return true; |
| 348 | } |
| 349 | Debug(_log, "Can't start Hyperhdr instance index '%d' with name '%s' it's already running or queued for start", inst, QSTRING_CSTR(_instanceTable->getNamebyIndex(inst))); |
| 350 | return false; |
| 351 | } |
| 352 | Debug(_log, "Can't start Hyperhdr instance index '%d' it doesn't exist in DB", inst); |
| 353 | return false; |
| 354 | } |
| 355 | |
| 356 | bool HyperHdrManager::stopInstance(quint8 instance) |
| 357 | { |
nothing calls this directly
no test coverage detected