Fix for multicountersec coordination issues implemented

This commit is contained in:
2015-06-26 11:32:05 +02:00
parent 766c8bbb73
commit 7643c51d74
2 changed files with 91 additions and 8 deletions

View File

@ -119,7 +119,7 @@ static void copyExponent(pHdb self, void *data)
/*---------------------------------------------------------------------------------*/
static void startMultiCounting(pHdb self, SConnection *pCon)
{
pHdb mode = NULL, preset = NULL, master = NULL, slaves = NULL;
pHdb mode = NULL, preset = NULL, slaves = NULL;
pHdb sID, mID;
char *pPtr, name[80];
pICountable pCount = NULL;
@ -130,13 +130,11 @@ static void startMultiCounting(pHdb self, SConnection *pCon)
mode = GetHipadabaNode(self,"mode");
preset = GetHipadabaNode(self,"preset");
master = GetHipadabaNode(self,"master");
slaves = GetHipadabaNode(self,"slaves");
sID = GetHipadabaNode(self,"slaveID");
mID = GetHipadabaNode(self,"masterID");
assert(mode != NULL);
assert(preset != NULL);
assert(master != NULL);
assert(slaves != NULL);
assert(sID != NULL);
assert(mID != NULL);
@ -176,15 +174,70 @@ static void startMultiCounting(pHdb self, SConnection *pCon)
}
}
v = MakeHdbInt(slaveID);
UpdateHipadabaPar(sID,v,pCon);
v = MakeHdbInt(-100);
UpdateHipadabaPar(mID,v,pCon);
}
/*---------------------------------------------------------------------------------*/
static int checkSlavesStarted(pCounter self, SConnection *pCon)
{
char *pPtr, name[80];
pHdb slaves = NULL, status = NULL, preset = NULL, master = NULL, mode = NULL, mID = NULL;
pDummy data = NULL;
pICountable pCount = NULL;
CounterMode eMode;
long masterID;
hdbValue v;
mID = GetHipadabaNode(self->objectNode,"masterID");
assert(mID != NULL);
if(mID->value.v.intValue != -100){
return 1;
}
slaves = GetHipadabaNode(self->objectNode,"slaves");
assert(slaves != NULL);
pPtr = slaves->value.v.text;
while((pPtr = stptok(pPtr,name,sizeof(name),",")) != NULL){
data = FindCommandData(pServ->pSics,name,NULL);
if(data != NULL){
status = GetHipadabaNode(data->pDescriptor->parNode,"status");
if(status != NULL){
if(strstr(status->value.v.text,"starting") != NULL){
return 0;
}
}
}
}
/*
start master
when we are here all HM were started and we can start master
*/
mode = GetHipadabaNode(self->objectNode,"mode");
preset = GetHipadabaNode(self->objectNode,"preset");
master = GetHipadabaNode(self->objectNode,"master");
assert(master != NULL);
assert(mode != NULL);
assert(preset != NULL);
strtolower(mode->value.v.text);
if(strcmp(mode->value.v.text,"timer") == 0) {
eMode = eTimer;
} else {
eMode = ePreset;
}
data = FindCommandData(pServ->pSics,master->value.v.text,NULL);
if(data != NULL){
pCount = GetCountableInterface(data);
if(pCount != NULL){
copyExponent(self,data);
copyExponent(self->objectNode,data);
pCount->SetCountParameters(data,preset->value.v.doubleValue,
eMode);
masterID = StartCountTask(data,pCon,master->value.v.text);
@ -193,9 +246,8 @@ static void startMultiCounting(pHdb self, SConnection *pCon)
v = MakeHdbInt(masterID);
UpdateHipadabaPar(mID,v,pCon);
v = MakeHdbInt(slaveID);
UpdateHipadabaPar(sID,v,pCon);
return 0;
}
/*---------------------------------------------------------------------------------*/
static hdbCallbackReturn MultiSecControllCallback(pHdb node,
@ -422,6 +474,10 @@ static int MultiSecStatus(void *pData, SConnection * pCon)
pCounter self = (pCounter)pData;
if(!checkSlavesStarted(self,pCon)) {
return HWBusy;
}
if(isMultiMasterRunning(self,pCon, &status)){
return status;
}