-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSimulation.h
123 lines (94 loc) · 2.31 KB
/
Simulation.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
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
114
115
116
117
118
119
120
121
122
/**
* FIT VUT Brno
* IMS: Projekt "Knihovna pro kombinovanou simulaci"
*
* @author Petr Mejzlik [email protected]
* @author Jiri Petruzelka [email protected]
*/
#ifndef SIMULATION_H
#define SIMULATION_H
#include <iostream>
#include "IMSimInternal.h"
using std::ostream;
using std::ofstream;
using std::istream;
namespace IMSim {
class Calendar;
class ConditionsContainer;
class BlockContainer;
/**
* Responsible for handling the simulation experiment
*/
class Simulation {
public:
// construction
Simulation();
explicit Simulation(char* name);
Simulation(STEP minStep, STEP maxStep, PRECISION precision = 0);
~Simulation();
// Basics
void setStep(STEP minStep, STEP maxStep);
void setPrecision(PRECISION precision);
void setName(char* name);
ENTITY_ID getNextId();
TIME getCurrentTime();
TIME now();
// Output
void setOutput( ostream* stream );
void setOutput( ostream* stream, unsigned char flags );
ostream* getOutput() const;
// Discrete support
Calendar* getCalendar();
// Continuous Support
ConditionsContainer* getConditionsContainer();
BlockContainer* getBlockContainer();
// Checking
bool isInRange(TIME time);
bool isInRange(TIME time, TIME interval);
bool isDebug();
bool isReady();
bool isInLoop();
// Running
void run();
void run(TIME startTime, TIME endTime);
void abort();
// Flags
enum flags {
OUTPUT_STANDARD = 0x0,
OUTPUT_VERBOSE = 0x1,
OUTPUT_DEBUG = 0x2
};
enum phase {
PHASE_CLEAR = 0,
PHASE_INIT = 1,
PHASE_RUNNING = 2,
PHASE_PAUSED = 3,
PHASE_TERMINATED = 4
};
private:
void init();
TIME start;
TIME end;
TIME current;
ENTITY_ID lastId;
PRECISION precision;
STEP minStep;
STEP maxStep;
unsigned int countOfRuns;
unsigned char phase;
char *name;
void setCurrentTime(TIME now);
void setTimeRange(TIME startTime, TIME endTime);
bool hasConditionsContainer();
bool hasBlockContainer();
void reset();
void terminate();
bool abortFlag;
ostream* output;
unsigned char outputFlags;
Calendar* calendar;
ConditionsContainer* conditionsContainer;
BlockContainer* blockContainer;
};
}
#endif /* SIMULATION_H */