-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathCounterComponent.cpp
More file actions
98 lines (83 loc) · 2.5 KB
/
CounterComponent.cpp
File metadata and controls
98 lines (83 loc) · 2.5 KB
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
//
// Copyright (c) Phoenix Contact GmbH & Co. KG. All rights reserved.
// Licensed under the MIT. See LICENSE file in the project root for full license information.
//
#include "CounterComponent.hpp"
#include "Arp/Plc/Commons/Esm/ProgramComponentBase.hpp"
#include "ProgramComponentInteractionLibrary.hpp"
namespace ProgramComponentInteraction
{
CounterComponent::CounterComponent(ILibrary& library, const String& name)
: ComponentBase(library, name, ComponentCategory::Custom, GetDefaultStartOrder())
, programProvider(*this)
, ProgramComponentBase(::ProgramComponentInteraction::ProgramComponentInteractionLibrary::GetInstance().GetNamespace(), programProvider)
{
}
void CounterComponent::Initialize()
{
// Allocate and initialize resources here
// Remember to free all allocated resources in the Dispose() method
DEBUG_FUNCTION_CALL
// never remove next line
ProgramComponentBase::Initialize();
// subscribe events from the event system (Nm) here
}
void CounterComponent::LoadConfig()
{
// Load project configuration here
DEBUG_FUNCTION_CALL
}
void CounterComponent::SetupConfig()
{
// never remove next line
ProgramComponentBase::SetupConfig();
// Setup project configuration here
DEBUG_FUNCTION_CALL
}
void CounterComponent::ResetConfig()
{
// never remove next line
ProgramComponentBase::ResetConfig();
DEBUG_FUNCTION_CALL
this->dataInfoProvider.Reset();}
void CounterComponent::PowerDown()
{
// implement this only if data shall be retained even on power down event
// will work only for PLCnext Control devices with an "Integrated uninterruptible power supply (UPS)"
// Available with 2021.6 FW
}
void CounterComponent::RefreshState()
{
DEBUG_FUNCTION_CALL
//
// When RefreshState is called the command gets toggled.
//
if (IP_Stop) // Component Port IP_Stop can set the Stop Command.
{
command = Command::Stop;
}
else
{
switch (command)
{
case Command::CountDown:
{
command = Command::CountUp;
}
break;
case Command::CountUp:
{
command = Command::CountDown;
}
break;
case Command::Stop:
{
command = Command::CountDown;
}
break;
}
}
// Print command and progress to the Custom.log file
log.Info("command: {2} progress_DC: {0} progress_UC: {1}", (int)progress_DC, (int)progress_UC, (int)command);
}
} // end of namespace ProgramComponentInteraction