- Adapted indenation to new agreed upon system
- Added support for second generation scriptcontext based counter
This commit is contained in:
438
multicounter.c
438
multicounter.c
@ -28,170 +28,183 @@
|
||||
#define MAXSLAVE 16
|
||||
#define NOCOUNTERS -2727
|
||||
/*=============== code for the driver ======================================*/
|
||||
typedef struct {
|
||||
void *slaveData[MAXSLAVE];
|
||||
pICountable slaves[MAXSLAVE];
|
||||
char *transferScript;
|
||||
int nSlaves;
|
||||
}MultiCounter, *pMultiCounter;
|
||||
typedef struct {
|
||||
void *slaveData[MAXSLAVE];
|
||||
pICountable slaves[MAXSLAVE];
|
||||
char *transferScript;
|
||||
int nSlaves;
|
||||
} MultiCounter, *pMultiCounter;
|
||||
/*--------------------------------------------------------------------------*/
|
||||
static void KillMultiDriver(struct __COUNTER *data){
|
||||
pMultiCounter self = (pMultiCounter)data->pData;
|
||||
if(self == NULL){
|
||||
return;
|
||||
}
|
||||
if(self->transferScript != NULL){
|
||||
free(self->transferScript);
|
||||
}
|
||||
free(self);
|
||||
static void KillMultiDriver(struct __COUNTER *data)
|
||||
{
|
||||
pMultiCounter self = (pMultiCounter) data->pData;
|
||||
if (self == NULL) {
|
||||
return;
|
||||
}
|
||||
if (self->transferScript != NULL) {
|
||||
free(self->transferScript);
|
||||
}
|
||||
free(self);
|
||||
}
|
||||
|
||||
/*============== countable interface functions ============================*/
|
||||
static int MMCCHalt(void *pData){
|
||||
static int MMCCHalt(void *pData)
|
||||
{
|
||||
int i, retVal = OKOK, status;
|
||||
pCounter pCount = NULL;
|
||||
pMultiCounter self = NULL;
|
||||
|
||||
pCount = (pCounter)pData;
|
||||
if(pCount != NULL){
|
||||
self = (pMultiCounter)pCount->pDriv->pData;
|
||||
pCount = (pCounter) pData;
|
||||
if (pCount != NULL) {
|
||||
self = (pMultiCounter) pCount->pDriv->pData;
|
||||
}
|
||||
assert(self);
|
||||
|
||||
for(i = 0; i < self->nSlaves; i++){
|
||||
for (i = 0; i < self->nSlaves; i++) {
|
||||
status = self->slaves[i]->Halt(self->slaveData[i]);
|
||||
ReleaseCountLock(self->slaves[i]);
|
||||
if(status != OKOK)
|
||||
if (status != OKOK)
|
||||
retVal = status;
|
||||
}
|
||||
ReleaseCountLock(pCount->pCountInt);
|
||||
return retVal;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
static int MMCCStart(void *pData, SConnection *pCon)
|
||||
static int MMCCStart(void *pData, SConnection * pCon)
|
||||
{
|
||||
int i, status;
|
||||
pCounter pCount = NULL;
|
||||
pMultiCounter self = NULL;
|
||||
|
||||
pCount = (pCounter)pData;
|
||||
if(pCount != NULL){
|
||||
self = (pMultiCounter)pCount->pDriv->pData;
|
||||
pCount = (pCounter) pData;
|
||||
if (pCount != NULL) {
|
||||
self = (pMultiCounter) pCount->pDriv->pData;
|
||||
}
|
||||
assert(self);
|
||||
|
||||
if(!GetCountLock(pCount->pCountInt, pCon)){
|
||||
return HWFault;
|
||||
|
||||
if (!GetCountLock(pCount->pCountInt, pCon)) {
|
||||
return HWFault;
|
||||
}
|
||||
|
||||
for(i = 0; i < self->nSlaves; i++){
|
||||
|
||||
for (i = 0; i < self->nSlaves; i++) {
|
||||
self->slaves[i]->SetCountParameters(self->slaveData[i],
|
||||
pCount->pDriv->fPreset, pCount->pDriv->eMode);
|
||||
pCount->pDriv->fPreset,
|
||||
pCount->pDriv->eMode);
|
||||
ReleaseCountLock(self->slaves[i]);
|
||||
status = self->slaves[i]->StartCount(self->slaveData[i],pCon);
|
||||
if(status != OKOK){
|
||||
status = self->slaves[i]->StartCount(self->slaveData[i], pCon);
|
||||
if (status != OKOK) {
|
||||
MMCCHalt(pData);
|
||||
return status;
|
||||
}
|
||||
}
|
||||
pCount->isUpToDate = 0;
|
||||
pCount->tStart = time(NULL);
|
||||
InvokeCallBack(pCount->pCall,COUNTSTART,pCon);
|
||||
InvokeCallBack(pCount->pCall, COUNTSTART, pCon);
|
||||
return OKOK;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
static int MMCCStatus(void *pData, SConnection *pCon){
|
||||
int status,i;
|
||||
static int MMCCStatus(void *pData, SConnection * pCon)
|
||||
{
|
||||
int status, i;
|
||||
pCounter pCount = NULL;
|
||||
pMultiCounter self = NULL;
|
||||
pDummy pDum = NULL;
|
||||
|
||||
pCount = (pCounter)pData;
|
||||
if(pCount != NULL){
|
||||
self = (pMultiCounter)pCount->pDriv->pData;
|
||||
pCount = (pCounter) pData;
|
||||
if (pCount != NULL) {
|
||||
self = (pMultiCounter) pCount->pDriv->pData;
|
||||
}
|
||||
assert(self);
|
||||
|
||||
if(self->nSlaves == 0) {
|
||||
if (self->nSlaves == 0) {
|
||||
pCount->pDriv->iErrorCode = NOCOUNTERS;
|
||||
return HWFault;
|
||||
}
|
||||
|
||||
status = self->slaves[0]->CheckCountStatus(self->slaveData[0],pCon);
|
||||
if(status == HWIdle || status == HWFault){
|
||||
status = self->slaves[0]->CheckCountStatus(self->slaveData[0], pCon);
|
||||
if (status == HWIdle || status == HWFault) {
|
||||
/*
|
||||
stop counting on slaves when finished or when an error
|
||||
occurred.
|
||||
*/
|
||||
InvokeCallBack(pCount->pCall,COUNTEND,pCon);
|
||||
stop counting on slaves when finished or when an error
|
||||
occurred.
|
||||
*/
|
||||
InvokeCallBack(pCount->pCall, COUNTEND, pCon);
|
||||
MMCCHalt(pCount);
|
||||
}
|
||||
for(i = 1; i < MAXSLAVE; i++){
|
||||
if(self->slaves[i] != NULL){
|
||||
pDum = (pDummy)self->slaveData[i];
|
||||
if(strcmp(pDum->pDescriptor->name,"HistMem") == 0){
|
||||
HistDirty((pHistMem)self->slaveData[i]);
|
||||
for (i = 1; i < MAXSLAVE; i++) {
|
||||
if (self->slaves[i] != NULL) {
|
||||
pDum = (pDummy) self->slaveData[i];
|
||||
if (strcmp(pDum->pDescriptor->name, "HistMem") == 0) {
|
||||
HistDirty((pHistMem) self->slaveData[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
static int MMCCPause(void *pData, SConnection *pCon){
|
||||
static int MMCCPause(void *pData, SConnection * pCon)
|
||||
{
|
||||
int i, status;
|
||||
pCounter pCount = NULL;
|
||||
pMultiCounter self = NULL;
|
||||
|
||||
pCount = (pCounter)pData;
|
||||
if(pCount != NULL){
|
||||
self = (pMultiCounter)pCount->pDriv->pData;
|
||||
pCount = (pCounter) pData;
|
||||
if (pCount != NULL) {
|
||||
self = (pMultiCounter) pCount->pDriv->pData;
|
||||
}
|
||||
assert(self);
|
||||
|
||||
for(i = 0; i < self->nSlaves; i++){
|
||||
status = self->slaves[i]->Pause(self->slaveData[i],pCon);
|
||||
if(status != OKOK){
|
||||
for (i = 0; i < self->nSlaves; i++) {
|
||||
status = self->slaves[i]->Pause(self->slaveData[i], pCon);
|
||||
if (status != OKOK) {
|
||||
MMCCHalt(pCount);
|
||||
return status;
|
||||
}
|
||||
}
|
||||
return OKOK;
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
static int MMCCContinue(void *pData, SConnection *pCon){
|
||||
static int MMCCContinue(void *pData, SConnection * pCon)
|
||||
{
|
||||
int i, status;
|
||||
pCounter pCount = NULL;
|
||||
pMultiCounter self = NULL;
|
||||
|
||||
pCount = (pCounter)pData;
|
||||
if(pCount != NULL){
|
||||
self = (pMultiCounter)pCount->pDriv->pData;
|
||||
pCount = (pCounter) pData;
|
||||
if (pCount != NULL) {
|
||||
self = (pMultiCounter) pCount->pDriv->pData;
|
||||
}
|
||||
assert(self);
|
||||
|
||||
for(i = 0; i < self->nSlaves; i++){
|
||||
status = self->slaves[i]->Continue(self->slaveData[i],pCon);
|
||||
if(status != OKOK){
|
||||
for (i = 0; i < self->nSlaves; i++) {
|
||||
status = self->slaves[i]->Continue(self->slaveData[i], pCon);
|
||||
if (status != OKOK) {
|
||||
MMCCHalt(pCount);
|
||||
return status;
|
||||
}
|
||||
}
|
||||
return OKOK;
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
static char *getNextMMCCNumber(char *pStart, char pNumber[80]){
|
||||
static char *getNextMMCCNumber(char *pStart, char pNumber[80])
|
||||
{
|
||||
int charCount = 0;
|
||||
pNumber[0] = '\0';
|
||||
|
||||
/* advance to first digit */
|
||||
while(isspace(*pStart) && *pStart != '\0'){
|
||||
while (isspace(*pStart) && *pStart != '\0') {
|
||||
pStart++;
|
||||
}
|
||||
if(*pStart == '\0'){
|
||||
if (*pStart == '\0') {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* copy */
|
||||
while(!isspace(*pStart) && *pStart != '\0' && charCount < 78){
|
||||
while (!isspace(*pStart) && *pStart != '\0' && charCount < 78) {
|
||||
pNumber[charCount] = *pStart;
|
||||
pStart++;
|
||||
charCount++;
|
||||
@ -199,146 +212,166 @@ static char *getNextMMCCNumber(char *pStart, char pNumber[80]){
|
||||
pNumber[charCount] = '\0';
|
||||
return pStart;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
static void loadCountData(pCounter pCount, const char *data){
|
||||
char *pPtr = NULL;
|
||||
char pNumber[80];
|
||||
int i = 0;
|
||||
|
||||
pPtr = (char *)data;
|
||||
pPtr = getNextMMCCNumber(pPtr,pNumber);
|
||||
pCount->pDriv->fTime = atof(pNumber);
|
||||
while(pPtr != NULL && i < MAXCOUNT){
|
||||
pPtr = getNextMMCCNumber(pPtr,pNumber);
|
||||
pCount->pDriv->lCounts[i] = atoi(pNumber);
|
||||
i++;
|
||||
}
|
||||
static void loadCountData(pCounter pCount, const char *data)
|
||||
{
|
||||
char *pPtr = NULL;
|
||||
char pNumber[80];
|
||||
int i = 0;
|
||||
|
||||
pPtr = (char *) data;
|
||||
pPtr = getNextMMCCNumber(pPtr, pNumber);
|
||||
pCount->pDriv->fTime = atof(pNumber);
|
||||
while (pPtr != NULL && i < MAXCOUNT) {
|
||||
pPtr = getNextMMCCNumber(pPtr, pNumber);
|
||||
pCount->pDriv->lCounts[i] = atoi(pNumber);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
static int MMCCTransfer(void *pData, SConnection *pCon){
|
||||
static int MMCCTransfer(void *pData, SConnection * pCon)
|
||||
{
|
||||
int i, retVal = OKOK, status;
|
||||
char pBueffel[132];
|
||||
pCounter pCount = NULL;
|
||||
pMultiCounter self = NULL;
|
||||
int tclStatus;
|
||||
|
||||
pCount = (pCounter)pData;
|
||||
if(pCount != NULL){
|
||||
self = (pMultiCounter)pCount->pDriv->pData;
|
||||
pCount = (pCounter) pData;
|
||||
if (pCount != NULL) {
|
||||
self = (pMultiCounter) pCount->pDriv->pData;
|
||||
}
|
||||
assert(self);
|
||||
|
||||
for(i = 0; i < self->nSlaves; i++){
|
||||
for (i = 0; i < self->nSlaves; i++) {
|
||||
status = self->slaves[i]->TransferData(self->slaveData[i], pCon);
|
||||
if(status != OKOK){
|
||||
if (status != OKOK) {
|
||||
retVal = status;
|
||||
sprintf(pBueffel,"WARNING: slave histogram %d failed to transfer data",
|
||||
i);
|
||||
SCWrite(pCon,pBueffel,eWarning);
|
||||
sprintf(pBueffel,
|
||||
"WARNING: slave histogram %d failed to transfer data", i);
|
||||
SCWrite(pCon, pBueffel, eWarning);
|
||||
}
|
||||
}
|
||||
if(self->transferScript != NULL){
|
||||
if (self->transferScript != NULL) {
|
||||
MacroPush(pCon);
|
||||
tclStatus = Tcl_Eval(InterpGetTcl(pServ->pSics), self->transferScript);
|
||||
if(tclStatus != TCL_OK){
|
||||
snprintf(pBueffel,131,"ERROR: TransferScript returned: %s",
|
||||
Tcl_GetStringResult(InterpGetTcl(pServ->pSics)));
|
||||
SCWrite(pCon,pBueffel,eError);
|
||||
MacroPop();
|
||||
return HWFault;
|
||||
if (tclStatus != TCL_OK) {
|
||||
snprintf(pBueffel, 131, "ERROR: TransferScript returned: %s",
|
||||
Tcl_GetStringResult(InterpGetTcl(pServ->pSics)));
|
||||
SCWrite(pCon, pBueffel, eError);
|
||||
MacroPop();
|
||||
return HWFault;
|
||||
}
|
||||
MacroPop();
|
||||
loadCountData(pCount,Tcl_GetStringResult(InterpGetTcl(pServ->pSics)));
|
||||
loadCountData(pCount, Tcl_GetStringResult(InterpGetTcl(pServ->pSics)));
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
static void MMCCParameter(void *pData, float fPreset, CounterMode eMode ){
|
||||
static void MMCCParameter(void *pData, float fPreset, CounterMode eMode)
|
||||
{
|
||||
int i;
|
||||
pCounter pCount = NULL;
|
||||
pMultiCounter self = NULL;
|
||||
|
||||
pCount = (pCounter)pData;
|
||||
if(pCount != NULL){
|
||||
self = (pMultiCounter)pCount->pDriv->pData;
|
||||
pCount = (pCounter) pData;
|
||||
if (pCount != NULL) {
|
||||
self = (pMultiCounter) pCount->pDriv->pData;
|
||||
}
|
||||
assert(self);
|
||||
|
||||
for(i = 0; i < self->nSlaves; i++){
|
||||
for (i = 0; i < self->nSlaves; i++) {
|
||||
self->slaves[i]->SetCountParameters(self->slaveData[i], fPreset,
|
||||
eMode);
|
||||
}
|
||||
}
|
||||
|
||||
/*======================= Driver Interface ==============================*/
|
||||
static int MultiCounterSet(struct __COUNTER *self, char *name,
|
||||
int iCter, float fVal){
|
||||
|
||||
return 0;
|
||||
static int MultiCounterSet(struct __COUNTER *self, char *name,
|
||||
int iCter, float fVal)
|
||||
{
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
static int MultiCounterGet(struct __COUNTER *self, char *name,
|
||||
int iCter, float *fVal){
|
||||
|
||||
return 0;
|
||||
static int MultiCounterGet(struct __COUNTER *self, char *name,
|
||||
int iCter, float *fVal)
|
||||
{
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
static int MultiCounterSend(struct __COUNTER *self, char *pText,
|
||||
char *reply, int replylen){
|
||||
|
||||
strncpy(reply,"NOT Implemented",replylen);
|
||||
return 0;
|
||||
static int MultiCounterSend(struct __COUNTER *self, char *pText,
|
||||
char *reply, int replylen)
|
||||
{
|
||||
|
||||
strncpy(reply, "NOT Implemented", replylen);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------*/
|
||||
static int MultiCounterError(struct __COUNTER *pDriv, int *iCode,
|
||||
char *error, int errlen){
|
||||
|
||||
char *error, int errlen)
|
||||
{
|
||||
|
||||
if(pDriv->iErrorCode == NOCOUNTERS){
|
||||
strncpy(error,"NO counters configured!",errlen);
|
||||
} else {
|
||||
strncpy(error,"Not Implemented", errlen);
|
||||
}
|
||||
return COTERM;
|
||||
}
|
||||
/*----------------------------------------------------------------------*/
|
||||
static int MultiCounterFix(struct __COUNTER *self, int iCode){
|
||||
|
||||
if (pDriv->iErrorCode == NOCOUNTERS) {
|
||||
strncpy(error, "NO counters configured!", errlen);
|
||||
} else {
|
||||
strncpy(error, "Not Implemented", errlen);
|
||||
}
|
||||
return COTERM;
|
||||
}
|
||||
/*=============== Interpreter Interface ================================ */
|
||||
int MultiCounterAction(SConnection *pCon, SicsInterp *pSics,
|
||||
void *pData, int argc, char *argv[]){
|
||||
pMultiCounter self = NULL;
|
||||
pCounter pCount = NULL;
|
||||
char buffer[256];
|
||||
|
||||
if(argc > 1){
|
||||
strtolower(argv[1]);
|
||||
if(strcmp(argv[1],"transferscript") == 0){
|
||||
pCount = (pCounter)pData;
|
||||
self = (pMultiCounter)pCount->pDriv->pData;
|
||||
if(argc < 3){
|
||||
SCPrintf(pCon,eValue,"%s.transferscript = %s",
|
||||
argv[0],self->transferScript);
|
||||
return 1;
|
||||
} else {
|
||||
if(!SCMatchRights(pCon,usUser)){
|
||||
return 0;
|
||||
}
|
||||
if(self->transferScript != NULL){
|
||||
free(self->transferScript);
|
||||
}
|
||||
Arg2Text(argc-2,&argv[2],buffer,255);
|
||||
self->transferScript = strdup(buffer);
|
||||
SCSendOK(pCon);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return CountAction(pCon,pSics,pData,argc,argv);
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
static int MultiCounterFix(struct __COUNTER *self, int iCode)
|
||||
{
|
||||
return COTERM;
|
||||
}
|
||||
|
||||
/*=============== Interpreter Interface ================================ */
|
||||
int MultiCounterAction(SConnection * pCon, SicsInterp * pSics,
|
||||
void *pData, int argc, char *argv[])
|
||||
{
|
||||
pMultiCounter self = NULL;
|
||||
pCounter pCount = NULL;
|
||||
char buffer[256];
|
||||
|
||||
if (argc > 1) {
|
||||
strtolower(argv[1]);
|
||||
if (strcmp(argv[1], "transferscript") == 0) {
|
||||
pCount = (pCounter) pData;
|
||||
self = (pMultiCounter) pCount->pDriv->pData;
|
||||
if (argc < 3) {
|
||||
SCPrintf(pCon, eValue, "%s.transferscript = %s",
|
||||
argv[0], self->transferScript);
|
||||
return 1;
|
||||
} else {
|
||||
if (!SCMatchRights(pCon, usUser)) {
|
||||
return 0;
|
||||
}
|
||||
if (self->transferScript != NULL) {
|
||||
free(self->transferScript);
|
||||
}
|
||||
Arg2Text(argc - 2, &argv[2], buffer, 255);
|
||||
self->transferScript = strdup(buffer);
|
||||
SCSendOK(pCon);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return CountAction(pCon, pSics, pData, argc, argv);
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
int MakeMultiCounter(SConnection *pCon, SicsInterp *pSics,
|
||||
void *pData, int argc, char *argv[]){
|
||||
int MakeMultiCounter(SConnection * pCon, SicsInterp * pSics,
|
||||
void *pData, int argc, char *argv[])
|
||||
{
|
||||
int i, status;
|
||||
pCounter pNew = NULL;
|
||||
char pBueffel[132];
|
||||
@ -348,42 +381,43 @@ int MakeMultiCounter(SConnection *pCon, SicsInterp *pSics,
|
||||
pCounterDriver pDriv = NULL;
|
||||
|
||||
/*
|
||||
need at least two parameters
|
||||
*/
|
||||
if(argc < 3){
|
||||
SCWrite(pCon,"ERROR: insufficient number of arguments to MakeMultiCounter",
|
||||
eError);
|
||||
need at least two parameters
|
||||
*/
|
||||
if (argc < 3) {
|
||||
SCWrite(pCon,
|
||||
"ERROR: insufficient number of arguments to MakeMultiCounter",
|
||||
eError);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
allocate our data structure
|
||||
*/
|
||||
*/
|
||||
self = malloc(sizeof(MultiCounter));
|
||||
pDriv = malloc(sizeof(CounterDriver));
|
||||
if(self == NULL || pDriv == NULL){
|
||||
SCWrite(pCon,"ERROR: out of memory in MakeMultiCounter",eError);
|
||||
if (self == NULL || pDriv == NULL) {
|
||||
SCWrite(pCon, "ERROR: out of memory in MakeMultiCounter", eError);
|
||||
return 0;
|
||||
}
|
||||
memset(self,0,sizeof(MultiCounter));
|
||||
memset(pDriv,0,sizeof(CounterDriver));
|
||||
memset(self, 0, sizeof(MultiCounter));
|
||||
memset(pDriv, 0, sizeof(CounterDriver));
|
||||
pDriv->pData = self;
|
||||
pDriv->KillPrivate = KillMultiDriver;
|
||||
pDriv->iNoOfMonitors = MAXCOUNT;
|
||||
pNew = CreateCounter(argv[1],pDriv);
|
||||
if(pNew == NULL){
|
||||
SCWrite(pCon,"ERROR: out of memory in MakeMultiCounter",eError);
|
||||
pNew = CreateCounter(argv[1], pDriv);
|
||||
if (pNew == NULL) {
|
||||
SCWrite(pCon, "ERROR: out of memory in MakeMultiCounter", eError);
|
||||
return 0;
|
||||
}
|
||||
pDriv->Get = MultiCounterGet;
|
||||
pDriv->GetError = MultiCounterError;
|
||||
pDriv->Get = MultiCounterGet;
|
||||
pDriv->GetError = MultiCounterError;
|
||||
pDriv->TryAndFixIt = MultiCounterFix;
|
||||
pDriv->Set = MultiCounterSet;
|
||||
pDriv->Send = MultiCounterSend;
|
||||
|
||||
pDriv->Set = MultiCounterSet;
|
||||
pDriv->Send = MultiCounterSend;
|
||||
|
||||
/*
|
||||
assign interface functions
|
||||
*/
|
||||
assign interface functions
|
||||
*/
|
||||
pNew->pCountInt->Halt = MMCCHalt;
|
||||
pNew->pCountInt->StartCount = MMCCStart;
|
||||
pNew->pCountInt->CheckCountStatus = MMCCStatus;
|
||||
@ -393,22 +427,21 @@ int MakeMultiCounter(SConnection *pCon, SicsInterp *pSics,
|
||||
pNew->pCountInt->SetCountParameters = MMCCParameter;
|
||||
|
||||
/*
|
||||
now loop through the remaining arguments, thereby entering them into
|
||||
the slave list.
|
||||
*/
|
||||
for(i = 2; i < argc; i++){
|
||||
pCom = FindCommand(pSics,argv[i]);
|
||||
if(!pCom){
|
||||
sprintf(pBueffel,"ERROR: object %s not found in MakeMultiCounter",
|
||||
now loop through the remaining arguments, thereby entering them into
|
||||
the slave list.
|
||||
*/
|
||||
for (i = 2; i < argc; i++) {
|
||||
pCom = FindCommand(pSics, argv[i]);
|
||||
if (!pCom) {
|
||||
sprintf(pBueffel, "ERROR: object %s not found in MakeMultiCounter",
|
||||
argv[i]);
|
||||
SCWrite(pCon,pBueffel,eError);
|
||||
SCWrite(pCon, pBueffel, eError);
|
||||
continue;
|
||||
}
|
||||
pCount = GetCountableInterface(pCom->pData);
|
||||
if(!pCount){
|
||||
sprintf(pBueffel,"ERROR: object %s is NOT countable",
|
||||
argv[i]);
|
||||
SCWrite(pCon,pBueffel,eError);
|
||||
if (!pCount) {
|
||||
sprintf(pBueffel, "ERROR: object %s is NOT countable", argv[i]);
|
||||
SCWrite(pCon, pBueffel, eError);
|
||||
continue;
|
||||
}
|
||||
self->slaves[self->nSlaves] = pCount;
|
||||
@ -417,17 +450,16 @@ int MakeMultiCounter(SConnection *pCon, SicsInterp *pSics,
|
||||
}
|
||||
|
||||
/*
|
||||
now install our action command and we are done
|
||||
*/
|
||||
status = AddCommand(pSics,argv[1],MultiCounterAction,DeleteCounter,
|
||||
pNew);
|
||||
if(!status){
|
||||
sprintf(pBueffel,"ERROR: duplicate command %s not created",argv[1]);
|
||||
SCWrite(pCon,pBueffel,eError);
|
||||
now install our action command and we are done
|
||||
*/
|
||||
status = AddCommand(pSics, argv[1], MultiCounterAction, DeleteCounter,
|
||||
pNew);
|
||||
if (!status) {
|
||||
sprintf(pBueffel, "ERROR: duplicate command %s not created", argv[1]);
|
||||
SCWrite(pCon, pBueffel, eError);
|
||||
DeleteCounter(pNew);
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user