mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-30 17:50:04 +00:00
Radar coded message stub
This commit is contained in:
parent
9b48db3d8d
commit
97ab1de94c
4 changed files with 159 additions and 0 deletions
|
|
@ -3,6 +3,7 @@
|
|||
#include <scwx/util/vectorbuf.hpp>
|
||||
#include <scwx/wsr88d/rpg/general_status_message.hpp>
|
||||
#include <scwx/wsr88d/rpg/graphic_product_message.hpp>
|
||||
#include <scwx/wsr88d/rpg/radar_coded_message.hpp>
|
||||
#include <scwx/wsr88d/rpg/tabular_product_message.hpp>
|
||||
|
||||
#include <unordered_map>
|
||||
|
|
@ -48,6 +49,7 @@ static const std::unordered_map<int16_t, CreateLevel3MessageFunction> //
|
|||
{65, GraphicProductMessage::Create},
|
||||
{66, GraphicProductMessage::Create},
|
||||
{67, GraphicProductMessage::Create},
|
||||
{74, RadarCodedMessage::Create},
|
||||
{75, TabularProductMessage::Create},
|
||||
{77, TabularProductMessage::Create},
|
||||
{78, GraphicProductMessage::Create},
|
||||
|
|
|
|||
112
wxdata/source/scwx/wsr88d/rpg/radar_coded_message.cpp
Normal file
112
wxdata/source/scwx/wsr88d/rpg/radar_coded_message.cpp
Normal file
|
|
@ -0,0 +1,112 @@
|
|||
#include <scwx/wsr88d/rpg/radar_coded_message.hpp>
|
||||
|
||||
#include <istream>
|
||||
#include <string>
|
||||
|
||||
#include <boost/log/trivial.hpp>
|
||||
|
||||
namespace scwx
|
||||
{
|
||||
namespace wsr88d
|
||||
{
|
||||
namespace rpg
|
||||
{
|
||||
|
||||
static const std::string logPrefix_ =
|
||||
"[scwx::wsr88d::rpg::radar_coded_message] ";
|
||||
|
||||
class RadarCodedMessageImpl
|
||||
{
|
||||
public:
|
||||
explicit RadarCodedMessageImpl() :
|
||||
descriptionBlock_ {0},
|
||||
pupSiteIdentifier_ {},
|
||||
productCategory_ {},
|
||||
rdaSiteIdentifier_ {}
|
||||
{
|
||||
}
|
||||
~RadarCodedMessageImpl() = default;
|
||||
|
||||
bool LoadBlocks(std::istream& is);
|
||||
|
||||
std::shared_ptr<ProductDescriptionBlock> descriptionBlock_;
|
||||
|
||||
std::string pupSiteIdentifier_;
|
||||
std::string productCategory_;
|
||||
std::string rdaSiteIdentifier_;
|
||||
};
|
||||
|
||||
RadarCodedMessage::RadarCodedMessage() :
|
||||
p(std::make_unique<RadarCodedMessageImpl>())
|
||||
{
|
||||
}
|
||||
RadarCodedMessage::~RadarCodedMessage() = default;
|
||||
|
||||
RadarCodedMessage::RadarCodedMessage(RadarCodedMessage&&) noexcept = default;
|
||||
RadarCodedMessage&
|
||||
RadarCodedMessage::operator=(RadarCodedMessage&&) noexcept = default;
|
||||
|
||||
std::shared_ptr<ProductDescriptionBlock>
|
||||
RadarCodedMessage::description_block() const
|
||||
{
|
||||
return p->descriptionBlock_;
|
||||
}
|
||||
|
||||
bool RadarCodedMessage::Parse(std::istream& is)
|
||||
{
|
||||
bool dataValid = true;
|
||||
|
||||
const std::streampos dataStart = is.tellg();
|
||||
|
||||
p->descriptionBlock_ = std::make_shared<ProductDescriptionBlock>();
|
||||
dataValid = p->descriptionBlock_->Parse(is);
|
||||
|
||||
if (dataValid)
|
||||
{
|
||||
dataValid = p->LoadBlocks(is);
|
||||
}
|
||||
|
||||
const std::streampos dataEnd = is.tellg();
|
||||
if (!ValidateMessage(is, dataEnd - dataStart))
|
||||
{
|
||||
dataValid = false;
|
||||
}
|
||||
|
||||
return dataValid;
|
||||
}
|
||||
|
||||
bool RadarCodedMessageImpl::LoadBlocks(std::istream& is)
|
||||
{
|
||||
BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "Loading Blocks";
|
||||
|
||||
pupSiteIdentifier_.resize(4);
|
||||
productCategory_.resize(5);
|
||||
rdaSiteIdentifier_.resize(4);
|
||||
|
||||
is.read(pupSiteIdentifier_.data(), 4);
|
||||
is.seekg(1, std::ios_base::cur);
|
||||
is.read(productCategory_.data(), 5);
|
||||
is.seekg(1, std::ios_base::cur);
|
||||
is.read(rdaSiteIdentifier_.data(), 4);
|
||||
|
||||
return !is.eof();
|
||||
}
|
||||
|
||||
std::shared_ptr<RadarCodedMessage>
|
||||
RadarCodedMessage::Create(Level3MessageHeader&& header, std::istream& is)
|
||||
{
|
||||
std::shared_ptr<RadarCodedMessage> message =
|
||||
std::make_shared<RadarCodedMessage>();
|
||||
message->set_header(std::move(header));
|
||||
|
||||
if (!message->Parse(is))
|
||||
{
|
||||
message.reset();
|
||||
}
|
||||
|
||||
return message;
|
||||
}
|
||||
|
||||
} // namespace rpg
|
||||
} // namespace wsr88d
|
||||
} // namespace scwx
|
||||
Loading…
Add table
Add a link
Reference in a new issue