/** * Handler for message data request * $Id$ * $HeadURL$ * $Author$ * Created by hjl, SLSE, 2016-10-12 */ #include "handler_sounds.h" #include "settings.h" #include "dds_handler.h" #include #include #include #include #include #include #include namespace SoundManagement { HandlerSounds::HandlerSounds(const std::shared_ptr &ddsHandler, const std::shared_ptr &dbHandler, QObject *parent) : QObject(parent) , GetActiveSoundsRequestHandler(ddsHandler->ftsSom()) , StopAllSoundsRequestHandler(ddsHandler->ftsSom()) , GetSoundsRequestHandler(ddsHandler->ftsSom()) , ControlSoundRequestHandler(ddsHandler->ftsSom()) , m_ddsHandler(ddsHandler) , m_dbHandler(dbHandler) , m_logger(getLogger("HandlerSounds")) { } // end of ctor() //----------------------------------------------------------------------------- bool HandlerSounds::init() { SoundManagement::Sounds topicData; SoundManagement::Sound sound; INFO_LOG(m_logger) << "HandlerConfigureSounds::init"; auto dtcIsm = m_ddsHandler->dtcIsm(); auto dtcSom = m_ddsHandler->dtcSom(); connect(dtcIsm.get(), &InfrastructureManagement::Interface::Dtc::instrumentationAssetChanged, this, &HandlerSounds::onInstrumentationAssetChanged); connect(dtcIsm.get(), &InfrastructureManagement::Interface::Dtc::mountingPointAssetChanged, this, &HandlerSounds::onMountingPointAssetChanged); connect(dtcSom.get(), &SoundManagement::Interface::Dtc::soundStateChanged, this, &HandlerSounds::onSoundStateChanged); m_updateActiveSoundsTimer->setSingleShot(true); connect(m_updateActiveSoundsTimer, &QTimer::timeout, this, &HandlerSounds::onTimerTimeout); // load data from db-table QVector soundVec; if (!m_dbHandler->db()->select(soundVec)) { ERROR_LOG(m_logger) << "Error reading data from database 'som_sound'!"; return false; } for (const Database::SomSound &data : qAsConst(soundVec)) { static int index = 0; DEBUG_LOG(m_logger) << "SomSound from DB data: id=" << data.id << " categoryId=" << data.categoryId << " name=" << data.name << " displayName=" << data.displayName; SoundStr soundEntry; soundEntry.index = data.id; soundEntry.soundId = data.soundId; soundEntry.category = static_cast(data.categoryId); soundEntry.name = data.name; soundEntry.displayName = data.displayName; soundEntry.duration = data.duration; soundEntry.isRepeatable = data.isRepeatable; m_soundNames.append(soundEntry); DEBUG_LOG(m_logger) << "id=" << index << " SomSound from DB data: id=" << soundEntry.index << " categoryId=" << soundEntry.category << " name=" << soundEntry.name << " displayName=" << soundEntry.displayName; sound.id(soundEntry.index); sound.category(soundEntry.category); sound.soundId(soundEntry.soundId); sound.name(soundEntry.name.toStdString()); sound.displayName(soundEntry.displayName.toStdString()); sound.duration(soundEntry.duration); sound.isRepeatable(soundEntry.isRepeatable); topicData.sounds().push_back(sound); index++; } m_ddsHandler->dtsSom()->publish(topicData); getActiveSounds(); // Get 'static' data for all MountPointAsset { auto cb = [this](const InfrastructureManagement::MountingPointAsset & mpa) { onMountingPointAssetChanged(mpa, DataModification::eAdded); }; if (!dtcIsm->mountingPointAssets(cb)) return false; } return true; } // end init() void HandlerSounds::getActiveSounds() { DEBUG_LOG(m_logger) << "getActiveSounds"; if (m_hostnames.size() == 0) { DEBUG_LOG(m_logger) << "No EGCUs available send empty topic ActiveSounds"; m_updateActiveSoundsTimer->stop(); // TODO alle aktiven Sounds vom DDS-Bus loeschen return; } m_updateActiveSoundsTimer->start(2000); m_activeSounds.clear(); QHashIterator i(m_hostnames); while (i.hasNext()) { i.next(); QString hostname = i.value(); DEBUG_LOG(m_logger) << "getActiveSound hostname=" << hostname; getActiveSound(getAssetId(hostname)); } } // get the active sounds from each EGCU void HandlerSounds::onGetActiveSoundsRequest(const rti::core::SampleIdentity &cookie, const GetActiveSoundsRequest &request) { // 200{ "ID":"0x510","Name":"Sound Report","sounds":[{"category":"Explosions","sound":"0001"}]} Core::FunctionReplyObject reply = Core::FunctionReplyObject(0, tr_lts("dds", "GetActiveSounds ")); DEBUG_LOG(m_logger) << "onGetActiveSoundsRequest: " << request; m_ddsHandler->ftsSom()->getActiveSoundsReply(cookie, reply); // Request each EGCU // Wait for response from each EGCU if (!m_updateActiveSoundsTimer->isActive()) getActiveSounds(); } void HandlerSounds::onStopAllSoundsRequest(const rti::core::SampleIdentity &cookie, const StopAllSoundsRequest &request) { DEBUG_LOG(m_logger) << "StopAllSounds: " << request; int failedCount = 0; if (request.egcuId() == -1) // stopp all sounds on each EGCU { QHashIterator i(m_hostnames); while (i.hasNext()) { i.next(); const QString hostname = m_hostnames.value(i.key()); DEBUG_LOG(m_logger) << "hostname=" << hostname; if (!stopAllSounds(i.key()).isEmpty()) // BLOCKING failedCount++; } m_soundStates.clear(); } else { QString hostname = m_hostnames.value(request.egcuId()); DEBUG_LOG(m_logger) << "getActiveSound hostname=" << hostname; if (!stopAllSounds(request.egcuId()).isEmpty()) // BLOCKING failedCount++; } Core::FunctionReplyObject reply = Core::FunctionReplyObject(0); if (failedCount > 0) reply = Core::FunctionReplyObject(0, tr_lts("dds", "Failed to stop %1 sounds.")).arg(failedCount); m_ddsHandler->ftsSom()->stopAllSoundsReply(cookie, reply); } void HandlerSounds::onGetSoundsRequest(const rti::core::SampleIdentity &cookie, const GetSoundsRequest &request) { Core::FunctionReplyObject reply = Core::FunctionReplyObject(0, tr_lts("dds", "GetSounds")); DEBUG_LOG(m_logger) << "GetSounds: " << request; m_ddsHandler->ftsSom()->getSoundsReply(cookie, reply); } QString HandlerSounds::enumToString(const SoundCategory &category) { switch (category.underlying()) { case SoundManagement::SoundCategory::Aircraft: return QStringLiteral("Aircrafts"); case SoundManagement::SoundCategory::Battlefield: return QStringLiteral("Battlefields"); case SoundManagement::SoundCategory::Boat: return QStringLiteral("Boats"); case SoundManagement::SoundCategory::Explosion: return QStringLiteral("Explosions"); case SoundManagement::SoundCategory::Helicopter: return QStringLiteral("Helicopter"); case SoundManagement::SoundCategory::MotorsAndUrbanTraffic: return QStringLiteral("Motors_and_urban_traffic"); case SoundManagement::SoundCategory::Vehicle: return QStringLiteral("Vehicles"); case SoundManagement::SoundCategory::InsideBuilding: return QStringLiteral("Inside_buildings"); case SoundManagement::SoundCategory::Unknown: return QStringLiteral("Unknown"); } return QStringLiteral("Unknown"); } SoundManagement::SoundCategory HandlerSounds::stringToEnum(const QString &category) { if (category.contains(QStringLiteral("Aircrafts"), Qt::CaseInsensitive)) return SoundManagement::SoundCategory::Aircraft; if (category.contains(QStringLiteral("Battlefields"), Qt::CaseInsensitive)) return SoundManagement::SoundCategory::Battlefield; if (category.contains(QStringLiteral("Boats"), Qt::CaseInsensitive)) return SoundManagement::SoundCategory::Boat; if (category.contains(QStringLiteral("Explosions"), Qt::CaseInsensitive)) return SoundManagement::SoundCategory::Explosion; if (category.contains(QStringLiteral("Helicopter"), Qt::CaseInsensitive)) return SoundManagement::SoundCategory::Helicopter; if (category.contains(QStringLiteral("Motors_and_urban_traffic"), Qt::CaseInsensitive)) return SoundManagement::SoundCategory::MotorsAndUrbanTraffic; if (category.contains(QStringLiteral("Vehicles"), Qt::CaseInsensitive)) return SoundManagement::SoundCategory::Vehicle; if (category.contains(QStringLiteral("Inside_buildings"), Qt::CaseInsensitive)) return SoundManagement::SoundCategory::InsideBuilding; if (category.contains(QStringLiteral("Unknown"), Qt::CaseInsensitive)) return SoundManagement::SoundCategory::Unknown; return SoundManagement::SoundCategory::Unknown; } /* * * void HandlerMenuStruct::onModifyMenuStructRequest(const rti::core::SampleIdentity &cookie, const MenuStruct &request) { DEBUG_LOG(m_logger) << "onModifyMenuStructRequest: " << request; auto ret = request.id() > 0 ? modifyMenuStructRequest(request) : createMenuStructRequest(request); if (ret.error()) WARNING_LOG(m_logger) << ret(); m_fts->modifyMenuStructReply(cookie, ret); } Core::FunctionReplyObject HandlerMenuStruct::createMenuStructRequest(const MenuStruct &request) { ObjectMenuStruct *ifs = new ObjectMenuStruct(m_dts, m_db); DEBUG_LOG(m_logger) << "request.menuEntries.size() : " << request.menuEntries().size(); Core::FunctionReplyObject ret = ifs->createFromDds(request); if (ret.error()) delete ifs; else m_objMap.insert(ifs->getId(), ifs); return ret; } */ void HandlerSounds::onControlSoundRequest(const rti::core::SampleIdentity &cookie, const ControlSoundRequest &request) { DEBUG_LOG(m_logger) << "ControlSound: " << request << " category=" << request.category(); const QString user = Settings::somUser(); const QString passwd = Settings::somPasswd(); const QString hostname = m_hostnames.value(request.egcuId()); switch (request.control().underlying()) { case SoundManagement::PlayControl::StopSound: { onStopSingleSound(request.egcuId(), request.category(), request.soundId()); Core::FunctionReplyObject reply = Core::FunctionReplyObject(0); m_ddsHandler->ftsSom()->controlSoundReply(cookie, reply); break; } case SoundManagement::PlayControl::PlaySingle: case SoundManagement::PlayControl::PlayLoop: // NOTE: falls through if PlaySingle ! { const bool loop = (request.control().underlying() == SoundManagement::PlayControl::PlayLoop); const int durationMs = getDuration(request.category(), request.soundId()); // QTimer::singleShot(1 * 60 * 1000, this, [id, this]() { m_mainHandler->dds()->dtsAlm()->removeNotificationByKey(id); }); const int soundId = request.soundId(); const int egcuId = request.egcuId(); const SoundManagement::SoundCategory category = request.category(); DEBUG_LOG(m_logger) << "Play: durationMs=" << durationMs << " egcuId=" << egcuId << " soundId=" << soundId << " loop=" << loop; const int control = static_cast(request.control().underlying()); const int volumePercent = static_cast(request.volumePercent()); const QString msg(playBackgroundSound(user, passwd, hostname, enumToString(request.category()), request.soundId(), volumePercent, control)); // => blocking !! if (!msg.isEmpty()) { Core::FunctionReplyObject reply = Core::FunctionReplyObject(-1, tr_lts("dds", "Playing sound failed: %1"), { msg.toStdString() }); m_ddsHandler->ftsSom()->controlSoundReply(cookie, reply); return; } if (!loop) QTimer::singleShot(durationMs, this, [ egcuId, category, soundId, this]() { onStopSingleSound(egcuId, category, soundId); }); // stop sound after n ms (aka. after clip ends) // Publish on DDS // insert into m_soundStates SoundManagement::SoundState soundState; soundState.egcuId(egcuId); soundState.soundId(soundId); soundState.category(request.category()); soundState.id(m_indexActiveSound); soundState.sampleTime(QDateTime::currentMSecsSinceEpoch()); soundState.inLoop(loop); DEBUG_LOG(m_logger) << "id=" << m_indexActiveSound << " category=" << request.category() << " egcuId=" << request.egcuId() << " soundId=" << request.soundId() << " time=" << soundState.sampleTime(); m_ddsHandler->dtsSom()->publish(soundState); m_soundStates.append(soundState); m_indexActiveSound++; Core::FunctionReplyObject reply = Core::FunctionReplyObject(0); m_ddsHandler->ftsSom()->controlSoundReply(cookie, reply); break; } case SoundManagement::PlayControl::StopAllSounds: { stopAllSounds(request.egcuId()); Core::FunctionReplyObject reply = Core::FunctionReplyObject(0); m_ddsHandler->ftsSom()->controlSoundReply(cookie, reply); break; } case SoundManagement::PlayControl::GetState: { getActiveSound(request.egcuId()); Core::FunctionReplyObject reply = Core::FunctionReplyObject(0); m_ddsHandler->ftsSom()->controlSoundReply(cookie, reply); break; } } } void HandlerSounds::onStopSingleSound(const int egcuId, const SoundManagement::SoundCategory soundCategory, const int soundId) { QString user = Settings::somUser(); QString passwd = Settings::somPasswd(); QString host = m_hostnames.value(egcuId); DEBUG_LOG(m_logger) << "egcuId=" << egcuId << " soundId=" << soundId << " category=" << enumToString(soundCategory); // QMutableVectorIterator simplifies and is less errorprone :-) QMutableVectorIterator it(m_soundStates); while (it.hasNext()) { const SoundState &item = it.next(); if ((item.soundId() == soundId) && (item.egcuId() == egcuId) && item.category() == soundCategory) { DEBUG_LOG(m_logger) << "remove Sound from DDS-BUS id=" << item.id() << " egcuId=" << item.egcuId(); { // start update request // http://ubeecu0001/bgsound.php?category=Vehicles&sound=2&control=2 QUrl url; int control = SoundManagement::PlayControl::StopSound; QString category = enumToString(soundCategory); QString request = QStringLiteral("http://%1/bgsound.php?category=%2&sound=%3&control=%4") .arg(host) .arg(category) .arg(soundId) .arg(control); url.setUrl(request); url.setUserName(user); url.setPassword(passwd); startRequest(url); } m_ddsHandler->dtsSom()->removeSoundStateByKey(item.id()); it.remove(); // combination of soundId and egcuId may occur more than once, do not break the loop } } //while } QString HandlerSounds::stopAllSounds(const int egcuId) { const QString user(Settings::somUser()); const QString passwd(Settings::somPasswd()); const QString host(m_hostnames.value(egcuId)); // http://ubeecu0001/bgsound.php?control=5 // 200{ "ID":"0x510","Name":"Sound Report","sounds":[{"category":"Explosions","sound":"0001"}]} // 200{ "ID":"0x510","Name":"Sound Report","sounds":[{"category":"Explosions","sound":"0001"},{"category":"Explosions","sound":"0001"}]} QUrl url; const int control = SoundManagement::PlayControl::StopAllSounds; const QString request = QStringLiteral("http://%1/bgsound.php?control=%2") .arg(host) .arg(control); url.setUrl(request); url.setUserName(user); url.setPassword(passwd); const QString msg(startRequestBlocking(url)); if (!msg.isEmpty()) return msg; QMutableVectorIterator it(m_soundStates); while (it.hasNext()) { const SoundState &ss(it.next()); DEBUG_LOG(m_logger) << "Sound EGCU=" << ss.egcuId() << " soundId=" << ss.soundId(); if (ss.egcuId() != egcuId) continue; DEBUG_LOG(m_logger) << "remove Sound from DDS-BUS id=" << ss.id() << " egcuId=" << ss.egcuId(); m_ddsHandler->dtsSom()->removeSoundStateByKey(ss.id()); it.remove(); } return {}; // no error } void HandlerSounds::getActiveSound(const int egcuId) { QString user = Settings::somUser(); QString passwd = Settings::somPasswd(); QString host = m_hostnames.value(egcuId); // http://ubeecu0001/bgsound.php?control=5 // 200{ "ID":"0x510","Name":"Sound Report","sounds":[{"category":"Explosions","sound":"0001"}]} // 200{ "ID":"0x510","Name":"Sound Report","sounds":[{"category":"Explosions","sound":"0001"},{"category":"Explosions","sound":"0001"}]} QUrl url; int control = SoundManagement::PlayControl::GetState; QString request = QStringLiteral("http://%1/bgsound.php?control=%2") .arg(host) .arg(control); url.setUrl(request); url.setUserName(user); url.setPassword(passwd); DEBUG_LOG(m_logger) << "startRequest: " << url.toString(); startRequest(url); } QString HandlerSounds::playBackgroundSound(const QString &user, const QString &passwd, const QString &host, const QString &category, const int sound, const int volume, const int control) { QUrl url; //http://localhost/bgsound.php?category=Aircrafts&sound=2&control=3&vol=50 QString request = QStringLiteral("http://%1/bgsound.php?category=%2&sound=%3&control=%4&vol=%5") .arg(host) .arg(category) .arg(sound) .arg(control) .arg(volume); url.setUrl(request); url.setUserName(user); url.setPassword(passwd); DEBUG_LOG(m_logger) << "startRequest: " << url.toString() << " host=" << host; return startRequestBlocking(url); } QString HandlerSounds::startRequestBlocking(const QUrl &requestedUrl) { DEBUG_LOG(m_logger) << "startRequest: " << requestedUrl.toString(); m_httpRequestAborted = false; auto reply = m_qnam.get(QNetworkRequest(requestedUrl)); await(reply, &QNetworkReply::finished); return httpFinishedBlocking(reply); } void HandlerSounds::startRequest(const QUrl &requestedUrl) { DEBUG_LOG(m_logger) << "startRequest: " << requestedUrl.toString(); m_httpRequestAborted = false; auto reply = m_qnam.get(QNetworkRequest(requestedUrl)); connect(reply, &QNetworkReply::finished, this, &HandlerSounds::httpFinished); } QString HandlerSounds::httpFinishedBlocking(QNetworkReply *reply) { DEBUG_LOG(m_logger) << "httpFinishedBlocking"; QUrl url; // auto reply = qobject_cast(sender()); // Q_ASSERT(reply); // if (!reply) // return {}; QNetworkRequest request = reply->request(); url = request.url(); if (m_httpRequestAborted) { ERROR_LOG(m_logger) << "httpRequestAborted"; reply->deleteLater(); return QString::fromStdString(tr_lts("dds", "httpRequestAborted")); } if (reply->error()) { QByteArray data = reply->readAll(); QString dataStr = QString::fromStdString(data.toStdString()); ERROR_LOG(m_logger) << "reply->error: " << reply->errorString() << " host=" << url.host() << " query='" << url.query() << "' '" << qUtf8Printable(url.toString()) << "'" << " data=" << dataStr; // Also add unsuccessful feedback QString query = url.query(); if (query.contains(QStringLiteral("control=5"))) { DEBUG_LOG(m_logger) << "m_activeSounds.insert host=" << url.host(); m_activeSounds.insert(url.host(), QString()); } reply->deleteLater(); return reply->errorString(); } // Sucess //parse the reply JSON and display result in the UI const QByteArray json(reply->readAll()); DEBUG_LOG(m_logger) << "Sucess " << json; QString jsonStr = QString::fromStdString(json.toStdString()); if (jsonStr.contains(QStringLiteral("510"))) // 510 = Sound Report handleSoundReport(jsonStr, url.host()); reply->deleteLater(); return {}; } void HandlerSounds::httpFinished() { DEBUG_LOG(m_logger) << "httpFinished"; QUrl url; auto reply = qobject_cast(sender()); if (!reply) return; QNetworkRequest request = reply->request(); url = request.url(); if (m_httpRequestAborted) { ERROR_LOG(m_logger) << "httpRequestAborted"; reply->deleteLater(); return; } if (reply->error()) { QByteArray data = reply->readAll(); QString dataStr = QString::fromStdString(data.toStdString()); ERROR_LOG(m_logger) << "reply->error: " << reply->errorString() << " host=" << url.host() << " query='" << url.query() << "' '" << qUtf8Printable(url.toString()) << "'" << " data=" << dataStr; // Also add unsuccessful feedback QString query = url.query(); if (query.contains(QStringLiteral("control=5"))) { DEBUG_LOG(m_logger) << "m_activeSounds.insert host=" << url.host(); m_activeSounds.insert(url.host(), QString()); } reply->deleteLater(); return; } // Sucess //parse the reply JSON and display result in the UI const QByteArray json(reply->readAll()); DEBUG_LOG(m_logger) << "Sucess " << json; QString jsonStr = QString::fromStdString(json.toStdString()); if (jsonStr.contains(QStringLiteral("510"))) // 510 = Sound Report handleSoundReport(jsonStr, url.host()); reply->deleteLater(); } int HandlerSounds::getAssetId(const QString &hostName) { QHashIterator i(m_hostnames); while (i.hasNext()) { i.next(); QString name = i.value(); if (name.contains(hostName, Qt::CaseInsensitive)) return i.key(); } return 0; } int HandlerSounds::getSoundIndex(const SoundCategory &category, const QString &name) { for (const SoundStr &soundName: qAsConst(m_soundNames)) if ((category == soundName.category) && (name == soundName.name)) return soundName.index; return -1; } int HandlerSounds::getDuration(const SoundManagement::SoundCategory& category,const int soundId) { for (const SoundStr &soundName: qAsConst(m_soundNames)) { if ( soundId == soundName.soundId && category == soundName.category) { DEBUG_LOG(m_logger) << "Duration=" << soundName.duration << "ms"; return soundName.duration; } } // for return -1; } void HandlerSounds::handleSoundReport(const QString &json, const QString &host) { SoundManagement::SoundState soundState; QString jsonString; QString jsonStr = QString::fromStdString(json.toStdString()); DEBUG_LOG(m_logger) << "remove 200"; jsonString = jsonStr.remove(QStringLiteral("200")); m_activeSounds.insert(host, jsonString); // Send Result Topic DEBUG_LOG(m_logger) << "Send Result Topic"; DEBUG_LOG(m_logger) << "m_updateActiveSoundsTimer->stop();"; DEBUG_LOG(m_logger) << "host=" << host << " jsonString= " << jsonString; // decode JSON-Object QJsonDocument doc = QJsonDocument::fromJson(jsonString.toUtf8()); QJsonObject jsonObject; // check validity of the document if (!doc.isNull()) { if (doc.isObject()) { jsonObject = doc.object(); const QJsonArray &sounds = jsonObject[QStringLiteral("sounds")].toArray(); // TODO Pruefen, ob in der lokalen Verwaltung noch Sounds sind, die geloescht und vom DDS-Bus genommen // werden muessen. for (const QJsonValue &valSound : qAsConst(sounds)) { const QJsonObject &sound = valSound.toObject(); bool found = false; QString categoryStr = sound.value(QStringLiteral("category")).toString(); QString name = sound.value(QStringLiteral("sound")).toString(); int egcuId = getAssetId(host); SoundManagement::SoundCategory category = stringToEnum(categoryStr); int soundId = getSoundIndex(category, name); soundState.egcuId(egcuId); soundState.soundId(soundId); soundState.category(category); soundState.id(m_indexActiveSound); soundState.sampleTime(QDateTime::currentMSecsSinceEpoch()); DEBUG_LOG(m_logger) << "id=" << m_indexActiveSound << " category=" << categoryStr << " name=" << name << " egcuId=" << egcuId << " soundId=" << soundId << " time=" << soundState.sampleTime(); for (const SoundManagement::SoundState& item : qAsConst(m_soundStates)) { if ( (item.egcuId() == soundState.egcuId()) && (item.category() == soundState.category()) && (item.soundId() == soundState.soundId()) ) { DEBUG_LOG(m_logger) << "Sound is already on DDS-Bus"; found = true; break; } } // for if (!found) { m_indexActiveSound++; DEBUG_LOG(m_logger) << "Sound publish"; m_ddsHandler->dtsSom()->publish(soundState); m_soundStates.append(soundState); } } } else ERROR_LOG(m_logger) << "Document is not an object"; } else { if (jsonStr.size() == 0) DEBUG_LOG(m_logger) << "No Sounds for " << host; else ERROR_LOG(m_logger) << "Invalid JSON...\n" << jsonStr; } m_updateActiveSoundsTimer->stop(); } void HandlerSounds::onTimerTimeout() { ERROR_LOG(m_logger) << "Problem when querying the active sounds from the EGCU's"; } void HandlerSounds::onInstrumentationAssetChanged(const InfrastructureManagement::InstrumentationAsset &data, DataModification modType) { if (modType != DataModification::eAdded && modType != DataModification::eModified) return; DEBUG_LOG(m_logger) << "onInstrumentationAssetChanged id=" << data.id() << " hostname=" << QString::fromStdString(data.hostname()) << " mountingPointTypeId=" << data.mountingPointTypeId() << " assetStateId=" << data.assetStateId(); if ((data.mountingPointTypeId() == InfrastructureManagement::MountingPointType::EffectGenerationControlUnit) && data.assetStateId() == InfrastructureManagement::InstrumentationAssetState::Mounted && data.hostname().size() > 0) { QString hostname = QString::fromStdString(data.hostname()); DEBUG_LOG(m_logger) << "m_hostnames.insert id=" << data.id() << " hostname=" << hostname << " hostname.size=" << hostname.size() << " mountingPointTypeId=" << data.mountingPointTypeId() << " assetStateId=" << data.assetStateId(); if (hostname.size() > 0 ) { DEBUG_LOG(m_logger) << "insert EGCU in m_hostnames " << data.hostname(); m_hostnames.insert(data.id(), QString::fromStdString(data.hostname())); } } } void HandlerSounds::onMountingPointAssetChanged(const InfrastructureManagement::MountingPointAsset &data, DataModification modType) { if (modType != DataModification::eAdded && modType != DataModification::eModified) return; DEBUG_LOG(m_logger) << "onMountingPointAssetChanged" << " id= " << data.id() << " assetId= " << data.assetId() << " structureElementId= " << data.structureElementId(); m_mountingPointAsset.insert(data.structureElementId(),data.assetId()); } void HandlerSounds::onSoundStateChanged(const SoundManagement::SoundState &data, DataModification modType) { DEBUG_LOG(m_logger) << "onSoundStateChanged" << " id= " << data.id() << " egcuId= " << data.egcuId() << " soundId=" << data.soundId() << " modType=" << modType; if (modType != DataModification::eAdded && modType != DataModification::eModified) return; } //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- } // namespace SoundManagement