diff --git a/CMakeLists.txt b/CMakeLists.txt index 3fe0643052bbbfc6a759664398e6f741938c081d..7cb5a9d737dd1bdd4f0db17c0fe81257a809d46e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -87,6 +87,10 @@ set_target_properties(pqxx_shared PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}") +set_target_properties(pqxx_static + PROPERTIES + POSITION_INDEPENDENT_CODE 1) + # Code Analysis ----------------------------------- if(HDBPP_TDB_ENABLE_CLANG) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) @@ -113,7 +117,7 @@ add_subdirectory(src) add_library(libhdbpp_timescale_shared_library SHARED ${SRC_FILES}) target_link_libraries(libhdbpp_timescale_shared_library - PUBLIC ${TDB_FOUND_LIBRARIES} pqxx_shared libhdbpp_headers spdlog Threads::Threads + PUBLIC ${TDB_FOUND_LIBRARIES} pqxx_static libhdbpp_headers spdlog Threads::Threads PRIVATE TangoInterfaceLibrary) target_include_directories(libhdbpp_timescale_shared_library diff --git a/db-schema/schema.sql b/db-schema/schema.sql index 1c2cd48264c66949fc5b9f70327e63af65a69ff0..4445653dc54d73c6a63452994799f830d21e215c 100755 --- a/db-schema/schema.sql +++ b/db-schema/schema.sql @@ -85,6 +85,7 @@ CREATE TABLE IF NOT EXISTS att_conf ( member text NOT NULL DEFAULT '', name text NOT NULL DEFAULT '', ttl int, + hide boolean DEFAULT false, PRIMARY KEY (att_conf_id), FOREIGN KEY (att_conf_type_id) REFERENCES att_conf_type (att_conf_type_id), FOREIGN KEY (att_conf_format_id) REFERENCES att_conf_format (att_conf_format_id), diff --git a/src/HdbppDefines.hpp b/src/HdbppDefines.hpp index 9e4f1ad446550913fe9366e0ec373c2a4a657255..4df8099a48dd88fe45ea9a389f45ccfa1d31b434 100644 --- a/src/HdbppDefines.hpp +++ b/src/HdbppDefines.hpp @@ -42,10 +42,10 @@ namespace libhdbpp_compatibility namespace events { // attribute history events as strings, these are used in the storage system - const std::string InsertEvent = "add"; - const std::string StartEvent = "start"; - const std::string StopEvent = "stop"; - const std::string RemoveEvent = "remove"; + const std::string AddEvent = "add"; // represents a attribute added to the system + const std::string StartEvent = "start"; // represents when the attribute starts sending data + const std::string StopEvent = "stop"; // represents when the attribute stops sending data + const std::string RemoveEvent = "remove"; // represents a attribute removed from the system const std::string InsertParamEvent = "insert_param"; const std::string UpdateTTLEvent = "update_ttl"; const std::string PauseEvent = "pause"; diff --git a/src/HdbppTimescaleDb.cpp b/src/HdbppTimescaleDb.cpp index 4d8c2d7bb427b2e12559d87ad53ef72f933a7fd4..d4e7c2eac80582fa14eb6386ce2ecabcd9c454bc 100644 --- a/src/HdbppTimescaleDb.cpp +++ b/src/HdbppTimescaleDb.cpp @@ -148,13 +148,21 @@ void HdbppTimescaleDb::insert_Attr(Tango::EventData *event_data, HdbEventDataTyp { spdlog::trace("Event type is error for attribute: {}", event_data->attr_name); + // now time data is passed for errors, so create some + struct timeval tv; + struct Tango::TimeVal tango_tv; + gettimeofday(&tv, NULL); + tango_tv.tv_sec = tv.tv_sec; + tango_tv.tv_usec = tv.tv_usec; + tango_tv.tv_nsec = 0; + Conn->createTx<HdbppTxDataEventError>() .withName(event_data->attr_name) .withTraits(static_cast<Tango::AttrWriteType>(event_data_type.write_type), static_cast<Tango::AttrDataFormat>(event_data_type.data_format), event_data_type.data_type) .withError(string(event_data->errors[0].desc)) - .withEventTime(event_data->attr_value->get_date()) + .withEventTime(tango_tv) .withQuality(event_data->attr_value->get_quality()) .store(); } @@ -208,8 +216,8 @@ void HdbppTimescaleDb::configure_Attr( .withTraits(static_cast<Tango::AttrWriteType>(write_type), static_cast<Tango::AttrDataFormat>(format), type) .store(); - // add a start event - Conn->createTx<HdbppTxHistoryEvent>().withName(fqdn_attr_name).withEvent(events::StartEvent).store(); + // add an add event + Conn->createTx<HdbppTxHistoryEvent>().withName(fqdn_attr_name).withEvent(events::AddEvent).store(); } //============================================================================= diff --git a/src/HdbppTxHistoryEvent.hpp b/src/HdbppTxHistoryEvent.hpp index dc499b7624ee6ec3de71175f4d06ebcbd2c4be1f..96f1d75d2d60dae88d0e36e1fb509b5ce73337b9 100644 --- a/src/HdbppTxHistoryEvent.hpp +++ b/src/HdbppTxHistoryEvent.hpp @@ -72,7 +72,7 @@ HdbppTxHistoryEvent<Conn> &HdbppTxHistoryEvent<Conn>::withEvent(unsigned char ev // without the need to decode a byte into a meaningful value. switch (event) { - case libhdbpp_compatibility::HdbppInsert: _event = events::InsertEvent; break; + case libhdbpp_compatibility::HdbppInsert: _event = events::AddEvent; break; case libhdbpp_compatibility::HdbppStart: _event = events::StartEvent; break; case libhdbpp_compatibility::HdbppStop: _event = events::StopEvent; break; case libhdbpp_compatibility::HdbppRemove: _event = events::RemoveEvent; break; diff --git a/test/HdbppTxHistoryEventTests.cpp b/test/HdbppTxHistoryEventTests.cpp index 2c627f46fb1ff60c65286c3349d7663a871a1c46..346a49df105b6abaf7cc114d9718fec5b42bc6d6 100644 --- a/test/HdbppTxHistoryEventTests.cpp +++ b/test/HdbppTxHistoryEventTests.cpp @@ -82,7 +82,7 @@ SCENARIO("Construct and store HdbppTxHistoryEvent data without error", "[hdbpp-t WHEN("Passing a valid configuration with method chaining") { - tx.withName(TestAttrFQDName).withEvent(events::InsertEvent); + tx.withName(TestAttrFQDName).withEvent(events::AddEvent); THEN("Storing the transaction does not raise an exception") { @@ -96,7 +96,7 @@ SCENARIO("Construct and store HdbppTxHistoryEvent data without error", "[hdbpp-t THEN("The data is the same as that passed via method chaining") { REQUIRE(conn.att_name == TestAttrFinalName); - REQUIRE(conn.att_last_event == events::InsertEvent); + REQUIRE(conn.att_last_event == events::AddEvent); } } } @@ -126,7 +126,7 @@ SCENARIO("When attempting to store invalid HdbppTxHistoryEvent states, errors ar } AND_WHEN("Setting a valid event and trying to store again") { - tx.withEvent(events::InsertEvent); + tx.withEvent(events::AddEvent); THEN("No exception is raised") { @@ -140,7 +140,7 @@ SCENARIO("When attempting to store invalid HdbppTxHistoryEvent states, errors ar { conn.disconnect(); REQUIRE(conn.isClosed()); - REQUIRE_NOTHROW(tx.withName(TestAttrFQDName).withEvent(events::InsertEvent)); + REQUIRE_NOTHROW(tx.withName(TestAttrFQDName).withEvent(events::AddEvent)); THEN("An exception is raised") { @@ -175,7 +175,7 @@ SCENARIO("HdbppTxHistoryEvent's overloaded functions return identical results wi tx2.withName(TestAttrFQDName); REQUIRE_NOTHROW(tx1.withEvent(libhdbpp_compatibility::HdbppInsert)); - REQUIRE_NOTHROW(tx2.withEvent(events::InsertEvent)); + REQUIRE_NOTHROW(tx2.withEvent(events::AddEvent)); THEN("The events are the same after storing") { @@ -228,43 +228,43 @@ SCENARIO("All event conversions result in correct events at store time", "[hdbpp { REQUIRE_NOTHROW(tx.withEvent(libhdbpp_compatibility::HdbppInsert).store()); - THEN("InsertEvent is recorded at store time") { REQUIRE(conn.att_last_event == events::InsertEvent); } + THEN("AddEvent is recorded at store time") { REQUIRE(conn.att_last_event == events::AddEvent); } } WHEN("Attempting to store event libhdbpp_compatibility::HdbppStart") { REQUIRE_NOTHROW(tx.withEvent(libhdbpp_compatibility::HdbppStart).store()); - THEN("InsertEvent is recorded at store time") { REQUIRE(conn.att_last_event == events::StartEvent); } + THEN("AddEvent is recorded at store time") { REQUIRE(conn.att_last_event == events::StartEvent); } } WHEN("Attempting to store event libhdbpp_compatibility::HdbppStop") { REQUIRE_NOTHROW(tx.withEvent(libhdbpp_compatibility::HdbppStop).store()); - THEN("InsertEvent is recorded at store time") { REQUIRE(conn.att_last_event == events::StopEvent); } + THEN("AddEvent is recorded at store time") { REQUIRE(conn.att_last_event == events::StopEvent); } } WHEN("Attempting to store event libhdbpp_compatibility::HdbppRemove") { REQUIRE_NOTHROW(tx.withEvent(libhdbpp_compatibility::HdbppRemove).store()); - THEN("InsertEvent is recorded at store time") { REQUIRE(conn.att_last_event == events::RemoveEvent); } + THEN("AddEvent is recorded at store time") { REQUIRE(conn.att_last_event == events::RemoveEvent); } } WHEN("Attempting to store event libhdbpp_compatibility::HdbppInsertParam") { REQUIRE_NOTHROW(tx.withEvent(libhdbpp_compatibility::HdbppInsertParam).store()); - THEN("InsertEvent is recorded at store time") { REQUIRE(conn.att_last_event == events::InsertParamEvent); } + THEN("AddEvent is recorded at store time") { REQUIRE(conn.att_last_event == events::InsertParamEvent); } } WHEN("Attempting to store event libhdbpp_compatibility::HdbppPause") { REQUIRE_NOTHROW(tx.withEvent(libhdbpp_compatibility::HdbppPause).store()); - THEN("InsertEvent is recorded at store time") { REQUIRE(conn.att_last_event == events::PauseEvent); } + THEN("AddEvent is recorded at store time") { REQUIRE(conn.att_last_event == events::PauseEvent); } } WHEN("Attempting to store event libhdbpp_compatibility::HdbppUpdateTTL") { REQUIRE_NOTHROW(tx.withEvent(libhdbpp_compatibility::HdbppUpdateTTL).store()); - THEN("InsertEvent is recorded at store time") { REQUIRE(conn.att_last_event == events::UpdateTTLEvent); } + THEN("AddEvent is recorded at store time") { REQUIRE(conn.att_last_event == events::UpdateTTLEvent); } } } }