Skip to content
Snippets Groups Projects
Commit 015f84d4 authored by Valerio Pastore's avatar Valerio Pastore
Browse files

small fixes

parent 200da98a
No related branches found
No related tags found
No related merge requests found
......@@ -5,9 +5,6 @@ set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
option(FILERECEIVER_BUILD_SHARED "Build FileReceiver as a shared library." OFF)
set(RAW_FILES_PATH "${CMAKE_INSTALL_PREFIX}/config/RawTestFiles/" CACHE PATH "Raw Test files Path")
add_compile_definitions(RAW_FILES_PATH="${RAW_FILES_PATH}")
set(SOURCES
src/File_Receiver.cpp
src/Builder.cpp
......@@ -34,5 +31,15 @@ set(INC_DIR
)
target_include_directories (FileReceiver PUBLIC ${INC_DIR})
set(CONFIG_DEST "${CMAKE_INSTALL_PREFIX}/config/FileReceiver" CACHE PATH "Destination of config files")
set(RAW_FILES_PATH "${CONFIG_DEST}/testfile/" CACHE PATH "Raw Test files Path")
add_compile_definitions(RAW_FILES_PATH="${RAW_FILES_PATH}")
set(CONFIG_DIR "config")
install(
DIRECTORY ${CONFIG_DIR}/
DESTINATION "${CONFIG_DEST}"
FILES_MATCHING PATTERN "*"
)
# make install
install(TARGETS FileReceiver DESTINATION "${CMAKE_INSTALL_PREFIX}/lib")
This document describes how to use the test file to check the AstriDAQ data receiving correctness.
The test file is constructed as follows:
3x HK101
3x VAR102
3x HK101
3x VAR103
1x CMD151 (go to run)
3x C11
3x HK101
3x C11
1x CMD151 (go to idle)
3x HK 101
3x VAR102
3x HK101
3x VAR103
1x CMD151 (go to run)
3x S22
3x HK101
3x S22
So, 45 packets in total: 18 HK101, 6 VAR102, 6 VAR103, 6 C11, 6 S22, 3 CMD151.
Sending this file to AstriDAQ will result in the creation of 4 files:
..F.. -> file of the first idle. It contains packets until first CMD151 (included);
..R.. -> file of the first run (calibration). It contains the rest of the packets until second CMD151 (included);
..I.. -> file of the second idle. It contains the rest of the packets until third CMD151 (included);
..R.. -> file of the second run (scientific). It contains the rest of the packets until last CMD151 (included);
If the mentioned files are generated, you can check the correctness by concatenating generated files and then performing a diff with the original test file.
$ cat ..F.. ..R.. ..I.. ..R.. > result.raw
$ diff test.raw result.raw
File added
......@@ -5,7 +5,7 @@
#include <fstream>
#ifndef RAW_FILES_PATH
#define RAW_FILES_PATH std::string(std::getenv("HOME")).append("/BIAS/config/RawTestFiles")
#define RAW_FILES_PATH std::string(std::getenv("HOME")).append("/BIAS/config/packets/raw test packets")
#endif
/**
......
......@@ -32,6 +32,13 @@ FileReceiver::FileReceiver(std::string source, int rate) :
}
int FileReceiver::receiveFromClient(Packets::BasePacket &pack) {
if (!this->isConnectedToClient()) {
time_t now = time(nullptr);
std::cerr << "[" << std::put_time(localtime(&now), "%Y-%m-%d %H:%M:%S")
<< "]\t[File Receiver]\t" << host << " not open!"
<< std::endl;
return -1;
}
if (ifile->tellg() == filesize) { // end of file, open next
if (!openNextFile()) { // all file processed
closeConnectionToClient();
......@@ -105,7 +112,7 @@ int FileReceiver::connectToClient() {
}
int FileReceiver::closeConnectionToClient() {
if (ifile != nullptr) {
if (isConnectedToClient()) {
ifile->close();
}
return 1;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment