- Added restart status code
- Small fixes to make regression tests work at the same level as for first generation devices
This commit is contained in:
57
countersec.c
57
countersec.c
@ -13,6 +13,8 @@
|
||||
#include <sics.h>
|
||||
#include <counter.h>
|
||||
#include "sicshipadaba.h"
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
* defines for commmands
|
||||
* -------------------------------------------------------------------------*/
|
||||
@ -26,6 +28,19 @@ typedef struct {
|
||||
float fCurrent;
|
||||
char *pName;
|
||||
} MonEvent, *pMonEvent;
|
||||
/*-------------------------------------------------------------------------*/
|
||||
static void SecCounterSetError(pCounter self, char *text)
|
||||
{
|
||||
hdbValue v;
|
||||
pHdb node;
|
||||
|
||||
node = GetHipadabaNode(self->pDes->parNode, "error");
|
||||
if(node != NULL){
|
||||
v = MakeHdbText(strdup(text));
|
||||
UpdateHipadabaPar(node,v,NULL);
|
||||
ReleaseHdbValue(&v);
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
int SecCtrInvokeFunction(pCounter self, SConnection *pCon, int code)
|
||||
{
|
||||
@ -52,7 +67,7 @@ static int SecStartCount(void *pData, SConnection *pCon)
|
||||
{
|
||||
pCounter self = (pCounter)pData;
|
||||
int status;
|
||||
pHdb node;
|
||||
pHdb node, statusNode;
|
||||
|
||||
assert(self != NULL);
|
||||
|
||||
@ -60,14 +75,14 @@ static int SecStartCount(void *pData, SConnection *pCon)
|
||||
return 0;
|
||||
}
|
||||
|
||||
statusNode = GetHipadabaNode(self->pDes->parNode, "status");
|
||||
UpdateHipadabaPar(statusNode,MakeHdbText("run"), pCon);
|
||||
status = SecCtrInvokeFunction(self,pCon, START);
|
||||
self->haltFixFlag = 0;
|
||||
if(status == 1){
|
||||
self->isUpToDate = 0;
|
||||
self->badStatusCount = 0;
|
||||
self->tStart = time(NULL);
|
||||
node = GetHipadabaNode(self->pDes->parNode, "status");
|
||||
UpdateHipadabaPar(node,MakeHdbText("run"), pCon);
|
||||
node = GetHipadabaNode(self->pDes->parNode, "control");
|
||||
UpdateHipadabaPar(node,MakeHdbFloat(.0), pCon);
|
||||
SetHdbProperty(node,"geterror", NULL);
|
||||
@ -79,8 +94,10 @@ static int SecStartCount(void *pData, SConnection *pCon)
|
||||
node = GetHipadabaNode(self->pDes->parNode, "time");
|
||||
UpdateHipadabaPar(node,MakeHdbFloat(.0), pCon);
|
||||
InvokeCallBack(self->pCall,COUNTSTART, pCon);
|
||||
SecCounterSetError(self,"None");
|
||||
return 1;
|
||||
} else {
|
||||
UpdateHipadabaPar(statusNode,MakeHdbText("error"), pCon);
|
||||
ReleaseCountLock(self->pCountInt);
|
||||
return HWFault;
|
||||
}
|
||||
@ -110,7 +127,8 @@ static int SecCtrCheckStatus(void *pData, SConnection *pCon)
|
||||
int status;
|
||||
MonEvent sMon;
|
||||
float fControl, fPreset;
|
||||
|
||||
char error[132];
|
||||
|
||||
assert(self != NULL);
|
||||
|
||||
node = GetHipadabaNode(self->pDes->parNode,"status");
|
||||
@ -135,9 +153,19 @@ static int SecCtrCheckStatus(void *pData, SConnection *pCon)
|
||||
status = HWNoBeam;
|
||||
} else if (strstr(v.v.text, "pause") != NULL) {
|
||||
status = HWPause;
|
||||
} else if (strstr(v.v.text, "restart") != NULL) {
|
||||
SecStartCount(self, pCon);
|
||||
return HWBusy;
|
||||
} else if (strstr(v.v.text, "error") != NULL) {
|
||||
InvokeCallBack(self->pCall, COUNTEND, NULL);
|
||||
ReleaseCountLock(self->pCountInt);
|
||||
if(GetHdbProperty(node,"geterror",error,sizeof(error)) == 1){
|
||||
SCPrintf(pCon,eError,"ERROR: %s", error);
|
||||
SecCounterSetError(self,error);
|
||||
} else {
|
||||
SecCounterSetError(self,"Undefined counter error: set status geterror");
|
||||
SCPrintf(pCon,eError,"ERROR: Unknown counter status error: set status geterror property");
|
||||
}
|
||||
status = HWFault;
|
||||
} else {
|
||||
SCPrintf(pCon, eError, "ERROR: unknown counter status %s found",
|
||||
@ -415,6 +443,20 @@ static int ContinueCmd(pSICSOBJ ccmd, SConnection * con,
|
||||
pCounter self = (pCounter)ccmd;
|
||||
return self->pCountInt->Continue(self,con);
|
||||
}
|
||||
/*-------------------------------------------------------------------------*/
|
||||
extern int CounterInterest(int iEvent, void *pEvent, void *pUser);
|
||||
/*--------------------------------------------------------------------------*/
|
||||
static int InterestCmd(pSICSOBJ ccmd, SConnection * con,
|
||||
Hdb * cmdNode, Hdb * par[], int nPar)
|
||||
{
|
||||
long lID;
|
||||
pCounter self = (pCounter)ccmd;
|
||||
lID = RegisterCallback(self->pCall, MONITOR, CounterInterest,
|
||||
SCCopyConnection(con), SCDeleteConnection);
|
||||
SCSendOK(con);
|
||||
return 1;
|
||||
|
||||
}
|
||||
/*--------------------------------------------------------------------------*/
|
||||
pCounter CreateSecCounter(SConnection *pCon, char *type, char *name, int length)
|
||||
{
|
||||
@ -499,6 +541,12 @@ pCounter CreateSecCounter(SConnection *pCon, char *type, char *name, int length)
|
||||
}
|
||||
AddHipadabaChild(node, child, NULL);
|
||||
|
||||
child = MakeSICSHdbPar("error", usInternal, MakeHdbText("None"));
|
||||
if (child == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
AddHipadabaChild(node, child, NULL);
|
||||
|
||||
child = MakeSICSHdbPar("control", usUser, MakeHdbFloat(.0));
|
||||
if (child == NULL) {
|
||||
return NULL;
|
||||
@ -521,6 +569,7 @@ pCounter CreateSecCounter(SConnection *pCon, char *type, char *name, int length)
|
||||
child = AddSICSHdbPar(node,"stop", usUser, MakeSICSFunc(StopCmd));
|
||||
child = AddSICSHdbPar(node,"pause", usUser, MakeSICSFunc(PauseCmd));
|
||||
child = AddSICSHdbPar(node,"continue", usUser, MakeSICSFunc(ContinueCmd));
|
||||
child = AddSICSHdbPar(node,"interest", usUser, MakeSICSFunc(InterestCmd));
|
||||
|
||||
return pRes;
|
||||
}
|
||||
|
Reference in New Issue
Block a user