forked from jacyara/GenESyS-Reborn
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Delay.cpp
72 lines (54 loc) · 1.91 KB
/
Delay.cpp
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
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/*
* File: Delay.cpp
* Author: cancian
*
* Created on 21 de Junho de 2018, 19:49
*/
#include "Delay.h"
#include "Model.h"
Delay::Delay(Model* model) : ModelComponent(model) {
_name = "Delay "+std::to_string(Util::GenerateNewIdOfType<Delay>());
}
Delay::Delay(const Delay& orig) : ModelComponent(orig) {
}
Delay::~Delay() {
}
std::string Delay::show() {
return ModelComponent::show() +
",delayExpression=" + this->_delayExpression +
",timeUnit=" + std::to_string(this->_delayTimeUnit);
}
void Delay::setDelayExpression(std::string _delayExpression) {
this->_delayExpression = _delayExpression;
}
std::string Delay::getDelayExpression() const {
return _delayExpression;
}
void Delay::setDelayTimeUnit(Util::TimeUnit _delayTimeUnit) {
this->_delayTimeUnit = _delayTimeUnit;
}
Util::TimeUnit Delay::getDelayTimeUnit() const {
return _delayTimeUnit;
}
void Delay::_execute(Entity* entity) {
double delayEndTime = _model->getSimulatedTime() + _model->parseExpression(_delayExpression) * Util::TimeUnitConvert(_delayTimeUnit, _model->getReplicationLengthTimeUnit());
Event* newEvent = new Event(delayEndTime, entity, this->getNextComponents()->first());
_model->getEvents()->insert(newEvent);
_model->trace(Util::TraceLevel::TL_blockInternal, "End of delay of entity " + std::to_string(entity->getId()) + " scheduled to time " + std::to_string(delayEndTime));
}
void Delay::_loadInstance(std::list<std::string> words) {
}
std::list<std::string>* Delay::_saveInstance() {
std::list<std::string>* words = new std::list<std::string>();
return words;
}
bool Delay::_verifySymbols(std::string* errorMessage) {
bool result = true;
this->_model->parseExpression(getDelayExpression(), &result, errorMessage);
return result;
}