correct interpretation of integrals
This commit is contained in:
38
channel.cc
38
channel.cc
@@ -1,32 +1,11 @@
|
|||||||
#include "channel.h"
|
#include "channel.h"
|
||||||
#include "spdlog/spdlog.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;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
Channel::Channel(char const * ptr, size_t len, uint32_t board) {
|
Channel::Channel(char const * ptr, size_t len, uint32_t board) {
|
||||||
board_id = board;
|
board_id = board;
|
||||||
valid = true;
|
valid = true;
|
||||||
uint32_t * wordData = (uint32_t *)ptr;
|
uint32_t * wordData = (uint32_t *)ptr;
|
||||||
|
block_data = (char *)ptr;
|
||||||
size = ((wordData[0] & 0xFFFFFF00) >> 8) * sizeof(uint32_t);
|
size = ((wordData[0] & 0xFFFFFF00) >> 8) * sizeof(uint32_t);
|
||||||
if (size != len) valid = false;
|
if (size != len) valid = false;
|
||||||
|
|
||||||
@@ -34,10 +13,10 @@ Channel::Channel(char const * ptr, size_t len, uint32_t board) {
|
|||||||
if (version != 0x1) valid = false;
|
if (version != 0x1) valid = false;
|
||||||
|
|
||||||
for (int i = 0; i < 3; i++)
|
for (int i = 0; i < 3; i++)
|
||||||
integral[i] = (wordData[i + 1] & 0xFFFFFF00)>>8;
|
integral[i] = ((int32_t)(wordData[i+1])) >> 8;
|
||||||
|
|
||||||
crossing = wordData[4] & 0x00FFFFFF;
|
crossing = wordData[4] & 0x00FFFFFF;
|
||||||
block_count = (wordData[5] &0xFF000000) >> 24;
|
block_count = wordData[5] >> 24;
|
||||||
id = (wordData[5] & 0x00FF0000) >> 16;
|
id = (wordData[5] & 0x00FF0000) >> 16;
|
||||||
spill = (wordData[5] & 0x0000FFFF);
|
spill = (wordData[5] & 0x0000FFFF);
|
||||||
if ((id > 8) || (id < 1)) {
|
if ((id > 8) || (id < 1)) {
|
||||||
@@ -45,9 +24,16 @@ Channel::Channel(char const * ptr, size_t len, uint32_t board) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
void Channel::Print(){
|
void Channel::Print(bool raw){
|
||||||
if (valid) {
|
if (valid) {
|
||||||
spdlog::get("zynqDump")->debug("board {}, channel {}, spill {}, size {}, blocks {}, crossing {}, integrals {}, {}, {}",
|
if (raw) {
|
||||||
|
uint32_t * wordData = (uint32_t *)block_data;
|
||||||
|
spdlog::info("{:08X} {:08X} {:08X}", wordData[0], wordData[1], wordData[2]);
|
||||||
|
spdlog::info("{:08X} {:08X} {:08X}", wordData[3], wordData[4], wordData[5]);
|
||||||
|
}
|
||||||
|
// spdlog::get("channel_logger")->info("board {}, channel {}, spill {}, size {}, blocks {}, crossing {}, integrals {}, {}, {}",
|
||||||
|
// board_id, id, spill, size, block_count, crossing, integral[0], integral[1], integral[2]);
|
||||||
|
spdlog::info("board {}, channel {}, spill {}, size {}, blocks {}, crossing {}, integrals {}, {}, {}",
|
||||||
board_id, id, spill, size, block_count, crossing, integral[0], integral[1], integral[2]);
|
board_id, id, spill, size, block_count, crossing, integral[0], integral[1], integral[2]);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
@@ -16,9 +16,8 @@ class Channel {
|
|||||||
char * block_data;
|
char * block_data;
|
||||||
bool valid;
|
bool valid;
|
||||||
public:
|
public:
|
||||||
Channel(char const * ptr, size_t len);
|
|
||||||
Channel(char const * ptr, size_t len, uint32_t board);
|
Channel(char const * ptr, size_t len, uint32_t board);
|
||||||
void Print();
|
void Print(bool raw = false);
|
||||||
|
|
||||||
};
|
};
|
||||||
#endif /* end of include guard */
|
#endif /* end of include guard */
|
||||||
|
|||||||
@@ -156,8 +156,9 @@ int open_socket(){
|
|||||||
void setup_logger(){
|
void setup_logger(){
|
||||||
try {
|
try {
|
||||||
auto max_size = 1048576 * 5;
|
auto max_size = 1048576 * 5;
|
||||||
auto max_files = 3;
|
auto max_files = 20;
|
||||||
auto logger = spdlog::rotating_logger_mt("zynqDump", "logs/dump.txt", max_size, max_files);
|
auto logger = spdlog::rotating_logger_mt("zynqDump", "output/run.txt", max_size, max_files);
|
||||||
|
auto channel_logger = spdlog::rotating_logger_mt("channel_logger", "output/chn.txt", max_size * 10, max_files);
|
||||||
}
|
}
|
||||||
catch (const spdlog::spdlog_ex &ex) {
|
catch (const spdlog::spdlog_ex &ex) {
|
||||||
std::cerr << "Log init failed: " << ex.what() << std::endl;
|
std::cerr << "Log init failed: " << ex.what() << std::endl;
|
||||||
@@ -212,7 +213,7 @@ size_t process_channel(char const * ptr, size_t len, uint32_t board_id){
|
|||||||
bytes_left -= channel_size;
|
bytes_left -= channel_size;
|
||||||
|
|
||||||
Channel c(ptr, channel_size, board_id);
|
Channel c(ptr, channel_size, board_id);
|
||||||
c.Print();
|
c.Print(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user