-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathExamplePayload.hpp
More file actions
63 lines (53 loc) · 1.75 KB
/
ExamplePayload.hpp
File metadata and controls
63 lines (53 loc) · 1.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
///////////////////////////////////////////////////////////////////////////////"
//
// Copyright PHOENIX CONTACT GmbH
//
///////////////////////////////////////////////////////////////////////////////
/*
* ExamplePayload.hpp
*
* Created on: 07.05.2019
*
*/
#ifndef EXAMPLEPAYLOAD_HPP_
#define EXAMPLEPAYLOAD_HPP_
#pragma once
// 1. Include header "SpecializedPayload.hpp"
#include "Arp/System/Nm/SpecializedPayload.hpp"
// 2. Use project namespace
namespace NotificationExample{
// 3. Use Arp namespace
using namespace Arp;
// and namespace of the notification manager
using namespace Arp::System::Nm;
// 4. Define payload
class ExamplePayload : public SpecializedPayload<ExamplePayload>
{
public:
// definition of the payload values
ExamplePayload(const uint16& uiPortValue, const String & sMyMessage)
: SpecializedPayload("The value is: {0}") // definition of the payload string
{
this->SetFieldValue(this->fieldIndexMyValue, uiPortValue); // relation variable value to index
this->SetFieldValue(this->fieldIndexMyString, sMyMessage); // relation variable value to index
}
ExamplePayload(const Notification& notification)
: SpecializedPayload(notification)
{
}
// 5. Method for receiving the notification
const uint16 GetMyValue() const
{
return this->GetFieldValueAs<uint16>( this->fieldIndexMyValue);
}
const String GetMyString() const
{
return this->GetFieldValueAs<String>( this->fieldIndexMyString);
}
private:
// 6. Define field index
size_t fieldIndexMyValue = this->AddField<uint16>();
size_t fieldIndexMyString = this->AddField<String>();
};
} // end of namespace
#endif /* EXAMPLEPAYLOAD_HPP_ */