- Extended sicshdbadapter to attach a node to the target of any
drivable. Required a new event in devexec.c - Fixed the phytron driver to handle speed well - Added a protocol driver for the TCP/IP bridge to the SLS magnets SKIPPED: psi/make_gen psi/phytron.c psi/psi.c psi/slsecho.c psi/sps.c
This commit is contained in:
@ -649,7 +649,87 @@ static hdbCallbackReturn SICSDataCallback(pHdb node, void *userData,
|
||||
|
||||
return hdbContinue;
|
||||
}
|
||||
/*================= targets ============================================*/
|
||||
typedef struct {
|
||||
char *name;
|
||||
pHdb node;
|
||||
}TargetData, *pTargetData ;
|
||||
/*----------------------------------------------------------------------*/
|
||||
static void KillTargetData(void *data)
|
||||
{
|
||||
pTargetData self = (pTargetData) data;
|
||||
if(self == NULL){
|
||||
return;
|
||||
}
|
||||
if(self->name != NULL){
|
||||
free(self->name);
|
||||
}
|
||||
free(self);
|
||||
}
|
||||
/*----------------------------------------------------------------------*/
|
||||
static int TargetCallback(int iEvent, void *pEventData, void *pUserData)
|
||||
{
|
||||
pTargetData user = NULL;
|
||||
pNewTarget event = NULL;
|
||||
hdbValue v;
|
||||
|
||||
if(iEvent != NEWTARGET){
|
||||
return 0;
|
||||
}
|
||||
|
||||
user = (pTargetData)pUserData;
|
||||
event = (pNewTarget)pEventData;
|
||||
assert(user != NULL && event != NULL);
|
||||
|
||||
if(strcmp(user->name,event->name) == 0){
|
||||
v = MakeHdbFloat((double)event->target);
|
||||
UpdateHipadabaPar(user->node, v, NULL);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
/*----------------------------------------------------------------------*/
|
||||
static int AttachTarget(SConnection *pCon, SicsInterp *pSics,
|
||||
char *drivename, char *nodename)
|
||||
{
|
||||
pTargetData tData = NULL;
|
||||
pHdb node = NULL;
|
||||
pIDrivable pDriv = NULL;
|
||||
CommandList *pCom = NULL;
|
||||
float val;
|
||||
|
||||
pDriv = FindDrivable(pSics, drivename);
|
||||
if(pDriv == NULL){
|
||||
SCPrintf(pCon,eError,"ERROR: drivable %s not found", drivename);
|
||||
return 0;
|
||||
}
|
||||
|
||||
node = FindHdbNode(NULL, nodename, pCon);
|
||||
if(node == NULL){
|
||||
SCPrintf(pCon,eError,"ERROR: node %s not found", nodename);
|
||||
return 0;
|
||||
}
|
||||
|
||||
tData = malloc(sizeof(TargetData));
|
||||
if(tData == NULL){
|
||||
SCWrite(pCon,"ERROR: out of memory in AttachTarget", eError);
|
||||
return 0;
|
||||
}
|
||||
tData->name = strdup(drivename);
|
||||
tData->node = node;
|
||||
|
||||
pCom = FindCommand(pSics,drivename);
|
||||
/* This cannot fail as we already located the drivable */
|
||||
GetDrivablePosition(pCom->pData, pCon,&val);
|
||||
UpdateHipadabaPar(node,MakeHdbFloat(val), pCon);
|
||||
|
||||
RegisterCallback((pICallBack)GetExecutorCallback(pServ->pExecutor),
|
||||
NEWTARGET,
|
||||
TargetCallback,
|
||||
tData,
|
||||
KillTargetData);
|
||||
SCSendOK(pCon);
|
||||
return 1;
|
||||
}
|
||||
/*============== interpreter function ==================================*/
|
||||
int SICSHdbAdapter(SConnection * pCon, SicsInterp * pSics, void *pData,
|
||||
int argc, char *argv[])
|
||||
@ -676,6 +756,10 @@ int SICSHdbAdapter(SConnection * pCon, SicsInterp * pSics, void *pData,
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(strcmp(argv[1],"target") == 0){
|
||||
return AttachTarget(pCon,pSics,argv[2], argv[3]);
|
||||
}
|
||||
|
||||
path = FindHdbNode(NULL, argv[1], pCon);
|
||||
if (path == NULL) {
|
||||
SCWrite(pCon, "ERROR: path to attach object too not found", eError);
|
||||
|
Reference in New Issue
Block a user