-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathClientQuantumInterface.cc
53 lines (43 loc) · 1016 Bytes
/
ClientQuantumInterface.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
41
42
43
44
45
46
47
48
49
50
51
52
53
/*
* Client.cc
*
* Created on: 3 Apr 2019
* Author: Faisal
*/
#include <string.h>
#include <omnetpp.h>
#include <bitset>
#include <iostream>
using namespace omnetpp;
class ClientQuantumInterface : public cSimpleModule
{
protected:
virtual void initialize() override;
virtual void handleMessage(cMessage *msg) override;
};
Define_Module(ClientQuantumInterface);
void ClientQuantumInterface::initialize()
{
}
void ClientQuantumInterface::handleMessage(cMessage *msg)
{
cGate *gate = msg->getArrivalGate();
if(gate->isName("quantumChannelCommunication$i"))
{
int randomGate;
double x = rand()/static_cast<double>(RAND_MAX+1);
randomGate = 0 + static_cast<int>( x * (2 - 0) );
if(randomGate == 1)
{
send(msg,"diagonal");
}
else
{
send(msg,"flat");
}
}
else
{
send(msg,"quantumChannelCommunication$o");
}
}