Formatted code (#1007)

* Updated style

* Updated files

* fixed new line

* Updated spacing

* File fix WIP

* Updated to clang 13

* updated comment style

* Removed old comment code
This commit is contained in:
jLynx 2023-05-19 08:16:05 +12:00 committed by GitHub
parent 7aca7ce74d
commit 033c4e9a5b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
599 changed files with 70746 additions and 66896 deletions

View file

@ -26,91 +26,94 @@
namespace ert {
size_t Packet::length() const {
return decoder_.symbols_count();
return decoder_.symbols_count();
}
bool Packet::is_valid() const {
return true;
return true;
}
Timestamp Packet::received_at() const {
return packet_.timestamp();
return packet_.timestamp();
}
Packet::Type Packet::type() const {
return type_;
return type_;
}
ID Packet::id() const {
if( type() == Type::SCM ) {
const auto msb = reader_.read(0, 2);
const auto lsb = reader_.read(35, 24);
return (msb << 24) | lsb;
}
if( type() == Type::SCMPLUS ) {
return reader_.read(2 * 8, 32);
}
if( type() == Type::IDM ) {
return reader_.read(5 * 8, 32);
}
return invalid_id;
if (type() == Type::SCM) {
const auto msb = reader_.read(0, 2);
const auto lsb = reader_.read(35, 24);
return (msb << 24) | lsb;
}
if (type() == Type::SCMPLUS) {
return reader_.read(2 * 8, 32);
}
if (type() == Type::IDM) {
return reader_.read(5 * 8, 32);
}
return invalid_id;
}
Consumption Packet::consumption() const {
if( type() == Type::SCM ) {
return reader_.read(11, 24);
}
if( type() == Type::SCMPLUS ) {
return reader_.read(6 * 8, 32);
}
if( type() == Type::IDM ) {
return reader_.read(25 * 8, 32);
}
return invalid_consumption;
if (type() == Type::SCM) {
return reader_.read(11, 24);
}
if (type() == Type::SCMPLUS) {
return reader_.read(6 * 8, 32);
}
if (type() == Type::IDM) {
return reader_.read(25 * 8, 32);
}
return invalid_consumption;
}
CommodityType Packet::commodity_type() const {
if( type() == Type::SCM ) {
return reader_.read(5, 4);
}
if( type() == Type::SCMPLUS ) {
return reader_.read(1 * 8 + 4, 4);
}
if( type() == Type::IDM ) {
return reader_.read(4 * 8 + 4, 4);
}
return invalid_commodity_type;
if (type() == Type::SCM) {
return reader_.read(5, 4);
}
if (type() == Type::SCMPLUS) {
return reader_.read(1 * 8 + 4, 4);
}
if (type() == Type::IDM) {
return reader_.read(4 * 8 + 4, 4);
}
return invalid_commodity_type;
}
FormattedSymbols Packet::symbols_formatted() const {
return format_symbols(decoder_);
return format_symbols(decoder_);
}
bool Packet::crc_ok() const {
switch(type()) {
case Type::SCM: return crc_ok_scm();
case Type::SCMPLUS:
case Type::IDM: return crc_ok_ccitt();
default: return false;
}
switch (type()) {
case Type::SCM:
return crc_ok_scm();
case Type::SCMPLUS:
case Type::IDM:
return crc_ok_ccitt();
default:
return false;
}
}
bool Packet::crc_ok_scm() const {
CRC<16> ert_bch { 0x6f63 };
size_t start_bit = 5;
ert_bch.process_byte(reader_.read(0, start_bit));
for(size_t i=start_bit; i<length(); i+=8) {
ert_bch.process_byte(reader_.read(i, 8));
}
return ert_bch.checksum() == 0x0000;
CRC<16> ert_bch{0x6f63};
size_t start_bit = 5;
ert_bch.process_byte(reader_.read(0, start_bit));
for (size_t i = start_bit; i < length(); i += 8) {
ert_bch.process_byte(reader_.read(i, 8));
}
return ert_bch.checksum() == 0x0000;
}
bool Packet::crc_ok_ccitt() const {
CRC<16> ert_crc_ccitt { 0x1021, 0xffff, 0x1d0f };
for(size_t i=0; i<length(); i+=8) {
ert_crc_ccitt.process_byte(reader_.read(i, 8));
}
return ert_crc_ccitt.checksum() == 0x0000;
CRC<16> ert_crc_ccitt{0x1021, 0xffff, 0x1d0f};
for (size_t i = 0; i < length(); i += 8) {
ert_crc_ccitt.process_byte(reader_.read(i, 8));
}
return ert_crc_ccitt.checksum() == 0x0000;
}
} /* namespace ert */