PLCnext API Documentation 25.0.2.69
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
41enum class SystemState : uint32
42{
43 // State flags:
44 None = 0,
45 Ready = 10,
46 Stop = 20,
47 Running = 30,
48
49 // State transition flags:
50 Initializing = (1 << 9),
51 Loading = (1 << 10),
52 Starting = (1 << 11),
53 Stopping = (1 << 12),
54 Resetting = (1 << 13),
55 Disposing = (1 << 14),
56
57 // Error FLags:
58 SystemError = (1 << 16),
59
60 // Flags masks
61 StateMask = 0x000000FF,
62 FlagsMask = ~StateMask,
63 TransitionFlags = 0x0000FF00,
64 ErrorFlags = 0xFFFF0000,
65};
66
67constexpr SystemState operator&(SystemState lhs, SystemState rhs)
68{
69 using U = std::underlying_type<SystemState>::type;
70 return static_cast<SystemState>(static_cast<U>(lhs) & static_cast<U>(rhs));
71}
72
73constexpr SystemState operator|(SystemState lhs, SystemState rhs)
74{
75 using U = std::underlying_type<SystemState>::type;
76 return static_cast<SystemState>(static_cast<U>(lhs) | static_cast<U>(rhs));
77}
78
79constexpr SystemState& operator&=(SystemState& lhs, SystemState rhs)
80{
81 lhs = lhs & rhs;
82 return lhs;
83}
84
85constexpr SystemState& operator|=(SystemState& lhs, SystemState rhs)
86{
87 lhs = lhs | rhs;
88 return lhs;
89}
90
91constexpr SystemState operator~(SystemState arg)
92{
93 using U = std::underlying_type<SystemState>::type;
94 return static_cast<SystemState>(~static_cast<U>(arg));
95}
96
98// global stream operators of enum SystemState for logging and parsing
99ARP_EXPORT std::ostream& operator<<(std::ostream& os, SystemState value);
100ARP_EXPORT std::istream& operator>>(std::istream& is, SystemState& value);
101
102}}}} // end of namespace Arp::Base::Acf::Commons
103
105// template specialization of SystemState formatter
106template<> 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