Commit d5019527 authored by legoc's avatar legoc

version 1.1.1 with writing of header.

parent 36713169
Version 1.1.1, 20YY-MM-DD Version 1.1.1, 20YY-MM-DD
------------------------- -------------------------
- Implemented writeListModeContextToBinary
Version 1.1.0, 2016-12-16 Version 1.1.0, 2016-12-16
------------------------- -------------------------
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
# This configure.ac script is free software; the Free Software Foundation # This configure.ac script is free software; the Free Software Foundation
# gives unlimited permission to copy, distribute and modify it. # gives unlimited permission to copy, distribute and modify it.
AC_INIT([lstdataprocess128], [1.1.1-dev]) AC_INIT([lstdataprocess128], [1.1.1])
LIBRARY_VERSION=1:1:1 LIBRARY_VERSION=1:1:1
......
...@@ -51,6 +51,46 @@ std::ostream& operator<< (std::ostream& os, ListModeContext const & header) { ...@@ -51,6 +51,46 @@ std::ostream& operator<< (std::ostream& os, ListModeContext const & header) {
return os; return os;
} }
std::string writeListModeContextToBinary(const ListModeContext & listModeContext) {
// Count the number of boards.
int boardSize = 0;
for (int c = 0; c < listModeContext.crateBoard.nbCrates; c++) {
for (int b = 0; b < listModeContext.crateBoard.crates[c].nbBoards; b++) {
++boardSize;
}
}
// Allocate the data.
uint32_t buffer[4 + boardSize];
buffer[0] = 1;
buffer[1] = 9;
buffer[2] = 0;
buffer[3] = boardSize;
int i = 0;
for (int c = 0; c < listModeContext.crateBoard.nbCrates; c++) {
for (int b = 0; b < listModeContext.crateBoard.crates[c].nbBoards; b++) {
int32_t eventType = listModeContext.crateBoard.crates[c].boards[b].eventType;
int32_t crate = listModeContext.crateBoard.crates[c].boards[b].crate;
int32_t nbChannels = listModeContext.crateBoard.crates[c].boards[b].nbChannels;
int32_t boardType = listModeContext.crateBoard.crates[c].boards[b].boardType;
buffer[4 + i] = boardType & 0x3F;
buffer[4 + i] |= (nbChannels & 0x3F) << 6;
buffer[4 + i] |= (crate & 0xF) << 12;
buffer[4 + i] |= (eventType & 0xFFFF) << 16;
++i;
}
}
// Return the binary content.
return string(reinterpret_cast<const char *>(buffer), (4 + boardSize) * sizeof(uint32_t));
}
uint32_t readListModeContextFromBinary(ListModeContext & listModeContext, uint32_t version, uint32_t timeBase, uint32_t nbEvents, uint32_t nbBoards, uint32_t* data) { uint32_t readListModeContextFromBinary(ListModeContext & listModeContext, uint32_t version, uint32_t timeBase, uint32_t nbEvents, uint32_t nbBoards, uint32_t* data) {
listModeContext.version = version; listModeContext.version = version;
......
...@@ -35,6 +35,15 @@ static const int EVENT_SIZE_32 = 4; ...@@ -35,6 +35,15 @@ static const int EVENT_SIZE_32 = 4;
*/ */
static const int EVENT_SIZE_8 = 16; static const int EVENT_SIZE_8 = 16;
/**
* Version of the file.
*/
static const int FORMAT_VERSION = 1;
/**
* Time base.
*/
static const int TIME_BASE = 9;
/** /**
* List of different available boards. * List of different available boards.
...@@ -197,7 +206,7 @@ struct ListModeContext { ...@@ -197,7 +206,7 @@ struct ListModeContext {
uint32_t nbEvents; uint32_t nbEvents;
CrateBoard crateBoard; CrateBoard crateBoard;
ListModeContext() : version(0), timeBase(0), nbEvents(0) {} ListModeContext() : version(FORMAT_VERSION), timeBase(TIME_BASE), nbEvents(0) {}
}; };
/** /**
...@@ -215,7 +224,10 @@ extern int32_t listModeHeaderSize; ...@@ -215,7 +224,10 @@ extern int32_t listModeHeaderSize;
*/ */
std::ostream& operator<< (std::ostream& os, ListModeContext const & header); std::ostream& operator<< (std::ostream& os, ListModeContext const & header);
//std::string writeListModeContextToBinary(); /**
* Writes the list mode header. Returns a binary string.
*/
std::string writeListModeContextToBinary(const ListModeContext & listModeContext);
/** /**
* Reads the list mode header. * Reads the list mode header.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment