/** * @RDE_HEADER@ * MeteoDataManagement - Static Meteo Data Edit Dialog * $Id$ * $HeadURL$ * $Author$ * Created by hjl, SLSE, 2016-10-17 */ #include "esm_convert_to_tab.h" #include #include #include namespace EffectShowManagement { namespace ConvertToTab { //============================================================================= std::vector convertEffectShowOrder(const EffectShowOrder_t &effectShowOrder) { QByteArray ba; ba.reserve(48); LtsUtils::set1Byte(150, ba); LtsUtils::set2Byte(effectShowOrder.idEffectShow, ba); LtsUtils::set4Byte(effectShowOrder.startTime, ba); LtsUtils::set8Byte(effectShowOrder.centerPosition.lon(), ba); LtsUtils::set8Byte(effectShowOrder.centerPosition.lat(), ba); // 50m squares LtsUtils::set1Byte(effectShowOrder.areaWidth / 50, ba); LtsUtils::set1Byte(effectShowOrder.areaDepth / 50, ba); double rotation = fmod(effectShowOrder.rotation, 360.0); if (rotation < 0.0) rotation += 360.0; LtsUtils::set2Byte(qRound(rotation * 100), ba); LtsUtils::set8Byte(effectShowOrder.lowerLeftPosition.lon(), ba); LtsUtils::set8Byte(effectShowOrder.lowerLeftPosition.lat(), ba); LtsUtils::set1Byte(effectShowOrder.numOfVolley, ba); LtsUtils::set1Byte(effectShowOrder.shotsPerVolley, ba); LtsUtils::set1Byte(effectShowOrder.typeOfAmmunition, ba); LtsUtils::set2Byte(static_cast(effectShowOrder.duration), ba); const QByteArray text = effectShowOrder.name.toUtf8().simplified(); for (auto c : text) LtsUtils::set1Byte(c, ba); return LtsUtils::convert>(ba); } //============================================================================= std::vector convertRelocationOrder(const RelocationOrder_t &relocationOrder) { QByteArray ba; ba.reserve(63); LtsUtils::set1Byte(155, ba); LtsUtils::set2Byte(relocationOrder.idRelocation, ba); LtsUtils::set4Byte(relocationOrder.executionTime, ba); LtsUtils::set8Byte(relocationOrder.centerPosition.lon(), ba); LtsUtils::set8Byte(relocationOrder.centerPosition.lat(), ba); const QByteArray text = relocationOrder.infoText.toUtf8().simplified(); for (auto c : text) LtsUtils::set1Byte(c, ba); return LtsUtils::convert>(ba); } //====================================================================== std::vector convertEffectShowStop(const qint16 &idEffectShow) { QByteArray ba; ba.reserve(3); LtsUtils::set1Byte(152, ba); LtsUtils::set2Byte(idEffectShow, ba); return LtsUtils::convert>(ba); } //====================================================================== std::vector convertEffectShowContinue(const EffectShowContinue_t &effectShowContinue) { QByteArray ba; ba.reserve(7); LtsUtils::set1Byte(151, ba); LtsUtils::set2Byte(effectShowContinue.idEffectShow, ba); LtsUtils::set4Byte(effectShowContinue.executionTime, ba); return LtsUtils::convert>(ba); } //====================================================================== std::vector convertOrderRetract(const RetractOrder_t &retractOrder) { QByteArray ba; ba.reserve(4); LtsUtils::set1Byte(153, ba); LtsUtils::set1Byte(retractOrder.orderType, ba); LtsUtils::set2Byte(retractOrder.id, ba); return LtsUtils::convert>(ba); } //===================================================================== std::vector convertStatusRequest() { std::vector tele; tele.resize(1, 154); return tele; } //====================================================================== std::vector convertMeteoData(const MeteoDataManagement::MeteoData &meteoData) { QByteArray ba; ba.reserve(11); LtsUtils::set1Byte(156, ba); LtsUtils::set2Byte(qRound(meteoData.temperature() * 10.0), ba); LtsUtils::set2Byte(qRound(meteoData.humidity()), ba); LtsUtils::set2Byte(qRound(meteoData.pressure()), ba); double dir = fmod(meteoData.windDirection(), 360.0); if (dir < 0.0) dir += 360.0; LtsUtils::set2Byte(qRound(dir * 100), ba); LtsUtils::set2Byte(qRound(meteoData.windSpeed()), ba); return LtsUtils::convert>(ba); } } // namespace ConvertToTab } // namespace EffectShowManagement