- Added bridge functions to histmemsec to make it look more like histmem

- Modifed many modules using histmem to work also with histmemsec
- Extended tasker with task names and task groups
- There is a new taskobj which allows to list tasks and to interact with them.
- Task now supports running Tcl functions as tasks
- There is a new experimental sctcomtask module which allows to define communication
  tasks against a scriptcontext. This is a new feature which should facilitate
  writing sequential scripts using asynchronous communication.
- A fix to make spss7 work when there are no switches
- ORION support for single X. TRICS measures crystals hanging down, ORION
  standing up
This commit is contained in:
koennecke
2012-12-20 11:32:34 +00:00
parent 28cea49d01
commit 59d292cb79
9 changed files with 44 additions and 65 deletions

2
ease.c
View File

@ -839,7 +839,7 @@ static int EaseInit(SConnection * pCon, EaseBase * eab, int argc,
return -1; return -1;
eab->task = FsmStartTask(eab, eab->handler, eab->idle, eab->p.name); eab->task = FsmStartTask(eab, eab->handler, eab->idle, eab->p.name);
TaskRegister(pServ->pTasker, (TaskFunc) FsmTaskHandler, NULL, FsmKill, TaskRegisterN(pServ->pTasker,"ease", (TaskFunc) FsmTaskHandler, NULL, FsmKill,
eab->task, 0); eab->task, 0);
return 1; return 1;
} }

View File

@ -384,9 +384,7 @@ int MakeFA(SConnection * pCon, SicsInterp * pSics, void *pData,
SCWrite(pCon, "ERROR: mbank value not found!", eError); SCWrite(pCon, "ERROR: mbank value not found!", eError);
} }
if (mbank == 1) { if (mbank == 1) {
pCom = FindCommand(pSics, "hm2"); pNew->pHistogram2 = FindHM(pSics,"hm2");
pDum = (pDummy) pCom->pData;
pNew->pHistogram2 = (pHistMem) pDum;
} }
var1 = FindVariable(pServ->pSics, "lbank"); var1 = FindVariable(pServ->pSics, "lbank");
if (var1) { if (var1) {
@ -395,9 +393,7 @@ int MakeFA(SConnection * pCon, SicsInterp * pSics, void *pData,
SCWrite(pCon, "ERROR: lbank value not found!", eError); SCWrite(pCon, "ERROR: lbank value not found!", eError);
} }
if (lbank == 1) { if (lbank == 1) {
pCom = FindCommand(pSics, "hm1"); pNew->pHistogram1 = FindHM(pSics,"hm1");
pDum = (pDummy) pCom->pData;
pNew->pHistogram1 = (pHistMem) pDum;
} }
var3 = FindVariable(pServ->pSics, "ubank"); var3 = FindVariable(pServ->pSics, "ubank");
if (var3) { if (var3) {
@ -406,9 +402,7 @@ int MakeFA(SConnection * pCon, SicsInterp * pSics, void *pData,
SCWrite(pCon, "ERROR: ubank value not found!", eError); SCWrite(pCon, "ERROR: ubank value not found!", eError);
} }
if (ubank == 1) { if (ubank == 1) {
pCom = FindCommand(pSics, "hm3"); pNew->pHistogram3 = FindHM(pSics,"hm3");
pDum = (pDummy) pCom->pData;
pNew->pHistogram3 = (pHistMem) pDum;
} }
iRet = AddCommand(pSics, argv[1], FocusAverageDo, KillFA, pNew); iRet = AddCommand(pSics, argv[1], FocusAverageDo, KillFA, pNew);
if (!iRet) { if (!iRet) {

View File

@ -151,15 +151,10 @@ static int JVLHandler(Ascon *a)
return 1; return 1;
break; break;
case AsconReading: case AsconReading:
if(!validResponse(priv)){ /* if(!validResponse(priv)){ */
a->state = AsconWriteStart; /* a->state = AsconWriteStart; */
return 1; /* return 1; */
} /* } */
if(time(NULL) > priv->start + a->timeout){
a->state = AsconReadDone;
DynStringConcat(a->rdBuffer,"timeout");
return 1;
}
ret = AsconReadChar(a->fd, &chr); ret = AsconReadChar(a->fd, &chr);
if (ret < 0) { if (ret < 0) {
/* EINTR means we must retry */ /* EINTR means we must retry */
@ -170,6 +165,10 @@ static int JVLHandler(Ascon *a)
*(priv->rdPtr) = (unsigned char)chr; *(priv->rdPtr) = (unsigned char)chr;
priv->toRead--; priv->toRead--;
priv->rdPtr++; priv->rdPtr++;
if(!validResponse(priv)){
a->state=AsconWriteStart;
return 1;
}
if(priv->toRead <= 0){ if(priv->toRead <= 0){
a->state = AsconReadDone; a->state = AsconReadDone;
if(priv->reading){ if(priv->reading){
@ -190,6 +189,12 @@ static int JVLHandler(Ascon *a)
} }
} }
} }
} else {
if(time(NULL) > priv->start + a->timeout){
a->state = AsconReadDone;
DynStringConcat(a->rdBuffer,"timeout");
return 1;
}
} }
return 1; return 1;
break; break;

View File

@ -14,7 +14,7 @@ OBJ=psi.o buffer.o ruli.o sps.o pimotor.o charbychar.o\
amorstat.o tasinit.o ptasdrive.o tasutil.o tasscan.o swmotor.o \ amorstat.o tasinit.o ptasdrive.o tasutil.o tasscan.o swmotor.o \
polterwrite.o ecb.o frame.o el734driv.o el734dc.o ecbdriv.o \ polterwrite.o ecb.o frame.o el734driv.o el734dc.o ecbdriv.o \
ecbcounter.o el737driv.o sinqhmdriv.o tdchm.o velodorn.o \ ecbcounter.o el737driv.o sinqhmdriv.o tdchm.o velodorn.o \
velodornier.o docho.o sanscook.o tecsdriv.o itc4driv.o itc4.o\ velodornier.o sanscook.o tecsdriv.o itc4driv.o itc4.o\
bruker.o ltc11.o A1931.o eurodriv.o slsmagnet.o \ bruker.o ltc11.o A1931.o eurodriv.o slsmagnet.o \
el755driv.o serial.o scontroller.o t_update.o \ el755driv.o serial.o scontroller.o t_update.o \
t_rlp.o t_conv.o el737hpdriv.o dornier2.o el734hp.o \ t_rlp.o t_conv.o el737hpdriv.o dornier2.o el734hp.o \

View File

@ -1088,7 +1088,7 @@ void ParOut(char *buf)
buf); buf);
if (!ctx->obj->logPending) { if (!ctx->obj->logPending) {
ctx->obj->logPending = 1; ctx->obj->logPending = 1;
TaskRegister(pServ->pTasker, ParLog, NULL, NULL, ctx->obj, 0); /* schedule ParLog */ TaskRegisterN(pServ->pTasker,"parlog", ParLog, NULL, NULL, ctx->obj, 0); /* schedule ParLog */
} }
break; break;
case PAR_LOG: case PAR_LOG:

View File

@ -71,7 +71,7 @@ static int Countstartcallback(int iEvent, void *pEventData, void *pUser)
self->iEnd = 0; self->iEnd = 0;
self->tUpdate = time(NULL); self->tUpdate = time(NULL);
self->pCon = (SConnection *) pEventData; self->pCon = (SConnection *) pEventData;
TaskRegister(pServ->pTasker, PoldiTask, NULL, NULL, self, 1); TaskRegisterN(pServ->pTasker,"POLDIUpdater", PoldiTask, NULL, NULL, self, 1);
return 1; return 1;
} }
return 1; return 1;

36
psi.c
View File

@ -311,8 +311,6 @@ static pVelSelDriv CreatePsiVelSelDriv(char *name, char *array,
} }
/*------------------------------------------------------------------*/ /*------------------------------------------------------------------*/
extern pCodri MakeDoChoDriver(char *pHost, int iPort, int iChannel,
int iSingle);
extern pCodri MakeCookerDriver(char *pHost, int iPort, int iChannel); extern pCodri MakeCookerDriver(char *pHost, int iPort, int iChannel);
/*-------------------------------------------------------------------*/ /*-------------------------------------------------------------------*/
static pCodri CreatePsiController(SConnection * pCon, int argc, static pCodri CreatePsiController(SConnection * pCon, int argc,
@ -323,39 +321,7 @@ static pCodri CreatePsiController(SConnection * pCon, int argc,
int iPort, iChannel, iRet, iSingle = 0; int iPort, iChannel, iRet, iSingle = 0;
char pBueffel[512]; char pBueffel[512];
if (strcmp(argv[0], "docho") == 0) { if (strcmp(argv[0], "sanscook") == 0) {
if (argc < 4) {
SCWrite(pCon,
"ERROR: Insufficient number of arguments to install Dornier Chopper driver",
eError);
return NULL;
}
iRet = Tcl_GetInt(pTcl, argv[2], &iPort);
if (iRet != TCL_OK) {
snprintf(pBueffel,511, "ERROR: expected integer as port number, got %s",
argv[2]);
SCWrite(pCon, pBueffel, eError);
return NULL;
}
iRet = Tcl_GetInt(pTcl, argv[3], &iChannel);
if (iRet != TCL_OK) {
snprintf(pBueffel,511,
"ERROR: expected integer as channel number, got %s",
argv[3]);
SCWrite(pCon, pBueffel, eError);
return NULL;
}
if (argc > 4) {
iRet = Tcl_GetInt(pTcl, argv[4], &iSingle);
if (iRet != TCL_OK) {
snprintf(pBueffel,511,
"ERROR: expected integer as single flag, got %s", argv[4]);
SCWrite(pCon, pBueffel, eError);
return NULL;
}
}
pNew = MakeDoChoDriver(argv[1], iPort, iChannel, iSingle);
} else if (strcmp(argv[0], "sanscook") == 0) {
if (argc < 4) { if (argc < 4) {
SCWrite(pCon, SCWrite(pCon,
"ERROR: Insufficient number of arguments to install SANS Cooker driver", "ERROR: Insufficient number of arguments to install SANS Cooker driver",

2
sinq.c
View File

@ -125,7 +125,7 @@ int SinqFactory(SConnection * pCon, SicsInterp * pSics,
for (i = 0; i < MAXLOG; i++) { for (i = 0; i < MAXLOG; i++) {
pNew->lastSinq[i] = -200; pNew->lastSinq[i] = -200;
} }
TaskRegister(pServ->pTasker, SinqTask, NULL, NULL, pNew, 1); TaskRegisterN(pServ->pTasker,"sinq", SinqTask, NULL, NULL, pNew, 1);
return AddCommand(pSics, "sinq", SinqWrapper, KillSinq, pNew); return AddCommand(pSics, "sinq", SinqWrapper, KillSinq, pNew);
} }

28
spss7.c
View File

@ -16,8 +16,12 @@
#include <sicsobj.h> #include <sicsobj.h>
#include <devser.h> #include <devser.h>
#include <sicshipadaba.h> #include <sicshipadaba.h>
#define MAXDATA 65552 /* 64KB + 16 Byte for headers */ #define MAXDATA 65552 /* 64KB + 16 Byte for headers */
#define NOTLOADED -10
#define NOSWITCHES -20
/*----------------------- private data structure --------------*/ /*----------------------- private data structure --------------*/
typedef struct { typedef struct {
DevSer *devser; DevSer *devser;
@ -448,8 +452,7 @@ static char *S7InitSwitchHandler(void *actionData, char *reply, int comerror)
/* /*
* Start: read length of the database * Start: read length of the database
*/ */
if(reply == NULL){ if(reply == NULL && self->sps->switchdblength == NOTLOADED){
self->sps->switchdblength = 0;
MakeFetchMessage(self,self->sps->switchdbnum, 0,2); MakeFetchMessage(self,self->sps->switchdbnum, 0,2);
return self->message; return self->message;
} }
@ -457,9 +460,13 @@ static char *S7InitSwitchHandler(void *actionData, char *reply, int comerror)
/* /*
* we are reading the database length * we are reading the database length
*/ */
if(self->sps->switchdblength == 0){ if(self->sps->switchdblength == NOTLOADED){
memcpy(&dblength, self->replyData+16,2); memcpy(&dblength, self->replyData+16,2);
self->sps->switchdblength = ntohs(dblength); self->sps->switchdblength = ntohs(dblength);
if(self->sps->switchdblength == 0){
self->sps->switchdblength = NOSWITCHES;
return NULL;
}
MakeFetchMessage(self,self->sps->switchdbnum, MakeFetchMessage(self,self->sps->switchdbnum,
0,ntohs(dblength)); 0,ntohs(dblength));
return self->message; return self->message;
@ -471,7 +478,13 @@ static char *S7InitSwitchHandler(void *actionData, char *reply, int comerror)
return NULL; return NULL;
} }
} }
/*-------------------------------------------------------------------*/
static void KillS7Action(void *data)
{
if(data != NULL){
free(data);
}
}
/*===================================================================*/ /*===================================================================*/
static int S7UpdateCmd(pSICSOBJ ccmd, SConnection * con, static int S7UpdateCmd(pSICSOBJ ccmd, SConnection * con,
Hdb * cmdNode, Hdb * par[], int nPar) Hdb * cmdNode, Hdb * par[], int nPar)
@ -487,7 +500,7 @@ static int S7UpdateCmd(pSICSOBJ ccmd, SConnection * con,
updateAction->sps = self; updateAction->sps = self;
updateAction->spsNode = ccmd->objectNode; updateAction->spsNode = ccmd->objectNode;
DevQueue(self->devser, updateAction, ProgressPRIO, DevQueue(self->devser, updateAction, ProgressPRIO,
S7UpdateHandler, S7ActionMatch, free, NULL); S7UpdateHandler, S7ActionMatch, KillS7Action, NULL);
SCSendOK(con); SCSendOK(con);
return 1; return 1;
} }
@ -538,6 +551,7 @@ int MakeSPSS7(SConnection * con, SicsInterp * sics,
self->dbnum = atoi(argv[2]); self->dbnum = atoi(argv[2]);
self->switchdbnum = atoi(argv[3]); self->switchdbnum = atoi(argv[3]);
self->switchdblength = NOTLOADED;
pNew = MakeSICSOBJv(argv[1],"SPS-S7", HIPNONE, usInternal); pNew = MakeSICSOBJv(argv[1],"SPS-S7", HIPNONE, usInternal);
if(pNew == NULL){ if(pNew == NULL){
@ -581,13 +595,13 @@ int MakeSPSS7(SConnection * con, SicsInterp * sics,
initSwitchAction->sps = self; initSwitchAction->sps = self;
initSwitchAction->spsNode = pNew->objectNode; initSwitchAction->spsNode = pNew->objectNode;
DevQueue(self->devser, initSwitchAction, WritePRIO, DevQueue(self->devser, initSwitchAction, WritePRIO,
S7InitSwitchHandler, S7ActionMatch, free, NULL); S7InitSwitchHandler, S7ActionMatch, KillS7Action, NULL);
updateAction->sps = self; updateAction->sps = self;
updateAction->spsNode = pNew->objectNode; updateAction->spsNode = pNew->objectNode;
DevSchedule(self->devser, updateAction, DevSchedule(self->devser, updateAction,
ReadPRIO, 60., ReadPRIO, 60.,
S7UpdateHandler, S7ActionMatch, free, NULL); S7UpdateHandler, S7ActionMatch, KillS7Action, NULL);
return 1; return 1;
} }