Parse Digital Radar Data (Message Type 31)

This commit is contained in:
Dan Paulat 2021-06-20 20:28:22 -05:00
parent 6acb6a8c9d
commit f0386cda27
8 changed files with 589 additions and 28 deletions

View file

@ -0,0 +1,37 @@
#pragma once
#include <scwx/wsr88d/rda/message.hpp>
namespace scwx
{
namespace wsr88d
{
namespace rda
{
class DigitalRadarDataImpl;
class DigitalRadarData : public Message
{
public:
explicit DigitalRadarData();
~DigitalRadarData();
DigitalRadarData(const Message&) = delete;
DigitalRadarData& operator=(const DigitalRadarData&) = delete;
DigitalRadarData(DigitalRadarData&&) noexcept;
DigitalRadarData& operator=(DigitalRadarData&&) noexcept;
bool Parse(std::istream& is);
static std::unique_ptr<DigitalRadarData> Create(MessageHeader&& header,
std::istream& is);
private:
std::unique_ptr<DigitalRadarDataImpl> p;
};
} // namespace rda
} // namespace wsr88d
} // namespace scwx

View file

@ -36,6 +36,18 @@ protected:
bool ValidateMessage(std::istream& is, size_t bytesRead) const;
public:
virtual ~Message();
const MessageHeader& header() const;
void set_header(MessageHeader&& header);
virtual bool Parse(std::istream& is) = 0;
static constexpr double ANGLE_DATA_SCALE = 0.005493125;
static constexpr double AZ_EL_RATE_DATA_SCALE = 0.001373291015625;
static void ReadBoolean(std::istream& is, bool& value)
{
std::string data(4, ' ');
@ -56,45 +68,43 @@ protected:
}
template<size_t _Size>
static void SwapFloatArray(std::array<float, _Size>& arr)
static void SwapArray(std::array<float, _Size>& arr, size_t size = _Size)
{
std::transform(std::execution::par_unseq,
arr.begin(),
arr.end(),
arr.begin() + size,
arr.begin(),
[](float f) { return SwapFloat(f); });
}
template<size_t _Size>
static void SwapUInt16Array(std::array<uint16_t, _Size>& arr)
static void SwapArray(std::array<uint16_t, _Size>& arr, size_t size = _Size)
{
std::transform(std::execution::par_unseq,
arr.begin(),
arr.end(),
arr.begin() + size,
arr.begin(),
[](uint16_t u) { return ntohs(u); });
}
template<size_t _Size>
static void SwapArray(std::array<uint32_t, _Size>& arr, size_t size = _Size)
{
std::transform(std::execution::par_unseq,
arr.begin(),
arr.begin() + size,
arr.begin(),
[](uint32_t u) { return ntohl(u); });
}
template<typename T>
static void SwapFloatMap(std::map<T, float>& m)
static void SwapMap(std::map<T, float>& m)
{
std::for_each(std::execution::par_unseq, m.begin(), m.end(), [](auto& p) {
p.second = SwapFloat(p.second);
});
}
public:
virtual ~Message();
const MessageHeader& header() const;
void set_header(MessageHeader&& header);
virtual bool Parse(std::istream& is) = 0;
static constexpr double ANGLE_DATA_SCALE = 0.005493125;
static constexpr double AZ_EL_RATE_DATA_SCALE = 0.001373291015625;
private:
std::unique_ptr<MessageImpl> p;
};