![]() |
Project
|
#include <DataPointValue.h>
Public Member Functions | |
DataPointValue ()=default | |
DataPointValue (const DataPointValue &other)=default | |
DataPointValue (const uint16_t flags, const uint16_t milliseconds, const uint32_t seconds, const uint64_t *const payload) noexcept | |
DataPointValue (const uint16_t flags, const uint16_t milliseconds, const uint32_t seconds, const uint64_t *const payload, const DeliveryType type) | |
void | set_payload (const uint64_t *const data, const DeliveryType type) |
uint16_t | get_flags () const noexcept |
void | update_timestamp () noexcept |
std::unique_ptr< std::string > | get_timestamp () const noexcept |
uint64_t | get_epoch_time () const noexcept |
DataPointValue & | operator= (const DataPointValue &other)=default |
bool | operator== (const DataPointValue &other) const noexcept |
bool | operator!= (const DataPointValue &other) const noexcept |
void | set (const uint16_t flags, const uint16_t milliseconds, const uint32_t seconds, const uint64_t *const payload, const DeliveryType type) |
void | set (const uint16_t milliseconds, const uint32_t seconds, const uint64_t *const payload, const DeliveryType type) |
void | set (const uint64_t *const data, const DeliveryType type) |
void | acquire_write_lock () |
void | release_write_lock () |
void | acquire_read_lock () |
void | release_read_lock () |
ClassDefNV (DataPointValue, 1) | |
Public Attributes | |
uint16_t | flags = 0 |
uint16_t | msec = 0 |
uint32_t | sec = 0 |
uint64_t | payload_pt1 = 0 |
uint64_t | payload_pt2 = 0 |
uint64_t | payload_pt3 = 0 |
uint64_t | payload_pt4 = 0 |
uint64_t | payload_pt5 = 0 |
uint64_t | payload_pt6 = 0 |
uint64_t | payload_pt7 = 0 |
Static Public Attributes | |
static constexpr uint16_t | KEEP_ALIVE_FLAG = 0x0001 |
static constexpr uint16_t | END_FLAG = 0x0002 |
static constexpr uint16_t | FBI_FLAG = 0x0004 |
static constexpr uint16_t | NEW_FLAG = 0x0008 |
static constexpr uint16_t | DIRTY_FLAG = 0x0010 |
static constexpr uint64_t | TURN_FLAG = 0x0020 |
static constexpr uint16_t | WRITE_FLAG = 0x0040 |
static constexpr uint16_t | READ_FLAG = 0x0080 |
static constexpr uint16_t | OVERWRITE_FLAG = 0x0100 |
static constexpr uint16_t | VICTIM_FLAG = 0x0200 |
static constexpr uint16_t | DIM_ERROR_FLAG = 0x0400 |
static constexpr uint16_t | BAD_DPID_FLAG = 0x0800 |
static constexpr uint16_t | BAD_FLAGS_FLAG = 0x1000 |
static constexpr uint16_t | BAD_TIMESTAMP_FLAG = 0x2000 |
static constexpr uint16_t | BAD_PAYLOAD_FLAG = 0x4000 |
static constexpr uint16_t | BAD_FBI_FLAG = 0x8000 |
static constexpr uint16_t | SESSION_MASK = 0x0007 |
static constexpr uint16_t | CONTROL_MASK = 0x00F8 |
static constexpr uint16_t | ERROR_MASK = 0xFF00 |
Friends | |
std::ostream & | operator<< (std::ostream &os, const DataPointValue &dpval) noexcept |
DataPointValue is the struct responsible for containing the flags, timestamp, and payload value of a data point. It represents a discrete update event to a data point. It should be noted that the constructors and setters of this struct, that take an array containing binary data as parameter, don't check the length of the given array.
Definition at line 48 of file DataPointValue.h.
|
default |
The default constuctor of DataPointValue. Fills the object with zeroes.
|
default |
The trivial copy constructor of DataPointValue.
other | The DataPointValue instance, whose state is to be copied to the new object. |
|
inlinenoexcept |
Constructor for DataPointValue. This constructor assumes that the payload
parameter points to a unit64_t
array with (at least) seven elements. The data will be treated as binary and will be written to the new DataPointValue object using std::memcpy
. Use of this constructor is discouraged, since it might copy garbage data. Please consider using the constructor with a DeliveryType
parameter instead.
flags | The ADAPOS flags. |
milliseconds | Milliseconds of the timestamp. |
seconds | Seconds of the timestamp. |
payload | Pointer to a memory segment containing the binary payload data. The next seven uint64_t values (i.e. 56 char s) will be copied to the DataPointValue object. payload must not be nullptr . For an empty DPVAL, use the default constructor. |
DeliveryType
parameter instead. Definition at line 334 of file DataPointValue.h.
|
inline |
Constructor for DataPointValue. Copies a data segment from the array payload
. Length of the copied data is determined by the argument type
. No sanity checks on the given array are performed.
If the given DeliveryType</t> is invalid, then the payload of the new DataPointValue object will be filled with zeros.
flags | The ADAPOS flags. |
milliseconds | Milliseconds of the timestamp. |
seconds | Seconds of the timestamp. |
payload | Pointer to a contiguous block of memory containing the binary payload data. |
type | Used for setting the payload correctly, using set_payload . If this argument is VOID , then the contents of the payload remain undefined. |
std::domain_error | If applied with an invalid DeliveryType. |
Definition at line 363 of file DataPointValue.h.
|
inline |
Acquires the lock for reading from this DPVAL. This function is based on Peterson's algorithm (with a spinlock). It can be used for ensuring mutual exclusion between two threads accessing this DPVAL object. It is important to release the read lock by calling release_read_lock()
after use.
This method may or may not work due to CPU instruction reordering, caching, and other optimizations. Using std::mutex
instead is recommended.
Definition at line 682 of file DataPointValue.h.
|
inline |
Acquires the lock for writing into this DPVAL. This method is based on Peterson's algorithm (with a spinlock). It can be used for ensuring mutual exclusion between two threads accessing this DPVAL object. It is important to release the write lock by calling release_write_lock()
after use.
This method may or may not work due to CPU instruction reordering, caching, and other optimizations. Using std::mutex
instead is recommended.
Definition at line 646 of file DataPointValue.h.
o2::dcs::DataPointValue::ClassDefNV | ( | DataPointValue | , |
1 | |||
) |
|
inlinenoexcept |
Returns a 64-bit unsigned integer containing the timestamp value of the DPVAL object.
Definition at line 485 of file DataPointValue.h.
|
inlinenoexcept |
Returns the ADAPOS flags of the DataPointValue.
Definition at line 437 of file DataPointValue.h.
|
inlinenoexcept |
On Linux platforms, Returns a unique pointer to a string containing an ISO 8601 timestamp. The value of the timestamp will be calculated from the values of the fields msec
and sec
and assuming the UTC timezone. The timestamp has the following format:
<YYYY-MM-DD> "T" <HH:MM:SS.SSS> "Z"
Definition at line 463 of file DataPointValue.h.
|
inlinenoexcept |
Negation of the equality comparison.
other | The second operand. |
true
or false
. Definition at line 522 of file DataPointValue.h.
|
default |
The standard copy assignment operator. Performs a normal deep copy operation overwriting this DataPointValue object with the other.
Note that this operator always copies a fixed size data segment from the given DPVAL to this DPVAL regardless of the payload value type. Therefore, non-zero garbage data might be copied as well. Using the setters with the type
parameter is recommended.
other | The DataPointValue object, whose state will be copied to this object. |
*this
after performing the copying.
|
inlinenoexcept |
Bit-by bit equality comparison of DPVAL objects.
other | The second operand of equality comparison. |
true
or false
. Definition at line 511 of file DataPointValue.h.
|
inline |
Releases the lock for reading from this DPVAL. This function is based on Peterson's algorithm (with a spinlock). It can be used for ensuring mutual exclusion between two threads accessing this DPVAL object.
This method may or may not work due to CPU instruction reordering, caching, and other optimizations. Using std::mutex
instead is recommended.
Definition at line 701 of file DataPointValue.h.
|
inline |
Releases the lock for writing into this DPVAL. This function is based on Peterson's algorithm (with a spinlock). It can be used for ensuring mutual exclusion between two threads accessing this DPVAL object.
This method may or may not work due to CPU instruction reordering, caching, and other optimizations. Using std::mutex
instead is recommended.
Definition at line 665 of file DataPointValue.h.
|
inline |
Sets the state of the DataPointValue. Copies a data segment from the array payload
. Length of the copied data is determined by the argument type
. No sanity checks on the given array are performed.
flags | New value for ADAPOS flags. |
milliseconds | New value for milliseconds. |
seconds | New value for seconds. |
payload | New payload data. |
type | Used for setting the payload correctly, using set_payload . |
std::domain_error | If applied with an invalid DeliveryType. |
Definition at line 543 of file DataPointValue.h.
|
inline |
Sets the state of the DataPointValue, except for the flags. This setter can be used for safely setting the state of the object without interfering with the locking mechanism or invalidating the mutual exclusion. This setter was added in ADAPRO 2.4.0.
milliseconds | Milliseconds of the new timestamp. |
seconds | Seconds of the new timestamp. |
payload | New payload. |
type | Used for setting the payload correctly, using set_payload . |
std::domain_error | If applied with an invalid DeliveryType. |
Definition at line 571 of file DataPointValue.h.
|
inline |
Sets the state of the DataPointValue. No sanity checks on the given array are performed. The first array element is assumed to contain data for the flags and the timestamp with their respective sizes and order, while the rest of the array is assumed to contain the payload data.
data | New DPVAL contents. |
type | Used for setting the payload correctly, using set_payload . |
std::domain_error | If applied with an invalid DeliveryType. |
Definition at line 596 of file DataPointValue.h.
|
inline |
Sets the given payload data to the DataPointValue. This setter avoids copying garbage, because it uses the type information. However, it assumes the given array to have at least the length determined by the payload type.
data | A binary segment containing the new payload data. |
type | Type of the payload data. |
std::domain_error | If applied with an invalid DeliveryType. |
Definition at line 385 of file DataPointValue.h.
|
inlinenoexcept |
Updates the timestamp of this DataPointValue object using system clock.
Definition at line 446 of file DataPointValue.h.
|
friend |
Prints the flags and timestamp of the DataPointValue object into the ostream
, but not the payload data. The reason for omitting the payload value is that DataPointValue lacks payload data typing information, so conversion from binary to string is not meaningful.
Definition at line 612 of file DataPointValue.h.
|
staticconstexpr |
This flag should be set if and only if the DPID of the DPCOM containing this DPVAL has incorrect or unexpected value.
If this flag is set, it will be denoted with letter I
in the CSV output generated from this DPVAL object.
Definition at line 147 of file DataPointValue.h.
|
staticconstexpr |
This flag should be set if it a FBI contains duplicated DPCOMs (i.e. DPCOMs with identical DPIDs). Also, partial FBI (with missing DPCOMs) can be indicated with this flag.
If this flag is set, it will be denoted with letter B
in the CSV output generated from this DPVAL object.
Definition at line 179 of file DataPointValue.h.
|
staticconstexpr |
This flag should be set if and only if the flags themselves have bad or unexpedcted value.
If this flag is set, it will be denoted with letter F
in the CSV output generated from this DPVAL object.
Definition at line 155 of file DataPointValue.h.
|
staticconstexpr |
This flag should be set if and only if the payload value is bad.
If this flag is set, it will be denoted with letter P
in the CSV output generated from this DPVAL object.
Definition at line 170 of file DataPointValue.h.
|
staticconstexpr |
This flag should be set if and only if the timestamp is incorrect.
If this flag is set, it will be denoted with letter T
in the CSV output generated from this DPVAL object.
Definition at line 163 of file DataPointValue.h.
|
staticconstexpr |
This mask covers the control flags: NEW_FLAG
, DIRTY_FLAG
, TURN_FLAG
, WRITE_FLAG
, and READ_FLAG
.
Definition at line 202 of file DataPointValue.h.
|
staticconstexpr |
This flag should be set if and only if there is a DIM error (namely, connection failure with the DIM service) in ADAPOS Engine affecting this DataPointValue object.
If this flag is set, it will be denoted with letter E
in the CSV output generated from this DPVAL object.
Definition at line 139 of file DataPointValue.h.
|
staticconstexpr |
This flag is reserved for the ADAPRO/ADAPOS Producer-Consumer model. A DataPointValue is dirty if and only if it's stored in the ring buffer but not been fully processed yet. This flag should always be set when a DPCOM containing the DataPointValue object arrives from ADAPOS Engine via TCP.
If this flag is set, it will be denoted with letter D
in the CSV output generated from this DPVAL object.
Definition at line 89 of file DataPointValue.h.
|
staticconstexpr |
This flag is used for signaling the end of transmission.
If this flag is set, it will be denoted with letter Z
in the CSV output generated from this DPVAL object.
Definition at line 62 of file DataPointValue.h.
|
staticconstexpr |
This mask covers the error flags: DIM_ERROR_FLAG
, OVERWRITE_FLAG
, VICTIM_FLAG
, BAD_DPID_FLAG
, BAD_FLAGS_FLAG
, BAD_TIMESTAMP_FLAG
, BAD_PAYLOAD_FLAG
, and BAD_FBI_FLAG
.
Definition at line 220 of file DataPointValue.h.
|
staticconstexpr |
This flag is set in the ADAPOS FBI Master DPCOM object.
If this flag is set, it will be denoted with letter M
in the CSV output generated from this DPVAL object.
Definition at line 69 of file DataPointValue.h.
uint16_t o2::dcs::DataPointValue::flags = 0 |
The ADAPOS flags, i.e. a bitmask of the 16 different DPVAL flags.
Definition at line 241 of file DataPointValue.h.
|
staticconstexpr |
This flag is used for signaling that a DPVAL stream connection is working, but there is no data to be sent.
If this flag is set, it will be denoted with letter A
in the CSV output generated from this DPVAL object.
Definition at line 55 of file DataPointValue.h.
uint16_t o2::dcs::DataPointValue::msec = 0 |
Milliseconds of the timestamp. This is the measured number of milliseconds passed since the UNIX epoch (1 January 1970, 01:00:00.000) modulo 1000. The purpose of this field together with sec
is to store a timestamp indicating the moment of creation/modification of the DataPointValue object.
Definition at line 252 of file DataPointValue.h.
|
staticconstexpr |
This flag is set by Producer to signal Consumer that this DataPointValue object belongs to a new service, that doesn't yet have its DataPointCompositeObject in the image.
If this flag is set, it will be denoted with letter N
in the CSV output generated from this DPVAL object.
Definition at line 78 of file DataPointValue.h.
|
staticconstexpr |
This flag should be set if and only if there is a ring buffer overflow happening. Ring buffer overflow is manifested as an overwrite of a dirty DPVAL.
If this flag is set, it will be denoted with letter O
in the CSV output generated from this DPVAL object.
Definition at line 120 of file DataPointValue.h.
uint64_t o2::dcs::DataPointValue::payload_pt1 = 0 |
First part of the 56-byte binary payload value.
Definition at line 266 of file DataPointValue.h.
uint64_t o2::dcs::DataPointValue::payload_pt2 = 0 |
Second part of the 56-byte binary payload value.
Definition at line 271 of file DataPointValue.h.
uint64_t o2::dcs::DataPointValue::payload_pt3 = 0 |
Third part of the 56-byte binary payload value.
Definition at line 276 of file DataPointValue.h.
uint64_t o2::dcs::DataPointValue::payload_pt4 = 0 |
Fourth part of the 56-byte binary payload value.
Definition at line 281 of file DataPointValue.h.
uint64_t o2::dcs::DataPointValue::payload_pt5 = 0 |
Fifth part of the 56-byte binary payload value.
Definition at line 286 of file DataPointValue.h.
uint64_t o2::dcs::DataPointValue::payload_pt6 = 0 |
Sixth part of the 56-byte binary payload value.
Definition at line 291 of file DataPointValue.h.
uint64_t o2::dcs::DataPointValue::payload_pt7 = 0 |
Seventh part of the 56-byte binary payload value.
Definition at line 296 of file DataPointValue.h.
|
staticconstexpr |
This flag is used by the DPVAL mutual exclusion mechanism.
If this flag is set, it will be denoted with letter R
in the CSV output generated from this DPVAL object.
Definition at line 111 of file DataPointValue.h.
uint32_t o2::dcs::DataPointValue::sec = 0 |
Seconds of the timestamp. This is the measured number of seconds passed since the UNIX epoch (1 January 1970, 01:00:00.000). The purpose of this field together with msec
is to store a timestamp indicating the moment of creation/modification of the DataPointValue object.
Definition at line 261 of file DataPointValue.h.
|
staticconstexpr |
This mask covers the session flags: KEEP_ALIVE_FLAG
, END_FLAG
, and FBI_MASTER_FLAG
.
Definition at line 189 of file DataPointValue.h.
|
staticconstexpr |
This flag is used as a part of the DPVAL mutual exclusion mechanism. This flag should be set iff reader has the turn.
If this flag is set, it will be denoted with letter U
in the CSV output generated from this DPVAL object.
Definition at line 97 of file DataPointValue.h.
|
staticconstexpr |
In case of buffer overflow, this flag can be used for indicating a service that lost an update. Not receiving this flag shouldn't be taken as an indication that every update was successfully transmitted.
If this flag is set, it will be denoted with letter V
in the CSV output generated from this DPVAL object.
Definition at line 130 of file DataPointValue.h.
|
staticconstexpr |
This flag is used by the DPVAL mutual exclusion mechanism.
If this flag is set, it will be denoted with letter W
in the CSV output generated from this DPVAL object.
Definition at line 104 of file DataPointValue.h.