#5, First Floor, 4th Street , Dr. Subbarayan Nagar, Kodambakkam, Chennai-600 024 pro@slogix.in

Office Address

  • #5, First Floor, 4th Street Dr. Subbarayan Nagar Kodambakkam, Chennai-600 024 Landmark : Samiyar Madam
  • pro@slogix.in
  • +91- 81240 01111

Social List

How to send specific number of tuples from a sensor

Description

Sensor class is the end node and is going to simulate the working of some sort of hardware like a camera, temperature measuring device etc. This is the source from where the tuples are generated representing the task and propagate them to the network for their computation. “Transmit()” abstract method implement to send specific number of tuples.

Source Code

static int numOfMaxTuples = 20;

static int tuplesCount = 0;

public void transmit()

{

System.out.print(CloudSim.clock()+": ");

if(tuplesCount

{

AppEdge _edge = null;

for(AppEdge edge : getApp().getEdges())

{

if(edge.getSource().equals(getTupleType()))

_edge = edge;

}

long cpuLength = (long) _edge.getTupleCpuLength();

long nwLength = (long) _edge.getTupleNwLength();

Tuple tuple = new Tuple(getAppId(), FogUtils.generateTupleId(), Tuple.UP, cpuLength, 1, nwLength, outputSize,

new UtilizationModelFull(), new UtilizationModelFull(), new UtilizationModelFull());

tuple.setUserId(getUserId());

tuple.setTupleType(getTupleType());

tuple.setDestModuleName(_edge.getDestination());

tuple.setSrcModuleName(getSensorName());

Logger.debug(getName(), "Sending tuple with tupleId = "+tuple.getCloudletId());

int actualTupleId = updateTimings(getSensorName(), tuple.getDestModuleName());

tuple.setActualTupleId(actualTupleId);

send(gatewayDeviceId,getLatency(), FogEvents.TUPLE_ARRIVAL,tuple);

tuplesCount++;

}

}


Output