PLCnext API Documentation  20.3.1.28622
PlcStateChangedPayload.hpp
1 //
3 // Copyright PHOENIX CONTACT Electronics GmbH
4 //
6 
7 #pragma once
8 
9 
10 #include "Arp/System/Core/Arp.h"
11 #include "Arp/System/Nm/SpecializedPayload.hpp"
12 #include "Arp/Plc/Commons/Domain/PlcState.hpp"
13 
14 
15 namespace Arp { namespace System { namespace NmPayload { namespace Plc
16 {
17 
18 
24 class PlcStateChangedPayload : public Arp::System::Nm::SpecializedPayload<PlcStateChangedPayload>
25 {
26 public:
28  using SpecializedPayload::SpecializedPayload;
29 
33  PlcStateChangedPayload(PlcState lastState, PlcState newState);
34 
36  PlcState GetLastState() const;
37 
39  PlcState GetNewState() const;
40 
41 private:
42  static String PlcStateToString(PlcState plcState);
43  static String GetFlagsDescriptions(PlcState plcState);
44  static bool IsFlagSet(PlcState plcState, PlcState flag);
45 
46 private:
47  using PayloadFieldType = std::underlying_type<Arp::Plc::Commons::Domain::PlcState>::type;
48 
49  // Do not change the order of the field initialization!
50  size_t indexLastState = this->AddField<PayloadFieldType>();
51  size_t indexNewState = this->AddField<PayloadFieldType>();
52 };
53 
54 
55 }}}} // namespace Arp::System::NmPayload::Plc
PlcState GetLastState() const
Retruns the last state of the PLC
Base class for custom Payload classes
Definition: SpecializedPayload.hpp:42
PlcStateChangedPayload(PlcState lastState, PlcState newState)
Creates a payload lobject
PlcState
Definition: PlcState.hpp:13
Root namespace for the PLCnext API
System components used by the System, Device, Plc or Io domains.
Payload class for state changes of the PLC
Definition: PlcStateChangedPayload.hpp:24
PlcState GetNewState() const
Returns the new state of the PLC