-
Notifications
You must be signed in to change notification settings - Fork 20
/
OpcPlcManagerComponent.hpp
113 lines (91 loc) · 3.14 KB
/
OpcPlcManagerComponent.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#pragma once
#include "Arp/System/Core/Arp.h"
#include "Arp/System/Acf/ComponentBase.hpp"
#include "Arp/System/Acf/IApplication.hpp"
#include "Arp/Plc/Commons/Meta/MetaComponentBase.hpp"
#include "Arp/System/Commons/Logging.h"
#include "Arp/System/Commons/Threading/WorkerThread.hpp"
#include "Arp/Plc/Domain/Services/IPlcManagerService2.hpp"
namespace OpcPlcManager
{
using namespace Arp;
using namespace Arp::System::Acf;
using namespace Arp::Plc::Commons::Meta;
using namespace Arp::Plc::Domain::Services;
using namespace Arp::System::Commons::Threading;
//#acfcomponent
class OpcPlcManagerComponent : public ComponentBase, public MetaComponentBase, private Loggable<OpcPlcManagerComponent>
{
public: // typedefs
public: // construction/destruction
OpcPlcManagerComponent(IApplication& application, const String& name);
virtual ~OpcPlcManagerComponent() = default;
public: // IComponent operations
void Initialize() override;
void SubscribeServices()override;
void LoadSettings(const String& settingsPath)override;
void SetupSettings()override;
void PublishServices()override;
void LoadConfig() override;
void SetupConfig() override;
void ResetConfig() override;
void Dispose()override;
void PowerDown()override;
public: // MetaComponentBase operations
void RegisterComponentPorts() override;
private: // methods
OpcPlcManagerComponent(const OpcPlcManagerComponent& arg) = delete;
OpcPlcManagerComponent& operator= (const OpcPlcManagerComponent& arg) = delete;
public: // static factory operations
static IComponent::Ptr Create(Arp::System::Acf::IApplication& application, const String& name);
private: // fields
WorkerThread workerThreadInstance;
IPlcManagerService2::Ptr plcManagerService2Ptr = nullptr;
private: // methods
void workerThreadBody(void);
public: // ports
// One struct is defined for each OPC UA method
// Each struct contains the method input and output parameters,
// and two special UA_* variables.
struct GET_PLC_STATE
{
//#attributes(Input|Opc)
Arp::int16 UA_MethodState = 0;
//#attributes(Output|Opc)
Arp::uint32 state = 0;
//#attributes(Output|Opc)
Arp::uint32 UA_StatusCode = 0;
};
struct START
{
//#attributes(Input|Opc)
Arp::uint8 startKind = 0;
//#attributes(Input|Opc)
Arp::boolean async = false;
//#attributes(Input|Opc)
Arp::int16 UA_MethodState = 0;
//#attributes(Output|Opc)
Arp::uint32 UA_StatusCode = 0;
};
struct STOP
{
//#attributes(Input|Opc)
Arp::boolean async = false;
//#attributes(Input|Opc)
Arp::int16 UA_MethodState = 0;
//#attributes(Output|Opc)
Arp::uint32 UA_StatusCode = 0;
};
// Now the port variables themselves
//#port
GET_PLC_STATE GetPlcState;
//#port
START Start;
//#port
STOP Stop;
};
inline IComponent::Ptr OpcPlcManagerComponent::Create(Arp::System::Acf::IApplication& application, const String& name)
{
return IComponent::Ptr(new OpcPlcManagerComponent(application, name));
}
} // end of namespace OpcPlcManager