Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/d3scomp/JDEECo into ROS-i…
Browse files Browse the repository at this point in the history
…ntegration
  • Loading branch information
vladamatena committed Oct 5, 2015
2 parents af7c299 + 6babde9 commit e3ca5ad
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public void registerL1(Layer1 layer1) {
* @param srcAddress
* source address
*/
protected void receive(byte[] data, Address srcAddress) {
layer1.processL0Packet(data, this, new ReceivedInfo(srcAddress));
protected void receive(byte[] data, ReceivedInfo info) {
layer1.processL0Packet(data, this, info);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ public class SimpleBroadcastDevice implements DEECoPlugin {
/**
* Loop device used to provide broadcast device to layer 1
*/
protected class LoopDevice extends Device {
final Layer1 layer1;
private class LoopDevice extends Device {
final MANETBroadcastAddress address;
final DEECoContainer container;
private PositionProvider positionProvider;
Expand All @@ -62,7 +61,6 @@ protected class LoopDevice extends Device {
public LoopDevice(DEECoContainer container) {
this.container = container;
address = new MANETBroadcastAddress(getId());
layer1 = container.getPluginInstance(Network.class).getL1();
positionProvider = container.getPluginInstance(PositionPlugin.class);
scheduler = container.getRuntimeFramework().getScheduler();
}
Expand Down Expand Up @@ -186,7 +184,7 @@ public void sendToAll(PacketWrapper packet) {

// Receive packet on the destination node
MANETReceivedInfo info = new MANETReceivedInfo(packet.source.address, rssi);
loop.layer1.processL0Packet(packet.data, packet.source, info);
loop.receive(packet.data, info);
}
}
}
Expand All @@ -211,8 +209,8 @@ public List<Class<? extends DEECoPlugin>> getDependencies() {
@Override
public void init(DEECoContainer container) {
random = new Random(container.getId());
Layer1 l1 = container.getPluginInstance(Network.class).getL1();
LoopDevice loop = new LoopDevice(container);
Layer1 l1 = container.getPluginInstance(Network.class).getL1();
l1.registerDevice(loop);
loops.add(loop);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,13 @@ public class SimpleInfrastructureDevice implements DEECoPlugin {
* Loop device used to provide broadcast device to layer 1
*/
private class LoopDevice extends Device {
public Layer1 layer1;
public IPAddress address;

private String id;

public LoopDevice(String id, IPAddress address, Layer1 layer1) {
this.id = id;
this.address = address;
this.layer1 = layer1;
}

@Override
Expand Down Expand Up @@ -144,7 +142,8 @@ public SimpleInfrastructureDevice() {
public void route(PacketWrapper packet) {
LoopDevice loop = loops.get(packet.destination);
if (loop != null) {
loop.layer1.processL0Packet(packet.data, packet.sender, new ReceivedInfo(packet.sender.address));
ReceivedInfo info = new ReceivedInfo(packet.sender.address);
loop.receive(packet.data, info);
} else {
throw new UnsupportedOperationException("Destination address not found in loop network");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ private DEECoContainer setupDestinationNode(int id) {
DEECoContainer node = setupBaseNode(0, 0);

// Configure Network for mocked container
Layer1 layer1 = Mockito.mock(Layer1.class);
Layer1 layer1 = Mockito.spy(new Layer1((byte) 0, DefaultDataIDSource.getInstance(), scheduler));
//Layer1 layer1 = Mockito.mock(Layer1.class);
Network network = Mockito.mock(Network.class);
Mockito.when(network.getL1()).thenReturn(layer1);
Mockito.when(node.getPluginInstance(Network.class)).thenReturn(network);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ private DEECoContainer setupDestinationNode(int id) {
Mockito.when(node.getRuntimeFramework()).thenReturn(runtime);

// Configure Network for mocked container
Layer1 layer1 = Mockito.mock(Layer1.class);
Layer1 layer1 = Mockito.spy(new Layer1((byte) id, DefaultDataIDSource.getInstance(), scheduler));
Mockito.doNothing().when(layer1).processL0Packet(Mockito.any(), Mockito.any(), Mockito.any());
Network network = Mockito.mock(Network.class);
Mockito.when(network.getL1()).thenReturn(layer1);
Mockito.when(node.getPluginInstance(Network.class)).thenReturn(network);
Expand Down
1 change: 1 addition & 0 deletions jdeeco-omnet-plugin/configs/omnetpp.ini
Original file line number Diff line number Diff line change
Expand Up @@ -214,4 +214,5 @@ cmdenv-module-messages = false
**.playgroundSizeX = 10000m
**.playgroundSizeY = 10000m

# Cheat packet size
**.node[*].appl.packet802154ByteLength = 128B

0 comments on commit e3ca5ad

Please sign in to comment.