-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathPlc.h
81 lines (64 loc) · 1.44 KB
/
Plc.h
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
#ifndef PLC_H
#define PLC_H
#include "PlcIo.h"
#include "PlcTask.h"
#include "PlcMemory.h"
/**
* Implementierung einer Softwarebasierten SPS.
* Der Speicher der SPS ist programmglobal, weil der gesamte Prozess EINE SPS beschreibt.
* Diese Klasse dient daher nur der Übersichtlichkeit
*
* @authors Mirko Wittek, Tim Trense
*/
class Plc {
public:
/**
* SPS-Zustand
*/
enum State {
RUN, STOP, ERROR
};
Plc(PlcIo *_io);
~Plc();
State getState() const;
PlcIo *getIo() const;
PlcTask *getTask() const;
void setTask(PlcTask *task);
unsigned int getCooldownCycleTime() const;
void setCooldownCycleTime(unsigned int _cooldownCycleTime);
/**
* Setup der PLC-Umgebung
*/
void begin();
/**
* Laufender Zyklus der PLC-Umgebung
*/
bool cycle();
/**
* Aufräumen vor dem Ende PLC-Umgebung
*/
void end();
private:
/**
* Intervall in Millisekunden das nach der Ausführung von cycle() eingehalten wird, um die CPU-Last zu begrenzen
*/
unsigned int cooldownCycleTime;
/**
* Zeitpunkt des letzten Zyklus
*/
plc_timepoint lastCycle;
/**
* Zeitpunkt des Aufrufs von begin()
*/
plc_timepoint startTime;
/**
* SPS-Zustand
*/
State state;
/**
* I/O Logik der SPS
*/
PlcIo *io;
PlcTask *task; //TODO: make a list that runs async to one another
};
#endif //PLC_H