SICS-195
This commit is contained in:
41
counter.c
41
counter.c
@ -556,6 +556,21 @@ static int GetNMonitorImpl(pCounter self)
|
||||
return self->pDriv->iNoOfMonitors;
|
||||
}
|
||||
|
||||
int GetControlMonitor(pCounter self)
|
||||
{
|
||||
return self->pDriv->iControlMonitor;
|
||||
}
|
||||
|
||||
int SetControlMonitor(pCounter self, int channel)
|
||||
{
|
||||
int maxchan = self->pDriv->iNoOfMonitors - 1;
|
||||
if (channel < 0 || channel > maxchan) {
|
||||
return 0;
|
||||
}
|
||||
self->pDriv->iControlMonitor = channel;
|
||||
return 1;
|
||||
}
|
||||
|
||||
#ifdef NONINTF
|
||||
extern float nintf(float f);
|
||||
#endif
|
||||
@ -628,7 +643,7 @@ static long GetCountsImpl(pCounter self, SConnection * pCon)
|
||||
if (!self->isUpToDate) {
|
||||
self->pCountInt->TransferData(self, pCon);
|
||||
}
|
||||
return self->pDriv->lCounts[0];
|
||||
return self->pDriv->lCounts[self->pDriv->iControlMonitor];
|
||||
}
|
||||
/*------------------------------------------------------------------------*/
|
||||
long GetMonitor(pCounter self, int iNum, SConnection * pCon)
|
||||
@ -643,7 +658,7 @@ static long GetMonitorImpl(pCounter self, int iNum, SConnection * pCon)
|
||||
if (!self->isUpToDate) {
|
||||
self->pCountInt->TransferData(self, pCon);
|
||||
}
|
||||
if ((iNum < 0) || (iNum > self->pDriv->iNoOfMonitors)) {
|
||||
if ((iNum < 0) || (iNum >= self->pDriv->iNoOfMonitors)) {
|
||||
return -1L;
|
||||
} else {
|
||||
return self->pDriv->lCounts[iNum];
|
||||
@ -814,7 +829,9 @@ int CountAction(SConnection * pCon, SicsInterp * pSics, void *pData,
|
||||
{"send", 0, {0, 0}},
|
||||
{"setpar", 3, {FUPATEXT, FUPAINT, FUPAFLOAT}},
|
||||
{"getpar", 2, {FUPATEXT, FUPAOPT}},
|
||||
{"getnmon", 0, {0, 0}}
|
||||
{"getnmon",0,{0,0}},
|
||||
{"getchannel",0,{0}},
|
||||
{"setchannel",1,{FUPAINT}}
|
||||
};
|
||||
char *pMode[] = {
|
||||
"timer",
|
||||
@ -831,7 +848,7 @@ int CountAction(SConnection * pCon, SicsInterp * pSics, void *pData,
|
||||
argtolower(argc, argv);
|
||||
argx = &argv[1];
|
||||
iRet =
|
||||
EvaluateFuPa((pFuncTemplate) & ActionTemplate, 23, argc - 1, argx,
|
||||
EvaluateFuPa((pFuncTemplate) & ActionTemplate, 25, argc - 1, argx,
|
||||
&PaRes);
|
||||
if (iRet < 0) {
|
||||
snprintf(pBueffel, 255,"%s", PaRes.pError);
|
||||
@ -1126,7 +1143,7 @@ int CountAction(SConnection * pCon, SicsInterp * pSics, void *pData,
|
||||
PaRes.Arg[1].iVal, &fVal);
|
||||
if (iRet == 1) {
|
||||
snprintf(pBueffel,255, "%s.%s %d = %f", argv[0], PaRes.Arg[0].text,
|
||||
PaRes.Arg[1].iVal, fVal);
|
||||
PaRes.Arg[1].text, fVal);
|
||||
SCWrite(pCon, pBueffel, eValue);
|
||||
return 1;
|
||||
} else {
|
||||
@ -1138,6 +1155,20 @@ int CountAction(SConnection * pCon, SicsInterp * pSics, void *pData,
|
||||
case 22: /* getnmon */
|
||||
snprintf(pBueffel, 131, "%s.getnmon = %d", argv[0], GetNMonitor(self));
|
||||
SCWrite(pCon, pBueffel, eValue);
|
||||
return 1;
|
||||
break;
|
||||
case 23: /* getchannel */
|
||||
snprintf(pBueffel,131,"%s.getchannel = %d", argv[0], GetControlMonitor(self));
|
||||
SCWrite(pCon,pBueffel,eValue);
|
||||
return 1;
|
||||
break;
|
||||
case 24: /* setchannel */
|
||||
if (SetControlMonitor(self, PaRes.Arg[0].iVal)) {
|
||||
return 1;
|
||||
} else {
|
||||
SCWrite(pCon,"ERROR: Invalid channel id",eError);
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
assert(0); /* internal error */
|
||||
|
@ -63,6 +63,8 @@ float GetControlValue(pCounter self);
|
||||
long GetCounts(pCounter self, SConnection * pCon);
|
||||
long GetMonitor(pCounter self, int iNum, SConnection * pCon);
|
||||
int GetNMonitor(pCounter self);
|
||||
int GetControlMonitor(pCounter self);
|
||||
int SetControlMonitor(pCounter self, int channel);
|
||||
void SetMonitorValue(pCounter self, int index, long value);
|
||||
float GetCountTime(pCounter self, SConnection * pCon);
|
||||
|
||||
|
Reference in New Issue
Block a user