RINASim  October 2016
Documentation of framework for OMNeT++
Socket.cc
Go to the documentation of this file.
1 // The MIT License (MIT)
2 //
3 // Copyright (c) 2014-2016 Brno University of Technology, PRISTINE project
4 //
5 // Permission is hereby granted, free of charge, to any person obtaining a copy
6 // of this software and associated documentation files (the "Software"), to deal
7 // in the Software without restriction, including without limitation the rights
8 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 // copies of the Software, and to permit persons to whom the Software is
10 // furnished to do so, subject to the following conditions:
11 //
12 // The above copyright notice and this permission notice shall be included in
13 // all copies or substantial portions of the Software.
14 //
15 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 // THE SOFTWARE.
22 /*
23  * @file Socket.cc
24  * @author Marcel Marek
25  * @date Apr 28, 2016
26  * @brief
27  * @detail
28  */
29 
30 #include <Socket.h>
31 #include <string>
32 
34 
36 {
37  readImm = true;
38  inputQCapacity = 10;
39 }
40 
42  return flow;
43 }
44 
45 void Socket::initialize(int step) {
46 
47  if(step == 2){
48  sigSocketQueueInfo = registerSignal(SIG_Socket_QueueInfo);
49  }
50 }
51 
52 void Socket::setFlow(Flow* flow) {
53  this->flow = flow;
54 }
55 
57 {
58 }
59 
61 {
62 
63  QueueInfo* qi = new QueueInfo();
65  qi->setOccupied(toAE.size());
66  qi->setFlow(flow);
67  return qi;
68 }
69 
70 void Socket::handleMessage(cMessage* msg) {
71  std::string str = msg->getArrivalGate()->getName();
72  if(strstr(msg->getArrivalGate()->getName(), "southIo$i") != NULL){
73 
74  if(readImm){
75  send(msg,"cdapIo$o");
76  QueueInfo* qi = makeQueueInfo();
77  emit(sigSocketQueueInfo, qi);
78  }else{
79  toAE.push(msg);
80  //emit notify AE, there is msg waiting to be read
81  //emit notify EFCP
82  QueueInfo* qi = makeQueueInfo();
83  emit(sigSocketQueueInfo, qi);
84 
85  }
86  }
87  else { //if(strstr(msg->getArrivalGate()->getName(), "cdapIo$i") != NULL){
88  send(msg,"southIo$o", 0);
89  QueueInfo* qi = makeQueueInfo();
90  emit(sigSocketQueueInfo, qi);
91  }
92 }
Class representing flow object with attributes from specs.
Definition: Flow.h:45
void setFlow(Flow *flow)
Definition: Socket.cc:52
Define_Module(Socket)
void handleMessage(cMessage *msg)
Definition: Socket.cc:70
QueueInfo * makeQueueInfo()
Definition: Socket.cc:60
Socket()
Definition: Socket.cc:35
void setOccupied(unsigned int occupied)
Definition: QueueInfo.cc:65
virtual ~Socket()
Definition: Socket.cc:56
Flow * getFlow() const
Definition: Socket.cc:41
std::queue< cMessage * > toAE
Definition: Socket.h:44
Flow * flow
Definition: Socket.h:45
void setCapacity(unsigned int capacity)
Definition: QueueInfo.cc:45
simsignal_t sigSocketQueueInfo
Definition: Socket.h:48
void initialize(int step)
Definition: Socket.cc:45
Definition: Socket.h:40
void setFlow(Flow *flow)
Definition: QueueInfo.cc:55
int inputQCapacity
Definition: Socket.h:50
const char * SIG_Socket_QueueInfo
Definition: RINASignals.cc:43
bool readImm
Definition: Socket.h:43