-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathUpCounterProgram.cpp
More file actions
59 lines (52 loc) · 1.45 KB
/
UpCounterProgram.cpp
File metadata and controls
59 lines (52 loc) · 1.45 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
//
// 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 "UpCounterProgram.hpp"
#include "Arp/System/Commons/Logging.h"
#include "Arp/Base/Core/ByteConverter.hpp"
namespace ProgramComponentInteraction
{
void UpCounterProgram::Execute()
{
Command c = counterComponent.GetCommand();
// This method will be executed each cycle
// We just increase the counter by one here
switch(progress)
{
// Check if counting shall be started next cycle
case Progress::Done :// idle state
{
if( c == Command::CountUp)
{ log.Info("UC Start");
progress = Progress::Running;
}
break;
}
// Count Up
case Progress::Running :
{
this->OP_Counter++;
if( this->OP_Counter >= 255 )
{
progress = Progress::Stopped;
}
break;
}
// Reset the Counter
case Progress::Stopped :// reinitialize state
{
log.Info("UC Done");
this->OP_Counter = 0;
counterComponent.RefreshState();
progress = Progress::Done;
break;
}
default :
progress = Progress::Stopped;
break;
}
// Push the Progress to the Component.
counterComponent.SetProgressUC(progress);
}
} // end of namespace ProgramComponentInteraction