TTEthernet Model for INET Framework
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
TTTrafficSourceApp.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 "TTTrafficSourceApp.h"
17 #include <CTFrame_m.h>
18 #include "TTEScheduler.h"
19 
20 namespace TTEthernetModel {
21 
22 Define_Module( TTTrafficSourceApp);
23 
25 }
26 
28 {
30 
31  TTEScheduler *tteScheduler = (TTEScheduler*) getParentModule()->getSubmodule("tteScheduler");
32  SchedulerActionTimeEvent *event = new SchedulerActionTimeEvent("API Scheduler Task Event", ACTION_TIME_EVENT);
33  event->setAction_time(par("action_time").doubleValue()/tteScheduler->par("tick").doubleValue());
34  event->setDestinationGate(gate("schedulerIn"));
35  tteScheduler->registerEvent(event);
36 }
37 
39 
40  if(msg->arrivedOn("schedulerIn")){
41  moduloCycle++;
42  if(moduloCycle==(unsigned int)par("modulo").longValue()){
43  sendMessage();
44  moduloCycle=0;
45  }
46 
47  TTEScheduler *tteScheduler = (TTEScheduler*) getParentModule()->getSubmodule("tteScheduler");
49  tteScheduler->registerEvent(event, true);
50  }
51  else{
52  delete msg;
53  }
54 }
55 
56 
57 } //namespace