Skip to content
Snippets Groups Projects
Commit f7a1aa64 authored by Stuart Mark James's avatar Stuart Mark James
Browse files

Added hide to att_conf, renamed InsertEvent->AddEvent, added an event time for data event errors

parent 80a768d2
No related branches found
No related tags found
No related merge requests found
...@@ -87,6 +87,10 @@ set_target_properties(pqxx_shared ...@@ -87,6 +87,10 @@ set_target_properties(pqxx_shared
PROPERTIES PROPERTIES
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}") LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}")
set_target_properties(pqxx_static
PROPERTIES
POSITION_INDEPENDENT_CODE 1)
# Code Analysis ----------------------------------- # Code Analysis -----------------------------------
if(HDBPP_TDB_ENABLE_CLANG) if(HDBPP_TDB_ENABLE_CLANG)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON) set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
...@@ -113,7 +117,7 @@ add_subdirectory(src) ...@@ -113,7 +117,7 @@ add_subdirectory(src)
add_library(libhdbpp_timescale_shared_library SHARED ${SRC_FILES}) add_library(libhdbpp_timescale_shared_library SHARED ${SRC_FILES})
target_link_libraries(libhdbpp_timescale_shared_library 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) PRIVATE TangoInterfaceLibrary)
target_include_directories(libhdbpp_timescale_shared_library target_include_directories(libhdbpp_timescale_shared_library
......
...@@ -85,6 +85,7 @@ CREATE TABLE IF NOT EXISTS att_conf ( ...@@ -85,6 +85,7 @@ CREATE TABLE IF NOT EXISTS att_conf (
member text NOT NULL DEFAULT '', member text NOT NULL DEFAULT '',
name text NOT NULL DEFAULT '', name text NOT NULL DEFAULT '',
ttl int, ttl int,
hide boolean DEFAULT false,
PRIMARY KEY (att_conf_id), PRIMARY KEY (att_conf_id),
FOREIGN KEY (att_conf_type_id) REFERENCES att_conf_type (att_conf_type_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), FOREIGN KEY (att_conf_format_id) REFERENCES att_conf_format (att_conf_format_id),
......
...@@ -42,10 +42,10 @@ namespace libhdbpp_compatibility ...@@ -42,10 +42,10 @@ namespace libhdbpp_compatibility
namespace events namespace events
{ {
// attribute history events as strings, these are used in the storage system // attribute history events as strings, these are used in the storage system
const std::string InsertEvent = "add"; const std::string AddEvent = "add"; // represents a attribute added to the system
const std::string StartEvent = "start"; const std::string StartEvent = "start"; // represents when the attribute starts sending data
const std::string StopEvent = "stop"; const std::string StopEvent = "stop"; // represents when the attribute stops sending data
const std::string RemoveEvent = "remove"; const std::string RemoveEvent = "remove"; // represents a attribute removed from the system
const std::string InsertParamEvent = "insert_param"; const std::string InsertParamEvent = "insert_param";
const std::string UpdateTTLEvent = "update_ttl"; const std::string UpdateTTLEvent = "update_ttl";
const std::string PauseEvent = "pause"; const std::string PauseEvent = "pause";
......
...@@ -148,13 +148,21 @@ void HdbppTimescaleDb::insert_Attr(Tango::EventData *event_data, HdbEventDataTyp ...@@ -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); 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>() Conn->createTx<HdbppTxDataEventError>()
.withName(event_data->attr_name) .withName(event_data->attr_name)
.withTraits(static_cast<Tango::AttrWriteType>(event_data_type.write_type), .withTraits(static_cast<Tango::AttrWriteType>(event_data_type.write_type),
static_cast<Tango::AttrDataFormat>(event_data_type.data_format), static_cast<Tango::AttrDataFormat>(event_data_type.data_format),
event_data_type.data_type) event_data_type.data_type)
.withError(string(event_data->errors[0].desc)) .withError(string(event_data->errors[0].desc))
.withEventTime(event_data->attr_value->get_date()) .withEventTime(tango_tv)
.withQuality(event_data->attr_value->get_quality()) .withQuality(event_data->attr_value->get_quality())
.store(); .store();
} }
...@@ -208,8 +216,8 @@ void HdbppTimescaleDb::configure_Attr( ...@@ -208,8 +216,8 @@ void HdbppTimescaleDb::configure_Attr(
.withTraits(static_cast<Tango::AttrWriteType>(write_type), static_cast<Tango::AttrDataFormat>(format), type) .withTraits(static_cast<Tango::AttrWriteType>(write_type), static_cast<Tango::AttrDataFormat>(format), type)
.store(); .store();
// add a start event // add an add event
Conn->createTx<HdbppTxHistoryEvent>().withName(fqdn_attr_name).withEvent(events::StartEvent).store(); Conn->createTx<HdbppTxHistoryEvent>().withName(fqdn_attr_name).withEvent(events::AddEvent).store();
} }
//============================================================================= //=============================================================================
......
...@@ -72,7 +72,7 @@ HdbppTxHistoryEvent<Conn> &HdbppTxHistoryEvent<Conn>::withEvent(unsigned char ev ...@@ -72,7 +72,7 @@ HdbppTxHistoryEvent<Conn> &HdbppTxHistoryEvent<Conn>::withEvent(unsigned char ev
// without the need to decode a byte into a meaningful value. // without the need to decode a byte into a meaningful value.
switch (event) 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::HdbppStart: _event = events::StartEvent; break;
case libhdbpp_compatibility::HdbppStop: _event = events::StopEvent; break; case libhdbpp_compatibility::HdbppStop: _event = events::StopEvent; break;
case libhdbpp_compatibility::HdbppRemove: _event = events::RemoveEvent; break; case libhdbpp_compatibility::HdbppRemove: _event = events::RemoveEvent; break;
......
...@@ -82,7 +82,7 @@ SCENARIO("Construct and store HdbppTxHistoryEvent data without error", "[hdbpp-t ...@@ -82,7 +82,7 @@ SCENARIO("Construct and store HdbppTxHistoryEvent data without error", "[hdbpp-t
WHEN("Passing a valid configuration with method chaining") 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") THEN("Storing the transaction does not raise an exception")
{ {
...@@ -96,7 +96,7 @@ SCENARIO("Construct and store HdbppTxHistoryEvent data without error", "[hdbpp-t ...@@ -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") THEN("The data is the same as that passed via method chaining")
{ {
REQUIRE(conn.att_name == TestAttrFinalName); 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 ...@@ -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") AND_WHEN("Setting a valid event and trying to store again")
{ {
tx.withEvent(events::InsertEvent); tx.withEvent(events::AddEvent);
THEN("No exception is raised") THEN("No exception is raised")
{ {
...@@ -140,7 +140,7 @@ SCENARIO("When attempting to store invalid HdbppTxHistoryEvent states, errors ar ...@@ -140,7 +140,7 @@ SCENARIO("When attempting to store invalid HdbppTxHistoryEvent states, errors ar
{ {
conn.disconnect(); conn.disconnect();
REQUIRE(conn.isClosed()); REQUIRE(conn.isClosed());
REQUIRE_NOTHROW(tx.withName(TestAttrFQDName).withEvent(events::InsertEvent)); REQUIRE_NOTHROW(tx.withName(TestAttrFQDName).withEvent(events::AddEvent));
THEN("An exception is raised") THEN("An exception is raised")
{ {
...@@ -175,7 +175,7 @@ SCENARIO("HdbppTxHistoryEvent's overloaded functions return identical results wi ...@@ -175,7 +175,7 @@ SCENARIO("HdbppTxHistoryEvent's overloaded functions return identical results wi
tx2.withName(TestAttrFQDName); tx2.withName(TestAttrFQDName);
REQUIRE_NOTHROW(tx1.withEvent(libhdbpp_compatibility::HdbppInsert)); 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") THEN("The events are the same after storing")
{ {
...@@ -228,43 +228,43 @@ SCENARIO("All event conversions result in correct events at store time", "[hdbpp ...@@ -228,43 +228,43 @@ SCENARIO("All event conversions result in correct events at store time", "[hdbpp
{ {
REQUIRE_NOTHROW(tx.withEvent(libhdbpp_compatibility::HdbppInsert).store()); 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") WHEN("Attempting to store event libhdbpp_compatibility::HdbppStart")
{ {
REQUIRE_NOTHROW(tx.withEvent(libhdbpp_compatibility::HdbppStart).store()); 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") WHEN("Attempting to store event libhdbpp_compatibility::HdbppStop")
{ {
REQUIRE_NOTHROW(tx.withEvent(libhdbpp_compatibility::HdbppStop).store()); 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") WHEN("Attempting to store event libhdbpp_compatibility::HdbppRemove")
{ {
REQUIRE_NOTHROW(tx.withEvent(libhdbpp_compatibility::HdbppRemove).store()); 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") WHEN("Attempting to store event libhdbpp_compatibility::HdbppInsertParam")
{ {
REQUIRE_NOTHROW(tx.withEvent(libhdbpp_compatibility::HdbppInsertParam).store()); 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") WHEN("Attempting to store event libhdbpp_compatibility::HdbppPause")
{ {
REQUIRE_NOTHROW(tx.withEvent(libhdbpp_compatibility::HdbppPause).store()); 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") WHEN("Attempting to store event libhdbpp_compatibility::HdbppUpdateTTL")
{ {
REQUIRE_NOTHROW(tx.withEvent(libhdbpp_compatibility::HdbppUpdateTTL).store()); 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); }
} }
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment