mirror of
				https://github.com/ciphervance/supercell-wx.git
				synced 2025-10-31 04:20:05 +00:00 
			
		
		
		
	Add parsing of transmission header
This commit is contained in:
		
							parent
							
								
									b65e9a3561
								
							
						
					
					
						commit
						f66a0b46e6
					
				
					 2 changed files with 41 additions and 0 deletions
				
			
		|  | @ -35,6 +35,7 @@ public: | |||
|    WmoHeader(WmoHeader&&) noexcept; | ||||
|    WmoHeader& operator=(WmoHeader&&) noexcept; | ||||
| 
 | ||||
|    const std::string& sequence_number() const; | ||||
|    const std::string& data_type() const; | ||||
|    const std::string& geographic_designator() const; | ||||
|    const std::string& bulletin_id() const; | ||||
|  |  | |||
|  | @ -26,6 +26,7 @@ class WmoHeaderImpl | |||
| { | ||||
| public: | ||||
|    explicit WmoHeaderImpl() : | ||||
|        sequenceNumber_ {}, | ||||
|        dataType_ {}, | ||||
|        geographicDesignator_ {}, | ||||
|        bulletinId_ {}, | ||||
|  | @ -36,6 +37,7 @@ public: | |||
|        productDesignator_ {} {}; | ||||
|    ~WmoHeaderImpl() = default; | ||||
| 
 | ||||
|    std::string sequenceNumber_; | ||||
|    std::string dataType_; | ||||
|    std::string geographicDesignator_; | ||||
|    std::string bulletinId_; | ||||
|  | @ -52,6 +54,11 @@ WmoHeader::~WmoHeader() = default; | |||
| WmoHeader::WmoHeader(WmoHeader&&) noexcept = default; | ||||
| WmoHeader& WmoHeader::operator=(WmoHeader&&) noexcept = default; | ||||
| 
 | ||||
| const std::string& WmoHeader::sequence_number() const | ||||
| { | ||||
|    return p->sequenceNumber_; | ||||
| } | ||||
| 
 | ||||
| const std::string& WmoHeader::data_type() const | ||||
| { | ||||
|    return p->dataType_; | ||||
|  | @ -96,9 +103,17 @@ bool WmoHeader::Parse(std::istream& is) | |||
| { | ||||
|    bool headerValid = true; | ||||
| 
 | ||||
|    std::string sohLine; | ||||
|    std::string sequenceLine; | ||||
|    std::string wmoLine; | ||||
|    std::string awipsLine; | ||||
| 
 | ||||
|    if (is.peek() == 0x01) | ||||
|    { | ||||
|       std::getline(is, sohLine); | ||||
|       std::getline(is, sequenceLine); | ||||
|    } | ||||
| 
 | ||||
|    std::getline(is, wmoLine); | ||||
|    std::getline(is, awipsLine); | ||||
| 
 | ||||
|  | @ -107,6 +122,17 @@ bool WmoHeader::Parse(std::istream& is) | |||
|       BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "Reached end of file"; | ||||
|       headerValid = false; | ||||
|    } | ||||
|    else if (!sohLine.empty() && !sohLine.ends_with("\r\r")) | ||||
|    { | ||||
|       BOOST_LOG_TRIVIAL(debug) | ||||
|          << logPrefix_ << "Start of Heading Line is malformed"; | ||||
|       headerValid = false; | ||||
|    } | ||||
|    else if (!sequenceLine.empty() && !sequenceLine.ends_with(" \r\r")) | ||||
|    { | ||||
|       BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "Sequence Line is malformed"; | ||||
|       headerValid = false; | ||||
|    } | ||||
|    else if (!wmoLine.ends_with("\r\r")) | ||||
|    { | ||||
|       BOOST_LOG_TRIVIAL(debug) | ||||
|  | @ -122,10 +148,24 @@ bool WmoHeader::Parse(std::istream& is) | |||
|    else | ||||
|    { | ||||
|       // Remove delimiters from the end of the line
 | ||||
|       if (!sequenceLine.empty()) | ||||
|       { | ||||
|          sequenceLine.erase(sequenceLine.end() - 3); | ||||
|       } | ||||
| 
 | ||||
|       wmoLine.erase(wmoLine.end() - 2); | ||||
|       awipsLine.erase(awipsLine.end() - 2); | ||||
|    } | ||||
| 
 | ||||
|    // Transmission Header:
 | ||||
|    // [SOH]
 | ||||
|    // nnn
 | ||||
| 
 | ||||
|    if (headerValid && !sequenceLine.empty()) | ||||
|    { | ||||
|       p->sequenceNumber_ = sequenceLine; | ||||
|    } | ||||
| 
 | ||||
|    // WMO Abbreviated Heading Line:
 | ||||
|    // T1T2A1A2ii CCCC YYGGgg (BBB)
 | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Dan Paulat
						Dan Paulat