PLCnext API Documentation  21.0.0.35466
PlcDomainProxy.hpp
1 //
3 // Copyright PHOENIX CONTACT Electronics GmbH
4 //
6 #pragma once
7 #include "Arp/System/Core/Arp.h"
8 #include "Arp/System/Core/event.hxx"
9 #include "Arp/System/Core/AppDomainSingleton.hxx"
10 #include "Arp/System/Commons/Logging.h"
11 #include "Arp/System/Acf/IComponent.hpp"
12 #include "Arp/System/Rsc/Services/IRscServiceFactory.hpp"
13 #include "Arp/Plc/Commons/Domain/PlcStartKind.hpp"
14 
15 // forwards
16 namespace Arp { namespace Plc { namespace Domain
17 {
18 class PlcDomainComponent;
19 class PlcDomainProxyComponent;
20 }}}
21 
22 namespace Arp { namespace Plc { namespace Commons { namespace Services { namespace Internal
23 {
24 class IPlcDomainService;
25 }}}}} // end of namespace Arp::Plc::Commons::Services::Internal
26 
27 namespace Arp { namespace System { namespace Watchdog { namespace Services { namespace Internal
28 {
29 class IWatchdogInfoService;
30 }}}}} // end of namespace Arp::Plc::Commons::Services::Internal
31 
32 namespace Arp { namespace Hardware { namespace DeviceHmi { namespace Services { namespace Internal
33 {
34 class ISwitchesService;
35 }}}}} // end of namespace Arp::Hardware::DeviceHmi::Services::Internal
36 
37 namespace Arp { namespace Plc { namespace Commons { namespace Domain
38 {
39 
40 using namespace Arp::System::Acf;
41 using namespace Arp::System::Rsc::Services;
42 using namespace Arp::Plc::Domain;
46 
47 class PlcDomainProxy : public AppDomainSingleton<PlcDomainProxy>, private Loggable<PlcDomainProxy>
48 {
49  friend class Arp::Plc::Domain::PlcDomainComponent;
50  friend class Arp::Plc::Domain::PlcDomainProxyComponent;
51 
52 private: // using/typedefs
53  using IPlcDomainServicePtr = std::shared_ptr<IPlcDomainService>;
54  using IWatchdogInfoServicePtr = std::shared_ptr<IWatchdogInfoService>;
55  using ISwitchesServicePtr = std::shared_ptr<ISwitchesService>;
56 
57 public: // construction/destruction
59  PlcDomainProxy(void) = default;
61  ~PlcDomainProxy(void) = default;
62 
63 public: // events
64  event<void> PlcLoading;
65  event<void> PlcLoaded;
66  event<PlcStartKind> PlcStarting;
67  event<void> PlcStarted;
68  event<void> PlcStopping;
69  event<void> PlcStopped;
70  event<bool> PlcUnloading; // bool parameter = 'onError'
71  event<bool> PlcUnloaded; // bool parameter = 'onError'
72  event<void> PlcChanging;
73  event<bool> PlcChanged; // bool parameter = 'success'
74 
75 public: // properties setter/getter
76  bool IsPlcSuspendedBySwitch(void);
77  bool IsPlcSuspendedBySystemWatchdog(bool& warmStartNotPossible, bool& autoRestart); // obsolete
78  bool IsPlcSuspendedBySystemWatchdog(PlcStartKind& startKind);
79 
80 public: // operations
81  void RegisterComponent(IComponent& component, bool isSystemComponent = false);
82  void UnregisterComponent(IComponent& component);
83 
84 private: // methods
85  void PublishComponentService(IComponent& component, const char* serviceName, IRscServiceFactory* pServiceFactory);
86 
87 private: // methods
88  void SubscribeServices(bool isPlcProcess = false);
89 
90 private: // deleted methods
91  PlcDomainProxy(const PlcDomainProxy& arg) = default;
92  PlcDomainProxy& operator=(const PlcDomainProxy& arg) = default;
93 
94 private: // fields
95  IPlcDomainServicePtr plcDomainSerivcePtr;
96  IWatchdogInfoServicePtr watchdogInfoServicePtr;
97  ISwitchesServicePtr switchesServicePtr;
98 
99 private: // static fields
100  boolean hasStartStopSwitch = false; /* here for binary compatibility */
101 
102 };
103 
105 // inline methods of class PlcDomainProxy
106 
107 }}}} // end of namespace Arp::Plc::Commons::Domain
Use this class to register and invoke several delegates (function pointer in OOP design).
Definition: event.hxx:192
Definition: PlcDomainProxy.hpp:22
Namespace for classes and interfaces for the Remote Service Call implementation
Definition: IRscReadEnumerator.hxx:9
This is the most important basic interface of the Arp platform. Any component shall implement this in...
Definition: IComponent.hpp:77
Definition: PlcDomainProxy.hpp:32
Definition: PlcDomainProxy.hpp:47
Namespace for the PLC domain
Definition: PlcDomainProxy.hpp:16
Root namespace for the PLCnext API
This class implements the singleton pattern for singletons with process wide scope.
Definition: AppDomainSingleton.hxx:24
System components used by the System, Device, Plc or Io domains.
This is the namespace of the Application Component Framework.
Definition: ComponentBase.hpp:12
Definition: PlcDomainProxy.hpp:27