move completely to spdlog, refactor channel class

This commit is contained in:
Nam Tran
2020-11-24 17:53:31 -06:00
parent 4a692fc42f
commit 14070f8017
5 changed files with 51 additions and 48 deletions

34
channel.cc Normal file
View File

@@ -0,0 +1,34 @@
#include "channel.h"
#include "spdlog/spdlog.h"
Channel::Channel(char const * ptr, size_t len) {
valid = true;
uint32_t * wordData = (uint32_t *)ptr;
size = ((wordData[0] & 0xFFFFFF00) >> 8) * sizeof(uint32_t);
if (size != len) valid = false;
version = wordData[0] && 0xFF;
if (version != 0x1) valid = false;
for (int i = 0; i < 3; i++)
integral[i] = (wordData[i + 1] & 0xFFFFFF00)>>8;
crossing = wordData[4] & 0x00FFFFFF;
block_count = (wordData[5] &0xFF000000) >> 24;
id = (wordData[5] & 0x00FF0000) >> 16;
spill = (wordData[5] & 0x0000FFFF);
if ((id > 8) || (id < 1)) {
valid = false;
}
}
void Channel::Print(){
if (valid) {
spdlog::info("channel {}, spill {}, size {}, blocks {}, crossing {}, integrals {}, {}, {}",
id, spill, size, block_count, crossing, integral[0], integral[1], integral[2]);
}
else {
spdlog::info("Invalid channel");
}
}