-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTickerCore.mpp
More file actions
81 lines (62 loc) · 1.75 KB
/
TickerCore.mpp
File metadata and controls
81 lines (62 loc) · 1.75 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
//LABEL (TickerCore, EN) Definition and initialization of Ticker actor
/*NOTE(TickerCore, EN)
This module contains the basic information associated with a Ticker actor.
One single Ticker actor is instantiated in a simulation. It is used to synchronise
time among all of the actors in the population in order to ensure
accurate reports.
*/
range REPORT_TIME //EN Reporting intervals
{
0, 200
};
actor Ticker //EN Actor for synchronising population-level activities
{
//EN Report time
REPORT_TIME report_time = { 0 };
//EN Time of next Tick event
TIME next_tick;
//LABEL(Ticker.Start, EN) Starts the ticker
void Start();
//LABEL(Ticker.Finish, EN) Finishes the actor
void Finish();
event timeTickEvent, TickEvent; //EN Tick event
};
/* NOTE(Ticker.Start,EN)
Initializes the Ticker actor.
*/
void Ticker::Start( )
{
time = (TIME) 0;
age = 0;
next_tick = 0;
}
/*NOTE(Ticker.Finish, EN)
The Finish function terminates the simulation of the ticker actor.
*/
void Ticker::Finish()
{
}
/* NOTE(Ticker.TickEvent,EN)
Increments the clock and synchronizes actors for reporting purposes.
*/
TIME Ticker::timeTickEvent()
{
return (TIME) next_tick;
}
void Ticker::TickEvent()
{
// Increment report time
report_time = COERCE(REPORT_TIME, report_time + 1);
// Age all TsetseFlys to the current time.
int nTsetseFly = asAllTsetseFly->Count();
for ( int nJ = 0; nJ < nTsetseFly; nJ++ )
{
TsetseFly *paTsetseFly = asAllTsetseFly->Item( nJ );
paTsetseFly->report_time = report_time;
}
// Schedule the next tick.
// The next line spreads reporting times evenly over the simulation
//next_tick = next_tick + SIMULATION_END() / SIZE(REPORT_TIME);
// The next line sets reporting times at equal intervals of size 1.0
next_tick = next_tick + (TIME) 1.0;
}