- added backwards calculation of hkl from four circle angles. This
required inclusion of a matrix package. - modified counter error handling to send a Stop when the _BAD_BUSY error is received. - added an environment interface to the general controller stuff in choco.* Also added setting a parameter directly at the controller object. - Added a driver for the ETH High Temperature Furnace to be used at SANS.
This commit is contained in:
189
chadapter.c
189
chadapter.c
@@ -14,10 +14,15 @@
|
||||
#include <tcl.h>
|
||||
#include "fortify.h"
|
||||
#include "sics.h"
|
||||
#define CHOCOINTERNAL
|
||||
#include "choco.h"
|
||||
#include "evcontroller.h"
|
||||
#include "evdriver.i"
|
||||
#define CHADAINTERNAL
|
||||
#include "chadapter.h"
|
||||
|
||||
#define NOTIMPLEMENTED -11555
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
static void *AdapterGetInterface(void *pData, int iID)
|
||||
{
|
||||
@@ -313,6 +318,190 @@
|
||||
|
||||
return 1;
|
||||
}
|
||||
/*=========================================================================
|
||||
An environment driver based on top of a controller object.
|
||||
-------------------------------------------------------------------------*/
|
||||
static int AVEVSetValue(pEVDriver self, float fNew)
|
||||
{
|
||||
pCHev myData;
|
||||
|
||||
assert(self);
|
||||
myData = (pCHev)self->pPrivate;
|
||||
assert(myData);
|
||||
myData->iLastError = 0;
|
||||
|
||||
return myData->pDriv->SetPar(myData->pDriv,myData->pParName,fNew);
|
||||
}
|
||||
/*-----------------------------------------------------------------------*/
|
||||
static int AVEVGetValue(pEVDriver self, float *fNew)
|
||||
{
|
||||
pCHev myData;
|
||||
int iRet;
|
||||
char pBueffel[80];
|
||||
|
||||
assert(self);
|
||||
myData = (pCHev)self->pPrivate;
|
||||
assert(myData);
|
||||
|
||||
iRet = myData->pDriv->GetPar(myData->pDriv,myData->pParName,
|
||||
pBueffel,79);
|
||||
sscanf(pBueffel,"%f",fNew);
|
||||
return iRet;
|
||||
}
|
||||
/*-----------------------------------------------------------------------*/
|
||||
static int AVEVSend(pEVDriver self, char *pCommand,
|
||||
char *pReply, int iLen)
|
||||
{
|
||||
pCHev myData;
|
||||
|
||||
assert(self);
|
||||
myData = (pCHev)self->pPrivate;
|
||||
assert(myData);
|
||||
myData->iLastError = NOTIMPLEMENTED;
|
||||
|
||||
return 0;
|
||||
}
|
||||
/*-----------------------------------------------------------------------*/
|
||||
static int AVEVGetError(pEVDriver self, int *iCode,
|
||||
char *pReply, int iLen)
|
||||
{
|
||||
pCHev myData;
|
||||
|
||||
assert(self);
|
||||
myData = (pCHev)self->pPrivate;
|
||||
assert(myData);
|
||||
|
||||
if(myData->iLastError == NOTIMPLEMENTED)
|
||||
{
|
||||
strncpy(pReply,"ERROR: Not Implemented here!", iLen);
|
||||
*iCode = NOTIMPLEMENTED;
|
||||
myData->iLastError = 0;
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return myData->pDriv->GetError(myData->pDriv, iCode,
|
||||
pReply, iLen);
|
||||
}
|
||||
}
|
||||
/*------------------------------------------------------------------------*/
|
||||
static int AVEVTryFixIt(pEVDriver self, int iCode)
|
||||
{
|
||||
pCHev myData;
|
||||
|
||||
assert(self);
|
||||
myData = (pCHev)self->pPrivate;
|
||||
assert(myData);
|
||||
|
||||
if(iCode == NOTIMPLEMENTED)
|
||||
{
|
||||
return DEVFAULT;
|
||||
}
|
||||
else
|
||||
{
|
||||
return myData->pDriv->TryFixIt(myData->pDriv, iCode);
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------*/
|
||||
static int AVEVInit(pEVDriver self)
|
||||
{
|
||||
pCHev myData;
|
||||
|
||||
assert(self);
|
||||
myData = (pCHev)self->pPrivate;
|
||||
assert(myData);
|
||||
|
||||
return myData->pDriv->Init(myData->pDriv);
|
||||
}
|
||||
/*---------------------------------------------------------------------*/
|
||||
static int AVEVClose(pEVDriver self)
|
||||
{
|
||||
pCHev myData;
|
||||
|
||||
assert(self);
|
||||
myData = (pCHev)self->pPrivate;
|
||||
assert(myData);
|
||||
|
||||
return myData->pDriv->Close(myData->pDriv);
|
||||
}
|
||||
/*----------------------------------------------------------------------*/
|
||||
static void AVEVKillPrivate(void *pData)
|
||||
{
|
||||
pCHev myData;
|
||||
|
||||
if(pData != NULL)
|
||||
{
|
||||
myData = (pCHev)pData;
|
||||
if(myData != NULL)
|
||||
{
|
||||
if(myData->pParName)
|
||||
free(myData->pParName);
|
||||
free(myData);
|
||||
}
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------*/
|
||||
pEVDriver MakeControllerEnvironmentDriver(int argc, char *argv[])
|
||||
{
|
||||
pEVDriver pNew = NULL;
|
||||
pCHev myData = NULL;
|
||||
CommandList *pCom = NULL;
|
||||
pDummy pDum = NULL;
|
||||
pChoco pChop;
|
||||
|
||||
/*
|
||||
Two arguments are needed: the name of the controller and the
|
||||
name of the parameter
|
||||
*/
|
||||
if(argc < 2)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
pCom = FindCommand(pServ->pSics,argv[0]);
|
||||
if(!pCom)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
pDum = pCom->pData;
|
||||
if(!pDum)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
if(strcmp(pDum->pDescriptor->name,"Chopper") != 0)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* alright: I think we got a controller now, let us create our
|
||||
act
|
||||
*/
|
||||
pNew = CreateEVDriver(argc,argv);
|
||||
if(!pNew)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
myData = (pCHev)malloc(sizeof(CHev));
|
||||
if(!myData)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pChop = (pChoco)pCom->pData;
|
||||
myData->iLastError = 0;
|
||||
myData->pDriv = pChop->pDriv;
|
||||
myData->pParName = strdup(argv[1]);
|
||||
pNew->pPrivate = myData;
|
||||
pNew->SetValue =AVEVSetValue;
|
||||
pNew->GetValue =AVEVGetValue;
|
||||
pNew->Send = AVEVSend;
|
||||
pNew->GetError =AVEVGetError;
|
||||
pNew->TryFixIt =AVEVTryFixIt;
|
||||
pNew->Init =AVEVInit;
|
||||
pNew->Close =AVEVClose;
|
||||
pNew->KillPrivate =AVEVKillPrivate;
|
||||
|
||||
return pNew;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user