MultiCounterSec revised now passes self test

This commit is contained in:
2015-06-30 15:03:06 +02:00
parent 7643c51d74
commit a3605ea96b
3 changed files with 40 additions and 5 deletions

View File

@ -17,6 +17,10 @@
#include <macro.h>
#include <status.h>
#include "sicshipadaba.h"
#define slaveSTARTING -100
/*---------------------------------------------------------------------------*/
typedef struct {
float fPreset;
@ -39,15 +43,18 @@ static void SecCounterSetError(pCounter self, char *text)
/*---------------------------------------------------------------------------------*/
static void doCountCommand(pHdb self, SConnection *pCon, int command)
{
pHdb master = NULL, slaves = NULL;
pHdb master = NULL, slaves = NULL, status = NULL;
char *pPtr, name[80];
pICountable pCount = NULL;
void *data;
master = GetHipadabaNode(self,"master");
slaves = GetHipadabaNode(self,"slaves");
status = GetHipadabaNode(self,"status");
assert(master != NULL);
assert(slaves != NULL);
assert(status != NULL);
/*
treat master
@ -61,7 +68,12 @@ static void doCountCommand(pHdb self, SConnection *pCon, int command)
pCount->Halt(data);
break;
case 1002: /*pause */
pCount->Pause(data,pCon);
if(strcmp(status->value.v.text,"starting") == 0){
SCWrite(pCon,"WARNINg: cannot pause when not yet started", eWarning);
return;
} else {
pCount->Pause(data,pCon);
}
break;
case 1003: /* continue */
pCount->Continue(data,pCon);
@ -177,7 +189,7 @@ static void startMultiCounting(pHdb self, SConnection *pCon)
v = MakeHdbInt(slaveID);
UpdateHipadabaPar(sID,v,pCon);
v = MakeHdbInt(-100);
v = MakeHdbInt(slaveSTARTING);
UpdateHipadabaPar(mID,v,pCon);
}
@ -195,10 +207,16 @@ static int checkSlavesStarted(pCounter self, SConnection *pCon)
mID = GetHipadabaNode(self->objectNode,"masterID");
assert(mID != NULL);
if(mID->value.v.intValue != -100){
if(mID->value.v.intValue != slaveSTARTING){
return 1;
}
if(SCGetInterrupt(pCon) != eContinue) {
doCountCommand(self->objectNode,pCon,1001);
mID->value.v.intValue = -1;
return 0;
}
slaves = GetHipadabaNode(self->objectNode,"slaves");
assert(slaves != NULL);