-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathDownCounterProgram.cpp
More file actions
61 lines (53 loc) · 1.65 KB
/
DownCounterProgram.cpp
File metadata and controls
61 lines (53 loc) · 1.65 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
//
// 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 "DownCounterProgram.hpp"
#include "Arp/System/Commons/Logging.h"
#include "Arp/Base/Core/ByteConverter.hpp"
namespace ProgramComponentInteraction
{
void DownCounterProgram::Execute()
{
// Print the current progress and the counter value to the Output.log file
Command c = counterComponent.GetCommand();
switch(progress)
{
// Check if counting shall be started next cycle
case Progress::Done : // idle state
{
// access GetCommand() funktion of the Component via reference.
if( c == Command::CountDown)
{
log.Info("DC Start");
progress = Progress::Running;
}
break;
}
// Decrement the OP_Counter
case Progress::Running :
{
this->OP_Counter--;
if( this->OP_Counter <= 0 )
{
progress = Progress::Stopped;
}
break;
}
// Reset the Counter
case Progress::Stopped :// reinitialize state
{
log.Info("DC Done");
this->OP_Counter = 255;
counterComponent.RefreshState();
progress = Progress::Done;
break;
}
default :
progress = Progress::Stopped;
break;
}
// Push the current progress to the component.
counterComponent.SetProgressDC(progress);
}
} // end of namespace ProgramComponentInteraction