mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2025-03-16 23:00:55 +00:00
AIS-related namespace cleanup.
This commit is contained in:
parent
37d7d5b273
commit
3e0acc9988
@ -39,13 +39,13 @@ static std::string latlon_normalized(const int32_t normalized) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static std::string mmsi(
|
static std::string mmsi(
|
||||||
const baseband::ais::MMSI& mmsi
|
const ais::MMSI& mmsi
|
||||||
) {
|
) {
|
||||||
return to_string_dec_uint(mmsi, 9, '0');
|
return to_string_dec_uint(mmsi, 9, '0');
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::string datetime(
|
static std::string datetime(
|
||||||
const baseband::ais::DateTime& datetime
|
const ais::DateTime& datetime
|
||||||
) {
|
) {
|
||||||
return to_string_dec_uint(datetime.year, 4, '0') + "/" +
|
return to_string_dec_uint(datetime.year, 4, '0') + "/" +
|
||||||
to_string_dec_uint(datetime.month, 2, '0') + "/" +
|
to_string_dec_uint(datetime.month, 2, '0') + "/" +
|
||||||
@ -89,7 +89,7 @@ AISModel::AISModel() {
|
|||||||
log_file.open_for_append("ais.txt");
|
log_file.open_for_append("ais.txt");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AISModel::on_packet(const baseband::ais::Packet& packet) {
|
bool AISModel::on_packet(const ais::Packet& packet) {
|
||||||
// TODO: Unstuff here, not in baseband!
|
// TODO: Unstuff here, not in baseband!
|
||||||
|
|
||||||
if( !packet.is_valid() ) {
|
if( !packet.is_valid() ) {
|
||||||
@ -122,7 +122,7 @@ void AISView::on_show() {
|
|||||||
const auto message = static_cast<const AISPacketMessage*>(p);
|
const auto message = static_cast<const AISPacketMessage*>(p);
|
||||||
rtc::RTC datetime;
|
rtc::RTC datetime;
|
||||||
rtcGetTime(&RTCD1, &datetime);
|
rtcGetTime(&RTCD1, &datetime);
|
||||||
const baseband::ais::Packet packet { datetime, message->packet };
|
const ais::Packet packet { datetime, message->packet };
|
||||||
if( this->model.on_packet(packet) ) {
|
if( this->model.on_packet(packet) ) {
|
||||||
this->on_packet(packet);
|
this->on_packet(packet);
|
||||||
}
|
}
|
||||||
@ -143,7 +143,7 @@ void AISView::truncate_entries() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AISView::on_packet(const baseband::ais::Packet& packet) {
|
void AISView::on_packet(const ais::Packet& packet) {
|
||||||
const auto source_id = packet.source_id();
|
const auto source_id = packet.source_id();
|
||||||
auto matching_recent = std::find_if(recent.begin(), recent.end(),
|
auto matching_recent = std::find_if(recent.begin(), recent.end(),
|
||||||
[source_id](const AISView::RecentEntry& entry) { return entry.mmsi == source_id; }
|
[source_id](const AISView::RecentEntry& entry) { return entry.mmsi == source_id; }
|
||||||
|
@ -42,7 +42,7 @@ class AISModel {
|
|||||||
public:
|
public:
|
||||||
AISModel();
|
AISModel();
|
||||||
|
|
||||||
bool on_packet(const baseband::ais::Packet& packet);
|
bool on_packet(const ais::Packet& packet);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
LogFile log_file;
|
LogFile log_file;
|
||||||
@ -69,7 +69,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
AISModel model;
|
AISModel model;
|
||||||
|
|
||||||
using EntryKey = baseband::ais::MMSI;
|
using EntryKey = ais::MMSI;
|
||||||
EntryKey selected_key;
|
EntryKey selected_key;
|
||||||
const EntryKey invalid_key = 0xffffffff;
|
const EntryKey invalid_key = 0xffffffff;
|
||||||
|
|
||||||
@ -77,12 +77,12 @@ private:
|
|||||||
|
|
||||||
struct Position {
|
struct Position {
|
||||||
rtc::RTC timestamp { };
|
rtc::RTC timestamp { };
|
||||||
baseband::ais::Latitude latitude { 0 };
|
ais::Latitude latitude { 0 };
|
||||||
baseband::ais::Longitude longitude { 0 };
|
ais::Longitude longitude { 0 };
|
||||||
};
|
};
|
||||||
|
|
||||||
struct RecentEntry {
|
struct RecentEntry {
|
||||||
baseband::ais::MMSI mmsi;
|
ais::MMSI mmsi;
|
||||||
std::string name;
|
std::string name;
|
||||||
std::string call_sign;
|
std::string call_sign;
|
||||||
std::string destination;
|
std::string destination;
|
||||||
@ -91,7 +91,7 @@ private:
|
|||||||
int8_t navigational_status;
|
int8_t navigational_status;
|
||||||
|
|
||||||
RecentEntry(
|
RecentEntry(
|
||||||
const baseband::ais::MMSI& mmsi
|
const ais::MMSI& mmsi
|
||||||
) : mmsi { mmsi },
|
) : mmsi { mmsi },
|
||||||
last_position { },
|
last_position { },
|
||||||
received_count { 0 },
|
received_count { 0 },
|
||||||
@ -103,7 +103,7 @@ private:
|
|||||||
using RecentEntries = std::list<RecentEntry>;
|
using RecentEntries = std::list<RecentEntry>;
|
||||||
RecentEntries recent;
|
RecentEntries recent;
|
||||||
|
|
||||||
void on_packet(const baseband::ais::Packet& packet);
|
void on_packet(const ais::Packet& packet);
|
||||||
|
|
||||||
void draw_entry(
|
void draw_entry(
|
||||||
const RecentEntry& entry,
|
const RecentEntry& entry,
|
||||||
|
@ -25,7 +25,6 @@
|
|||||||
|
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
|
||||||
namespace baseband {
|
|
||||||
namespace ais {
|
namespace ais {
|
||||||
|
|
||||||
using CRCFieldReader = ::FieldReader<baseband::Packet, BitRemapNone>;
|
using CRCFieldReader = ::FieldReader<baseband::Packet, BitRemapNone>;
|
||||||
@ -225,4 +224,3 @@ bool Packet::length_valid() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} /* namespace ais */
|
} /* namespace ais */
|
||||||
} /* namespace baseband */
|
|
||||||
|
@ -32,7 +32,6 @@ using namespace lpc43xx;
|
|||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
namespace baseband {
|
|
||||||
namespace ais {
|
namespace ais {
|
||||||
|
|
||||||
struct DateTime {
|
struct DateTime {
|
||||||
@ -97,6 +96,5 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
} /* namespace ais */
|
} /* namespace ais */
|
||||||
} /* namespace baseband */
|
|
||||||
|
|
||||||
#endif/*__AIS_PACKET_H__*/
|
#endif/*__AIS_PACKET_H__*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user