TTEthernet Model for INET Framework
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
RCIncoming.cc
Go to the documentation of this file.
1 //
2 // This program is free software: you can redistribute it and/or modify
3 // it under the terms of the GNU Lesser General Public License as published by
4 // the Free Software Foundation, either version 3 of the License, or
5 // (at your option) any later version.
6 //
7 // This program is distributed in the hope that it will be useful,
8 // but WITHOUT ANY WARRANTY; without even the implied warranty of
9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 // GNU Lesser General Public License for more details.
11 //
12 // You should have received a copy of the GNU Lesser General Public License
13 // along with this program. If not, see http://www.gnu.org/licenses/.
14 //
15 
16 #include "RCIncoming.h"
17 
18 #include <TTEScheduler.h>
19 
20 namespace TTEthernetModel {
21 
22 Define_Module(RCIncoming);
23 
24 
26 {
27  lastArrived=0;
28 }
29 
30 void RCIncoming::handleMessage(cMessage *msg)
31 {
32  if(msg->arrivedOn("in")){
33  TTEScheduler *tteScheduler = (TTEScheduler*)getParentModule()->getSubmodule("tteScheduler");
34  unsigned long currentTotalTicks = tteScheduler->getTotalTicks();
35  //Now check for correct arrival:
36  //TODO what todo with JITTER?
37  //Check too early
38  if(currentTotalTicks-lastArrived < bag){
39  emit(ctDroppedSignal, 1);
40  if(ev.isGUI()){
41  ev.printf("Received frame in %s too early! Gap was %d Ticks, should have been between minimum %d! \n", getName(), currentTotalTicks-lastArrived,par("bag").longValue());
42  bubble("Frame to early");
43  getDisplayString().setTagArg("i2", 0, "status/excl3");
44  getParentModule()->getDisplayString().setTagArg("i2", 0, "status/excl3");
45  }
46 
47  delete msg;
48  }
49  //Timing ok
50  else{
51  lastArrived=currentTotalTicks;
52  sendDelayed(msg,SimTime(getParentModule()->par("hardware_delay").doubleValue()),"out");
53  //send(msg,"out");
54  }
55  }
56 }
57 
58 void RCIncoming::handleParameterChange(const char* parname){
59  bag = (uint64_t)par("bag").longValue();
60 }
61 
62 } //namespace