- 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:
55
countersec.c
55
countersec.c
@ -13,6 +13,8 @@
|
|||||||
#include <sics.h>
|
#include <sics.h>
|
||||||
#include <counter.h>
|
#include <counter.h>
|
||||||
#include "sicshipadaba.h"
|
#include "sicshipadaba.h"
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------
|
/*---------------------------------------------------------------------------
|
||||||
* defines for commmands
|
* defines for commmands
|
||||||
* -------------------------------------------------------------------------*/
|
* -------------------------------------------------------------------------*/
|
||||||
@ -26,6 +28,19 @@ typedef struct {
|
|||||||
float fCurrent;
|
float fCurrent;
|
||||||
char *pName;
|
char *pName;
|
||||||
} MonEvent, *pMonEvent;
|
} 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)
|
int SecCtrInvokeFunction(pCounter self, SConnection *pCon, int code)
|
||||||
{
|
{
|
||||||
@ -52,7 +67,7 @@ static int SecStartCount(void *pData, SConnection *pCon)
|
|||||||
{
|
{
|
||||||
pCounter self = (pCounter)pData;
|
pCounter self = (pCounter)pData;
|
||||||
int status;
|
int status;
|
||||||
pHdb node;
|
pHdb node, statusNode;
|
||||||
|
|
||||||
assert(self != NULL);
|
assert(self != NULL);
|
||||||
|
|
||||||
@ -60,14 +75,14 @@ static int SecStartCount(void *pData, SConnection *pCon)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
statusNode = GetHipadabaNode(self->pDes->parNode, "status");
|
||||||
|
UpdateHipadabaPar(statusNode,MakeHdbText("run"), pCon);
|
||||||
status = SecCtrInvokeFunction(self,pCon, START);
|
status = SecCtrInvokeFunction(self,pCon, START);
|
||||||
self->haltFixFlag = 0;
|
self->haltFixFlag = 0;
|
||||||
if(status == 1){
|
if(status == 1){
|
||||||
self->isUpToDate = 0;
|
self->isUpToDate = 0;
|
||||||
self->badStatusCount = 0;
|
self->badStatusCount = 0;
|
||||||
self->tStart = time(NULL);
|
self->tStart = time(NULL);
|
||||||
node = GetHipadabaNode(self->pDes->parNode, "status");
|
|
||||||
UpdateHipadabaPar(node,MakeHdbText("run"), pCon);
|
|
||||||
node = GetHipadabaNode(self->pDes->parNode, "control");
|
node = GetHipadabaNode(self->pDes->parNode, "control");
|
||||||
UpdateHipadabaPar(node,MakeHdbFloat(.0), pCon);
|
UpdateHipadabaPar(node,MakeHdbFloat(.0), pCon);
|
||||||
SetHdbProperty(node,"geterror", NULL);
|
SetHdbProperty(node,"geterror", NULL);
|
||||||
@ -79,8 +94,10 @@ static int SecStartCount(void *pData, SConnection *pCon)
|
|||||||
node = GetHipadabaNode(self->pDes->parNode, "time");
|
node = GetHipadabaNode(self->pDes->parNode, "time");
|
||||||
UpdateHipadabaPar(node,MakeHdbFloat(.0), pCon);
|
UpdateHipadabaPar(node,MakeHdbFloat(.0), pCon);
|
||||||
InvokeCallBack(self->pCall,COUNTSTART, pCon);
|
InvokeCallBack(self->pCall,COUNTSTART, pCon);
|
||||||
|
SecCounterSetError(self,"None");
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
|
UpdateHipadabaPar(statusNode,MakeHdbText("error"), pCon);
|
||||||
ReleaseCountLock(self->pCountInt);
|
ReleaseCountLock(self->pCountInt);
|
||||||
return HWFault;
|
return HWFault;
|
||||||
}
|
}
|
||||||
@ -110,6 +127,7 @@ static int SecCtrCheckStatus(void *pData, SConnection *pCon)
|
|||||||
int status;
|
int status;
|
||||||
MonEvent sMon;
|
MonEvent sMon;
|
||||||
float fControl, fPreset;
|
float fControl, fPreset;
|
||||||
|
char error[132];
|
||||||
|
|
||||||
assert(self != NULL);
|
assert(self != NULL);
|
||||||
|
|
||||||
@ -135,9 +153,19 @@ static int SecCtrCheckStatus(void *pData, SConnection *pCon)
|
|||||||
status = HWNoBeam;
|
status = HWNoBeam;
|
||||||
} else if (strstr(v.v.text, "pause") != NULL) {
|
} else if (strstr(v.v.text, "pause") != NULL) {
|
||||||
status = HWPause;
|
status = HWPause;
|
||||||
|
} else if (strstr(v.v.text, "restart") != NULL) {
|
||||||
|
SecStartCount(self, pCon);
|
||||||
|
return HWBusy;
|
||||||
} else if (strstr(v.v.text, "error") != NULL) {
|
} else if (strstr(v.v.text, "error") != NULL) {
|
||||||
InvokeCallBack(self->pCall, COUNTEND, NULL);
|
InvokeCallBack(self->pCall, COUNTEND, NULL);
|
||||||
ReleaseCountLock(self->pCountInt);
|
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;
|
status = HWFault;
|
||||||
} else {
|
} else {
|
||||||
SCPrintf(pCon, eError, "ERROR: unknown counter status %s found",
|
SCPrintf(pCon, eError, "ERROR: unknown counter status %s found",
|
||||||
@ -415,6 +443,20 @@ static int ContinueCmd(pSICSOBJ ccmd, SConnection * con,
|
|||||||
pCounter self = (pCounter)ccmd;
|
pCounter self = (pCounter)ccmd;
|
||||||
return self->pCountInt->Continue(self,con);
|
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)
|
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);
|
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));
|
child = MakeSICSHdbPar("control", usUser, MakeHdbFloat(.0));
|
||||||
if (child == NULL) {
|
if (child == NULL) {
|
||||||
return 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,"stop", usUser, MakeSICSFunc(StopCmd));
|
||||||
child = AddSICSHdbPar(node,"pause", usUser, MakeSICSFunc(PauseCmd));
|
child = AddSICSHdbPar(node,"pause", usUser, MakeSICSFunc(PauseCmd));
|
||||||
child = AddSICSHdbPar(node,"continue", usUser, MakeSICSFunc(ContinueCmd));
|
child = AddSICSHdbPar(node,"continue", usUser, MakeSICSFunc(ContinueCmd));
|
||||||
|
child = AddSICSHdbPar(node,"interest", usUser, MakeSICSFunc(InterestCmd));
|
||||||
|
|
||||||
return pRes;
|
return pRes;
|
||||||
}
|
}
|
||||||
|
50
motorsec.c
50
motorsec.c
@ -47,6 +47,19 @@
|
|||||||
|
|
||||||
#define ABS(x) (x < 0 ? -(x) : (x))
|
#define ABS(x) (x < 0 ? -(x) : (x))
|
||||||
|
|
||||||
|
/*-------------------------------------------------------------------------*/
|
||||||
|
static void SecMotorSetError(pMotor self, char *text)
|
||||||
|
{
|
||||||
|
hdbValue v;
|
||||||
|
pHdb node;
|
||||||
|
|
||||||
|
node = GetHipadabaNode(self->pDescriptor->parNode, "error");
|
||||||
|
if(node != NULL){
|
||||||
|
v = MakeHdbText(strdup(text));
|
||||||
|
UpdateHipadabaPar(node,v,NULL);
|
||||||
|
ReleaseHdbValue(&v);
|
||||||
|
}
|
||||||
|
}
|
||||||
/*--------------------------------------------------------------------------*/
|
/*--------------------------------------------------------------------------*/
|
||||||
static int SecMotorGetPar(pMotor self, char *name, float *fVal)
|
static int SecMotorGetPar(pMotor self, char *name, float *fVal)
|
||||||
{
|
{
|
||||||
@ -106,8 +119,10 @@ static long SecMotorRun(void *sulf, SConnection * pCon, float fNew)
|
|||||||
}
|
}
|
||||||
self->stopped = 0;
|
self->stopped = 0;
|
||||||
self->stopReported = 0;
|
self->stopReported = 0;
|
||||||
|
self->fTarget = fNew;
|
||||||
|
|
||||||
v = MakeHdbFloat(fNew);
|
v = MakeHdbFloat(fNew);
|
||||||
|
SecMotorSetError(sulf,"None");
|
||||||
status = SetHipadabaPar(self->pDescriptor->parNode, v, pCon);
|
status = SetHipadabaPar(self->pDescriptor->parNode, v, pCon);
|
||||||
node = GetHipadabaNode(self->pDescriptor->parNode, "status");
|
node = GetHipadabaNode(self->pDescriptor->parNode, "status");
|
||||||
if(node != NULL){
|
if(node != NULL){
|
||||||
@ -200,12 +215,17 @@ static int SecMotorLimits(void *sulf, float fVal, char *error, int iErrLen)
|
|||||||
{
|
{
|
||||||
float fHard;
|
float fHard;
|
||||||
pMotor self;
|
pMotor self;
|
||||||
|
int status;
|
||||||
|
|
||||||
assert(sulf);
|
assert(sulf);
|
||||||
|
|
||||||
self = (pMotor) sulf;
|
self = (pMotor) sulf;
|
||||||
|
|
||||||
return SecMotorCheckBoundary(self, fVal, &fHard, error, iErrLen);
|
status = SecMotorCheckBoundary(self, fVal, &fHard, error, iErrLen);
|
||||||
|
if(status != 1){
|
||||||
|
SecMotorSetError(sulf,error);
|
||||||
|
}
|
||||||
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------*/
|
||||||
@ -231,10 +251,11 @@ static int checkPosition(pMotor self, SConnection * pCon)
|
|||||||
if (ABS(target - hard) > precision) {
|
if (ABS(target - hard) > precision) {
|
||||||
if (self->retryCount >= (int) maxretry) {
|
if (self->retryCount >= (int) maxretry) {
|
||||||
SCPrintf(pCon, eLogError,
|
SCPrintf(pCon, eLogError,
|
||||||
"ERROR: Aborting %s after %d retries, off position by %f",
|
"ERROR: aborting %s after %d retries, off position by %f",
|
||||||
self->name, (int) maxretry, target - hard);
|
self->name, (int) maxretry, target - hard);
|
||||||
node = GetHipadabaNode(self->pDescriptor->parNode, "status");
|
node = GetHipadabaNode(self->pDescriptor->parNode, "status");
|
||||||
assert(node != NULL);
|
assert(node != NULL);
|
||||||
|
SecMotorSetError(self,"Aborted poistioning after many retries");
|
||||||
UpdateHipadabaPar(node, MakeHdbText("error"), pCon);
|
UpdateHipadabaPar(node, MakeHdbText("error"), pCon);
|
||||||
return HWFault;
|
return HWFault;
|
||||||
}
|
}
|
||||||
@ -277,6 +298,7 @@ static int SecMotorStatus(void *sulf, SConnection * pCon)
|
|||||||
pHdb node = NULL;
|
pHdb node = NULL;
|
||||||
hdbValue v;
|
hdbValue v;
|
||||||
float interrupt;
|
float interrupt;
|
||||||
|
char error[132];
|
||||||
|
|
||||||
assert(sulf);
|
assert(sulf);
|
||||||
self = (pMotor) sulf;
|
self = (pMotor) sulf;
|
||||||
@ -298,8 +320,20 @@ static int SecMotorStatus(void *sulf, SConnection * pCon)
|
|||||||
handleMoveCallback(self, pCon);
|
handleMoveCallback(self, pCon);
|
||||||
status = HWBusy;
|
status = HWBusy;
|
||||||
} else if (strstr(v.v.text, "poserror") != NULL) {
|
} else if (strstr(v.v.text, "poserror") != NULL) {
|
||||||
|
SCWrite(pCon,"WARNING: Position not reached",eLog);
|
||||||
status = checkPosition(self, pCon);
|
status = checkPosition(self, pCon);
|
||||||
|
} else if (strstr(v.v.text, "restart") != NULL) {
|
||||||
|
SCPrintf(pCon,eLog,"WARNING: restarting motor %s", self->name);
|
||||||
|
SecMotorRun(self,pCon,self->fTarget);
|
||||||
|
return HWBusy;
|
||||||
} else if (strstr(v.v.text, "error") != NULL) {
|
} else if (strstr(v.v.text, "error") != NULL) {
|
||||||
|
if(GetHdbProperty(node,"geterror",error,sizeof(error)) == 1){
|
||||||
|
SecMotorSetError(sulf,error);
|
||||||
|
}
|
||||||
|
node = GetHipadabaNode(self->pDescriptor->parNode, "targetposition");
|
||||||
|
if(GetHdbProperty(node,"geterror",error,sizeof(error)) == 1){
|
||||||
|
SecMotorSetError(sulf,error);
|
||||||
|
}
|
||||||
status = HWFault;
|
status = HWFault;
|
||||||
} else {
|
} else {
|
||||||
SCPrintf(pCon, eError, "ERROR: unknown motor status %s found",
|
SCPrintf(pCon, eError, "ERROR: unknown motor status %s found",
|
||||||
@ -334,8 +368,15 @@ static float SecMotorGetValue(void *pData, SConnection * pCon)
|
|||||||
int status;
|
int status;
|
||||||
pMotor self = (pMotor) pData;
|
pMotor self = (pMotor) pData;
|
||||||
hdbValue v;
|
hdbValue v;
|
||||||
|
char error[132];
|
||||||
|
|
||||||
|
|
||||||
assert(pData);
|
assert(pData);
|
||||||
|
status = GetHdbProperty(self->pDescriptor->parNode,"geterror", error,sizeof(error));
|
||||||
|
if(status == 1 && strcmp(error,"none") != 0) {
|
||||||
|
SCPrintf(pCon,eValue,"ERROR: Failed to read %s with %s", self->name, error);
|
||||||
|
return -9999999.99;
|
||||||
|
}
|
||||||
status = GetHipadabaPar(self->pDescriptor->parNode, &v, pCon);
|
status = GetHipadabaPar(self->pDescriptor->parNode, &v, pCon);
|
||||||
if (status != 1) {
|
if (status != 1) {
|
||||||
return -9999999.99;
|
return -9999999.99;
|
||||||
@ -473,7 +514,7 @@ static hdbCallbackReturn SecMotorCallback(pHdb node, void *userData,
|
|||||||
* check for alarm condition
|
* check for alarm condition
|
||||||
*/
|
*/
|
||||||
SecMotorGetPar(self, "failafter", &fVal);
|
SecMotorGetPar(self, "failafter", &fVal);
|
||||||
if (self->pDrivInt->iErrorCount > (int) fVal) {
|
if (self->pDrivInt->iErrorCount >= (int) fVal) {
|
||||||
/* big alarm */
|
/* big alarm */
|
||||||
ServerWriteGlobal("ERROR: !!! MOTOR ALARM !!! MOTOR ALARM !!!",
|
ServerWriteGlobal("ERROR: !!! MOTOR ALARM !!! MOTOR ALARM !!!",
|
||||||
eError);
|
eError);
|
||||||
@ -744,6 +785,9 @@ pMotor SecMotorInit(char *name)
|
|||||||
SetHdbProperty(child, "motname", name);
|
SetHdbProperty(child, "motname", name);
|
||||||
AddHipadabaChild(node, child, NULL);
|
AddHipadabaChild(node, child, NULL);
|
||||||
|
|
||||||
|
child = MakeHipadabaNode("error", HIPTEXT, 1);
|
||||||
|
AddHipadabaChild(node, child, NULL);
|
||||||
|
|
||||||
pM->endScriptID = 0;
|
pM->endScriptID = 0;
|
||||||
|
|
||||||
/* initialise Drivable interface */
|
/* initialise Drivable interface */
|
||||||
|
Reference in New Issue
Block a user