forked from jacyara/GenESyS-Reborn
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathResource.cpp
118 lines (92 loc) · 2.75 KB
/
Resource.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
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
/*
* 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: Resource.cpp
* Author: cancian
*
* Created on 21 de Agosto de 2018, 16:52
*/
#include "Resource.h"
Resource::Resource(Model* model) : ModelInfrastructure(Util::TypeOf<Resource>()) {
model->getInfrastructures(Util::TypeOf<StatisticsCollector>())->insert(this->_cstatTimeSeized);
}
Resource::Resource(const Resource& orig) : ModelInfrastructure(orig) {
}
Resource::~Resource() {
}
std::string Resource::show() {
return ModelInfrastructure::show() +
",capacity=" + std::to_string(_capacity) +
",costBusyByour=" + std::to_string(_costBusyHour) +
",costIdleByour=" + std::to_string(_costIdleHour) +
",costPerUse=" + std::to_string(_costPerUse) +
",state=" + std::to_string(_resourceState);
}
void Resource::seize(unsigned int quantity, double tnow) {
_numberBusy += quantity;
_seizes++;
_whenSeized = tnow;
}
void Resource::release(unsigned int quantity, double tnow) {
if (_numberBusy >= quantity) {
_numberBusy -= quantity;
} else {
_numberBusy = 0;
}
_numberOut++;
double timeSeized = tnow - _whenSeized;
// Collect statistics about time seized
//cstats := Genesys.Model.SIMAN._GetModuleStructuresByKind(cCSTAT);
//i := cstats.IndexOf(IntToStr(aCSTATTimeSeizedID));
//TCStat(cstats.Objects[i]).AddValue(timeSeized);
this->_cstatTimeSeized->getCollector()->addValue(timeSeized);
//
_lastTimeSeized = timeSeized; // check. Isn't it TNOW?
}
void Resource::setResourceState(ResourceState _resourceState) {
this->_resourceState = _resourceState;
}
Resource::ResourceState Resource::getResourceState() const {
return _resourceState;
}
void Resource::setCapacity(unsigned int _capacity) {
this->_capacity = _capacity;
}
unsigned int Resource::getCapacity() const {
return _capacity;
}
void Resource::setCostBusyHour(double _costBusyHour) {
this->_costBusyHour = _costBusyHour;
}
double Resource::getCostBusyHour() const {
return _costBusyHour;
}
void Resource::setCostIdleHour(double _costIdleHour) {
this->_costIdleHour = _costIdleHour;
}
double Resource::getCostIdleHour() const {
return _costIdleHour;
}
void Resource::setCostPerUse(double _costPerUse) {
this->_costPerUse = _costPerUse;
}
double Resource::getCostPerUse() const {
return _costPerUse;
}
unsigned int Resource::getNumberBusy() const {
return _numberBusy;
}
unsigned int Resource::getNumberOut() const {
return _numberOut;
}
void Resource::_loadInstance(std::list<std::string> words) {
}
std::list<std::string>* Resource::_saveInstance() {
std::list<std::string>* words = new std::list<std::string>();
return words;
}
bool Resource::_verifySymbols(std::string* errorMessage) {
}