Skip to content

Commit

Permalink
Removed Coord, ConnectionManager 2D-3D flag, adjusted some includes. …
Browse files Browse the repository at this point in the history
…Removed getter/setter methods from coord and makes the x,y, and z values public. (Needed for INET integration)
  • Loading branch information
mlindig committed Oct 15, 2011
1 parent 1caaa90 commit 2925377
Show file tree
Hide file tree
Showing 75 changed files with 933 additions and 1,036 deletions.
31 changes: 10 additions & 21 deletions src/base/connectionManager/BaseConnectionManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -86,20 +86,17 @@ void BaseConnectionManager::initialize(int stage)
//step 3 - calculate the factor which maps the coordinate of a node
// to the grid cell
//if we use a 1x1 grid every coordinate is mapped to (0,0, 0)
findDistance = Coord(std::max(playgroundSize->getX(),
maxInterferenceDistance),
std::max(playgroundSize->getY(),
maxInterferenceDistance),
std::max(playgroundSize->getZ(),
maxInterferenceDistance));
findDistance = Coord(std::max(playgroundSize->x, maxInterferenceDistance),
std::max(playgroundSize->y, maxInterferenceDistance),
std::max(playgroundSize->z, maxInterferenceDistance));
//otherwise we divide the playground into cells of size of the maximum
//interference distance
if (gridDim.x != 1)
findDistance.setX(playgroundSize->getX() / gridDim.x);
findDistance.x = playgroundSize->x / gridDim.x;
if (gridDim.y != 1)
findDistance.setY(playgroundSize->getY() / gridDim.y);
findDistance.y = playgroundSize->y / gridDim.y;
if (gridDim.z != 1)
findDistance.setZ(playgroundSize->getZ() / gridDim.z);
findDistance.z = playgroundSize->z / gridDim.z;

//since the upper playground borders (at pg-size) are part of the
//playground we have to assure that they are mapped to a valid
Expand All @@ -110,10 +107,9 @@ void BaseConnectionManager::initialize(int stage)

//findDistance (equals cell size) has to be greater or equal
//maxInt-distance
assert(findDistance.getX() >= maxInterferenceDistance);
assert(findDistance.getY() >= maxInterferenceDistance);
assert(world->use2D()
|| findDistance.getZ() >= maxInterferenceDistance);
assert(findDistance.x >= maxInterferenceDistance);
assert(findDistance.y >= maxInterferenceDistance);
assert(findDistance.z >= maxInterferenceDistance);

//playGroundSize has to be part of the playGround
assert(GridCoord(*playgroundSize, findDistance).x == gridDim.x - 1);
Expand Down Expand Up @@ -226,9 +222,6 @@ void BaseConnectionManager::fillUnionWithNeighbors(CoordSet& gridUnion,
GridCoord cell)
{
for(int iz = (int)cell.z - 1; iz <= (int)cell.z + 1; iz++) {
if(iz != cell.z && cell.use2D) {
continue;
}
int cz = wrapIfTorus(iz, gridDim.z);
if(cz == -1) {
continue;
Expand All @@ -241,11 +234,7 @@ void BaseConnectionManager::fillUnionWithNeighbors(CoordSet& gridUnion,
for(int iy = (int)cell.y - 1; iy <= (int)cell.y + 1; iy++) {
int cy = wrapIfTorus(iy, gridDim.y);
if(cy != -1) {
if(cell.use2D) {
gridUnion.add(GridCoord(cx, cy));
} else {
gridUnion.add(GridCoord(cx, cy, cz));
}
gridUnion.add(GridCoord(cx, cy, cz));
}
}
}
Expand Down
24 changes: 7 additions & 17 deletions src/base/connectionManager/BaseConnectionManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,36 +35,32 @@ class MIXIM_API BaseConnectionManager : public cSimpleModule
class GridCoord
{
public:
/** @brief Constant for undefined coordinates.*/
static const int UNDEFINED = 0;
/** @name Coordinates in the grid.*/
/*@{*/
int x;
int y;
int z;
/*@}*/
/** @brief Use 2D or 3D coordinates?*/
bool use2D;

public:
/**
* @brief Initialize this GridCoord with the origin.
* Creates a 3-dimensional coord.
*/
GridCoord()
:x(0), y(0), z(0), use2D(false) {};
:x(0), y(0), z(0) {};

/**
* @brief Initialize a 2-dimensional GridCoord with x and y.
*/
GridCoord(int x, int y)
:x(x), y(y), z(UNDEFINED), use2D(true) {};
:x(x), y(y), z(0) {};

/**
* @brief Initialize a 3-dimensional GridCoord with x, y and z.
*/
GridCoord(int x, int y, int z)
:x(x), y(y), z(z), use2D(false) {};
:x(x), y(y), z(z) {};

/**
* @brief Simple copy-constructor.
Expand All @@ -73,7 +69,6 @@ class MIXIM_API BaseConnectionManager : public cSimpleModule
x = o.x;
y = o.y;
z = o.z;
use2D = o.use2D;
}

/**
Expand All @@ -82,20 +77,15 @@ class MIXIM_API BaseConnectionManager : public cSimpleModule
* The dimension of the GridCoord depends on the Coord.
*/
GridCoord(const Coord& c, const Coord& gridCellSize = Coord(1.0,1.0,1.0)) {
x = static_cast<int>(c.getX() / gridCellSize.getX());
y = static_cast<int>(c.getY() / gridCellSize.getY());
z = static_cast<int>(c.getZ() / gridCellSize.getZ());
use2D = c.is2D();
x = static_cast<int>(c.x / gridCellSize.x);
y = static_cast<int>(c.y / gridCellSize.y);
z = static_cast<int>(c.z / gridCellSize.z);
}

/** @brief Output string for this coordinate.*/
std::string info() const {
std::stringstream os;
if (use2D) {
os << "(" << x << "," << y << ")";
} else {
os << "(" << x << "," << y << "," << z << ")";
}
os << "(" << x << "," << y << "," << z << ")";
return os.str();
}

Expand Down
16 changes: 8 additions & 8 deletions src/base/connectionManager/ChannelAccess.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,20 +104,20 @@ class MIXIM_API ChannelAccess : public BatteryAccess
*/
static BaseConnectionManager* getConnectionManager(cModule* nic);

/** @brief Register with ConnectionManager and subscribe to hostPos
*
/** @brief Register with ConnectionManager.
*
* Upon initialization ChannelAccess registers the nic parent module
* to have all its connections handeled by ConnectionManager
**/
virtual void initialize(int stage);
virtual void initialize(int stage);

/**
* @brief Called by Blackboard to inform of changes
*
/**
* @brief Called by the signalling mechanism to inform of changes.
*
* ChannelAccess is subscribed to position changes and informs the
* ConnectionManager
* ConnectionManager.
*/
virtual void receiveBBItem(int category, const BBItem *details, int scopeModuleId);
virtual void receiveBBItem(int category, const BBItem *details, int scopeModuleId);
};

#endif
Expand Down
1 change: 1 addition & 0 deletions src/base/modules/AddressingInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <omnetpp.h>

#include "MiXiMDefs.h"

/**
* @brief Interface for modules which assign L2 and L3 addresses for modules.
*
Expand Down
1 change: 1 addition & 0 deletions src/base/modules/ArpInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#define ARPINTERFACE_H_

#include "MiXiMDefs.h"

/**
* @brief Interface every Address resolution protocol (ARP) module has to
* implement.
Expand Down
6 changes: 5 additions & 1 deletion src/base/modules/BaseApplLayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
*
* @author Daniel Willkomm
**/
class BaseApplLayer : public BaseLayer
class MIXIM_API BaseApplLayer : public BaseLayer
{
public:
/** @brief The message kinds this layer uses.*/
Expand All @@ -63,6 +63,10 @@ class BaseApplLayer : public BaseLayer

public:
//Module_Class_Members(BaseApplLayer, BaseLayer, 0);
BaseApplLayer() : BaseLayer()
{}
BaseApplLayer(unsigned stacksize) : BaseLayer(stacksize)
{}

/** @brief Initialization of the module and some variables*/
virtual void initialize(int);
Expand Down
6 changes: 1 addition & 5 deletions src/base/modules/BaseArp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,7 @@ int BaseArp::getMacAddr(const int netwAddr)
/*
int BaseArp::getNetwAddr(const int macAddr)
{
if(coreDebug) {
Enter_Method("getNetwAddr(%d)",macAddr);
} else {
Enter_Method_Silent();
}
Enter_Method("getNetwAddr(%d)",macAddr);
coreEV << "for host[" << simulation.getModule( macAddr )->getParentModule()->getIndex()
<< "]: macAddr " << macAddr << "; netw address "
<< simulation.getModule( macAddr )->getParentModule()->getSubmodule("nic")->getId() <<endl;
Expand Down
4 changes: 4 additions & 0 deletions src/base/modules/BaseBattery.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ class MIXIM_API DrawAmount {
*/
class MIXIM_API BaseBattery : public BaseModule {
public:
BaseBattery() : BaseModule()
{}
BaseBattery(unsigned stacksize) : BaseModule(stacksize)
{}
/**
* @brief Registers a power draining device with this battery.
*
Expand Down
13 changes: 8 additions & 5 deletions src/base/modules/BaseLayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,22 +50,25 @@ class MIXIM_API BaseLayer : public BatteryAccess
int upperControlOut;
int lowerControlIn;
int lowerControlOut;

/*@}*/

/** @brief Signal for PassedMessage.*/
int catPassedMsg;
int catPassedMsg;
/** @brief The last message passed through this layer. This variable will be only not NULL if we are
in statistic recording mode.*/
PassedMessage* passedMsg;
PassedMessage *passedMsg;
/** @brief This layers hosts id.*/
int hostId;
int hostId;

public:
BaseLayer()
: BatteryAccess()
, passedMsg(NULL)
{}
BaseLayer(unsigned stacksize)
: BatteryAccess(stacksize)
, passedMsg(NULL)
{}
virtual ~BaseLayer();
//Module_Class_Members(BaseLayer, BaseModule, 0 );

Expand All @@ -76,7 +79,7 @@ class MIXIM_API BaseLayer : public BatteryAccess
virtual void handleMessage( cMessage* );

/** @brief Called when the simulation has finished.*/
virtual void finish();
virtual void finish();

protected:
/**
Expand Down
8 changes: 8 additions & 0 deletions src/base/modules/BaseMacLayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,14 @@ class MIXIM_API BaseMacLayer : public BaseLayer

public:
//Module_Class_Members( BaseMacLayer, BaseLayer, 0 );
BaseMacLayer()
: BaseLayer()
, phy(NULL)
{}
BaseMacLayer(unsigned stacksize)
: BaseLayer(stacksize)
, phy(NULL)
{}

/** @brief Initialization of the module and some variables*/
virtual void initialize(int);
Expand Down
Loading

0 comments on commit 2925377

Please sign in to comment.