From e12beee26194aae1524ab9062facd5e3bf20706d Mon Sep 17 00:00:00 2001 From: Valerio Pastore Date: Thu, 11 Jan 2024 19:30:36 +0100 Subject: [PATCH 1/3] adding doxygen --- deps/Base-DAQ | 2 +- include/Astri_Horn_Generic.h | 48 ++++++- include/Astri_Horn_Recognized_Packet.h | 14 +- include/Astri_MA_Generic.h | 182 ++++++++++++++++++++++++- include/Astri_MA_Recognized_Packet.h | 14 +- include/Packet_Structure_Json.h | 44 ++++-- src/Packet_Structure_Json.cpp | 14 +- 7 files changed, 280 insertions(+), 38 deletions(-) diff --git a/deps/Base-DAQ b/deps/Base-DAQ index 8a0ea2d..b581d9c 160000 --- a/deps/Base-DAQ +++ b/deps/Base-DAQ @@ -1 +1 @@ -Subproject commit 8a0ea2d0e699863df5fe1c91caf2d7b0855957be +Subproject commit b581d9c117fbdc1cdadb7d030bcde2c2e4aa35a1 diff --git a/include/Astri_Horn_Generic.h b/include/Astri_Horn_Generic.h index 655b25c..c000ad0 100644 --- a/include/Astri_Horn_Generic.h +++ b/include/Astri_Horn_Generic.h @@ -4,15 +4,59 @@ namespace inaf::oasbo::Packets { -class AstriHornGeneric : public inaf::oasbo::PacketLib::BasePacket { +/** + * @brief Represents a generic ASTRI horn packet. + * @note the "magic numbers" in the implementation of this class derived from the ASTRI Camera BEE – Camera Camera Data Acquisition + * Interface Control Document. + * If the document is updated, be sure to update the magic numbers appropriately. + * This class inherits from the BasePacket class and provides + * functionality specific to ASTRI horn packets. + */ +class AstriHornGeneric : public inaf::oasbo::Packets::BasePacket { public: + /** + * @brief Constructs an AstriHornGeneric object with the given packet structure. + * + * @param structure The packet structure to be used. + */ AstriHornGeneric(inaf::oasbo::PacketLib::BasePacketStructure &structure) : BasePacket(structure){} + + /** + * @brief Gets the size of the header in bytes. + * + * @return The size of the header. + */ uint getHeaderSize() const override; + + /** + * @brief Gets the size of the payload in bytes. + * + * @return The size of the payload. + */ uint getPayloadSize() const override; + + /** + * @brief Gets the size of the tail in bytes. + * + * @return The size of the tail. + */ uint getTailSize() const override; + + /** + * @brief Checks if the packet has a recognized header. + * + * @return True if the packet has a recognized header, false otherwise. + */ bool hasRecognizedHeader() const override; + + /** + * @brief Checks if the given buffer contains a recognized header. + * + * @param buff The buffer to check. + * @return True if the buffer contains a recognized header, false otherwise. + */ bool isRecognizedHeader(std::vector buff) const override; }; -} +} diff --git a/include/Astri_Horn_Recognized_Packet.h b/include/Astri_Horn_Recognized_Packet.h index 2fca692..f476a67 100755 --- a/include/Astri_Horn_Recognized_Packet.h +++ b/include/Astri_Horn_Recognized_Packet.h @@ -1,9 +1,13 @@ -/* - * - * Created on: Mar 1, 2021 - * Author: astrisw +/** + * @brief This file contains the definition of the recognizedPackets for Astri Horn. + * + * The recognizedPackets vector is a static member of the inaf::oasbo::Packets::AstriHorn namespace. + * It stores tuples representing recognized packets, where each tuple contains three values: + * - The first value represents the packet type. + * - The second value represents the packet subtype. + * - The third value represents the packet length. + * */ - #pragma once #include diff --git a/include/Astri_MA_Generic.h b/include/Astri_MA_Generic.h index 612c7c3..0cc4be8 100644 --- a/include/Astri_MA_Generic.h +++ b/include/Astri_MA_Generic.h @@ -4,39 +4,207 @@ namespace inaf::oasbo::Packets { -class AstriMaGeneric : public inaf::oasbo::PacketLib::BasePacket { +/** + * @brief The AstriMaGeneric class represents a generic packet used in the ASTRI DAQ system. + * + * @note the "magic numbers" in the implementation of this class derived from the ASTRI Camera BEE – Camera Camera Data Acquisition + * Interface Control Document. + * If the document is updated, be sure to update the magic numbers appropriately. + * This class inherits from the BasePacket class in the inaf::oasbo::Packets namespace. + * It provides methods to retrieve various properties of the packet, such as header size, payload size, tail size, + * telescope ID, type, subtype, SSC, packet length, date and time information, event counter, and various flags. + */ +class AstriMaGeneric : public inaf::oasbo::Packets::BasePacket { public: - AstriMaGeneric(inaf::oasbo::PacketLib::BasePacketStructure &structure) : BasePacket(structure){} - AstriMaGeneric(inaf::oasbo::PacketLib::BasePacket &other) : BasePacket(other){} + /** + * @brief Constructs an AstriMaGeneric object with the given packet structure. + * + * @param structure The packet structure. + */ + AstriMaGeneric(inaf::oasbo::Packets::BasePacketStructure &structure) : BasePacket(structure){} + + /** + * @brief Constructs an AstriMaGeneric object by copying another BasePacket object. + * + * @param other The other BasePacket object to copy. + */ + AstriMaGeneric(inaf::oasbo::Packets::BasePacket &other) : BasePacket(other){} + + /** + * @brief Gets the size of the header in bytes. + * + * @return The size of the header. + */ uint getHeaderSize() const override; + + /** + * @brief Gets the size of the payload in bytes. + * + * @return The size of the payload. + */ uint getPayloadSize() const override; + + /** + * @brief Gets the size of the tail in bytes. + * + * @return The size of the tail. + */ uint getTailSize() const override; + + /** + * @brief Checks if the packet has a recognized header. + * + * @return True if the packet has a recognized header, false otherwise. + */ bool hasRecognizedHeader() const override; + + /** + * @brief Checks if the given buffer contains a recognized header. + * + * @param buff The buffer to check. + * @return True if the buffer contains a recognized header, false otherwise. + */ bool isRecognizedHeader(std::vector buff) const override; - + + /** + * @brief Gets the telescope ID field value. + * + * @return The telescope ID value. + */ uint getTelescopeID() const; + + /** + * @brief Gets the type of the packet. + * + * @return The packet type. + */ uint getType() const; + + /** + * @brief Gets the subtype of the packet. + * + * @return The packet subtype. + */ uint getSubType() const; + + /** + * @brief Gets the SSC field value. + * + * @return The SSC value. + */ uint getSSC() const; + + /** + * @brief Gets the packetlength field value. + * + * @return The packet length. + */ uint getPacketLength() const; + + /** + * @brief Gets the year field value. + * + * @return The year. + */ uint getYear() const; + + /** + * @brief Gets the month field value. + * + * @return The month. + */ uint getMonth() const; + + /** + * @brief Gets the day field value. + * + * @return The day. + */ uint getDay() const; + + /** + * @brief Gets the hour field value. + * + * @return The hour. + */ uint getHour() const; + + /** + * @brief Gets the minutes field value. + * + * @return The minutes. + */ uint getMinutes() const; + + /** + * @brief Gets the seconds field value. + * + * @return The seconds. + */ uint getSeconds() const; + + /** + * @brief get the validtime field value + * + * @return validtime + */ bool getValidTime() const; + + /** + * @brief Gets the time tag nanoseconds field value + * + * @return time tag nanoseconds. + */ uint getTimeTagNanoseconds() const; + + /** + * @brief Gets the event counter field value. + * + * @return The event counter. + */ uint getEventCounter() const; + + /** + * @brief get the lif field value. + * + * @return lid value + */ bool getLid() const; + + /** + * @brief get the fibst field value. + * + * @return fibst value. + */ bool fibSt() const; + + /** + * @brief get the fibCont field value. + * + * @return fibCont value. + */ bool fibCont() const; + + /** + * @brief get the fibPuls field value. + * + * @return fibPuls value. + */ bool fibPuls() const; + + /** + * @brief get the rgbCont field value. + * + * @return rgbCont value. + */ uint rgbCont() const; + + /** + * @brief get the rgbPuls field value. + * + * @return rgbPuls value. + */ uint rgbPuls() const; - - - }; } diff --git a/include/Astri_MA_Recognized_Packet.h b/include/Astri_MA_Recognized_Packet.h index a046371..9971307 100755 --- a/include/Astri_MA_Recognized_Packet.h +++ b/include/Astri_MA_Recognized_Packet.h @@ -1,9 +1,13 @@ -/* - * - * Created on: Mar 1, 2021 - * Author: astrisw +/** + * @brief This file contains the definition of the recognizedPackets for Astri MA. + * + * The recognizedPackets vector is a static member of the inaf::oasbo::Packets::AstriMa namespace. + * It stores tuples representing recognized packets, where each tuple contains three values: + * - The first value represents the packet type. + * - The second value represents the packet subtype. + * - The third value represents the packet length. + * */ - #pragma once #include diff --git a/include/Packet_Structure_Json.h b/include/Packet_Structure_Json.h index 6d3c5cb..88ea2d2 100644 --- a/include/Packet_Structure_Json.h +++ b/include/Packet_Structure_Json.h @@ -1,12 +1,4 @@ -/* - * PacketLib.h - * - * Created on: Nov 24, 2022 - * Author: valerio - */ - -#ifndef INCLUDE_INAF_OAS_PACKET_STRUCTURE_JSON_H_ -#define INCLUDE_INAF_OAS_PACKET_STRUCTURE_JSON_H_ +#pragma once #include #include @@ -23,18 +15,48 @@ using my_json = basic_json; namespace inaf::oasbo::Packets { +/** + * @brief Represents a JSON packet structure for ASTRI DAQ. + * + * This class extends the BasePacketStructure class and provides functionality + * to convert JSON data into a tuple vector and read the structure from a source. + * The compatible json files are in config folder. + */ class PacketStructureJson : public inaf::oasbo::PacketLib::BasePacketStructure { protected: + /** + * @brief Converts JSON data into a tuple vector. + * + * @param data The JSON data to convert. + * @param count The count of tuples in the vector. + * @return An optional structure representing the tuple vector. + */ static std::optional convertToTupleVector(const my_json &data, uint &count); + + /** + * @brief Reads the packet structure from a source. + * + * @param source The source from which to read the structure. + * @return The structure read from the source. + */ static Structure readStructureFromSource(std::string source); + public: + /** + * @brief Constructs a PacketStructureJson object with the specified source. + * + * @param source The source from which to read the structure. + */ PacketStructureJson(std::string source) : BasePacketStructure(source, &readStructureFromSource){ } + /** + * @brief Constructs a PacketStructureJson object from another BasePacketStructure object. + * + * @param other The BasePacketStructure object to copy from. + */ PacketStructureJson(const BasePacketStructure &other) : BasePacketStructure(other){ } }; } - -#endif /* INCLUDE_INAF_OAS_PACKET_STRUCTURE_JSON_H_ */ diff --git a/src/Packet_Structure_Json.cpp b/src/Packet_Structure_Json.cpp index 927b3f3..fbe1447 100644 --- a/src/Packet_Structure_Json.cpp +++ b/src/Packet_Structure_Json.cpp @@ -8,7 +8,7 @@ Structure PacketStructureJson::readStructureFromSource(std::string source) { Structure s_empty; std::ifstream file; file.open(source, std::ios::in); - if (!file.is_open()) { + if (!file.is_open()) { // error handling time_t now = time(nullptr); std::cerr << "[" << std::put_time(localtime(&now), "%Y-%m-%d %H:%M:%S") <<"]\t[PacketStructure Json]\t" << "Could not open file: " << source << std::endl; @@ -37,8 +37,8 @@ std::optional PacketStructureJson::convertToTupleVector( const my_json &data, uint &count) { std::optional out = Structure(); for (auto it = data.begin(); it != data.end(); ++it) { - if (it.value().is_object()) { - if (it.value().find("size") == it.value().end() + if (it.value().is_object()) { // array found + if (it.value().find("size") == it.value().end() // error handling || it.value().find("fields") == it.value().end() || it.value().size() != 2) { time_t now = time(nullptr); @@ -46,7 +46,7 @@ std::optional PacketStructureJson::convertToTupleVector( << it.value().dump() << std::endl; return std::nullopt; } - for (uint i = 0; i < it.value()["size"]; i++) { + for (uint i = 0; i < it.value()["size"]; i++) { // convert to tuple vector the json array std::optional subArray = convertToTupleVector( it.value()["fields"], count).value(); if (!subArray.has_value()) @@ -59,8 +59,8 @@ std::optional PacketStructureJson::convertToTupleVector( out.value().insert(out.value().end(), subArray.value().begin(), subArray.value().end()); } - } else { - if (!it.value().is_number_integer()) { + } else { // single field found + if (!it.value().is_number_integer()) { // error handling time_t now = time(nullptr); std::cerr << "[" << std::put_time(localtime(&now), "%Y-%m-%d %H:%M:%S") <<"]\t[PacketStructure Json]\t" << "Not an int: " << it.value().dump() << std::endl; @@ -70,7 +70,7 @@ std::optional PacketStructureJson::convertToTupleVector( std::transform(fieldName.begin(), fieldName.end(), fieldName.begin(), ::tolower); out.value().push_back( - std::make_tuple(count, fieldName, it.value())); + std::make_tuple(count, fieldName, it.value())); count += 1; } } -- GitLab From 1869e4009dd8079bc9a00d09deb2ab1b9a9f9b72 Mon Sep 17 00:00:00 2001 From: valerio pastore Date: Thu, 11 Jan 2024 19:42:18 +0100 Subject: [PATCH 2/3] . --- deps/Base-DAQ | 2 +- include/Astri_Horn_Generic.h | 6 +- include/Astri_Horn_Recognized_Packet.h | 3 +- include/Astri_MA_Generic.h | 62 ++++++++++-------- include/Astri_MA_Recognized_Packet.h | 3 +- include/Packet_Structure_Json.h | 12 ++-- src/Astri_Horn_Generic.cpp | 1 - src/Astri_MA_Generic.cpp | 91 +++++++++++++++----------- src/Packet_Structure_Json.cpp | 33 ++++++---- 9 files changed, 122 insertions(+), 91 deletions(-) diff --git a/deps/Base-DAQ b/deps/Base-DAQ index b581d9c..f81453c 160000 --- a/deps/Base-DAQ +++ b/deps/Base-DAQ @@ -1 +1 @@ -Subproject commit b581d9c117fbdc1cdadb7d030bcde2c2e4aa35a1 +Subproject commit f81453c9f6d51b1cce2ce0507264c69f5dddc725 diff --git a/include/Astri_Horn_Generic.h b/include/Astri_Horn_Generic.h index c000ad0..25433d1 100644 --- a/include/Astri_Horn_Generic.h +++ b/include/Astri_Horn_Generic.h @@ -12,7 +12,7 @@ namespace inaf::oasbo::Packets { * This class inherits from the BasePacket class and provides * functionality specific to ASTRI horn packets. */ -class AstriHornGeneric : public inaf::oasbo::Packets::BasePacket { +class AstriHornGeneric: public inaf::oasbo::Packets::BasePacket { public: /** @@ -20,7 +20,9 @@ public: * * @param structure The packet structure to be used. */ - AstriHornGeneric(inaf::oasbo::PacketLib::BasePacketStructure &structure) : BasePacket(structure){} + AstriHornGeneric(inaf::oasbo::Packets::BasePacketStructure &structure) : + BasePacket(structure) { + } /** * @brief Gets the size of the header in bytes. diff --git a/include/Astri_Horn_Recognized_Packet.h b/include/Astri_Horn_Recognized_Packet.h index f476a67..77d6e82 100755 --- a/include/Astri_Horn_Recognized_Packet.h +++ b/include/Astri_Horn_Recognized_Packet.h @@ -20,6 +20,5 @@ static std::vector> recognizedPackets = { std::make_tuple(1, 3, 13268), std::make_tuple(1, 4, 13268), std::make_tuple(2, 1, 9568), std::make_tuple(2, 2, 10900), std::make_tuple(10, 1, 4526), std::make_tuple(10, 2, 19040), - std::make_tuple(15, 1, 12) -}; + std::make_tuple(15, 1, 12) }; } diff --git a/include/Astri_MA_Generic.h b/include/Astri_MA_Generic.h index 0cc4be8..c2b31e7 100644 --- a/include/Astri_MA_Generic.h +++ b/include/Astri_MA_Generic.h @@ -14,7 +14,7 @@ namespace inaf::oasbo::Packets { * It provides methods to retrieve various properties of the packet, such as header size, payload size, tail size, * telescope ID, type, subtype, SSC, packet length, date and time information, event counter, and various flags. */ -class AstriMaGeneric : public inaf::oasbo::Packets::BasePacket { +class AstriMaGeneric: public inaf::oasbo::Packets::BasePacket { public: /** @@ -22,43 +22,47 @@ public: * * @param structure The packet structure. */ - AstriMaGeneric(inaf::oasbo::Packets::BasePacketStructure &structure) : BasePacket(structure){} - + AstriMaGeneric(inaf::oasbo::Packets::BasePacketStructure &structure) : + BasePacket(structure) { + } + /** * @brief Constructs an AstriMaGeneric object by copying another BasePacket object. * * @param other The other BasePacket object to copy. */ - AstriMaGeneric(inaf::oasbo::Packets::BasePacket &other) : BasePacket(other){} - + AstriMaGeneric(inaf::oasbo::Packets::BasePacket &other) : + BasePacket(other) { + } + /** * @brief Gets the size of the header in bytes. * * @return The size of the header. */ uint getHeaderSize() const override; - + /** * @brief Gets the size of the payload in bytes. * * @return The size of the payload. */ uint getPayloadSize() const override; - + /** * @brief Gets the size of the tail in bytes. * * @return The size of the tail. */ uint getTailSize() const override; - + /** * @brief Checks if the packet has a recognized header. * * @return True if the packet has a recognized header, false otherwise. */ bool hasRecognizedHeader() const override; - + /** * @brief Checks if the given buffer contains a recognized header. * @@ -66,140 +70,140 @@ public: * @return True if the buffer contains a recognized header, false otherwise. */ bool isRecognizedHeader(std::vector buff) const override; - + /** * @brief Gets the telescope ID field value. * * @return The telescope ID value. */ uint getTelescopeID() const; - + /** * @brief Gets the type of the packet. * * @return The packet type. */ uint getType() const; - + /** * @brief Gets the subtype of the packet. * * @return The packet subtype. */ uint getSubType() const; - + /** * @brief Gets the SSC field value. * * @return The SSC value. */ uint getSSC() const; - + /** * @brief Gets the packetlength field value. * * @return The packet length. */ uint getPacketLength() const; - + /** * @brief Gets the year field value. * * @return The year. */ uint getYear() const; - + /** * @brief Gets the month field value. * * @return The month. */ uint getMonth() const; - + /** * @brief Gets the day field value. * * @return The day. */ uint getDay() const; - + /** * @brief Gets the hour field value. * * @return The hour. */ uint getHour() const; - + /** * @brief Gets the minutes field value. * * @return The minutes. */ uint getMinutes() const; - + /** * @brief Gets the seconds field value. * * @return The seconds. */ uint getSeconds() const; - + /** * @brief get the validtime field value * * @return validtime */ bool getValidTime() const; - + /** * @brief Gets the time tag nanoseconds field value * * @return time tag nanoseconds. */ uint getTimeTagNanoseconds() const; - + /** * @brief Gets the event counter field value. * * @return The event counter. */ uint getEventCounter() const; - + /** * @brief get the lif field value. * * @return lid value */ bool getLid() const; - + /** * @brief get the fibst field value. * * @return fibst value. */ bool fibSt() const; - + /** * @brief get the fibCont field value. * * @return fibCont value. */ bool fibCont() const; - + /** * @brief get the fibPuls field value. * * @return fibPuls value. */ bool fibPuls() const; - + /** * @brief get the rgbCont field value. * * @return rgbCont value. */ uint rgbCont() const; - + /** * @brief get the rgbPuls field value. * diff --git a/include/Astri_MA_Recognized_Packet.h b/include/Astri_MA_Recognized_Packet.h index 9971307..138cf28 100755 --- a/include/Astri_MA_Recognized_Packet.h +++ b/include/Astri_MA_Recognized_Packet.h @@ -19,6 +19,5 @@ static std::vector> recognizedPackets = { std::make_tuple(1, 1, 10014), std::make_tuple(1, 4, 12980), std::make_tuple(2, 2, 12976), std::make_tuple(10, 1, 11098), std::make_tuple(10, 2, 9566), std::make_tuple(10, 3, 9566), - std::make_tuple(15, 1, 10) -}; + std::make_tuple(15, 1, 10) }; } diff --git a/include/Packet_Structure_Json.h b/include/Packet_Structure_Json.h index 88ea2d2..79a3015 100644 --- a/include/Packet_Structure_Json.h +++ b/include/Packet_Structure_Json.h @@ -12,7 +12,6 @@ template using my_workaround_fifo_map = fifo_map, A>; using my_json = basic_json; - namespace inaf::oasbo::Packets { /** @@ -22,7 +21,7 @@ namespace inaf::oasbo::Packets { * to convert JSON data into a tuple vector and read the structure from a source. * The compatible json files are in config folder. */ -class PacketStructureJson : public inaf::oasbo::PacketLib::BasePacketStructure { +class PacketStructureJson: public inaf::oasbo::Packets::BasePacketStructure { protected: /** @@ -32,7 +31,8 @@ protected: * @param count The count of tuples in the vector. * @return An optional structure representing the tuple vector. */ - static std::optional convertToTupleVector(const my_json &data, uint &count); + static std::optional convertToTupleVector(const my_json &data, + uint &count); /** * @brief Reads the packet structure from a source. @@ -48,7 +48,8 @@ public: * * @param source The source from which to read the structure. */ - PacketStructureJson(std::string source) : BasePacketStructure(source, &readStructureFromSource){ + PacketStructureJson(std::string source) : + BasePacketStructure(source, &readStructureFromSource) { } /** @@ -56,7 +57,8 @@ public: * * @param other The BasePacketStructure object to copy from. */ - PacketStructureJson(const BasePacketStructure &other) : BasePacketStructure(other){ + PacketStructureJson(const BasePacketStructure &other) : + BasePacketStructure(other) { } }; } diff --git a/src/Astri_Horn_Generic.cpp b/src/Astri_Horn_Generic.cpp index 8634a81..5d67c45 100644 --- a/src/Astri_Horn_Generic.cpp +++ b/src/Astri_Horn_Generic.cpp @@ -1,4 +1,3 @@ - #include #include diff --git a/src/Astri_MA_Generic.cpp b/src/Astri_MA_Generic.cpp index f2905a1..0720663 100644 --- a/src/Astri_MA_Generic.cpp +++ b/src/Astri_MA_Generic.cpp @@ -1,4 +1,3 @@ - #include #include @@ -21,9 +20,10 @@ uint AstriMaGeneric::getTelescopeID() const { if (val.has_value()) return val.value(); else { - time_t now = time(nullptr); + time_t now = time(nullptr); std::cerr << "[" << std::put_time(localtime(&now), "%Y-%m-%d %H:%M:%S") - << "]\t[AstriMA Packet]\t" << "Cannot access field n.0 to get TelescopeID." << std::endl; + << "]\t[AstriMA Packet]\t" + << "Cannot access field n.0 to get TelescopeID." << std::endl; return -1; } } @@ -56,9 +56,10 @@ uint AstriMaGeneric::getSSC() const { if (val.has_value()) return val.value(); else { - time_t now = time(nullptr); + time_t now = time(nullptr); std::cerr << "[" << std::put_time(localtime(&now), "%Y-%m-%d %H:%M:%S") - << "]\t[AstriMA Packet]\t" << "Cannot access field n.3 to get TelescopeID." << std::endl; + << "]\t[AstriMA Packet]\t" + << "Cannot access field n.3 to get TelescopeID." << std::endl; return -1; } } @@ -67,9 +68,10 @@ uint AstriMaGeneric::getPacketLength() const { if (val.has_value()) return val.value(); else { - time_t now = time(nullptr); + time_t now = time(nullptr); std::cerr << "[" << std::put_time(localtime(&now), "%Y-%m-%d %H:%M:%S") - << "]\t[AstriMA Packet]\t" << "Cannot access field n.4 to get TelescopeID." << std::endl; + << "]\t[AstriMA Packet]\t" + << "Cannot access field n.4 to get TelescopeID." << std::endl; return -1; } } @@ -78,9 +80,10 @@ uint AstriMaGeneric::getYear() const { if (val.has_value()) return val.value(); else { - time_t now = time(nullptr); + time_t now = time(nullptr); std::cerr << "[" << std::put_time(localtime(&now), "%Y-%m-%d %H:%M:%S") - << "]\t[AstriMA Packet]\t" << "Cannot access field n.5 to get TelescopeID." << std::endl; + << "]\t[AstriMA Packet]\t" + << "Cannot access field n.5 to get TelescopeID." << std::endl; return -1; } } @@ -89,9 +92,10 @@ uint AstriMaGeneric::getMonth() const { if (val.has_value()) return val.value(); else { - time_t now = time(nullptr); + time_t now = time(nullptr); std::cerr << "[" << std::put_time(localtime(&now), "%Y-%m-%d %H:%M:%S") - << "]\t[AstriMA Packet]\t" << "Cannot access field n.6 to get TelescopeID." << std::endl; + << "]\t[AstriMA Packet]\t" + << "Cannot access field n.6 to get TelescopeID." << std::endl; return -1; } } @@ -100,9 +104,10 @@ uint AstriMaGeneric::getDay() const { if (val.has_value()) return val.value(); else { - time_t now = time(nullptr); + time_t now = time(nullptr); std::cerr << "[" << std::put_time(localtime(&now), "%Y-%m-%d %H:%M:%S") - << "]\t[AstriMA Packet]\t" << "Cannot access field n.7 to get TelescopeID." << std::endl; + << "]\t[AstriMA Packet]\t" + << "Cannot access field n.7 to get TelescopeID." << std::endl; return -1; } } @@ -111,9 +116,10 @@ uint AstriMaGeneric::getHour() const { if (val.has_value()) return val.value(); else { - time_t now = time(nullptr); + time_t now = time(nullptr); std::cerr << "[" << std::put_time(localtime(&now), "%Y-%m-%d %H:%M:%S") - << "]\t[AstriMA Packet]\t" << "Cannot access field n.8 to get TelescopeID." << std::endl; + << "]\t[AstriMA Packet]\t" + << "Cannot access field n.8 to get TelescopeID." << std::endl; return -1; } } @@ -122,9 +128,10 @@ uint AstriMaGeneric::getMinutes() const { if (val.has_value()) return val.value(); else { - time_t now = time(nullptr); + time_t now = time(nullptr); std::cerr << "[" << std::put_time(localtime(&now), "%Y-%m-%d %H:%M:%S") - << "]\t[AstriMA Packet]\t" << "Cannot access field n.9 to get TelescopeID." << std::endl; + << "]\t[AstriMA Packet]\t" + << "Cannot access field n.9 to get TelescopeID." << std::endl; return -1; } } @@ -133,9 +140,10 @@ uint AstriMaGeneric::getSeconds() const { if (val.has_value()) return val.value(); else { - time_t now = time(nullptr); + time_t now = time(nullptr); std::cerr << "[" << std::put_time(localtime(&now), "%Y-%m-%d %H:%M:%S") - << "]\t[AstriMA Packet]\t" << "Cannot access field n.10 to get TelescopeID." << std::endl; + << "]\t[AstriMA Packet]\t" + << "Cannot access field n.10 to get TelescopeID." << std::endl; return -1; } } @@ -144,9 +152,10 @@ bool AstriMaGeneric::getValidTime() const { if (val.has_value()) return val.value(); else { - time_t now = time(nullptr); + time_t now = time(nullptr); std::cerr << "[" << std::put_time(localtime(&now), "%Y-%m-%d %H:%M:%S") - << "]\t[AstriMA Packet]\t" << "Cannot access field n.11 to get TelescopeID." << std::endl; + << "]\t[AstriMA Packet]\t" + << "Cannot access field n.11 to get TelescopeID." << std::endl; return -1; } } @@ -155,9 +164,10 @@ uint AstriMaGeneric::getTimeTagNanoseconds() const { if (val.has_value()) return val.value(); else { - time_t now = time(nullptr); + time_t now = time(nullptr); std::cerr << "[" << std::put_time(localtime(&now), "%Y-%m-%d %H:%M:%S") - << "]\t[AstriMA Packet]\t" << "Cannot access field n.12 to get TelescopeID." << std::endl; + << "]\t[AstriMA Packet]\t" + << "Cannot access field n.12 to get TelescopeID." << std::endl; return -1; } } @@ -166,9 +176,10 @@ uint AstriMaGeneric::getEventCounter() const { if (val.has_value()) return val.value(); else { - time_t now = time(nullptr); + time_t now = time(nullptr); std::cerr << "[" << std::put_time(localtime(&now), "%Y-%m-%d %H:%M:%S") - << "]\t[AstriMA Packet]\t" << "Cannot access field n.13 to get TelescopeID." << std::endl; + << "]\t[AstriMA Packet]\t" + << "Cannot access field n.13 to get TelescopeID." << std::endl; return -1; } } @@ -177,9 +188,10 @@ bool AstriMaGeneric::getLid() const { if (val.has_value()) return val.value(); else { - time_t now = time(nullptr); + time_t now = time(nullptr); std::cerr << "[" << std::put_time(localtime(&now), "%Y-%m-%d %H:%M:%S") - << "]\t[AstriMA Packet]\t" << "Cannot access field n.14 to get TelescopeID." << std::endl; + << "]\t[AstriMA Packet]\t" + << "Cannot access field n.14 to get TelescopeID." << std::endl; return -1; } } @@ -188,9 +200,10 @@ bool AstriMaGeneric::fibSt() const { if (val.has_value()) return val.value(); else { - time_t now = time(nullptr); + time_t now = time(nullptr); std::cerr << "[" << std::put_time(localtime(&now), "%Y-%m-%d %H:%M:%S") - << "]\t[AstriMA Packet]\t" << "Cannot access field n.15 to get TelescopeID." << std::endl; + << "]\t[AstriMA Packet]\t" + << "Cannot access field n.15 to get TelescopeID." << std::endl; return -1; } } @@ -199,9 +212,10 @@ bool AstriMaGeneric::fibCont() const { if (val.has_value()) return val.value(); else { - time_t now = time(nullptr); + time_t now = time(nullptr); std::cerr << "[" << std::put_time(localtime(&now), "%Y-%m-%d %H:%M:%S") - << "]\t[AstriMA Packet]\t" << "Cannot access field n.16 to get TelescopeID." << std::endl; + << "]\t[AstriMA Packet]\t" + << "Cannot access field n.16 to get TelescopeID." << std::endl; return -1; } } @@ -210,9 +224,10 @@ bool AstriMaGeneric::fibPuls() const { if (val.has_value()) return val.value(); else { - time_t now = time(nullptr); + time_t now = time(nullptr); std::cerr << "[" << std::put_time(localtime(&now), "%Y-%m-%d %H:%M:%S") - << "]\t[AstriMA Packet]\t" << "Cannot access field n.17 to get TelescopeID." << std::endl; + << "]\t[AstriMA Packet]\t" + << "Cannot access field n.17 to get TelescopeID." << std::endl; return -1; } } @@ -221,9 +236,10 @@ uint AstriMaGeneric::rgbCont() const { if (val.has_value()) return val.value(); else { - time_t now = time(nullptr); + time_t now = time(nullptr); std::cerr << "[" << std::put_time(localtime(&now), "%Y-%m-%d %H:%M:%S") - << "]\t[AstriMA Packet]\t" << "Cannot access field n.18 to get TelescopeID." << std::endl; + << "]\t[AstriMA Packet]\t" + << "Cannot access field n.18 to get TelescopeID." << std::endl; return -1; } } @@ -232,9 +248,10 @@ uint AstriMaGeneric::rgbPuls() const { if (val.has_value()) return val.value(); else { - time_t now = time(nullptr); + time_t now = time(nullptr); std::cerr << "[" << std::put_time(localtime(&now), "%Y-%m-%d %H:%M:%S") - << "]\t[AstriMA Packet]\t" << "Cannot access field n.19 to get TelescopeID." << std::endl; + << "]\t[AstriMA Packet]\t" + << "Cannot access field n.19 to get TelescopeID." << std::endl; return -1; } } diff --git a/src/Packet_Structure_Json.cpp b/src/Packet_Structure_Json.cpp index fbe1447..1291264 100644 --- a/src/Packet_Structure_Json.cpp +++ b/src/Packet_Structure_Json.cpp @@ -9,8 +9,9 @@ Structure PacketStructureJson::readStructureFromSource(std::string source) { std::ifstream file; file.open(source, std::ios::in); if (!file.is_open()) { // error handling - time_t now = time(nullptr); - std::cerr << "[" << std::put_time(localtime(&now), "%Y-%m-%d %H:%M:%S") <<"]\t[PacketStructure Json]\t" << "Could not open file: " + time_t now = time(nullptr); + std::cerr << "[" << std::put_time(localtime(&now), "%Y-%m-%d %H:%M:%S") + << "]\t[PacketStructure Json]\t" << "Could not open file: " << source << std::endl; std::cerr << "\t Returning empty structure" << std::endl; return s_empty; @@ -20,16 +21,20 @@ Structure PacketStructureJson::readStructureFromSource(std::string source) { try { file >> data; } catch (nlohmann::detail::parse_error &ex) { - time_t now = time(nullptr); - std::cerr << "[" << std::put_time(localtime(&now), "%Y-%m-%d %H:%M:%S") <<"]\t[PacketStructure Json]\t" << ex.what() << "\n\t\tReturning empty structure" << std::endl; + time_t now = time(nullptr); + std::cerr << "[" << std::put_time(localtime(&now), "%Y-%m-%d %H:%M:%S") + << "]\t[PacketStructure Json]\t" << ex.what() + << "\n\t\tReturning empty structure" << std::endl; return s_empty; } std::optional s_tmp = convertToTupleVector(data, count); file.close(); if (s_tmp.has_value()) return s_tmp.value(); - time_t now = time(nullptr); - std::cerr << "[" << std::put_time(localtime(&now), "%Y-%m-%d %H:%M:%S") <<"]\t[PacketStructure Json]\t" << "Returning empty structure" << std::endl; + time_t now = time(nullptr); + std::cerr << "[" << std::put_time(localtime(&now), "%Y-%m-%d %H:%M:%S") + << "]\t[PacketStructure Json]\t" << "Returning empty structure" + << std::endl; return s_empty; } @@ -39,10 +44,12 @@ std::optional PacketStructureJson::convertToTupleVector( for (auto it = data.begin(); it != data.end(); ++it) { if (it.value().is_object()) { // array found if (it.value().find("size") == it.value().end() // error handling - || it.value().find("fields") == it.value().end() + || it.value().find("fields") == it.value().end() || it.value().size() != 2) { - time_t now = time(nullptr); - std::cerr << "[" << std::put_time(localtime(&now), "%Y-%m-%d %H:%M:%S") <<"]\t[PacketStructure Json]\t" << "Error in file: " + time_t now = time(nullptr); + std::cerr << "[" + << std::put_time(localtime(&now), "%Y-%m-%d %H:%M:%S") + << "]\t[PacketStructure Json]\t" << "Error in file: " << it.value().dump() << std::endl; return std::nullopt; } @@ -61,8 +68,10 @@ std::optional PacketStructureJson::convertToTupleVector( } } else { // single field found if (!it.value().is_number_integer()) { // error handling - time_t now = time(nullptr); - std::cerr << "[" << std::put_time(localtime(&now), "%Y-%m-%d %H:%M:%S") <<"]\t[PacketStructure Json]\t" << "Not an int: " + time_t now = time(nullptr); + std::cerr << "[" + << std::put_time(localtime(&now), "%Y-%m-%d %H:%M:%S") + << "]\t[PacketStructure Json]\t" << "Not an int: " << it.value().dump() << std::endl; return std::nullopt; } @@ -70,7 +79,7 @@ std::optional PacketStructureJson::convertToTupleVector( std::transform(fieldName.begin(), fieldName.end(), fieldName.begin(), ::tolower); out.value().push_back( - std::make_tuple(count, fieldName, it.value())); + std::make_tuple(count, fieldName, it.value())); count += 1; } } -- GitLab From a4c32676a99747fa8210886b20bdc39620635039 Mon Sep 17 00:00:00 2001 From: valerio pastore Date: Fri, 12 Jan 2024 20:17:21 +0100 Subject: [PATCH 3/3] . --- deps/Base-DAQ | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deps/Base-DAQ b/deps/Base-DAQ index f81453c..a00f9a2 160000 --- a/deps/Base-DAQ +++ b/deps/Base-DAQ @@ -1 +1 @@ -Subproject commit f81453c9f6d51b1cce2ce0507264c69f5dddc725 +Subproject commit a00f9a27afbf5f75dab7db2368b9b9b6fcb395e1 -- GitLab