--- a/src/DAF/AE/AE.cc
+++ b/src/DAF/AE/AE.cc
@@ -20,10 +20,13 @@
AE::AE() :
Irm(NULL), Cdap(NULL)
{
+ FlowObject = NULL;
connectionState = NIL;
}
AE::~AE() {
+ connectionState = NIL;
+ FlowObject = NULL;
Irm = NULL;
Cdap = NULL;
}
@@ -83,7 +86,8 @@
//Setup signals
initSignalsAndListeners();
//Watchers
- WATCH_LIST(flows);
+ //WATCH_LIST(flows);
+ WATCH(FlowObject);
WATCH(connectionState);
}
@@ -108,83 +112,32 @@
ApMon->getOrCreateFirstUnconnectedGatePair(GATE_SOUTHIO, false, true, *&gApIn, *&gApOut);
//Get AE gates
- cGate* gAeIn;
- cGate* gAeOut;
- this->getParentModule()->getOrCreateFirstUnconnectedGatePair(GATE_DATAIO, false, true, *&gAeIn, *&gAeOut);
+ cGate* gAeIn = this->getParentModule()->gateHalf(GATE_AEIO, cGate::INPUT);
+ cGate* gAeOut = this->getParentModule()->gateHalf(GATE_AEIO, cGate::OUTPUT);
//CDAPParent Module gates
- cGate* gCdapParentIn;
- cGate* gCdapParentOut;
- Cdap->getOrCreateFirstUnconnectedGatePair(GATE_SOUTHIO, false, true, *&gCdapParentIn, *&gCdapParentOut);
-
- //CDAPSplitter gates
- cModule* CdapSplit = Cdap->getSubmodule(MOD_CDAPSPLIT);
- cGate* gSplitIn;
- cGate* gSplitOut;
- CdapSplit->getOrCreateFirstUnconnectedGatePair(GATE_SOUTHIO, false, true, *&gSplitIn, *&gSplitOut);
- cGate* gSplitCaceIn;
- cGate* gSplitCaceOut;
- CdapSplit->getOrCreateFirstUnconnectedGatePair(GATE_CACEIO, false, true, *&gSplitCaceIn, *&gSplitCaceOut);
- cGate* gSplitAuthIn;
- cGate* gSplitAuthOut;
- CdapSplit->getOrCreateFirstUnconnectedGatePair(GATE_AUTHIO, false, true, *&gSplitAuthIn, *&gSplitAuthOut);
- cGate* gSplitCdapIn;
- cGate* gSplitCdapOut;
- CdapSplit->getOrCreateFirstUnconnectedGatePair(GATE_CDAPIO, false, true, *&gSplitCdapIn, *&gSplitCdapOut);
-
- //CACE Module gates
- cModule* CdapCace = Cdap->getSubmodule(MOD_CDAPCACE);
- cGate* gCaceIn;
- cGate* gCaceOut;
- CdapCace->getOrCreateFirstUnconnectedGatePair(GATE_SPLITIO, false, true, *&gCaceIn, *&gCaceOut);
-
- //AUTH Module gates
- cModule* CdapAuth = Cdap->getSubmodule(MOD_CDAPAUTH);
- cGate* gAuthIn;
- cGate* gAuthOut;
- CdapAuth->getOrCreateFirstUnconnectedGatePair(GATE_SPLITIO, false, true, *&gAuthIn, *&gAuthOut);
-
- //CDAP Module gates
- cModule* CdapCdap = Cdap->getSubmodule(MOD_CDAPCDAP);
- cGate* gCdapIn;
- cGate* gCdapOut;
- CdapCdap->getOrCreateFirstUnconnectedGatePair(GATE_SPLITIO, false, true, *&gCdapIn, *&gCdapOut);
+ cGate* gCdapParentIn = Cdap->gateHalf(GATE_SOUTHIO, cGate::INPUT);
+ cGate* gCdapParentOut = Cdap->gateHalf(GATE_SOUTHIO, cGate::OUTPUT);
//Connect gates together
gIrmOut->connectTo(gIrmModOut);
gIrmModOut->connectTo(gApIn);
gApIn->connectTo(gAeIn);
gAeIn->connectTo(gCdapParentIn);
- gCdapParentIn->connectTo(gSplitIn);
-
- gSplitOut->connectTo(gCdapParentOut);
+
gCdapParentOut->connectTo(gAeOut);
gAeOut->connectTo(gApOut);
gApOut->connectTo(gIrmModIn);
gIrmModIn->connectTo(gIrmIn);
- gSplitCaceOut->connectTo(gCaceIn);
- gCaceOut->connectTo(gSplitCaceIn);
-
- gSplitAuthOut->connectTo(gAuthIn);
- gAuthOut->connectTo(gSplitAuthIn);
-
- gSplitCdapOut->connectTo(gCdapIn);
- gCdapOut->connectTo(gSplitCdapIn);
-
-
//Set north-half of the routing in ConnectionTable
Irm->setNorthGates(&flow, gIrmIn, gIrmOut);
//Return true if all dynamically created gates have same index
- return gIrmIn->getIndex() == gAeIn->getIndex()
- && gIrmIn->getIndex() == gIrmModIn->getIndex()
- && gIrmIn->getIndex() == gApIn->getIndex()
- && gIrmIn->getIndex() == gCdapParentIn->getIndex()
- && gIrmIn->getIndex() == gSplitIn->getIndex()
- && gIrmIn->getIndex() == gSplitCaceIn->getIndex()
- && gIrmIn->getIndex() == gSplitAuthIn->getIndex()
- && gIrmIn->getIndex() == gSplitCdapIn->getIndex();
+ return gIrmIn->isConnected()
+ && gAeIn->isConnected()
+ && gIrmModIn->isConnected()
+ && gApIn->isConnected();
}
void AE::initPointers() {
@@ -195,17 +148,16 @@
error("Pointers to Irm or ConnectionTable or Cdap are not initialized!");
}
-void AE::insertFlow(Flow& flow) {
- //Add a new flow to the end of the Flow list
- flows.push_back(flow);
+void AE::insertFlow() {
+ //Add a new flow to
//Prepare flow
- Irm->newFlow(&flows.back());
+ Irm->newFlow(FlowObject);
//Interconnect IRM and AE
- bool status = createBindings(flow);
+ bool status = createBindings(*FlowObject);
if (!status) {
- throw("Gate inconsistency during creation of a new flow!");
+ error("Gate inconsistency during creation of a new flow!");
}
}
@@ -238,17 +190,22 @@
//TODO: Vesely - More sophisticated decission
if (QoSRequirements.countFeasibilityScore(flow->getQosParameters()) > 0) {
//Initialize flow within AE
- insertFlow(*flow);
+ FlowObject = flow;
+ insertFlow();
//EV << "======================" << endl << flow->info() << endl;
//Interconnect IRM and IPC
- Irm->receiveAllocationResponsePositiveFromIpc(flow);
+
+ Irm->receiveAllocationResponsePositiveFromIpc(flow) ?
+ Irm->changeStatus(FlowObject, ConnectionTableEntry::CON_CONNECTPENDING)
+ :
+ Irm->changeStatus(FlowObject, ConnectionTableEntry::CON_ERROR);
//Change connection status
changeConStatus(CONNECTION_PENDING);
- this->signalizeAllocateResponsePositive(flow);
+ this->signalizeAllocateResponsePositive(FlowObject);
}
else {
- this->signalizeAllocateResponseNegative(flow);
+ this->signalizeAllocateResponseNegative(FlowObject);
}
}
@@ -266,6 +223,8 @@
//Change allocation status
Irm->changeStatus(flow, ConnectionTableEntry::CON_ERROR);
+ deleteBindings(*FlowObject);
+
//Change connection status
changeConStatus(NIL);
}
@@ -301,9 +260,8 @@
void AE::sendData(Flow* flow, CDAPMessage* msg) {
//Retrieve handle from ConTab record
- int handle = Irm->getGateHandle(flow);
+ int handle = Irm->getIrmGateHandle(flow);
if (handle != VAL_UNDEF_HANDLE) {
- msg->setHandle(handle);
//Pass Data to CDAP
//Connection/Release or send data msg
if (dynamic_cast<CDAP_M_Connect*>(msg) != NULL &&
@@ -353,59 +311,30 @@
bool AE::deleteBindings(Flow& flow) {
EV << this->getFullPath() << " deleted bindings" << endl;
- int handle = Irm->getGateHandle(&flow);
- if (handle == VAL_UNDEF_HANDLE)
+ int handle1 = Irm->getIrmGateHandle(&flow);
+ int handle2 = Irm->getApGateHandle(&flow);
+ if (handle1 == VAL_UNDEF_HANDLE)
error("Delete gates before flow allocation is impossible!");
//Disconnect gates
- cGate* gIrmIn = Irm->gateHalf(GATE_AEIO, cGate::INPUT, handle);
- cGate* gIrmOut = Irm->gateHalf(GATE_AEIO, cGate::OUTPUT, handle);
+ cGate* gIrmIn = Irm->gateHalf(GATE_AEIO, cGate::INPUT, handle1);
+ cGate* gIrmOut = Irm->gateHalf(GATE_AEIO, cGate::OUTPUT, handle1);
cModule* IrmMod = Irm->getParentModule();
- cGate* gIrmModIn = IrmMod->gateHalf(GATE_NORTHIO,cGate::INPUT, handle);
- cGate* gIrmModOut = IrmMod->gateHalf(GATE_NORTHIO,cGate::OUTPUT, handle);
+ cGate* gIrmModIn = IrmMod->gateHalf(GATE_NORTHIO,cGate::INPUT, handle1);
+ cGate* gIrmModOut = IrmMod->gateHalf(GATE_NORTHIO,cGate::OUTPUT, handle1);
cModule* ApMon = this->getParentModule()->getParentModule();
- cGate* gApIn = ApMon->gateHalf(GATE_SOUTHIO,cGate::INPUT, handle);
- cGate* gApOut = ApMon->gateHalf(GATE_SOUTHIO,cGate::OUTPUT, handle);
+ cGate* gApIn = ApMon->gateHalf(GATE_SOUTHIO,cGate::INPUT, handle2);
+ cGate* gApOut = ApMon->gateHalf(GATE_SOUTHIO,cGate::OUTPUT, handle2);
//Get AE gates
- cGate* gAeIn = this->getParentModule()->gateHalf(GATE_DATAIO, cGate::INPUT, handle);
- cGate* gAeOut = this->getParentModule()->gateHalf(GATE_DATAIO, cGate::OUTPUT, handle);
+ cGate* gAeIn = this->getParentModule()->gateHalf(GATE_AEIO, cGate::INPUT);
+ cGate* gAeOut = this->getParentModule()->gateHalf(GATE_AEIO, cGate::OUTPUT);
//CDAPParent Module gates
- cGate* gCdapParentIn = Cdap->gateHalf(GATE_SOUTHIO, cGate::INPUT, handle);
- cGate* gCdapParentOut = Cdap->gateHalf(GATE_SOUTHIO, cGate::OUTPUT, handle);
-
- //CDAPSplitter gates
- cModule* CdapSplit = Cdap->getSubmodule(MOD_CDAPSPLIT);
- cGate* gSplitIn = CdapSplit->gateHalf(GATE_SOUTHIO, cGate::INPUT, handle);
- cGate* gSplitOut = CdapSplit->gateHalf(GATE_SOUTHIO, cGate::OUTPUT, handle);
-
- cGate* gSplitCaceIn = CdapSplit->gateHalf(GATE_CACEIO, cGate::INPUT, handle);
- cGate* gSplitCaceOut = CdapSplit->gateHalf(GATE_CACEIO, cGate::OUTPUT, handle);
-
- cGate* gSplitAuthIn = CdapSplit->gateHalf(GATE_AUTHIO, cGate::INPUT, handle);
- cGate* gSplitAuthOut = CdapSplit->gateHalf(GATE_AUTHIO, cGate::OUTPUT, handle);
-
- cGate* gSplitCdapIn = CdapSplit->gateHalf(GATE_CDAPIO, cGate::INPUT, handle);
- cGate* gSplitCdapOut = CdapSplit->gateHalf(GATE_CDAPIO, cGate::OUTPUT, handle);
-
-
- //CACE Module gates
- cModule* CdapCace = Cdap->getSubmodule(MOD_CDAPCACE);
- cGate* gCaceIn = CdapCace->gateHalf(GATE_SPLITIO, cGate::INPUT, handle);
- cGate* gCaceOut = CdapCace->gateHalf(GATE_SPLITIO, cGate::OUTPUT, handle);
-
- //AUTH Module gates
- cModule* CdapAuth = Cdap->getSubmodule(MOD_CDAPAUTH);
- cGate* gAuthIn = CdapAuth->gateHalf(GATE_SPLITIO, cGate::INPUT, handle);
- cGate* gAuthOut = CdapAuth->gateHalf(GATE_SPLITIO, cGate::OUTPUT, handle);
-
- //CDAP Module gates
- cModule* CdapCdap = Cdap->getSubmodule(MOD_CDAPCDAP);
- cGate* gCdapIn = CdapCdap->gateHalf(GATE_SPLITIO, cGate::INPUT, handle);
- cGate* gCdapOut = CdapCdap->gateHalf(GATE_SPLITIO, cGate::OUTPUT, handle);
+ cGate* gCdapParentIn = Cdap->gateHalf(GATE_SOUTHIO, cGate::INPUT);
+ cGate* gCdapParentOut = Cdap->gateHalf(GATE_SOUTHIO, cGate::OUTPUT);
//Disconnect gates
gIrmOut->disconnect();
@@ -413,38 +342,17 @@
gApIn->disconnect();
gAeIn->disconnect();
gCdapParentIn->disconnect();
- gSplitIn->disconnect();
-
- gSplitOut->disconnect();
+
gCdapParentOut->disconnect();
gAeOut->disconnect();
gApOut->disconnect();
gIrmModIn->disconnect();
gIrmIn->disconnect();
- gSplitCaceOut->disconnect();
- gCaceIn->disconnect();
- gCaceOut->disconnect();
- gSplitCaceIn->disconnect();
-
- gSplitAuthOut->disconnect();
- gAuthIn->disconnect();
- gAuthOut->disconnect();
- gSplitAuthIn->disconnect();
-
- gSplitCdapOut->disconnect();
- gCdapIn->disconnect();
- gCdapOut->disconnect();
- gSplitCdapIn->disconnect();
-
//Return true if all dynamically created gates are disconnected
return !gIrmIn->isConnected() && !gIrmOut->isConnected()
&& !gAeIn->isConnected() && !gAeOut->isConnected()
- && !gCdapParentIn->isConnected() && !gCdapParentOut->isConnected()
- && !gSplitIn->isConnected() && !gSplitOut->isConnected()
- && !gSplitCaceIn->isConnected() && !gSplitCaceOut->isConnected()
- && !gSplitAuthIn->isConnected() && !gSplitAuthOut->isConnected()
- && !gSplitCdapIn->isConnected() && !gSplitCdapOut->isConnected();
+ && !gCdapParentIn->isConnected() && !gCdapParentOut->isConnected();
}
void AE::processMReadR(CDAPMessage* msg) {