该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
T = 0.25 * Tcomp; ev << "rd rec: " << rec << " cHeadsRound " << this->
cHeadsRound << " T: " << T << " rd: " << rd << " lCR " << nPtr->
lastClusterRound << "\n"; if (nPtr->myStatus != STATUS_DEAD && rd < T && nPtr->lastClusterRound == 0)
{
best[bestCtr].xpos = nPtr->xpos;
best[bestCtr].ypos = nPtr->ypos;
best[bestCtr].id = rec;
ev << "cHead: " << rec << "\n";
bestCtr++;
if (!this->solarOn || (nPtr->myStatus != STATUS_SUN && this->solarOn))
nPtr->lastClusterRound = 1;
if (nPtr->myStatus == STATUS_SUN)
this->sunCtr++;
else
this->darkCtr++;
this->cHeadsRound++;
if (bestCtr == FBEST)
break;
//nPtr->lastClusterRound = this->roundsDone;
}
this->nrHeads[this->roundsDone] = bestCtr;
} if (bestCtr == 0)
{
int allDone = 1; if (this->cHeadsRound + this->deadNodes == this->numNodes)
{
ev << "BS: goto reset\n";
goto reset;
} // check if not all are already done!!
for (int rec = 2; rec < this->nrNodes + 2; rec++)
{
Node *nPtr = (Node *) nodePtr[rec]; if (nPtr->lastClusterRound == 0 && nPtr->myStatus != STATUS_DEAD)
{
allDone = 0;
break;
}
}
if (allDone == 0)
{
ev << "BS: restart\n";
goto restart;
}
ev << "no cluster heads\n";
this->calledEnd = 5;
endSimulation();
} if (this->roundsDone == 250)
{
ev << "all rounds done\n";
this->calledEnd = 0;
endSimulation();
} // now we send message to all nodes and announce their cluster head
{
int head = 0;
int tmp;
char str[32]; for (int rec = 2; rec < this->nrNodes + 2; rec++)
{
Node *nPtr = (Node *) nodePtr[rec];
head = 0;
if (nPtr->myStatus != STATUS_DEAD)
{
//ev << "rec: " << rec;
min = 9999999;
for (j = 0; j < bestCtr; j++)
{
if (rec != best[j].id)
{
tmp = (nPtr->xpos - best[j].xpos) * (nPtr->xpos - best[j].xpos) +
(nPtr->ypos - best[j].ypos) * (nPtr->ypos - best[j].ypos);