PLCnext API Documentation 26.6.0.38
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 // Info Flags:
71 SystemTerminating = (1 << 24),
72
73 // Flags masks
74 StateMask = 0x000000FF,
75 FlagsMask = ~StateMask,
76 TransitionFlags = 0x0000FF00,
77 ErrorFlags = 0x00FF0000,
78 InfoFlags = 0xFF000000,
79};
80
81constexpr SystemState operator&(SystemState lhs, SystemState rhs)
82{
83 using U = std::underlying_type<SystemState>::type;
84 return static_cast<SystemState>(static_cast<U>(lhs) & static_cast<U>(rhs));
85}
86
87constexpr SystemState operator|(SystemState lhs, SystemState rhs)
88{
89 using U = std::underlying_type<SystemState>::type;
90 return static_cast<SystemState>(static_cast<U>(lhs) | static_cast<U>(rhs));
91}
92
93constexpr SystemState& operator&=(SystemState& lhs, SystemState rhs)
94{
95 lhs = lhs & rhs;
96 return lhs;
97}
98
99constexpr SystemState& operator|=(SystemState& lhs, SystemState rhs)
100{
101 lhs = lhs | rhs;
102 return lhs;
103}
104
105constexpr SystemState operator~(SystemState arg)
106{
107 using U = std::underlying_type<SystemState>::type;
108 return static_cast<SystemState>(~static_cast<U>(arg));
109}
110
112// global stream operators of enum SystemState for logging and parsing
113ARP_EXPORT std::ostream& operator<<(std::ostream& os, SystemState value);
114ARP_EXPORT std::istream& operator>>(std::istream& is, SystemState& value);
115
116}}}} // end of namespace Arp::Base::Acf::Commons
117
119// template specialization of SystemState formatter
120template<> 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