- Added an edge function to peakcenter for NARZISS

- Fixed ei interrupt bug in tasdrive.c
- Made eiger A2 driving work
- Added force start facility to devexec for POLDI HV


SKIPPED:
	psi/eigera2.c
	psi/polterwrite.c
This commit is contained in:
koennecke
2011-12-19 12:24:58 +00:00
parent a207ebf46d
commit 14f257c2ab
14 changed files with 361 additions and 43 deletions

123
devexec.c
View File

@ -398,7 +398,106 @@ int StartDevice(pExeList self, char *name, pObjectDescriptor pDes,
}
return 0;
}
/*------------------------------------------------------------------------
* This is a hacking thing to bypass the whole access checking thing. I
* need it at POLDI to run the fucking high voltage while the instrument is
* still counting.
*/
static int ForceStartDevice(pExeList self, char *name, pObjectDescriptor pDes,
void *pData, SConnection * pCon, float fNew)
{
pDevEntry pNew = NULL;
int iRet;
char pBueffel[132], pError[80];
pIDrivable pDrivInt = NULL;
pICountable pCountInt = NULL;
static int overwriteOwner = -1;
char *overwriteOption;
float oldVal;
assert(self);
assert(pDes);
assert(pCon);
/* may we? */
if (self->pOwner != NULL) {
pCon = self->pOwner;
}
if (self->iLock == 1) {
SCWrite(pCon, "ERROR: instrument is locked", eError);
return 0;
}
/* well create a new entry */
self->iStop = 0;
pNew = CreateDevEntry(pDes, SCCopyConnection(pCon),
pData, fNew, name, RUNRUN);
if (!pNew) {
SCWrite(pCon, "ERROR: memory exhausted in Device Executor ", eError);
return 0;
}
/* start it */
pDrivInt = pDes->GetInterface(pData, DRIVEID);
pCountInt = pDes->GetInterface(pData, COUNTID);
if (pDrivInt) {
iRet = pDrivInt->SetValue(pData, pCon, fNew);
if (iRet == OKOK && self->drivePrint == 1) {
oldVal = pDrivInt->GetValue(pData, pCon);
snprintf(pBueffel, 131, "Driving %s from %8.3f to %8.3f",
name, oldVal, fNew);
SCWrite(pCon, pBueffel, eValue);
}
if(iRet == OKOK){
InvokeNewTarget(self,name,fNew);
}
} else if (pCountInt) {
/**
* Cannot set count parameters here: means of getting hold of the
* count mode missing here. As this is a POLDI hack where I only need
* to run a HV, I omit this now. But it will work if a proper
* preset and mode is set on a counter to start it.
*/
iRet = pCountInt->StartCount(pData, pCon);
} else { /* this is a programmers error */
SCWrite(pCon, "ERROR: Programmer error in StartDevice ", eError);
iRet = 0;
}
/* check return status */
if (iRet == OKOK) {
LLDnodeAppendFrom(self->iList, &pNew);
sprintf(pBueffel, "started");
if (NULL != pNew->pCon->deviceID) {
snprintf(pBueffel, 130, "started (%s)", pNew->pCon->deviceID);
}
ExeInterest(self, pNew, pBueffel);
self->iRun = 1;
self->iStatus = DEVDONE;
/* if no task: start it */
if (self->lTask < 0) {
self->lTask = TaskRegister(self->pTask,
DevExecTask,
DevExecSignal, NULL, self, 1);
self->iEnd = 0;
pCon->conStatus = HWBusy;
}
DevexecLog("START", pNew->name);
return 1;
} else {
snprintf(pBueffel,131, "ERROR: cannot start device %s", name);
SCWrite(pCon, pBueffel, eError);
DeleteDevEntry(pNew);
if (LLDcheck(self->iList) >= LIST_EMPTY) {
if (self->pOwner != NULL) {
SCDeleteConnection(self->pOwner);
}
self->pOwner = NULL;
}
return 0;
}
return 0;
}
/*--------------------------------------------------------------------------*/
int StartMotor(pExeList self, SicsInterp * pSics, SConnection * pCon,
char *name, int level, float fVal)
@ -1147,6 +1246,10 @@ int DevexecAction(SConnection * pCon, SicsInterp * pSics, void *pData,
{
int val;
char pBueffel[256];
void *data = NULL;
pDummy pDum = NULL;
float fTarget;
CommandList *pCom = NULL;
pExeList self = (pExeList) pData;
if (argc < 2) {
@ -1166,6 +1269,26 @@ int DevexecAction(SConnection * pCon, SicsInterp * pSics, void *pData,
SCWrite(pCon, pBueffel, eValue);
return 1;
}
} else if(strcmp(argv[1],"force") == 0) {
if(argc < 4){
SCWrite(pCon,"ERROR: insufficient number of arguments to devexec force",
eError);
return 0;
}
pCom = FindCommand(pSics,argv[2]);
fTarget = atof(argv[3]);
if(pCom == NULL){
SCPrintf(pCon,eError,"ERROR: command %s to force not found", argv[2]);
return 0;
}
data = pCom->pData;
pDum = (pDummy)data;
if(GetDrivableInterface(data) == NULL && GetCountableInterface(data) == NULL ){
SCPrintf(pCon,eError,"ERROR: command %s not startable", argv[2]);
return 0;
}
val = ForceStartDevice(self,argv[2],pDum->pDescriptor,data, pCon, fTarget);
return val;
} else {
SCWrite(pCon, "ERROR: unknown subcommand to devexec", eError);
return 0;