PLCnext API Documentation  21.0.0.35466
Notification.hpp
1 //
3 // Copyright PHOENIX CONTACT Electronics GmbH
4 //
6 #pragma once
7 #include "Arp/System/Core/Arp.h"
8 #include "Arp/System/Nm/NotificationManagerTypes.hpp"
9 #include "Arp/System/Nm/Services/Severity.hpp"
10 #include "Arp/System/Rsc/Services/IRscSerializable.hpp"
11 #include "Arp/System/Rsc/Services/RscReader.hpp"
12 #include "Arp/System/Rsc/Services/RscString.hxx"
13 #include "Arp/System/Rsc/Services/RscWriter.hpp"
14 
15 
16 namespace Arp { namespace System { namespace Nm
17 {
18 
19 
22 {
23 public:
25  Notification() = default;
26  ~Notification() override = default;
27 
31  const DateTime& timestamp, Severity severity, PayloadTypeIdType payloadTypeId,
32  const RawPayloadType& payload);
33 
34  // Methods inherited from IRscSerializable
35  void Serialize(Arp::System::Rsc::Services::RscWriter& writer) const override;
37  static size_t GetFieldCount(void);
38 
40  NotificationIdType GetId() const;
41 
44 
46  DateTime GetTimestamp() const;
47 
49  Severity GetSeverity() const;
50 
53 
55  const RawPayloadType& GetPayload() const;
56 
59  template<typename PayloadType>
60  const PayloadType GetPayloadAs() const
61  {
62  return PayloadType(*this);
63  }
64 
65 private:
67  NotificationNameIdType NotificationNameId;
68  DateTime Timestamp;
69  Severity severity = Severity::Default;
70  PayloadTypeIdType PayloadTypeId;
71  RawPayloadType Payload;
72 };
73 
74 
75 }}} // namespace Arp::System::Nm
Reads data from Rsc
Definition: RscReader.hpp:23
void Serialize(Arp::System::Rsc::Services::RscWriter &writer) const override
Serializes the datatype. All fields of the datatype have to be serialized in use of RscWriter...
const PayloadType GetPayloadAs() const
Returns a view to the Payload using the defined PayloadType
Definition: Notification.hpp:60
NotificationIdType GetId() const
Returns the id
Contains meta data and paylod of a Notification
Definition: Notification.hpp:21
Writes data to Rsc.
Definition: RscWriter.hpp:32
The class contains date and time informations.
Definition: DateTime.hpp:44
std::vector< Arp::System::Rsc::Services::RscVariant< RawPayloadTypeLength > > RawPayloadType
type for the internally transferred payloads
Definition: NotificationManagerTypes.hpp:34
Marshalls structure or class data types. Serialize and Deserialize have to marshal fields in the same...
Definition: IRscSerializable.hpp:18
Severity
Enumeration of Severities for notifications
Definition: Severity.hpp:15
Root namespace for the PLCnext API
PayloadTypeIdType GetPayloadTypeId() const
Returns the PayloadTypeId
Severity GetSeverity() const
Returns the Severity
void Deserialize(Arp::System::Rsc::Services::RscReader &reader) override
Deserializes the datatype. All fields of the datatype have to be deserialized in use of RscReader...
System components used by the System, Device, Plc or Io domains.
NotificationNameIdType GetNotificationNameId() const
Returns the NotificationNameId
const RawPayloadType & GetPayload() const
Returns a reference to the raw payload
DateTime GetTimestamp() const
Returns the timestamp
Notification()=default
Creates an empty Notification