25 void MM_maxPST_Out::initialize() {
27 maxTH = par(
"maxTH").longValue();
28 margin = par(
"margin").longValue();
30 cXMLElement* Xml = NULL;
31 if (par(
"data").xmlValue() != NULL && par(
"data").xmlValue()->hasChildren()){
32 Xml = par(
"data").xmlValue();
34 error(
"Error data not initialized!");
37 cXMLElementList queues = Xml->getChildrenByTagName(
"queue");
38 for(
auto queue : queues){
39 if (!queue->getAttribute(
"id")) { error(
"Error parsing id missing!"); }
40 if (!queue->getAttribute(
"th")) { error(
"Error parsing th missing!"); }
41 if (!queue->getAttribute(
"p1")) { error(
"Error parsing p1 missing!"); }
42 if (!queue->getAttribute(
"p2")) { error(
"Error parsing p2 missing!"); }
44 string id = queue->getAttribute(
"id");
45 int th = atoi(queue->getAttribute(
"th"));
46 int p1 = atoi(queue->getAttribute(
"p1"));
47 int p2 = atoi(queue->getAttribute(
"p2"));
49 if(th < 0) { th = 0; }
50 if(p1 < 0) { p1 = 0; }
52 if(p2 < p1) { p2 = p1; }
55 qName2Threshold[id] = th;
56 qName2PrePrio[id] = p1;
57 qName2PostPrio[id] = p2;
61 MM_maxPST_Out::~MM_maxPST_Out(){}
63 void MM_maxPST_Out::finish() {}
66 queueInTime[q].push_back(portTime[p]);
70 queueInTime[q].pop_back();
77 portQueues[p].insert(q);
79 vector<string> qv =
split(q->getName(),
'_');
82 if(qv.size() == 2 && qv[1] ==
"M") {
83 if(qName2Threshold.find(qv[1]) != qName2Threshold.end()) {
84 th = qName2Threshold[qv[1]];
86 }
else if(qv.size() == 3) {
87 int h = stoi(qv[2].c_str());
89 if(qName2Threshold.find(qv[1]) != qName2Threshold.end()) {
90 th = qName2Threshold[qv[1]];
94 cout <<
"Queue : "<< q->getName() << endl;
95 error(
"Queue name must be \"M\" or of the form \"in/outQ_QoS_distance\"");
99 if(th < 0) { th = 0; }
103 qPrePrio[q] = qName2PrePrio[qv[1]];
104 qPostPrio[q] = qName2PostPrio[qv[1]];
106 cout <<
"queue : " << q->getName() <<
" | Threshold " << th <<endl ;
111 long cT = portTime[p];
117 for(
auto & q : portQueues[p]) {
118 if(!queueInTime[q].empty()) {
119 int pst = cT - queueInTime[q].front();
120 int th = qThreshold[q];
121 int qP = pst < th ? qPrePrio[q] : qPostPrio[q];
130 if(th >0) { max /= th; }
132 }
else if(qP == currP) {
134 if(th >0) { temp /= th; }
147 queueInTime[ret].pop_front();
153 simtime_t MM_maxPST_Out::getnextTime(
RMTPort * p) {
std::vector< std::string > & split(const std::string &s, char delim, std::vector< std::string > &elems)
Define_Module(MM_maxPST_Out)