PLCnext API Documentation 26.0.1.58
SystemState.hpp
1
2//
3// Copyright Phoenix Contact GmbH & Co. KG
4//
6#pragma once
8#include "Arp/Base/Core/Enum.hxx"
9
10namespace Arp { namespace Base { namespace Acf { namespace Commons
11{
12
49enum class SystemState : uint32
50{
51 // State flags:
52 None = 0,
53 Ready = 10,
54 Stop = 20,
55 Running = 30,
56 PoweredDown = 40,
57
58 // State transition flags:
59 Initializing = (1 << 9),
60 Loading = (1 << 10),
61 Starting = (1 << 11),
62 Stopping = (1 << 12),
63 Resetting = (1 << 13),
64 Disposing = (1 << 14),
65 PoweringDown = (1 << 15),
66
67 // Error FLags:
68 SystemError = (1 << 16),
69
70 // Flags masks
71 StateMask = 0x000000FF,
72 FlagsMask = ~StateMask,
73 TransitionFlags = 0x0000FF00,
74 ErrorFlags = 0xFFFF0000,
75};
76
77constexpr SystemState operator&(SystemState lhs, SystemState rhs)
78{
79 using U = std::underlying_type<SystemState>::type;
80 return static_cast<SystemState>(static_cast<U>(lhs) & static_cast<U>(rhs));
81}
82
83constexpr SystemState operator|(SystemState lhs, SystemState rhs)
84{
85 using U = std::underlying_type<SystemState>::type;
86 return static_cast<SystemState>(static_cast<U>(lhs) | static_cast<U>(rhs));
87}
88
89constexpr SystemState& operator&=(SystemState& lhs, SystemState rhs)
90{
91 lhs = lhs & rhs;
92 return lhs;
93}
94
95constexpr SystemState& operator|=(SystemState& lhs, SystemState rhs)
96{
97 lhs = lhs | rhs;
98 return lhs;
99}
100
101constexpr SystemState operator~(SystemState arg)
102{
103 using U = std::underlying_type<SystemState>::type;
104 return static_cast<SystemState>(~static_cast<U>(arg));
105}
106
108// global stream operators of enum SystemState for logging and parsing
109ARP_EXPORT std::ostream& operator<<(std::ostream& os, SystemState value);
110ARP_EXPORT std::istream& operator>>(std::istream& is, SystemState& value);
111
112}}}} // end of namespace Arp::Base::Acf::Commons
113
115// template specialization of SystemState formatter
116template<> struct fmt::formatter<Arp::Base::Acf::Commons::SystemState> : public fmt::ostream_formatter {};
std::uint32_t uint32
The Arp unsigned integer type of 4 byte size.
Definition: PrimitiveTypes.hpp:33
Root namespace for the PLCnext API