This commit is contained in:
Douglas Clowes
2012-11-28 15:20:29 +11:00
parent b0115d2569
commit c277681fa1
2 changed files with 48 additions and 15 deletions

View File

@ -536,7 +536,7 @@ static int SetCounterModeImpl(pCounter self, CounterMode eNew)
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
CounterMode GetCounterMode(pCounter self) CounterMode GetCounterMode(pCounter self)
{ {
return self->getMode(self); return self->getMode(self);
} }
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
static CounterMode GetCounterModeImpl(pCounter self) static CounterMode GetCounterModeImpl(pCounter self)
@ -547,7 +547,7 @@ static CounterMode GetCounterModeImpl(pCounter self)
/*------------------------------------------------------------------------*/ /*------------------------------------------------------------------------*/
int GetNMonitor(pCounter self) int GetNMonitor(pCounter self)
{ {
return self->getNMonitor(self); return self->getNMonitor(self);
} }
/*------------------------------------------------------------------------*/ /*------------------------------------------------------------------------*/
static int GetNMonitorImpl(pCounter self) static int GetNMonitorImpl(pCounter self)
@ -556,13 +556,28 @@ static int GetNMonitorImpl(pCounter self)
return self->pDriv->iNoOfMonitors; 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 #ifdef NONINTF
extern float nintf(float f); extern float nintf(float f);
#endif #endif
/*------------------------------------------------------------------------*/ /*------------------------------------------------------------------------*/
int SetCounterPreset(pCounter self, float fVal) int SetCounterPreset(pCounter self, float fVal)
{ {
return self->setPreset(self,fVal); return self->setPreset(self,fVal);
} }
/*------------------------------------------------------------------------*/ /*------------------------------------------------------------------------*/
static int SetCounterPresetImpl(pCounter self, float fVal) static int SetCounterPresetImpl(pCounter self, float fVal)
@ -588,17 +603,17 @@ static int SetCounterPresetImpl(pCounter self, float fVal)
/*------------------------------------------------------------------------*/ /*------------------------------------------------------------------------*/
float GetCounterPreset(pCounter self) float GetCounterPreset(pCounter self)
{ {
return self->getPreset(self); return self->getPreset(self);
} }
/*------------------------------------------------------------------------*/ /*------------------------------------------------------------------------*/
float GetControlValue(pCounter self) float GetControlValue(pCounter self)
{ {
return self->getControlValue(self); return self->getControlValue(self);
} }
/*------------------------------------------------------------------------*/ /*------------------------------------------------------------------------*/
static float GetControlValueImpl(pCounter self) static float GetControlValueImpl(pCounter self)
{ {
return self->pDriv->fLastCurrent; return self->pDriv->fLastCurrent;
} }
/*------------------------------------------------------------------------*/ /*------------------------------------------------------------------------*/
static float GetCounterPresetImpl(pCounter self) static float GetCounterPresetImpl(pCounter self)
@ -619,7 +634,7 @@ static float GetCounterPresetImpl(pCounter self)
/*-----------------------------------------------------------------------*/ /*-----------------------------------------------------------------------*/
long GetCounts(pCounter self, SConnection * pCon) long GetCounts(pCounter self, SConnection * pCon)
{ {
return self->getCounts(self, pCon); return self->getCounts(self, pCon);
} }
/*-----------------------------------------------------------------------*/ /*-----------------------------------------------------------------------*/
static long GetCountsImpl(pCounter self, SConnection * pCon) static long GetCountsImpl(pCounter self, SConnection * pCon)
@ -628,12 +643,12 @@ static long GetCountsImpl(pCounter self, SConnection * pCon)
if (!self->isUpToDate) { if (!self->isUpToDate) {
self->pCountInt->TransferData(self, pCon); 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) long GetMonitor(pCounter self, int iNum, SConnection * pCon)
{ {
return self->getMonitor(self, iNum, pCon); return self->getMonitor(self, iNum, pCon);
} }
/*------------------------------------------------------------------------*/ /*------------------------------------------------------------------------*/
static long GetMonitorImpl(pCounter self, int iNum, SConnection * pCon) static long GetMonitorImpl(pCounter self, int iNum, SConnection * pCon)
@ -643,7 +658,7 @@ static long GetMonitorImpl(pCounter self, int iNum, SConnection * pCon)
if (!self->isUpToDate) { if (!self->isUpToDate) {
self->pCountInt->TransferData(self, pCon); self->pCountInt->TransferData(self, pCon);
} }
if ((iNum < 0) || (iNum > self->pDriv->iNoOfMonitors)) { if ((iNum < 0) || (iNum >= self->pDriv->iNoOfMonitors)) {
return -1L; return -1L;
} else { } else {
return self->pDriv->lCounts[iNum]; return self->pDriv->lCounts[iNum];
@ -652,7 +667,7 @@ static long GetMonitorImpl(pCounter self, int iNum, SConnection * pCon)
/*-----------------------------------------------------------------------*/ /*-----------------------------------------------------------------------*/
void SetMonitorValue(pCounter self, int index, long value) void SetMonitorValue(pCounter self, int index, long value)
{ {
return self->setMonitor(self, index, value); return self->setMonitor(self, index, value);
} }
/*-----------------------------------------------------------------------*/ /*-----------------------------------------------------------------------*/
static void SetMonitorValueImpl(pCounter self, int index, long value) static void SetMonitorValueImpl(pCounter self, int index, long value)
@ -666,7 +681,7 @@ static void SetMonitorValueImpl(pCounter self, int index, long value)
/*------------------------------------------------------------------------*/ /*------------------------------------------------------------------------*/
float GetCountTime(pCounter self, SConnection * pCon) float GetCountTime(pCounter self, SConnection * pCon)
{ {
return self->getTime(self, pCon); return self->getTime(self, pCon);
} }
/*------------------------------------------------------------------------*/ /*------------------------------------------------------------------------*/
static float GetCountTimeImpl(pCounter self, SConnection * pCon) static float GetCountTimeImpl(pCounter self, SConnection * pCon)
@ -814,7 +829,9 @@ int CountAction(SConnection * pCon, SicsInterp * pSics, void *pData,
{"send", 0, {0, 0}}, {"send", 0, {0, 0}},
{"setpar", 3, {FUPATEXT, FUPAINT, FUPAFLOAT}}, {"setpar", 3, {FUPATEXT, FUPAINT, FUPAFLOAT}},
{"getpar", 2, {FUPATEXT, FUPAOPT}}, {"getpar", 2, {FUPATEXT, FUPAOPT}},
{"getnmon", 0, {0, 0}} {"getnmon",0,{0,0}},
{"getchannel",0,{0}},
{"setchannel",1,{FUPAINT}}
}; };
char *pMode[] = { char *pMode[] = {
"timer", "timer",
@ -831,7 +848,7 @@ int CountAction(SConnection * pCon, SicsInterp * pSics, void *pData,
argtolower(argc, argv); argtolower(argc, argv);
argx = &argv[1]; argx = &argv[1];
iRet = iRet =
EvaluateFuPa((pFuncTemplate) & ActionTemplate, 23, argc - 1, argx, EvaluateFuPa((pFuncTemplate) & ActionTemplate, 25, argc - 1, argx,
&PaRes); &PaRes);
if (iRet < 0) { if (iRet < 0) {
snprintf(pBueffel, 255,"%s", PaRes.pError); snprintf(pBueffel, 255,"%s", PaRes.pError);
@ -1126,7 +1143,7 @@ int CountAction(SConnection * pCon, SicsInterp * pSics, void *pData,
PaRes.Arg[1].iVal, &fVal); PaRes.Arg[1].iVal, &fVal);
if (iRet == 1) { if (iRet == 1) {
snprintf(pBueffel,255, "%s.%s %d = %f", argv[0], PaRes.Arg[0].text, 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); SCWrite(pCon, pBueffel, eValue);
return 1; return 1;
} else { } else {
@ -1138,6 +1155,20 @@ int CountAction(SConnection * pCon, SicsInterp * pSics, void *pData,
case 22: /* getnmon */ case 22: /* getnmon */
snprintf(pBueffel, 131, "%s.getnmon = %d", argv[0], GetNMonitor(self)); snprintf(pBueffel, 131, "%s.getnmon = %d", argv[0], GetNMonitor(self));
SCWrite(pCon, pBueffel, eValue); 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; break;
default: default:
assert(0); /* internal error */ assert(0); /* internal error */

View File

@ -63,6 +63,8 @@ float GetControlValue(pCounter self);
long GetCounts(pCounter self, SConnection * pCon); long GetCounts(pCounter self, SConnection * pCon);
long GetMonitor(pCounter self, int iNum, SConnection * pCon); long GetMonitor(pCounter self, int iNum, SConnection * pCon);
int GetNMonitor(pCounter self); int GetNMonitor(pCounter self);
int GetControlMonitor(pCounter self);
int SetControlMonitor(pCounter self, int channel);
void SetMonitorValue(pCounter self, int index, long value); void SetMonitorValue(pCounter self, int index, long value);
float GetCountTime(pCounter self, SConnection * pCon); float GetCountTime(pCounter self, SConnection * pCon);