-
Notifications
You must be signed in to change notification settings - Fork 0
/
Source.cc
40 lines (33 loc) · 845 Bytes
/
Source.cc
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
/*
* source.cc
*
* Created on: 27 Sep 2020
* Author: smondal
*/
#include "Header.h"
#include <math.h>
using namespace std;
using namespace omnetpp;
class SourceMMc : public cSimpleModule
{
protected:
virtual void initialize() override;
virtual void handleMessage(cMessage *msg) override;
};
Define_Module(SourceMMc);
void SourceMMc::initialize()
{
cMessage *Arrival = new cMessage("Arrival");
scheduleAt(simTime(), Arrival);
}
void SourceMMc::handleMessage(cMessage *msg)
{
if(strcmp(msg->getName(),"Arrival")==0)
{
// Generate and send job request to the Queue
cMessage *Job = new cMessage("Job request");
send(Job,"out");
// schedule next call
scheduleAt(simTime()+exponential(1.0/ArrivalRate), msg);
}
}