- Introduced a state filed into first generation objects
- Fixed some issues with error returns not being properly handled in devexec - Fixed a bug in motorlist which caused limit checks to fail - Fixed an issue with the TDCHM not properly updating the counter values on finish - Readded getHipadabaPar in ChainCallback as this caused a problem in ei - Made tasdrive ignore sgu, sgl when out of plane not allowed SKIPPED: psi/eigermono.c psi/sinqhttp.c psi/tdchm.c
This commit is contained in:
102
counter.c
102
counter.c
@ -205,6 +205,42 @@ static int ContinueCount(void *pData, SConnection * pCon)
|
||||
SCSetInterrupt(pCon, eAbortBatch);
|
||||
return HWFault;
|
||||
}
|
||||
/*------------------------------------------------------------------------*/
|
||||
static int TransferData(void *pData, SConnection * pCon)
|
||||
{
|
||||
pCounter self = NULL;
|
||||
int i, iRet;
|
||||
char pError[80];
|
||||
char pBueffel[132];
|
||||
int iCode;
|
||||
|
||||
self = (pCounter) pData;
|
||||
assert(self);
|
||||
assert(pCon);
|
||||
|
||||
/* try three times */
|
||||
for (i = 0; i < 3; i++) {
|
||||
iRet = self->pDriv->ReadValues(self->pDriv);
|
||||
if (iRet == OKOK) {
|
||||
self->isUpToDate = 1;
|
||||
return OKOK;
|
||||
} else {
|
||||
self->pDriv->GetError(self->pDriv, &iCode, pError, 79);
|
||||
sprintf(pBueffel, "WARNING: %s", pError);
|
||||
SCWrite(pCon, pBueffel, eError);
|
||||
iRet = self->pDriv->TryAndFixIt(self->pDriv, iCode);
|
||||
if (iRet == COTERM) {
|
||||
SCWrite(pCon, "ERROR: Cannot fix counter problem, aborting",
|
||||
eError);
|
||||
SCSetInterrupt(pCon, eAbortBatch);
|
||||
return HWFault;
|
||||
}
|
||||
}
|
||||
}
|
||||
SCWrite(pCon, "ERROR: Cannot fix counter problem, aborting", eError);
|
||||
SCSetInterrupt(pCon, eAbortBatch);
|
||||
return HWFault;
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
static int CheckCountStatus(void *pData, SConnection * pCon)
|
||||
@ -266,7 +302,8 @@ static int CheckCountStatus(void *pData, SConnection * pCon)
|
||||
notification on finish
|
||||
*/
|
||||
if (eCt == HWIdle) {
|
||||
self->isUpToDate = 0;
|
||||
self->isUpToDate = 0;
|
||||
TransferData(self,pCon);
|
||||
InvokeCallBack(self->pCall, COUNTEND, NULL);
|
||||
ReleaseCountLock(self->pCountInt);
|
||||
}
|
||||
@ -294,42 +331,6 @@ static int SaveCounterStatus(void *pData, char *name, FILE * fd)
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
static int TransferData(void *pData, SConnection * pCon)
|
||||
{
|
||||
pCounter self = NULL;
|
||||
int i, iRet;
|
||||
char pError[80];
|
||||
char pBueffel[132];
|
||||
int iCode;
|
||||
|
||||
self = (pCounter) pData;
|
||||
assert(self);
|
||||
assert(pCon);
|
||||
|
||||
/* try three times */
|
||||
for (i = 0; i < 3; i++) {
|
||||
iRet = self->pDriv->ReadValues(self->pDriv);
|
||||
if (iRet == OKOK) {
|
||||
self->isUpToDate = 1;
|
||||
return OKOK;
|
||||
} else {
|
||||
self->pDriv->GetError(self->pDriv, &iCode, pError, 79);
|
||||
sprintf(pBueffel, "WARNING: %s", pError);
|
||||
SCWrite(pCon, pBueffel, eError);
|
||||
iRet = self->pDriv->TryAndFixIt(self->pDriv, iCode);
|
||||
if (iRet == COTERM) {
|
||||
SCWrite(pCon, "ERROR: Cannot fix counter problem, aborting",
|
||||
eError);
|
||||
SCSetInterrupt(pCon, eAbortBatch);
|
||||
return HWFault;
|
||||
}
|
||||
}
|
||||
}
|
||||
SCWrite(pCon, "ERROR: Cannot fix counter problem, aborting", eError);
|
||||
SCSetInterrupt(pCon, eAbortBatch);
|
||||
return HWFault;
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
static void *CounterGetInterface(void *pData, int iID)
|
||||
@ -701,6 +702,9 @@ static int CounterInterest(int iEvent, void *pEvent, void *pUser)
|
||||
char pBueffel[512];
|
||||
int rights;
|
||||
|
||||
pCon = (SConnection *) pUser;
|
||||
pMon = (pMonEvent) pEvent;
|
||||
|
||||
if (pCon == NULL || !SCisConnected(pCon)) {
|
||||
return -1;
|
||||
}
|
||||
@ -709,17 +713,13 @@ static int CounterInterest(int iEvent, void *pEvent, void *pUser)
|
||||
return 0;
|
||||
}
|
||||
|
||||
pCon = (SConnection *) pUser;
|
||||
pMon = (pMonEvent) pEvent;
|
||||
assert(pCon);
|
||||
assert(pMon);
|
||||
snprintf(pBueffel,511, "%s.CountStatus = %f %d", pMon->pName, pMon->fPreset,
|
||||
(int) nintf(pMon->fCurrent));
|
||||
/**
|
||||
* prevent this to be written to log files
|
||||
*/
|
||||
SCSetRights(pCon, usSpy);
|
||||
SCWrite(pCon, pBueffel, eWarning);
|
||||
SCWrite(pCon, pBueffel, eLog);
|
||||
return 1;
|
||||
}
|
||||
/*------------------------------------------------------------------------*/
|
||||
@ -815,7 +815,8 @@ int CountAction(SConnection * pCon, SicsInterp * pSics, void *pData,
|
||||
{"send", 0, {0, 0}},
|
||||
{"setpar", 3, {FUPATEXT, FUPAINT, FUPAFLOAT}},
|
||||
{"getpar", 2, {FUPATEXT, FUPAOPT}},
|
||||
{"getnmon", 0, {0, 0}}
|
||||
{"getnmon", 0, {0, 0}},
|
||||
{"state", 0, {0, 0}}
|
||||
};
|
||||
char *pMode[] = {
|
||||
"timer",
|
||||
@ -832,7 +833,7 @@ int CountAction(SConnection * pCon, SicsInterp * pSics, void *pData,
|
||||
argtolower(argc, argv);
|
||||
argx = &argv[1];
|
||||
iRet =
|
||||
EvaluateFuPa((pFuncTemplate) & ActionTemplate, 23, argc - 1, argx,
|
||||
EvaluateFuPa((pFuncTemplate) & ActionTemplate, 24, argc - 1, argx,
|
||||
&PaRes);
|
||||
if (iRet < 0) {
|
||||
snprintf(pBueffel, 255,"%s", PaRes.pError);
|
||||
@ -992,9 +993,9 @@ int CountAction(SConnection * pCon, SicsInterp * pSics, void *pData,
|
||||
"ERROR: Insufficient privilege to set threshold", eError);
|
||||
return 0;
|
||||
}
|
||||
if (isInRunMode(pServ->pExecutor)) {
|
||||
if (isRunning(self->pCountInt)) {
|
||||
SCWrite(pCon,
|
||||
"ERROR: cannot change threshold while instrument is active",
|
||||
"ERROR: cannot change threshold while counting",
|
||||
eError);
|
||||
return 0;
|
||||
}
|
||||
@ -1140,6 +1141,15 @@ int CountAction(SConnection * pCon, SicsInterp * pSics, void *pData,
|
||||
snprintf(pBueffel, 131, "%s.getnmon = %d", argv[0], GetNMonitor(self));
|
||||
SCWrite(pCon, pBueffel, eValue);
|
||||
break;
|
||||
case 23: /* state */
|
||||
if(isRunning(self->pCountInt)){
|
||||
snprintf(pBueffel, 131, "%s.state = run", argv[0]);
|
||||
} else {
|
||||
snprintf(pBueffel, 131, "%s.state = idle", argv[0]);
|
||||
}
|
||||
SCWrite(pCon, pBueffel, eValue);
|
||||
return 1;
|
||||
break;
|
||||
default:
|
||||
assert(0); /* internal error */
|
||||
}
|
||||
|
66
devexec.c
66
devexec.c
@ -273,14 +273,13 @@ int StartDevice(pExeList self, char *name, pObjectDescriptor pDes,
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
self->pOwner = SCCopyConnection(pCon);
|
||||
}
|
||||
if (self->iLock == 1) {
|
||||
SCWrite(pCon, "ERROR: instrument is locked", eError);
|
||||
return 0;
|
||||
}
|
||||
|
||||
SetDevexecStatus(self,DEVDONE);
|
||||
if(self->waitID < 0 && level == RUNDRIVE){
|
||||
self->waitID = GetTaskGroupID(pServ->pTasker);
|
||||
self->iStatus = DEVBUSY;
|
||||
@ -293,7 +292,7 @@ int StartDevice(pExeList self, char *name, pObjectDescriptor pDes,
|
||||
|
||||
if((pDrivInt = pDes->GetInterface(pData,DRIVEID)) != NULL){
|
||||
taskID = StartDriveTask(pData, pCon, name, fNew);
|
||||
if(self->instStatus != eCounting){
|
||||
if(taskID > 0 && self->instStatus != eCounting){
|
||||
self->instStatus = eDriving;
|
||||
SetStatus(eDriving);
|
||||
}
|
||||
@ -305,14 +304,19 @@ int StartDevice(pExeList self, char *name, pObjectDescriptor pDes,
|
||||
}
|
||||
} else if(pDes->GetInterface(pData,COUNTID) != NULL){
|
||||
taskID = StartCountTask(pData,pCon,name);
|
||||
self->instStatus = eCounting;
|
||||
SetStatus(eCounting);
|
||||
if(taskID > 0){
|
||||
self->instStatus = eCounting;
|
||||
SetStatus(eCounting);
|
||||
}
|
||||
} else {
|
||||
SCPrintf(pCon,eLogError, "ERROR: type unkonw, cannot start %s", name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(taskID > 0){
|
||||
if(self->pOwner == NULL){
|
||||
self->pOwner = SCCopyConnection(pCon);
|
||||
}
|
||||
self->lastRun = time(NULL);
|
||||
if(level == RUNRUN){
|
||||
AddTaskToGroup(pServ->pTasker, taskID, self->runID);
|
||||
@ -519,10 +523,12 @@ int PauseExecution(pExeList self)
|
||||
|
||||
assert(self);
|
||||
|
||||
if(IsCounting(self)){
|
||||
TaskSignalGroup(self->pTask, IPAUSE, &interrupt, self->waitID);
|
||||
TaskSignalGroup(self->pTask, IPAUSE, &interrupt, self->runID);
|
||||
SetStatus(ePaused);
|
||||
}
|
||||
|
||||
TaskSignalGroup(self->pTask, IPAUSE, &interrupt, self->waitID);
|
||||
|
||||
SetStatus(ePaused);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -546,10 +552,11 @@ int ContinueExecution(pExeList self)
|
||||
int interrupt = 0;
|
||||
assert(self);
|
||||
|
||||
|
||||
TaskSignalGroup(self->pTask, CONTINUE, &interrupt, self->waitID);
|
||||
|
||||
SetStatus(eCounting);
|
||||
if(GetStatus() == ePaused){
|
||||
TaskSignalGroup(self->pTask, CONTINUE, &interrupt, self->waitID);
|
||||
TaskSignalGroup(self->pTask, CONTINUE, &interrupt, self->runID);
|
||||
SetStatus(eCounting);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -715,8 +722,14 @@ int Success(SConnection * pCon, SicsInterp * pSics, void *pData,
|
||||
level = RUNRUN;
|
||||
}
|
||||
|
||||
while(DevExecLevelRunning(self, level)){
|
||||
if(level == RUNRUN) {
|
||||
while(isTaskIDRunning(self->pTask,self->lTask)){
|
||||
TaskYield(self->pTask);
|
||||
}
|
||||
} else {
|
||||
while(DevExecLevelRunning(self, level)){
|
||||
TaskYield(self->pTask);
|
||||
}
|
||||
}
|
||||
iRet = self->iStatus;
|
||||
if (iRet == DEVINT) {
|
||||
@ -728,10 +741,20 @@ int Success(SConnection * pCon, SicsInterp * pSics, void *pData,
|
||||
}
|
||||
} else if (iRet == DEVDONE) {
|
||||
SCWrite(pCon, "All done", eValue);
|
||||
self->iRun = 0;
|
||||
iRet = 1;
|
||||
} else if (iRet == DEVERROR) {
|
||||
SCWrite(pCon, "Finished with Problems", eValue);
|
||||
iRet = 1;
|
||||
} else if(iRet == DEVBUSY){
|
||||
/*
|
||||
some other level may still be running
|
||||
*/
|
||||
if(level == RUNRUN){
|
||||
self->iRun = 0;
|
||||
}
|
||||
SCWrite(pCon, "Level done", eValue);
|
||||
iRet = 1;
|
||||
}
|
||||
SetStatus(eEager);
|
||||
return iRet;
|
||||
@ -867,12 +890,20 @@ int DevExecTask(void *pData)
|
||||
*/
|
||||
self->waitID = -1;
|
||||
self->lTask = -1;
|
||||
self->iRun = 0;
|
||||
self->instStatus = eEager;
|
||||
SetStatus(eEager);
|
||||
/*
|
||||
This is sort of unclean. Setting DEVERROR has to be done in the
|
||||
device task function as it is the only one that knows about this.
|
||||
Interrupts always have priority, thus they are dealt with here.
|
||||
*/
|
||||
if(SCGetInterrupt(self->pOwner) != eContinue){
|
||||
self->iStatus = DEVINT;
|
||||
} else {
|
||||
self->iStatus = DEVDONE;
|
||||
if(self->iStatus != DEVERROR){
|
||||
self->iStatus = DEVDONE;
|
||||
}
|
||||
}
|
||||
SCDeleteConnection(self->pOwner);
|
||||
self->pOwner = NULL;
|
||||
@ -925,3 +956,10 @@ void *GetExecutorCallback(pExeList self)
|
||||
{
|
||||
return self->pCall;
|
||||
}
|
||||
/*----------------------------------------------------------------------*/
|
||||
void SetDevexecStatus(pExeList pExe, int code)
|
||||
{
|
||||
if(code >= 0 || code <= DEVBUSY){
|
||||
pExe->iStatus = code;
|
||||
}
|
||||
}
|
||||
|
@ -187,4 +187,5 @@
|
||||
void DevexecLog(char *op, char *device);
|
||||
void ExeInterest(pExeList pExe, char *name, char *action);
|
||||
void InvokeNewTarget(pExeList pExe, char *name, float fTarget);
|
||||
void SetDevexecStatus(pExeList pExe, int code);
|
||||
#endif
|
||||
|
@ -376,6 +376,7 @@ to the global SICS device executor.
|
||||
\mbox{}\verb@ void DevexecLog(char *op, char *device);@\\
|
||||
\mbox{}\verb@ void ExeInterest(pExeList pExe, char *name, char *action); @\\
|
||||
\mbox{}\verb@ void InvokeNewTarget(pExeList pExe, char *name, float fTarget);@\\
|
||||
\mbox{}\verb@ void SetDevexecStatus(pExeList pExe, int code);@\\
|
||||
\mbox{}\verb@#endif @\\
|
||||
\mbox{}\verb@@$\Diamond$
|
||||
\end{list}
|
||||
|
@ -322,6 +322,7 @@ to the global SICS device executor.
|
||||
void DevexecLog(char *op, char *device);
|
||||
void ExeInterest(pExeList pExe, char *name, char *action);
|
||||
void InvokeNewTarget(pExeList pExe, char *name, float fTarget);
|
||||
void SetDevexecStatus(pExeList pExe, int code);
|
||||
#endif
|
||||
@}
|
||||
|
||||
|
@ -571,5 +571,6 @@ int CenterWrapper(SConnection * pCon, SicsInterp * pSics, void *pData,
|
||||
self = (pFit) pData;
|
||||
assert(self);
|
||||
|
||||
CalculateFit(self);
|
||||
return DriveCenter(self, pCon, pSics);
|
||||
}
|
||||
|
10
histmem.c
10
histmem.c
@ -1373,6 +1373,16 @@ int HistAction(SConnection * pCon, SicsInterp * pSics, void *pData,
|
||||
SCSendOK(pCon);
|
||||
return 1;
|
||||
}
|
||||
/* state */
|
||||
else if (strcmp(argv[1], "status") == 0) {
|
||||
HistCountStatus(self,pCon);
|
||||
if(isRunning(self->pCountInt)){
|
||||
SCPrintf(pCon,eValue,"%s.status = run",argv[0]);
|
||||
} else {
|
||||
SCPrintf(pCon,eValue,"%s.status = idle",argv[0]);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
/* normal counting */
|
||||
else if (strcmp(argv[1], "count") == 0) {
|
||||
if (SCMatchRights(pCon, self->iAccess)) {
|
||||
|
20
hmdata.c
20
hmdata.c
@ -58,7 +58,9 @@ void clearHMData(pHMdata self)
|
||||
if (self->tofMode) {
|
||||
size *= getNoOfTimebins(self);
|
||||
}
|
||||
memset(self->localBuffer, 0, size * sizeof(HistInt));
|
||||
if(self->localBuffer != NULL){
|
||||
memset(self->localBuffer, 0, size * sizeof(HistInt));
|
||||
}
|
||||
self->nextUpdate = time(NULL) + self->updateIntervall;
|
||||
}
|
||||
|
||||
@ -146,18 +148,10 @@ int configureHMdata(pHMdata self, pStringDict pOpt, SConnection * pCon)
|
||||
self->localBuffer = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
note: remove update request in histmem.c
|
||||
*/
|
||||
if (self->updateIntervall > 0) {
|
||||
/*
|
||||
we do buffer
|
||||
*/
|
||||
status = resizeBuffer(self);
|
||||
if (!status) {
|
||||
SCWrite(pCon, "ERROR: failed to resize buffer", eError);
|
||||
return 0;
|
||||
}
|
||||
status = resizeBuffer(self);
|
||||
if (!status) {
|
||||
SCWrite(pCon, "ERROR: failed to resize buffer", eError);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
11
interface.c
11
interface.c
@ -226,6 +226,12 @@ static int DriveTaskFunc(void *data)
|
||||
if(status == HWBusy){
|
||||
return 1;
|
||||
}
|
||||
if(status == HWFault){
|
||||
taskData->pDriv->iErrorCount++;
|
||||
}
|
||||
if(status == HWFault || status == HWPosFault){
|
||||
SetDevexecStatus(pServ->pExecutor,DEVERROR);
|
||||
}
|
||||
DevexecLog("STOP",taskData->name);
|
||||
if(status == HWIdle || status == OKOK){
|
||||
ExeInterest(pServ->pExecutor,taskData->name, "finished");
|
||||
@ -370,6 +376,10 @@ static int CountTaskFunc(void *data)
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(status == HWFault){
|
||||
SetDevexecStatus(pServ->pExecutor,DEVERROR);
|
||||
}
|
||||
|
||||
DevexecLog("STOP",taskData->name);
|
||||
if(status == HWIdle || status == OKOK){
|
||||
ExeInterest(pServ->pExecutor,taskData->name, "finished");
|
||||
@ -396,6 +406,7 @@ long StartCountTask(void *obj, SConnection *pCon, char *name)
|
||||
return -1;
|
||||
}
|
||||
if(pCount->StartCount(obj,pCon) != OKOK){
|
||||
pCount->running = 0;
|
||||
return -1;
|
||||
}
|
||||
ExeInterest(pServ->pExecutor,name,"started");
|
||||
|
2
macro.c
2
macro.c
@ -761,7 +761,7 @@ int ClientLog(SConnection * pCon, SicsInterp * pInter, void *pData,
|
||||
memset(pMessage, 0, (iLen + 100) * sizeof(char));
|
||||
Arg2Text(argc - 1, &argv[1], pMessage, (iLen + 100) * sizeof(char));
|
||||
|
||||
SCLogWrite(pCon,pMessage, eError);
|
||||
SCLogWrite(pCon,pMessage, eLog);
|
||||
free(pMessage);
|
||||
return 1;
|
||||
}
|
||||
|
@ -74,10 +74,10 @@ static int RGRunTo(void *data, float newValue)
|
||||
RGMotorDriver *self = NULL;
|
||||
|
||||
self = (RGMotorDriver *) data;
|
||||
self->target = newValue;
|
||||
if (self->errorType == STARTFAIL) {
|
||||
return HWFault;
|
||||
}
|
||||
self->target = newValue;
|
||||
return OKOK;
|
||||
}
|
||||
|
||||
|
7
motor.c
7
motor.c
@ -1364,6 +1364,13 @@ int MotorAction(SConnection * pCon, SicsInterp * pSics, void *pData,
|
||||
SCWrite(pCon, pBueffel, eValue);
|
||||
DeleteTokenList(pList);
|
||||
return 1;
|
||||
} else if(strcmp(pName->text,"status") == 0){
|
||||
if(self->running){
|
||||
SCPrintf(pCon,eValue,"%s.status = run",argv[0]);
|
||||
} else {
|
||||
SCPrintf(pCon,eValue,"%s.status = idle",argv[0]);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
iRet = MotorGetPar(self, pName->text, &fValue);
|
||||
if (!iRet) {
|
||||
|
@ -52,7 +52,7 @@ static int MOLICheckLimits(void *data, float val, char *error, int errlen)
|
||||
iRet = LLDnodePtr2First(self);
|
||||
while (iRet != 0) {
|
||||
LLDnodeDataTo(self, &tuktuk);
|
||||
test = tuktuk.pDriv->CheckLimits(tuktuk.data, val, error, errlen);
|
||||
test = tuktuk.pDriv->CheckLimits(tuktuk.data, tuktuk.target, error, errlen);
|
||||
if (test == 0) {
|
||||
retVal = 0;
|
||||
}
|
||||
|
@ -144,6 +144,7 @@ static int MMCCStatus(void *pData, SConnection * pCon)
|
||||
self->checkSlaves = 1;
|
||||
status = HWBusy;
|
||||
}
|
||||
pCount->pDriv->fLastCurrent = GetControlValue(self->slaveData[0]);
|
||||
} else {
|
||||
/*
|
||||
* wait for the detectors to report finish too. Otherwise, with the second
|
||||
|
@ -4,6 +4,10 @@
|
||||
copyright: see file COPYRIGHT
|
||||
|
||||
Mark Koennecke, September 2006
|
||||
|
||||
Added generating a gaussian for scan testing
|
||||
|
||||
Mark Koennecke, April 2013
|
||||
----------------------------------------------------------------------------*/
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
@ -20,16 +24,22 @@
|
||||
#define PAUSEFAIL 3
|
||||
#define CONTFAIL 4
|
||||
#define READFAIL 5
|
||||
#define GAUSS 6
|
||||
|
||||
#define STATEIDLE 0
|
||||
#define STATERUN 1
|
||||
#define STATEPAU 2
|
||||
/*---------------------------- for generating a gaussian -------------------*/
|
||||
#define FWHM 2.5
|
||||
#define POS 6.
|
||||
#define HEIGHT 100.
|
||||
/*--------------------------------------------------------------------------*/
|
||||
typedef struct {
|
||||
int errType;
|
||||
int recover;
|
||||
int state;
|
||||
time_t endTime;
|
||||
int startCount;
|
||||
} RegressSt;
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static int RegressGetStatus(struct __COUNTER *self, float *fControl)
|
||||
@ -83,6 +93,7 @@ static int RegressStart(struct __COUNTER *self)
|
||||
} else {
|
||||
pSim->endTime = time(NULL) + 7;
|
||||
}
|
||||
pSim->startCount++;
|
||||
|
||||
return OKOK;
|
||||
}
|
||||
@ -144,6 +155,7 @@ static int RegressReadValues(struct __COUNTER *self)
|
||||
{
|
||||
RegressSt *pSim = NULL;
|
||||
int i;
|
||||
float stddev, tmp, y;
|
||||
|
||||
assert(self);
|
||||
pSim = (RegressSt *) self->pData;
|
||||
@ -156,6 +168,12 @@ static int RegressReadValues(struct __COUNTER *self)
|
||||
for (i = 0; i < MAXCOUNT; i++) {
|
||||
self->lCounts[i] = i * 10 + 5;
|
||||
}
|
||||
if(pSim->errType == GAUSS){
|
||||
stddev = FWHM/2.254;
|
||||
tmp = ((float)pSim->startCount - POS)/stddev;
|
||||
y = HEIGHT*exp(-.5*tmp*tmp);
|
||||
self->lCounts[0] = (long)y + 10;
|
||||
}
|
||||
self->lCounts[1] = self->fPreset;
|
||||
self->fTime = self->fPreset;
|
||||
return OKOK;
|
||||
@ -199,6 +217,9 @@ static int RegressSet(struct __COUNTER *self, char *name, int iCter,
|
||||
|
||||
if (strcmp(name, "errortype") == 0) {
|
||||
pSim->errType = (int) FVal;
|
||||
if(pSim->errType == GAUSS){
|
||||
pSim->startCount = 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
if (strcmp(name, "recover") == 0) {
|
||||
|
5
scan.c
5
scan.c
@ -658,12 +658,15 @@ int DoScan(pScanData self, int iNP, int iMode, float fPreset,
|
||||
if (!iRet) {
|
||||
self->pCon = NULL;
|
||||
self->pSics = NULL;
|
||||
self->iActive = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
iRet = ScanLoop(self);
|
||||
ScriptScanFinish(self);
|
||||
if(self->pCon != NULL && self->pSics != NULL){
|
||||
ScriptScanFinish(self);
|
||||
}
|
||||
InvokeCallBack(self->pCall, SCANEND, self);
|
||||
SendQuieck(QUIECK, self->pFile);
|
||||
self->iActive = 0;
|
||||
|
@ -37,6 +37,7 @@
|
||||
#include "commandlog.h"
|
||||
#include "arrayutil.h"
|
||||
#include "HistMem.h"
|
||||
#include "asynnet.h"
|
||||
|
||||
#define MAX_HDB_PATH 1024
|
||||
|
||||
@ -2547,7 +2548,63 @@ static int ZipReadHdbNode(SConnection * pCon, SicsInterp * pSics,
|
||||
}
|
||||
return status;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static int BinReadHdbNode(SConnection *pCon, SicsInterp *pSics,
|
||||
void *pData, int argc, char *argv[])
|
||||
{
|
||||
static int binMagic = 7333;
|
||||
pHdb targetNode = NULL;
|
||||
char oriPath[512];
|
||||
hdbValue val;
|
||||
int *data = NULL, i;
|
||||
|
||||
if (argc < 2) {
|
||||
SCWrite(pCon, "ERROR: need path to node", eError);
|
||||
return 0;
|
||||
}
|
||||
|
||||
strlcpy(oriPath, argv[1], 511);
|
||||
targetNode = FindHdbNode(NULL, argv[1], pCon);
|
||||
if (targetNode == NULL) {
|
||||
return 0;
|
||||
}
|
||||
val = targetNode->value;
|
||||
switch(val.dataType){
|
||||
case HIPINTAR:
|
||||
case HIPINTVARAR:
|
||||
data = malloc(val.arrayLength+2*sizeof(int));
|
||||
if(data == NULL){
|
||||
SCWrite(pCon,"ERROR: out of memory in BinReadHdbNode",eError);
|
||||
return 0;
|
||||
}
|
||||
data[0] = binMagic;
|
||||
data[1] = val.arrayLength;
|
||||
memcpy(data+2,val.v.intArray,val.arrayLength*sizeof(int));
|
||||
break;
|
||||
case HIPFLOATAR:
|
||||
case HIPFLOATVARAR:
|
||||
data = malloc(val.arrayLength+2*sizeof(int));
|
||||
if(data == NULL){
|
||||
SCWrite(pCon,"ERROR: out of memory in BinReadHdbNode",eError);
|
||||
return 0;
|
||||
}
|
||||
data[0] = binMagic;
|
||||
data[1] = val.arrayLength;
|
||||
for(i = 0; i < val.arrayLength; i++){
|
||||
data[i+2] = (int)(val.v.floatArray[i]*65536.);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
SCWrite(pCon,"ERROR: cannot send binary data for this node type",eError);
|
||||
return 0;
|
||||
}
|
||||
if(data != NULL){
|
||||
ANETwrite(pCon->sockHandle,data,(val.arrayLength+2)*sizeof(int));
|
||||
free(data);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static int GetHdbNode(SConnection * pCon, SicsInterp * pSics, void *pData,
|
||||
int argc, char *argv[])
|
||||
@ -3314,12 +3371,15 @@ static hdbCallbackReturn ChainCallback(pHdb node, void *userData,
|
||||
}
|
||||
|
||||
if (slave != NULL) {
|
||||
/*
|
||||
memset(&vv, 0, sizeof(hdbValue));
|
||||
GetHipadabaPar(slave, &vv, mm->callData);
|
||||
/*
|
||||
The GetHipadabaPar here has to happen. Otherwise
|
||||
necessary calculations to update the slave are not
|
||||
performed.
|
||||
*/
|
||||
UpdateHipadabaPar(slave, *(mm->v), mm->callData);
|
||||
/* ReleaseHdbValue(&vv); */
|
||||
GetHipadabaPar(slave, &vv, mm->callData);
|
||||
UpdateHipadabaPar(slave, vv, mm->callData);
|
||||
ReleaseHdbValue(&vv);
|
||||
}
|
||||
return hdbContinue;
|
||||
}
|
||||
@ -3735,6 +3795,7 @@ int InstallSICSHipadaba(SConnection * pCon, SicsInterp * pSics,
|
||||
AddCommand(pSics, "hval", GetHdbVal, NULL, NULL);
|
||||
AddCommand(pSics, "hzipget", ZipGetHdbNode, NULL, NULL);
|
||||
AddCommand(pSics, "hzipread", ZipReadHdbNode, NULL, NULL);
|
||||
AddCommand(pSics, "hbinread", BinReadHdbNode, NULL, NULL);
|
||||
AddCommand(pSics, "hlist", ListHdbNode, NULL, NULL);
|
||||
AddCommand(pSics, "hnotify", AutoNotifyHdbNode, NULL, NULL);
|
||||
AddCommand(pSics, "hdelcb", RemoveHdbCallback, NULL, NULL);
|
||||
|
@ -59,7 +59,7 @@ static long TASSetValue(void *pData, SConnection * pCon, float value)
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------*/
|
||||
static int readTASMotAngles(ptasUB self, SConnection * pCon,
|
||||
int readTASMotAngles(ptasUB self, SConnection * pCon,
|
||||
ptasAngles ang)
|
||||
{
|
||||
int status;
|
||||
@ -130,6 +130,10 @@ static int readTASMotAngles(ptasUB self, SConnection * pCon,
|
||||
return status;
|
||||
}
|
||||
ang->sgl = val;
|
||||
if(!self->outOfPlaneAllowed){
|
||||
ang->sgu = .0;
|
||||
ang->sgl = .0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -14,4 +14,6 @@ int InstallTasMotor(SicsInterp *pSics, ptasUB self, int tasVar, char *name);
|
||||
int InstallTasQMMotor(SicsInterp *pSics, ptasUB self);
|
||||
int TasMot(SConnection *pCon,SicsInterp *pSics, void *pData,
|
||||
int argc, char *argv[]);
|
||||
|
||||
int readTASMotAngles(ptasUB self, SConnection *pCon, ptasAngles ang);
|
||||
#endif
|
||||
|
69
tasub.c
69
tasub.c
@ -207,60 +207,6 @@ static void KillTasUB(void *pData)
|
||||
free(self);
|
||||
}
|
||||
|
||||
/*===================== computation section =========================*/
|
||||
static int readTASAngles(ptasUB self, SConnection * pCon, ptasAngles ang)
|
||||
{
|
||||
int status;
|
||||
float val;
|
||||
|
||||
/*
|
||||
Monochromator
|
||||
*/
|
||||
status = GetDrivablePosition(self->motors[A2], pCon, &val);
|
||||
if (status == 0) {
|
||||
return status;
|
||||
}
|
||||
ang->monochromator_two_theta = val;
|
||||
|
||||
/*
|
||||
Analyzer
|
||||
*/
|
||||
if (self->tasMode != ELASTIC) {
|
||||
status = GetDrivablePosition(self->motors[A6], pCon, &val);
|
||||
if (status == 0) {
|
||||
return status;
|
||||
}
|
||||
ang->analyzer_two_theta = val;
|
||||
} else {
|
||||
ang->analyzer_two_theta = ang->monochromator_two_theta;
|
||||
}
|
||||
|
||||
/*
|
||||
crystal
|
||||
*/
|
||||
status = GetDrivablePosition(self->motors[A3], pCon, &val);
|
||||
if (status == 0) {
|
||||
return status;
|
||||
}
|
||||
ang->a3 = val;
|
||||
status = GetDrivablePosition(self->motors[A4], pCon, &val);
|
||||
if (status == 0) {
|
||||
return status;
|
||||
}
|
||||
ang->sample_two_theta = val;
|
||||
status = GetDrivablePosition(self->motors[SGU], pCon, &val);
|
||||
if (status == 0) {
|
||||
return status;
|
||||
}
|
||||
ang->sgu = val;
|
||||
status = GetDrivablePosition(self->motors[SGL], pCon, &val);
|
||||
if (status == 0) {
|
||||
return status;
|
||||
}
|
||||
ang->sgl = val;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*==================== interpreter interface section =================*/
|
||||
static int testMotor(ptasUB pNew, SConnection * pCon, char *name, int idx)
|
||||
{
|
||||
@ -280,7 +226,7 @@ static void updateTargets(ptasUB pNew, SConnection * pCon)
|
||||
{
|
||||
tasAngles ang;
|
||||
|
||||
readTASAngles(pNew, pCon, &ang);
|
||||
readTASMotAngles(pNew, pCon, &ang);
|
||||
calcTasQEPosition(&pNew->machine, ang, &pNew->target);
|
||||
}
|
||||
/*--------------------------------------------------------------------*/
|
||||
@ -761,7 +707,7 @@ static int addReflection(ptasUB self, SicsInterp * pSics,
|
||||
"WARNING: not all angles given on command line, using positions instead",
|
||||
eWarning);
|
||||
}
|
||||
status = readTASAngles(self, pCon, &r.angles);
|
||||
status = readTASMotAngles(self, pCon, &r.angles);
|
||||
if (status != 1) {
|
||||
return status;
|
||||
}
|
||||
@ -1253,6 +1199,13 @@ static int calcUB(ptasUB self, SConnection * pCon, SicsInterp * pSics,
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(!self->outOfPlaneAllowed){
|
||||
r1.angles.sgu = .0;
|
||||
r1.angles.sgl = .0;
|
||||
r2.angles.sgu = .0;
|
||||
r2.angles.sgl = .0;
|
||||
}
|
||||
|
||||
UB = calcTasUBFromTwoReflections(self->cell, r1, r2, &status);
|
||||
if (UB == NULL) {
|
||||
switch (status) {
|
||||
@ -1848,7 +1801,7 @@ int tasUpdate(SConnection * pCon, ptasUB self)
|
||||
int status;
|
||||
tasAngles angles;
|
||||
|
||||
status = readTASAngles(self, pCon, &angles);
|
||||
status = readTASMotAngles(self, pCon, &angles);
|
||||
if (status != 1) {
|
||||
return status;
|
||||
}
|
||||
@ -2126,6 +2079,8 @@ int TasUBWrapper(SConnection * pCon, SicsInterp * pSics, void *pData,
|
||||
}
|
||||
self->outOfPlaneAllowed = newSS;
|
||||
invokeUpdate(self,pCon,"main");
|
||||
SCWrite(pCon,"WARNING: You have to recalculate the UB matrix after swapping outofplane mode",
|
||||
eWarning);
|
||||
SCSendOK(pCon);
|
||||
return 1;
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user