Merge branch 'RELEASE-3_0' of ics2-dev.nbi.ansto.gov.au:/opt/sicsdev_git into RELEASE-3_0

This commit is contained in:
Nick Hauser
2014-04-14 13:25:50 +10:00
158 changed files with 10805 additions and 1442 deletions

2
.gitignore vendored
View File

@ -15,3 +15,5 @@ CVSPSI
*.d
*.out
*.sqlite
parser.out
parsetab.py

View File

@ -45,7 +45,7 @@
#define MAXCONNECTIONS 1024
#define RBUFFERSIZE 262144 /* 256kb */
#define WBUFFERSIZE 20*262144
/* #define WBUFFERSIZE 100*262144 /*
/* #define WBUFFERSIZE 100*262144 */
/*--------------------------------------------------------------------------*/
typedef struct {
int socket;

View File

@ -536,7 +536,7 @@ int CommandLog(SConnection * pCon, SicsInterp * pSics, void *pData,
if (iCompact > 0)
iIntervall = 0;
}
SCPrintf(pCon, eValue, "%s.compact [sec] = %d", argv[0], iCompact);
SCPrintf(pCon, eValue, "%s.compact [sec] = %d", argv[0], (int)iCompact);
return 1;
} else if (strcmp(argv[1], "close") == 0) { /* close command */
fclose(fd);

View File

@ -770,6 +770,61 @@ static int testAndWriteSocket(SConnection * pCon, char *buffer, int iOut)
return 0;
}
/*--------------------------------------------------------------------------*/
static int isOK(const char *buffer)
{
if ((buffer[0] == 'O' && buffer[1] == 'K')
&& (buffer[2] == '\0' || buffer[2] == '\r' || buffer[2] == '\n'))
return 1;
return 0;
}
/*--------------------------------------------------------------------------*/
static void testAndWriteSICSLog(SConnection * self, char *buffer, int iOut)
{
char *tp;
/* We don't want to log the "OK" messages */
if (isOK(buffer))
return;
if (SCinMacro(self)) {
tp = "M";
if (sicsdebug())
tp = "D";
} else
tp = "N";
switch (iOut) {
case eStatus:
case eStart:
case eFinish:
case eEvent:
case eHdbValue:
case eHdbEvent:
case eLog:
case eLogError:
case eError:
case eWarning:
/* Log it */
SICSLogPrintf(iOut, "%s:%s", tp, buffer);
return;
case eValue:
if (sicsdebug() || !SCinMacro(self)) {
/* Log it */
SICSLogPrintf(iOut, "%s:%s", tp, buffer);
return;
} else {
/* Suppressed */
/* SICSLogPrintf(iOut, "%s!:%s", tp, buffer); */
return;
}
break;
default:
printf("Unrecognized ouput code %d in testAndWriteSICSLog: FIXME!!!\n", iOut);
SICSLogPrintf(iOut, "%s:%s", tp, buffer);
return;
}
}
/*--------------------------------------------------------------------------*/
int SCNormalWrite(SConnection * self, char *buffer, int iOut)
{
@ -784,10 +839,14 @@ int SCNormalWrite(SConnection * self, char *buffer, int iOut)
}
/* log it for any case */
#if 0
if ( (sicsdebug() || !SCinMacro(self)) && !(iOut == eInternal
|| (buffer[0] == 'O' && buffer[1] == 'K'
&& (buffer[2] == '\0' || buffer[2] == '\r' || buffer[2] == '\n'))))
SICSLogWrite(buffer, iOut);
#else
testAndWriteSICSLog(self, buffer, iOut);
#endif
testAndWriteCommandLog(self, buffer, iOut);

View File

@ -91,7 +91,14 @@ void SCSignalFunction(void *pCon, int iSignal, void *pSigData);
/* ***************************** I/O ************************************** */
void SCSetOutputClass(SConnection * self, int iClass);
int SCWrite(SConnection * self, char *pBuffer, int iOut);
int SCPrintf(SConnection * self, int iOut, char *fmt, ...);
#if __GNUC__ > 2
#define G_GNUC_PRINTF( format_idx, arg_idx ) \
__attribute__((__format__ (__printf__, format_idx, arg_idx)))
#else
#define G_GNUC_PRINTF( format_idx, arg_idx )
#endif
int SCPrintf(SConnection * self, int iOut, char *fmt, ...) G_GNUC_PRINTF (3, 4);
#undef G_GNUC_PRINTF
int SCRead(SConnection * self, char *pBuffer, int iBufLen);
int SCPrompt(SConnection * pCon, char *pPrompt, char *pResult, int iLen);
int SCSendOK(SConnection * self);

View File

@ -1142,7 +1142,7 @@ int CountAction(SConnection * pCon, SicsInterp * pSics, void *pData,
iRet = self->pDriv->Get(self->pDriv, PaRes.Arg[0].text,
PaRes.Arg[1].iVal, &fVal);
if (iRet == 1) {
snprintf(pBueffel,255, "%s.%s %d = %f", argv[0], PaRes.Arg[0].text,
snprintf(pBueffel,255, "%s.%s %s = %f", argv[0], PaRes.Arg[0].text,
PaRes.Arg[1].text, fVal);
SCWrite(pCon, pBueffel, eValue);
return 1;

View File

@ -400,7 +400,7 @@ static int DiffScanTask(void *pData)
traceSys("diffscan","START:normalizing on %d, scale monitor is %d",
self->normalizationScale, self->scaleMonitor);
} else {
traceSys("diffscan","START:normalization count %d, on scale monitor is %d and is to low",
traceSys("diffscan","START:normalization count %ld, on scale monitor is %d and is to low",
rawMon, self->scaleMonitor);
SCWrite(self->scanObject->pCon,"WARNING: Skipping first point because of low count rate", eWarning);
return finish;
@ -409,7 +409,7 @@ static int DiffScanTask(void *pData)
if (data->Monitors[self->scaleMonitor - 1] -
self->last.Monitors[self->scaleMonitor - 1] < 5) {
SCWrite(self->scanObject->pCon, "WARNING: low count rate", eLog);
traceSys("diffscan","RUN:low monitor difference from %d to %d",data->Monitors[self->scaleMonitor-1],
traceSys("diffscan","RUN:low monitor difference from %ld to %ld",data->Monitors[self->scaleMonitor-1],
self->last.Monitors[self->scaleMonitor -1]);
}
rawCount = data->lCount;
@ -441,7 +441,7 @@ static int DiffScanTask(void *pData)
ReleaseHdbValue(&v);
}
InvokeCallBack(self->scanObject->pCall, SCANPOINT, self->scanObject);
traceSys("diffscan","RUN: pos, count, rawcount, rawmon: %f, %d, %d, %d",
traceSys("diffscan","RUN: pos, count, rawcount, rawmon: %f, %f, %ld, %ld",
fPos, countValue, rawCount, rawMon);
/*

View File

@ -35,7 +35,14 @@ typedef struct {
* \return the new error message list head
*/
void ErrPutMsg(ErrList *list, char *fmt, ...);
#if __GNUC__ > 2
#define G_GNUC_PRINTF( format_idx, arg_idx ) \
__attribute__((__format__ (__printf__, format_idx, arg_idx)))
#else
#define G_GNUC_PRINTF( format_idx, arg_idx )
#endif
void ErrPutMsg(ErrList *list, char *fmt, ...) G_GNUC_PRINTF (2, 3);
#undef G_GNUC_PRINTF
/** \brief Get the most recent error message
* \param list the error list

View File

@ -48,7 +48,7 @@ extern void StopExit(void); /* in SICSmain.c */
extern int openDevexecLog(); /* in devexec.c */
extern void NetWatchInit(void); /* in nwatch.c */
extern int NetWatchTask(void *pData); /* in nwatch.c */
/* ========================= Less dreadful file statics =================== */
#define DEFAULTINIFILE "servo.tcl"
@ -120,7 +120,7 @@ int InitServer(char *file, pServer * pServ)
pSICSOptions = IFAddOption(pSICSOptions, "ConMask", "0");
/* initialize the network watcher */
NetWatchInit();
TaskRegister(self->pTasker, NetWatchTask, NULL, NULL, NULL, 1);
/* initialise the server from script */
SetWriteHistory(0);

View File

@ -36,27 +36,24 @@ typedef struct __netwatcher_s {
/* Singleton pattern */
static pNetWatch instance = NULL;
static int NetWatchTask(void *pData);
/**
* \brief Initialises the Net Watcher singleton and starts the task
*
* \return 1=success, 0=failure
*/
int NetWatchInit(void)
static pNetWatch NetWatchGetInstance(void)
{
/*
* If the singleton has not yet been created, do so now
*/
if (instance == NULL) {
instance = (pNetWatch) malloc(sizeof(NetWatch));
if (instance == NULL)
return 0;
if (instance != NULL) {
memset(instance, 0, sizeof(NetWatch));
instance->lMagic = NWMAGIC;
TaskRegister(pServ->pTasker, NetWatchTask, NULL, NULL, NULL, 1);
}
return 1;
}
return instance;
}
/*
@ -162,7 +159,7 @@ int NetWatchRegisterTimer(pNWTimer * handle, int mSec,
pNWCallback callback, void *context)
{
assert(callback);
pNetWatch self = instance;
pNetWatch self = NetWatchGetInstance();
if (!self || self->lMagic != NWMAGIC)
return 0;
pNWTimer pNew = (pNWTimer) malloc(sizeof(NWTimer));
@ -238,7 +235,7 @@ int NetWatchSetTimerPeriod(pNWTimer handle, int mSecPeriod)
int NetWatchRemoveTimer(pNWTimer handle)
{
pNetWatch self = instance;
pNetWatch self = NetWatchGetInstance();
if (!self || self->lMagic != NWMAGIC)
return 0;
if (handle == NULL || handle->vrfy != NWMAGIC)
@ -317,7 +314,7 @@ int NetWatchRegisterCallback(pNWContext * handle, int iSocket,
{
assert(callback);
pNWContext pNew = NULL;
pNetWatch self = instance;
pNetWatch self = NetWatchGetInstance();
if (!self || self->lMagic != NWMAGIC)
return 0;
if (iSocket < 0 || iSocket > 65535)
@ -337,7 +334,7 @@ int NetWatchRegisterCallback(pNWContext * handle, int iSocket,
int NetWatchRemoveCallback(pNWContext handle)
{
pNetWatch self = instance;
pNetWatch self = NetWatchGetInstance();
if (handle == NULL || handle->vrfy != NWMAGIC)
return 0;
if (!self || self->lMagic != NWMAGIC)
@ -379,7 +376,7 @@ int NetWatchTask(void *pData)
int iCount;
/* Check the singleton */
self = (pNetWatch) instance;
self = NetWatchGetInstance();
if (!self || self->lMagic != NWMAGIC)
return 0;

120
nxdict.c
View File

@ -1475,6 +1475,126 @@ NXstatus NXDinfoalias(NXhandle hFil, NXdict dict, char *pAlias, int *rank,
return iRet;
}
/*------------------------------------------------------------------------*/
NXstatus NXDdefnamedlink(NXhandle hFil, NXdict dict,
char *pTarget, char *pVictim, char *newname)
{
NXdict pDict;
ParDat pParseT, pParseV;
int iRet, i, iStat;
NXlink sLink;
pDict = NXDIAssert(dict);
#ifdef DEFDEBUG
printf("Linking: %s\n", pVictim);
printf("To: %s\n", pTarget);
#endif
/* parse Victim */
pParseV.iMayCreate = 0;
pParseV.pPtr = pVictim;
pParseV.iDepth = 0;
iRet = NXDIDefParse(hFil, pDict, &pParseV);
if (iRet == NX_ERROR) {
/* unwind and throw up */
NXDIUnwind(hFil, pParseV.iDepth);
return NX_ERROR;
}
/* get link data */
if (pParseV.iTerminal == TERMSDS) {
NXgetdataID(hFil, &sLink);
iRet = NXclosedata(hFil);
if (iRet != NX_OK) {
/* unwind and throw up */
NXDIUnwind(hFil, pParseV.iDepth);
return NX_ERROR;
}
} else if (pParseV.iTerminal == TERMVG) {
NXgetgroupID(hFil, &sLink);
} else {
assert(0); /* serious programming error */
}
/* Unwind */
iRet = NXDIUnwind(hFil, pParseV.iDepth);
if (iRet != NX_OK) {
return NX_ERROR;
}
/* parse Target */
pParseT.iMayCreate = 1;
pParseT.pPtr = pTarget;
pParseT.iDepth = 0;
iRet = NXDIDefParse(hFil, pDict, &pParseT);
if (iRet == NX_ERROR) {
/* unwind and throw up */
NXDIUnwind(hFil, pParseT.iDepth);
return NX_ERROR;
}
/* check it being a vGroup! */
if (pParseT.iTerminal != TERMVG) {
NXReportError("ERROR: can link only into a vGroup");
NXDIUnwind(hFil, pParseT.iDepth);
return NX_ERROR;
}
/* link, finally */
iRet = NXmakenamedlink(hFil, newname, &sLink);
/* Unwind anyway */
iStat = NXDIUnwind(hFil, pParseT.iDepth);
if (iStat != NX_OK) {
return NX_ERROR;
}
return iStat;
}
/*--------------------------------------------------------------------------*/
NXstatus NXDaliasnamedlink(NXhandle hFil, NXdict dict,
char *pTarget, char *pVictim, char *newname)
{
char pTargetDef[2048], pVictimDef[2048];
int iRet;
NXdict pDict;
pDynString pRep1 = NULL, pRep2 = NULL;
pDict = NXDIAssert(dict);
/* get Target Definition String */
iRet = NXDget(pDict, pTarget, pTargetDef, 2047);
if (iRet != NX_OK) {
sprintf(pTargetDef, "ERROR: alias %s not recognized", pTarget);
NXReportError(pTargetDef);
return NX_ERROR;
}
/* get Victim definition string */
iRet = NXDget(pDict, pVictim, pVictimDef, 2047);
if (iRet != NX_OK) {
sprintf(pTargetDef, "ERROR: alias %s not recognized", pTarget);
NXReportError(pTargetDef);
return NX_ERROR;
}
/* do replacements */
pRep1 = NXDItextreplace(dict, pTargetDef);
pRep2 = NXDItextreplace(dict, pVictimDef);
if ((!pRep1) || (!pRep2)) {
if (pRep1)
DeleteDynString(pRep1);
if (pRep2)
DeleteDynString(pRep2);
return NX_ERROR;
}
/* call NXdeflin */
iRet = NXDdefnamedlink(hFil, pDict, GetCharArray(pRep1), GetCharArray(pRep2), newname);
DeleteDynString(pRep1);
DeleteDynString(pRep2);
return iRet;
}
/*------------------------------------------------------------------------*/
NXstatus NXDdeflink(NXhandle hFil, NXdict dict,
char *pTarget, char *pVictim)

View File

@ -1589,6 +1589,31 @@ static void makeLink(SConnection * pCon, SicsInterp * pSics,
SCSendOK(pCon);
}
/*----------------------------------------------------------------------*/
static void makeNamedLink(SConnection * pCon, SicsInterp * pSics,
pNXScript self, int argc, char *argv[])
{
int status;
char pBueffel[256];
if (argc < 5) {
SCWrite(pCon, "ERROR: insufficient number of arguments to makenamedlink",
eLogError);
return;
}
status = NXDaliasnamedlink(self->fileHandle, self->dictHandle,
argv[2], argv[3], argv[4]);
if (status != NX_OK) {
snprintf(pBueffel, 255, "ERROR: linking %s against %s as %s failed",
argv[2], argv[3], argv[4]);
SCWrite(pCon, pBueffel, eLogError);
return;
}
SCSendOK(pCon);
}
/*----------------------------------------------------------------------*/
static void updateDictVar(SConnection * pCon, pNXScript self, int argc,
char *argv[])
@ -1698,6 +1723,10 @@ int NXScriptAction(SConnection * pCon, SicsInterp * pSics, void *pData,
makeLink(pCon, pSics, self, argc, argv);
return 1;
}
if (strcmp(argv[1], "makenamedlink") == 0) {
makeNamedLink(pCon, pSics, self, argc, argv);
return 1;
}
return 1;
}

View File

@ -779,7 +779,7 @@ NXstatus NXXputdatatable (NXhandle fid, const void *data){
}
/*------------------------------------------------------------------------*/
NXstatus NXXputdata (NXhandle fid, void *data){
NXstatus NXXputdata (NXhandle fid, const void *data){
pXMLNexus xmlHandle = NULL;
mxml_node_t *userData = NULL;
mxml_node_t *current = NULL;
@ -1074,8 +1074,8 @@ NXstatus NXXputslabtable (NXhandle fid, const void *data,
return NX_OK;
}
/*----------------------------------------------------------------------*/
NXstatus NXXputslab64 (NXhandle fid, void *data,
int64_t iStart[], int64_t iSize[]){
NXstatus NXXputslab64 (NXhandle fid, const void *data,
const int64_t iStart[], const int64_t iSize[]){
pXMLNexus xmlHandle = NULL;
mxml_node_t *userData = NULL;
@ -1295,7 +1295,7 @@ static char *formatAttributeData(const void *data, int datalen, int iType){
return number;
}
/*---------------------------------------------------------------------*/
NXstatus NXXputattr (NXhandle fid, CONSTCHAR *name, void *data,
NXstatus NXXputattr (NXhandle fid, CONSTCHAR *name, const void *data,
int datalen, int iType){
char buffer[256];
pXMLNexus xmlHandle = NULL;

View File

@ -44,15 +44,15 @@ NXstatus NXXmakedata64 (NXhandle fid,
int rank, int64_t dimensions[]);
NXstatus NXXopendata (NXhandle fid, CONSTCHAR *name);
NXstatus NXXclosedata (NXhandle fid);
NXstatus NXXputdata (NXhandle fid, void *data);
NXstatus NXXputdata (NXhandle fid, const void *data);
NXstatus NXXgetdata (NXhandle fid, void *data);
NXstatus NXXgetinfo64 (NXhandle fid, int *rank,
int64_t dimension[], int *iType);
NXstatus NXXputslab64 (NXhandle fid, void *data,
int64_t iStart[], int64_t iSize[]);
NXstatus NXXputslab64 (NXhandle fid, const void *data,
const int64_t iStart[], const int64_t iSize[]);
NXstatus NXXgetslab64 (NXhandle fid, void *data,
const int64_t iStart[], const int64_t iSize[]);
NXstatus NXXputattr (NXhandle fid, CONSTCHAR *name, void *data,
NXstatus NXXputattr (NXhandle fid, CONSTCHAR *name, const void *data,
int datalen, int iType);
NXstatus NXXgetattr (NXhandle fid, char *name,
void *data, int* datalen, int* iType);

View File

@ -172,7 +172,7 @@ static int ContextDo(SConnection * pCon, SicsInterp * pSics, void *pData,
comCon = SCCopyConnection(pCon);
if (comCon == NULL) {
SCWrite(pCon, "EROOR: out of memory in contextdo", eError);
SCWrite(pCon, "ERROR: out of memory in contextdo", eError);
return 0;
}
status = Tcl_GetInt(pSics->pTcl, argv[1], &comCon->transID);

View File

@ -204,7 +204,7 @@ static int StatCmd(pSICSOBJ self, SConnection *pCon, pHdb commandNode,
}
average = (double)sum/(double)length;
SCPrintf(pCon,eValue,"Stat:sum,max,min,av = %d,%d,%d,%f", sum,max,min,average);
SCPrintf(pCon,eValue,"Stat:sum,max,min,av = %ld,%ld,%ld,%f", sum,max,min,average);
return 1;
}

View File

@ -402,6 +402,7 @@ static char *SctActionHandler(void *actionData, char *lastReply,
char *errorScript = NULL;
char *send = NULL;
int i;
int j;
SConnection *con;
char eprop[80];
char msg[1024];
@ -516,6 +517,21 @@ static char *SctActionHandler(void *actionData, char *lastReply,
if (strcasecmp(data->name, "read") == 0) {
SetHdbProperty(node, "geterror", result);
}
/* Sanitize the text to reduce TCL problems with unbalanced and substituted items */
for (j = 0; msg[j]; ++j) {
switch (msg[j]) {
case '{':
case '}':
case '[':
case ']':
case '<':
case '>':
case '\'':
case '"':
case '$':
msg[j] = '_';
}
}
SetHdbProperty(node, eprop, msg);
blank = strchr(origScript, ' ');
if (blank != NULL) {
@ -531,6 +547,21 @@ static char *SctActionHandler(void *actionData, char *lastReply,
}
cnt++;
snprintf(msg, sizeof msg, "%dx {%s}: %s", cnt, origScript, result);
/* Sanitize the text to reduce TCL problems with unbalanced and substituted items */
for (j = 0; msg[j]; ++j) {
switch (msg[j]) {
case '{':
case '}':
case '[':
case ']':
case '<':
case '>':
case '\'':
case '"':
case '$':
msg[j] = '_';
}
}
SetHdbProperty(node, eprop, msg);
send = NULL;
free(script);

View File

@ -82,6 +82,28 @@ typedef struct __LogLog {
static pCaptureEntry pCapture = NULL;
/*------------------------------------------------------------------------*/
static char* OutCodeToTxt(OutCode eOut)
{
switch (eOut) {
case eInternal: return "Int"; /* internal */
case eCommand: return "Cmd"; /* reserved, not used */
case eHWError: return "ErH"; /* reserved, used only for SICSLog */
case eInError: return "ErI"; /* reserved, used as a mark in the handling of output codes */
case eStatus: return "Sta"; /* reserved, deprecated */
case eValue: return "Val"; /* value reponse: copied into Tcl */
case eStart: return "Beg"; /* start message */
case eFinish: return "End"; /* finish message */
case eEvent: return "Evt"; /* some callback messages */
case eWarning: return "Wrn"; /* warnings */
case eError: return "Err"; /* error: copied into Tcl */
case eHdbValue: return "HVa"; /* hipadaba value chnage */
case eHdbEvent: return "HEv"; /* Hipadaba event */
case eLog: return "Log"; /* log message: is always written to client */
case eLogError: return "ErL"; /* error message to log: is always written to client */
}
return "???";
}
int KillCapture(SConnection * pCon)
{
pCaptureEntry pCurrent, pTemp;
@ -325,7 +347,7 @@ static void SICSLogWriteFile(char *pText, OutCode eOut, struct timeval *tp)
if (iLineCount == 0)
fprintf(fLogFile, "%s: <<<open logfile>>>\n", timestamp(NULL));
fprintf(fLogFile, "%s: ", timestamp(tp));
fprintf(fLogFile, "%s:%s:", timestamp(tp), OutCodeToTxt(eOut));
fprintf(fLogFile, "%s", pText);
if (text_len < 1 || pText[text_len - 1] != '\n')
fprintf(fLogFile, "\n");
@ -351,6 +373,8 @@ void SICSLogWriteTime(char *pText, OutCode eOut, struct timeval *tp)
buf[idx++] = '\0';
SICSLogWriteFile(buf, eOut, tp);
idx = 0;
buf[idx++] = '*';
buf[idx++] = ':';
} else if (*cp == '\r') {
buf[idx++] = '\\';
buf[idx++] = 'r';
@ -372,6 +396,8 @@ void SICSLogWriteTime(char *pText, OutCode eOut, struct timeval *tp)
buf[idx++] = '\0';
SICSLogWriteFile(buf, eOut, tp);
idx = 0;
buf[idx++] = '*';
buf[idx++] = ':';
}
}
if (idx > 0) {
@ -521,29 +547,3 @@ void SICSLogPrintf(OutCode eOut, const char *fmt, ...)
SICSLogWrite(buf, eOut);
return;
}
/* Test of the logging facilities */
int testLogCmd(SConnection *pCon, SicsInterp *pInter, void *pData,
int argc, char *argv[]) {
char lbuf[2048];
char sbuf[1000];
int i;
SICSLogWrite("Multiline:\nLine 1\r\nLine 2\r\nLine 3\r\n", eStatus);
memset(lbuf, 0, sizeof(lbuf));
memset(sbuf, ' ', sizeof(sbuf));
SICSLogPrintf(eStatus, "Hexlog %d all zero bytes", sizeof(lbuf));
SICSLogWriteHex(lbuf, sizeof(lbuf), eStatus);
for (i = 0; i <= 128; ++i)
sbuf[i] = sbuf[sizeof(sbuf) - 1 - i] = i;
sbuf[sizeof(sbuf) / 2] = '!';
SICSLogPrintf(eStatus, "Hexlog %d mid space bytes", sizeof(sbuf));
SICSLogWriteHex(sbuf, sizeof(sbuf), eStatus);
for (i = 0; i < 1000; ++i)
sbuf[i] = ' ' + (i % 96);
sbuf[sizeof(sbuf) - 1] = '\0';
SICSLogWrite("Very long line 1000 bytes", eStatus);
SICSLogWrite(sbuf, eStatus);
SCSendOK(pCon);
return OKOK;
}

View File

@ -20,9 +20,16 @@ void SICSLogWriteTime(char *ptext, OutCode eOut, struct timeval *tp);
void SICSLogWriteHex(const char *text, int count, OutCode eOut);
void SICSLogWriteHexTime(const char *text, int count, OutCode eOut,
struct timeval *tp);
void SICSLogPrintf(OutCode eOut, const char *fmt, ...);
#if __GNUC__ > 2
#define G_GNUC_PRINTF( format_idx, arg_idx ) \
__attribute__((__format__ (__printf__, format_idx, arg_idx)))
#else
#define G_GNUC_PRINTF( format_idx, arg_idx )
#endif
void SICSLogPrintf(OutCode eOut, const char *fmt, ...) G_GNUC_PRINTF (2, 3);
void SICSLogTimePrintf(OutCode eOut, struct timeval *tp, const char *fmt,
...);
...) G_GNUC_PRINTF (3, 4);
#undef G_GNUC_PRINTF
void SICSLogEnable(int flag);
int KillCapture(SConnection * pCon);

View File

@ -85,6 +85,7 @@ int SimIdxRun();
* \param errCode pointer to an integer error code
* \param error A text buffer to hold a description of the error
* \param errLen The length of error
*/
void SimIdxGetError(int *errCode, char *error, int errLen);
/**

View File

@ -163,6 +163,8 @@ kookaburra: all
make -C instrument/kookaburra
dingo: all
make -C instrument/dingo
bilby: all
emu: all
libansto.a: $(OBJ)
rm -f libansto.a
@ -170,10 +172,10 @@ libansto.a: $(OBJ)
ranlib libansto.a
libhardsup:
$(MAKE) -C hardsup/ INC_TCL8="$(INC_TCL8)"
$(MAKE) -C hardsup/ INC_TCL8="$(INC_TCL8)" "CC=${CC}"
libsics:
$(MAKE) -C .. -f site_ansto/Makefile_SICS INC_TCL8="$(INC_TCL8)" INC_HDF5="$(INC_HDF5)" all
$(MAKE) -C .. -f site_ansto/Makefile_SICS INC_TCL8="$(INC_TCL8)" INC_HDF5="$(INC_HDF5)" "CC=${CC}" all
anstohm.o : anstohm.cpp
$(CXX) -c anstohm.cpp $(CFLAGS) $(CXXFLAGS) -Wno-all

View File

@ -278,6 +278,11 @@ int ANSTO_SctMakeDriveAdapter(SConnection *pCon, SicsInterp *pSics, void *object
pSICSOBJ obj = NULL;
hdbCallback *cb;
if(argc < 4){
SCWrite(pCon,"ERROR: not enough arguments for ANSTO_SctMakeDriveAdapter", eError);
return 0;
}
pNew = SCTDRIVMakeObject();
if(pNew == NULL){
SCWrite(pCon,"ERROR: out of memory in ANSTO_SctMakeDriveAdapter",
@ -285,11 +290,6 @@ int ANSTO_SctMakeDriveAdapter(SConnection *pCon, SicsInterp *pSics, void *object
return 0;
}
if(argc < 4){
SCWrite(pCon,"ERROR: not enough arguments for ANSTO_SctMakeDriveAdapter", eError);
return 0;
}
pNew->write_node = FindHdbNode(NULL,argv[2], pCon);
pNew->read_node = FindHdbNode(NULL,argv[3], pCon);
obj = FindCommandData(pSics,argv[4], "SctController");

View File

@ -397,27 +397,29 @@ static int TclSetPar(void *self, SConnection * pCon, char *name,
if (result == NULL) {
pDriv->errorCode = NOTCLRESULT;
free(tclCommand);
free(tclCommandPara);;
free(tclCommandPara);
return HWFault;
}
if (status != TCL_OK) {
pDriv->errorCode = TCLERROR;
strncpy(pDriv->tclError, result, 1023);
free(tclCommand);
free(tclCommandPara);;
free(tclCommandPara);
return HWFault;
} else {
snprintf(pBuffer, 511, "%s.%s = %s", pDriv->motName, name, result);
SCWrite(pCon, pBuffer, eValue);
}
free(tclCommand);
free(tclCommandPara);;
free(tclCommandPara);
return OKOK;
} else {
pDriv->errorCode = PARANOTFOUND;
free(tclCommand);
return 0;
}
free(tclCommand);
return OKOK;
}
}

View File

@ -422,6 +422,7 @@ void sock_accept(int n)
fdv[num_fds].device = fdv[n].device;
fdv[num_fds].line_len = 0;
fdv[num_fds].state = 0;
fdv[num_fds].match = 0;
fds[num_fds].fd = sock_n;
fds[num_fds].events = POLLIN;
++num_fds;

View File

@ -909,8 +909,12 @@ pCodri MakeTcpDoChoDriver(char *tclArray, SConnection *pCon){
allocate memory
*/
pNew = (pCodri)malloc(sizeof(Codri));
if(!pNew){
return NULL;
}
self = (pTcpDoCho)malloc(sizeof(TcpDoCho));
if(!pNew || !self){
if(!self){
free(pNew);
return NULL;
}
memset(pNew,0,sizeof(Codri));
@ -952,6 +956,7 @@ pCodri MakeTcpDoChoDriver(char *tclArray, SConnection *pCon){
SCWrite(pCon,"ERROR: number of choppers not in range 1 - 8",eError);
free(pNew);
free(self);
return NULL;
}
self->numChoppers = port;

View File

@ -191,7 +191,11 @@ static int scaqaProtHandler(Ascon *a)
return 0;
}
if (pp->txn.transWait < 0) {
if (GetDynStringLength(a->rdBuffer) == 0) {
a->state = AsconTimeout;
} else {
a->state = AsconReadDone;
}
} else if (pp->txn.transWait == 0) {
a->state = AsconReadDone;
}

View File

@ -203,19 +203,21 @@ static int HttpProtInit(Ascon *a, SConnection *con,
int argc, char *argv[]){
pHttpProt pHttp = NULL;
if(argc < 3){
SCWrite(con,"ERROR: too few arguments in HttpProtInit", eError);
return 0;
}
pHttp = calloc(sizeof(HttpProt), 1);
if(pHttp == NULL){
SCWrite(con,"ERROR: out of memory in HttpProtInit", eError);
return 0;
}
if(argc < 3){
return 0;
}
a->hostport = strdup(argv[1]);
pHttp->binData = (pSICSData)FindCommandData(pServ->pSics,
argv[2], "SICSData");
if(pHttp->binData == NULL){
SCWrite(con,"ERROR: SICSData objct not found", eError);
SCWrite(con,"ERROR: SICSData object not found", eError);
free(pHttp);
return 0;
}
if(argc > 3){

View File

@ -346,7 +346,7 @@
/*--------------------------------------------------------------------------*/
int WEST4100_Query(pWEST4100 *pData, int parAddress, int *parValue)
{
unsigned char pCommand[20], pReply[132], pAddress[1];
unsigned char pCommand[20], pReply[132], pAddress[2];
int iRet;
pWEST4100 self;
@ -374,7 +374,7 @@
/* -------------------------------------------------------------------------*/
int WEST4100_Write(pWEST4100 *pData, int parAddress, int parValue)
{
unsigned char displaytext[20];
unsigned char displaytext[40];
int iRet;
pWEST4100 self;

View File

@ -77,8 +77,9 @@ class MyScreen(Screen):
def main(**kwargs):
global screen, devices, factories
parser = argparse.ArgumentParser( description="Generates fake Galil controllers for testing SICS" )
parser.add_argument("instrument", help="The instrument name")
parser = argparse.ArgumentParser( description='Generates fake Galil controllers for testing SICS' )
parser.add_argument('instrument', help='The instrument name')
parser.add_argument('-w', '--window', help='Create a display window', action='store_true', default=False)
args = parser.parse_args()
basePort = {
@ -89,7 +90,7 @@ def main(**kwargs):
log.startLogging(open(("/tmp/Fake_Galil_%d.log" % basePort[args.instrument]), "w"))
devices = {}
factories = {}
for dev in range(0, 6):
for dev in range(0, 8):
port = basePort[args.instrument] + dev
controllerName = "mc%d" % (dev + 1)
factory = GalilFactory(port)
@ -97,6 +98,7 @@ def main(**kwargs):
factories[controllerName] = factory
reactor.listenTCP(port, factory)
if (args.window):
stdscr = curses.initscr()
screen = MyScreen(stdscr)
reactor.addReader(screen)

View File

@ -1,3 +1,4 @@
#!/usr//bin/env tclsh
# $Revision: 1.1.2.5 $
# $Date: 2010-05-20 00:51:15 $
# Author: Ferdi Franceschini (ffr@ansto.gov.au)

View File

@ -0,0 +1,6 @@
runsics_def.py
bilby_configuration.tcl
config
util
hostport_config.tcl
hostport_config_test.tcl

View File

@ -0,0 +1,63 @@
# Author: Ferdi Franceschini (ffr@ansto.gov.au)
# Required by server_config.tcl
VarMake Instrument Text Internal
Instrument bilby
Instrument lock
#START SERVER CONFIGURATION SECTION
source util/dmc2280/dmc2280_util.tcl
source server_config.tcl
MakeDrive
#END SERVER CONFIGURATION SECTION
########################################
# INSTRUMENT SPECIFIC CONFIGURATION
fileeval $cfPath(motors)/motor_configuration.tcl
fileeval $cfPath(source)/source.tcl
source $cfPath(hipadaba)/hipadaba_configuration.tcl
fileeval $cfPath(motors)/positmotor_configuration.tcl
fileeval $cfPath(velsel)/velsel.tcl
fileeval $cfPath(parameters)/parameters.tcl
fileeval $cfPath(plc)/plc.tcl
fileeval $cfPath(chopper)/chopper.tcl
fileeval $cfPath(optics)/optics.tcl
fileeval $cfPath(counter)/counter.tcl
fileeval $cfPath(environment)/temperature/sct_lakeshore_340.tcl
fileeval $cfPath(environment)/temperature/sct_lakeshore_336.tcl
fileeval $cfPath(hmm)/hmm_configuration.tcl
fileeval $cfPath(nexus)/nxscripts.tcl
fileeval $cfPath(hmm)/detector.tcl
fileeval $cfPath(scan)/scan.tcl
fileeval $cfPath(commands)/commands.tcl
fileeval $cfPath(anticollider)/anticollider.tcl
fileeval $cfPath(environment)/temperature/sct_julabo_lh45.tcl
fileeval $cfPath(environment)/temperature/sct_qlink.tcl
fileeval $cfPath(environment)/temperature/sct_watlow_st4.tcl
fileeval $cfPath(environment)/temperature/sct_watlow_rm.tcl
fileeval $cfPath(environment)/temperature/sct_rvasm2.tcl
fileeval $cfPath(environment)/temperature/sct_oxford_itc.tcl
fileeval $cfPath(environment)/magneticField/oxford_labview.tcl
fileeval $cfPath(environment)/magneticField/sct_bruker_BEC1.tcl
fileeval $cfPath(environment)/environment.tcl
fileeval $cfPath(environment)/sct_rheometer.tcl
fileeval $cfPath(environment)/sct_protek_common.tcl
fileeval $cfPath(beamline)/spin_flipper.tcl
fileeval $cfPath(commands)/pulser.tcl
fileeval $cfPath(commands)/hvcommands.tcl
source gumxml.tcl
::utility::mkVar ::anticollider::protect_detector text manager protect_detector false detector true false
::anticollider::protect_detector "true"
server_init
###########################################
# WARNING: Do not add any code below server_init, if you do SICS may fail to initialise properly.
# You can add extra-configuration code in ../extraconfig.tcl
sicspoll intervall /instrument/detector/max_binrate 1
sicspoll intervall /instrument/detector/total_maprate 1

View File

@ -0,0 +1,32 @@
config/source/sct_reactor_status.tcl
config/source/source.tcl
config/anticollider/anticollider_common.tcl
config/plc/plc_common_1.tcl
config/counter/counter_common_1.tcl
config/hipadaba/hipadaba_configuration_common.tcl
config/hipadaba/common_instrument_dictionary.tcl
config/hipadaba/instdict_specification.tcl
config/hmm/hmm_configuration_common_1.tcl
config/hmm/hmm_object.tcl
config/hmm/anstohm_linked.xml
config/hmm/sct_orhvps_common.tcl
config/scan/scan_common_1.hdd
config/scan/scan_common_1.tcl
config/nexus/nxscripts_common_1.tcl
config/commands/commands_common.tcl
config/commands/pulser.tcl
config/commands/hvcommands.tcl
config/motors/sct_positmotor_common.tcl
config/environment/sct_protek_common.tcl
config/environment/temperature/sct_julabo_lh45.tcl
config/environment/temperature/sct_lakeshore_340.tcl
config/environment/temperature/sct_lakeshore_336.tcl
config/environment/temperature/sct_qlink.tcl
config/environment/temperature/sct_watlow_st4.tcl
config/environment/temperature/sct_rvasm2.tcl
config/environment/temperature/sct_oxford_itc.tcl
config/environment/magneticField/sct_bruker_BEC1.tcl
config/environment/magneticField/sct_oxford_ips.tcl
config/environment/magneticField/sct_oxford_labview.tcl
config/motors/sct_jogmotor_common.tcl

View File

@ -0,0 +1,128 @@
# Author: Ferdi Franceschini (ffr@ansto.gov.au)
fileeval $cfPath(anticollider)/anticollider_common.tcl
namespace eval ::anticollider {
set guide_posit 1
set aperture_posit 2
set apD10_posit 1
set coltol 0.5
set aptol 0.1
for {set n 1} {$n < 8} {incr n} {
foreach {col ap} "col$n ap$n" {
set col_limit [expr [SplitReply [$col posit2unit $aperture_posit]] - $coltol]
set ap_limit [expr [SplitReply [$ap posit2unit $apD10_posit]] - $aptol]
set acrule [subst {forbid {-inf inf} for $ap when $col in {-inf $col_limit} }]
lappend ::anticollider::veto_rules $acrule
set acrule [subst {forbid {-inf inf} for $col when $ap in {$ap_limit inf} }]
lappend ::anticollider::veto_rules $acrule
anticollision register $col
anticollision register $ap
}
}
proc ::anticollider::load_acrules {} {
variable proximity_rules
# Proximity rules have the following form,
# m1 m2 mdist
# This means that the position of m2 is always >= m1 and that a drive or
# run command which tries to drive them closer than mdist will be rejected.
# TODO Abort driving motors registered with the anticollider if one of them
# fails during the drive.
# TESTING WITH SLITS, uncomment this block and the foreach block to test with slits
# set proximity_rules {
# ss1l ss1r 10
# }
# TODO UNCOMMENT FOLLOWING TO ENABLE ANTICOLLISION FOR DETECTOR CARRIAGES
# # Detector carriage proximity rules.
# # det1 = curtain detector
# # det2 = main detector which is at higher y-pos then det1
# set proximity_rules {
# det1 det2 2000
# }
# foreach {m1 m2 minsep} $proximity_rules {
# anticollision register $m1
# anticollision register $m2
# clientput "::anticollider::proximity_rule: $m1 $m2 minsep = $minsep"
# }
}
# @brief Don't allow two axes to get closer than a minimum separation given in the 'proximity_rules' list.
# Assumes that both objects are on the same open track
# Both axes are required to move at the same speed with the same accel and decel values.
# NOTE: Doesn't check that the speeds and accel set by the Galil match what is requested.
# If axes are within the minimum distance then you can only drive them
# apart when the targets are greater than the minimum allowed separation.
proc proximity_script {args} {
set catch_status [ catch {
variable proximity_rules
if {[info exists proximity_rules] == 0} {
return
} elseif {[len $proximity_rules] == 0} {
return
}
foreach {m1 m2 mdist} $proximity_rules {
set final($m1) [SplitReply [$m1]]
set final($m2) [SplitReply [$m2]]
}
foreach {mot val} $args {
set final($mot) $val
}
foreach {mot val} $args {
set rulenum 1
foreach {m1 m2 mdist} $proximity_rules {
if {$m1 != $mot && $m2 != $mot} {
continue
}
if {$mdist <=0} {
error "Minimum separation for $m1 and $m2 must be > 0 in proximity_rule $rulenum"
}
set speed($m1) [SplitReply [$m1 speed]]
set accel($m1) [SplitReply [$m1 accel]]
set decel($m1) [SplitReply [$m1 decel]]
set pos($m1) [SplitReply [$m1]]
set speed($m2) [SplitReply [$m2 speed]]
set accel($m2) [SplitReply [$m2 accel]]
set decel($m2) [SplitReply [$m2 decel]]
set pos($m2) [SplitReply [$m2]]
# NOTE Speed and accel tests assume that the Galil actually sets the
# speeds and accelerations to the same expected steps after taking gear
# ratios, transmission, (something else?) into account on both axes
# when we drive the motors.
if {$speed($m1) != $speed($m2)} {
error "$m1 and $m2 speeds must be equal to ensure they won't collide"
}
if {$accel($m1) != $accel($m2)} {
error "$m1 and $m2 accelerations must be equal to ensure they won't collide"
}
if {$decel($m1) != $decel($m2)} {
error "$m1 and $m2 decelerations must be equal to ensure they won't collide"
}
if {$pos($m2) - $pos($m1) < 0} {
error "Rule($rulenum): $m1 $m2 $mdist seems to be invalid. It assumes that $m2 pos is always >= $m1 pos but $m1 is at $pos($m1) and $m2 is at $pos($m2)"
}
if {$final($m2) - $final($m1) < $mdist} {
error "$m1 and $m2 will violate rule:$rulenum, the minimum allowed separation is positive $mdist"
}
incr rulenum
}
}
} message ]
handle_exception $catch_status $message
}
lappend ::anticollider::scripts ::anticollider::proximity_script
}
# NOTE: This is called with a list of motorname target pairs
proc ::anticollider::enable {args} {
if {[SplitReply [::anticollider::protect_detector]] == "false"} {
return "false"
} else {
return "true"
}
}
::anticollider::loadscript acscript.txt

View File

@ -0,0 +1,34 @@
namespace eval chopper {
variable sim_mode [SplitReply [chopper_simulation]]
set master_chopper_id_simvar 1
}
if {$sim_mode == false} {
MakeAsyncProtocol std
MakeAsyncQueue chopsel std chopsel1-bilby 30000
}
::utility::macro::getset int master_chopper_id {args} {
variable sim_mode [SplitReply [chopper_simulation]]
if {$sim_mode == false} {
if {$args == ""} {
chopsel send {get master chopper}
return "master_chopper_id = [SplitReply [chopsel send {get master chopper}]]"
} else {
chopsel send "get master chopper"
chopsel send "enable chopper selection"
chopsel send "set master chopper=$args"
chopsel send "disable chopper selection"
}
} else {
if {$args == ""} {
return master_chopper_id = $::chopper::master_chopper_id_simvar
} else {
set ::chopper::master_chopper_id_simvar $args
}
}
}
sicslist setatt master_chopper_id klass NXdisk_chopper
sicslist setatt master_chopper_id long_name master_chopper_id
sicslist setatt master_chopper_id mutable false

View File

@ -0,0 +1,216 @@
source $cfPath(commands)/commands_common.tcl
namespace eval motor {
# is_homing_list = comma separated list of motors which are safe to send "home"
variable is_homing_list ""
}
#namespace eval sample {
# command select {int=0:8 sampid} {
# SampleNum $sampid
# }
#}
##
# @brief Beamstop select command
# @param bs beamstop, 1,2,3,4,5 or 6
# @param bx beam position in detector coordinates
# @param bz beam position in detector coordinates
# Given
# (Xbf,Zbf) = beam pos in frame coords
# (Xbd,Zbd) = beam pos in detector coords
# (Xbbs, Zbbs) = beam pos in beamstop coords
# (Xdf,Zdf) = detector pos in frame coords
# (Xbsf,Zbsf) = beamstop pos in frame coords
#
# (Xbf,Zbf) = (Xdf+Xbd, Zdf+Zbd) = (Xbsf+Xbbs, Zbsf+Zbbs)
# Origin of detector coords = frame origin
#
# Detector and beamstop motor readings with beamstop disk centers
# overlapping over detector center mark.
# Xdf = 264.542 (7283813) Zdf = 0
# Xbbs = 296.291 (8054270)
# Zbbs = 259.641 (13488244)
# Xbd = dethw, Zbd = (dethh)
#
# 264.542+dethw = Xbsf+296.291
# 0+dethh = Zbsf+259.641
#
# Xbsf = -31.749 + dethw, Zbsf = -259.641 + dethh
proc selbs {bs {bx "UNDEF"} {bz "UNDEF"}} {
set bsdriving false
set dethw [expr {[SplitReply [detector_active_height_mm]]/2.0}]
set dethh [expr {[SplitReply [detector_active_width_mm]]/2.0}]
set Xbsf [expr -31.749 + $dethw]
set Zbsf [expr -259.641 + $dethh]
array set bsl [subst {
1 [SplitReply [bs1 softlowerlim]]
2 [SplitReply [bs2 softlowerlim]]
3 [SplitReply [bs3 softlowerlim]]
4 [SplitReply [bs4 softlowerlim]]
5 [SplitReply [bs5 softlowerlim]]
6 [SplitReply [bs6 softlowerlim]]
}]
if [ catch {
switch $bs {
"1" {
set bsmot "bs1"
set bs_target 93.20
set bs_diameter 110
set bsdownCmd "drive bs2 $bsl(2) bs3 $bsl(3) bs4 $bsl(4) bs5 $bsl(5) bs6 $bsl(6)"
}
"2" {
set bsmot "bs2"
set bs_target 86.84
set bs_diameter 88
set bsdownCmd "drive bs1 $bsl(1) bs3 $bsl(3) bs4 $bsl(4) bs5 $bsl(5) bs6 $bsl(6)"
}
"3" {
set bsmot "bs3"
set bs_target 93.35
set bs_diameter 66
set bsdownCmd "drive bs2 $bsl(2) bs1 $bsl(1) bs4 $bsl(4) bs5 $bsl(5) bs6 $bsl(6)"
}
"4" {
set bsmot "bs4"
set bs_target 86.85
set bs_diameter 44
set bsdownCmd "drive bs2 $bsl(2) bs3 $bsl(3) bs1 $bsl(1) bs5 $bsl(5) bs6 $bsl(6)"
}
"5" {
set bsmot "bs5"
set bs_target 93.27
set bs_diameter 22
set bsdownCmd "drive bs2 $bsl(2) bs3 $bsl(3) bs4 $bsl(4) bs1 $bsl(1) bs6 $bsl(6)"
}
"6" {
set bsmot "bs6"
set bs_target 86.98
set bs_diameter 11
set bsdownCmd "drive bs2 $bsl(2) bs3 $bsl(3) bs4 $bsl(4) bs5 $bsl(5) bs1 $bsl(1)"
}
default {
error "beamstop selection must be an integer from 1 to 6"
}
}
set detoff_val [SplitReply [detoff]]
if {$bx == "UNDEF" || $bz == "UNDEF"} {
statemon start selbs
if {[info level] > 1} {statemon start [lindex [info level -1] 0]}
set bsdriving true
BeamStop -1
BSdiam -1
drive $bsmot $bs_target
eval $bsdownCmd
BeamStop $bs
BSdiam $bs_diameter
set bsdriving false
statemon stop selbs
if {[info level] > 1} {statemon stop [lindex [info level -1] 0]}
} else {
if { [string is double $bx] == false } {
if { [string is double $bz] == false } {
error "beam coordinates must be floats"
}
}
set bsx_target [expr {$bx-$Xbsf+$detoff_val}]
set bsz_target [expr {$bz-$Zbsf}]
statemon start selbs
if {[info level] > 1} {statemon start [lindex [info level -1] 0]}
set bsdriving true
BeamStop -1
BSdiam -1
drive $bsmot $bs_target bsx $bsx_target bsz $bsz_target
eval $bsdownCmd
BeamStop $bs
BSdiam $bs_diameter
set bsdriving false
statemon stop selbs
if {[info level] > 1} {statemon stop [lindex [info level -1] 0]}
}
} msg ] {
if {$bsdriving} {
statemon stop selbs
if {[info level] > 1} {statemon stop [lindex [info level -1] 0]}
}
return -code error $msg
}
}
publish selbs user
namespace eval beamstops {
command selbsn {int=1,2,3,4,5,6 bs} {
selbs $bs "UNDEF" "UNDEF"
}
command selbsxz {int=1,2,3,4,5,6 bs float bx float bz} {
selbs $bs $bx $bz
}
}
namespace eval optics {
VarMake ::optics::select::section text user
VarMake ::optics::polarizer::in text user
VarMake ::optics::lens::selection text user
command rotary_attenuator {int=0,15,45,90,180 angle} {
drive att $angle
}
command entrance_aperture {
int=0,45,90,135,180,270 angle
} {
drive srce $angle
}
# TODO Do we need this
# command sample_aperture {
# int=25,50 size
# text=circ,squ,open,rect shape
# } {
# SApXmm $size
# SApZmm $size
# SApShape $shape
# }
##############################
##
# @brief The "guide" command uses a lookup table to setup the collimation system
# @param row, selects a row from the guide configuration table
#
# eg\n
# guide ga
command guide "
text=[join [array names ::optics::guide_configuration] , ] configuration
" {
variable guide_configuration
variable guide_configuration_columns
if [ catch {
foreach {compselection position} $guide_configuration($configuration) {
foreach el $compselection guide $guide_configuration_columns {
lappend to_config $guide
lappend to_config [set ::optics::${guide}_map($el)]
}
::optics::guide -set feedback status BUSY
set msg [eval "drive $to_config"]
EApPosY $position
}
GuideConfig $configuration
} message ] {
::optics::guide -set feedback status IDLE
if {$::errorCode=="NONE"} {return $message}
return -code error $message
}
::optics::guide -set feedback status IDLE
}
::optics::guide -addfb text status
::optics::guide -set feedback status IDLE
}
proc ::commands::isc_initialize {} {
::commands::ic_initialize
}

View File

@ -0,0 +1,32 @@
source $cfPath(counter)/counter_common_1.tcl
## TODO Put all the counter macros in the counter namespace
namespace eval counter {
variable isc_numchannels
variable isc_monitor_address
variable isc_portlist
variable isc_beam_monitor_list
proc set_sobj_attributes {} {
}
}
proc ::counter::isc_initialize {} {
if [catch {
variable isc_numchannels
variable isc_monitor_address
variable isc_portlist
dict for {k v} $::MONITOR_HOSTPORT {
lappend monlist $k
lappend hostlist [dict get $v HOST]
lappend isc_portlist [dict get $v PORT]
}
variable isc_beam_monitor_list $monlist
set isc_monitor_address [lindex $hostlist 0]
set isc_numchannels [llength $isc_beam_monitor_list]
::counter::ic_initialize
} message ] {
if {$::errorCode=="NONE"} {return $message}
return -code error "$message"
}
}

View File

@ -0,0 +1 @@
source $cfPath(hipadaba)/hipadaba_configuration_common.tcl

View File

@ -0,0 +1,70 @@
fileeval $cfPath(hmm)/hmm_configuration_common_1.tcl
set sim_mode [SplitReply [hmm_simulation]]
proc ::histogram_memory::init_OAT_TABLE {} {
if [ catch {
# We don't need a MAX_CHAN parameter for time because the time channel
# is scaled by calling the ::histogram_memory::clock_scale function
OAT_TABLE X -setdata MAX_CHAN 240
OAT_TABLE Y -setdata MAX_CHAN 256
OAT_TABLE X -setdata BMIN -0.5
OAT_TABLE X -setdata BMAX 239.5
OAT_TABLE Y -setdata BMIN -0.5
OAT_TABLE Y -setdata BMAX 255.5
set clock_scale 1000
set freq 50
hmm configure fat_clock_scale $clock_scale
hmm configure fat_frame_frequency $freq
hmm configure fat_frame_source INTERNAL
OAT_TABLE -set X { 239.5 238.5 } NXC 240 Y { -0.5 0.5 } NYC 256 T { 0 20000 } NTC 1
} message ] {
return -code error $message
}
}
proc ::histogram_memory::pre_count {} {}
proc ::histogram_memory::post_count {} {}
proc ::histogram_memory::isc_initialize {} {
# Instrument specific X and Y dimension names
variable INST_NXC "oat_nxc_eff"
variable INST_NYC "oat_nyc_eff"
if [ catch {
::histogram_memory::init_hmm_objs
if {$::sim_mode == "true"} {
hmm configure oat_ntc_eff 1
hmm configure $INST_NYC 256
hmm configure $INST_NXC 240
}
BAT_TABLE -init
CAT_TABLE -init
SAT_TABLE -init
OAT_TABLE -init
FAT_TABLE -init
::histogram_memory::ic_initialize
detector_active_height_mm [expr 5.08 * 256]
detector_active_width_mm [expr 5.08 * 240]
detector_active_height_mm lock
detector_active_width_mm lock
# hmm configure FAT_SIMULATED_EVENT_Y0 $y_bb0
# hmm configure FAT_SIMULATED_EVENT_Y1 $ybbmax
# hmm configure FAT_SIMULATED_EVENT_X0 $x_bb0
# hmm configure FAT_SIMULATED_EVENT_X1 $xbbmax
::histogram_memory::init_OAT_TABLE
::histogram_memory::upload_config Filler_defaults
set ::histogram_memory::histmem_axes(HOR) /instrument/detector/x_pixel_offset
set ::histogram_memory::histmem_axes(VER) /instrument/detector/y_pixel_offset
} message ] {
return -code error $message
}
}
proc histmem {cmd args} {
eval "_histmem $cmd $args"
}
publish histmem user

View File

@ -0,0 +1,464 @@
ap1_100X40,110608
ap1_40X40,102604
ap1_axis,A
ap1_axis_number,1
ap1_cnts_per_x,364.088888888889
ap1_D10,86208
ap1_D20,91680
ap1_D40,97116
ap1_description,Aperture Selector (Collimator SEG 1 Start)
ap1_dflt_accel_steps,50000
ap1_dflt_decel_steps,50000
ap1_dflt_speed_steps,50000
ap1_fwd_enc_lim,112188
ap1_maxaccel,2.8125
ap1_maxdecel,2.8125
ap1_maxspeed,2.8125
ap1_mc,mc1
ap1_rev_enc_lim,73952
ap1_steps_per_x,35555.5555555556
ap2_100X40,93637
ap2_40X40,85637
ap2_axis,B
ap2_axis_number,2
ap2_cnts_per_x,364.088888888889
ap2_D10,69193
ap2_D20,74677
ap2_D40,80149
ap2_description,Aperture Selector (COLLIMATION SEG 2)
ap2_dflt_accel_steps,50000
ap2_dflt_decel_steps,50000
ap2_dflt_speed_steps,50000
ap2_fwd_enc_lim,95461
ap2_maxaccel,2.8125
ap2_maxdecel,2.8125
ap2_maxspeed,2.8125
ap2_mc,mc1
ap2_rev_enc_lim,54293
ap2_steps_per_x,35555.5555555556
ap3_100X40,49584
ap3_40X40,41532
ap3_axis,C
ap3_axis_number,3
ap3_cnts_per_x,364.088888888889
ap3_D10,25168
ap3_D20,30656
ap3_D40,36080
ap3_description,Aperture Selector (COLLIMATION SEG 3)
ap3_dflt_accel_steps,50000
ap3_dflt_decel_steps,50000
ap3_dflt_speed_steps,50000
ap3_fwd_enc_lim,51616
ap3_maxaccel,2.8125
ap3_maxdecel,2.8125
ap3_maxspeed,2.8125
ap3_mc,mc1
ap3_rev_enc_lim,13644
ap3_steps_per_x,35555.5555555556
ap4_100X40,43506
ap4_40X40,35490
ap4_axis,D
ap4_axis_number,4
ap4_cnts_per_x,364.088888888889
ap4_D10,19118
ap4_D20,24578
ap4_D40,30038
ap4_description,Aperture Selector (COLLIMATION SEG 4)
ap4_dflt_accel_steps,50000
ap4_dflt_decel_steps,50000
ap4_dflt_speed_steps,50000
ap4_fwd_enc_lim,45234
ap4_maxaccel,2.8125
ap4_maxdecel,2.8125
ap4_maxspeed,2.8125
ap4_mc,mc1
ap4_rev_enc_lim,5666
ap4_steps_per_x,35555.5555555556
ap5_100X40,109480
ap5_40X40,101476
ap5_axis,E
ap5_axis_number,5
ap5_cnts_per_x,364.088888888889
ap5_D10,85076
ap5_D20,90552
ap5_D40,96008
ap5_description,Aperture Selector (COLLIMATION SEG 5)
ap5_dflt_accel_steps,50000
ap5_dflt_decel_steps,50000
ap5_dflt_speed_steps,50000
ap5_fwd_enc_lim,110696
ap5_maxaccel,2.8125
ap5_maxdecel,2.8125
ap5_maxspeed,2.8125
ap5_mc,mc1
ap5_rev_enc_lim,72824
ap5_steps_per_x,35555.5555555556
ap6_100X40,110499
ap6_40X40,102419
ap6_axis,F
ap6_axis_number,6
ap6_cnts_per_x,364.088888888889
ap6_D10,86097
ap6_D20,91587
ap6_D40,97011
ap6_description,Aperture Selector (COLLIMATION SEG 6)
ap6_dflt_accel_steps,50000
ap6_dflt_decel_steps,50000
ap6_dflt_speed_steps,50000
ap6_fwd_enc_lim,112435
ap6_maxaccel,2.8125
ap6_maxdecel,2.8125
ap6_maxspeed,2.8125
ap6_mc,mc1
ap6_rev_enc_lim,72115
ap6_steps_per_x,35555.5555555556
ap7_100X40,110371
ap7_40X40,102343
ap7_axis,G
ap7_axis_number,7
ap7_cnts_per_x,364.088888888889
ap7_D10,85929
ap7_D20,91399
ap7_D40,96871
ap7_description,Aperture Selector (COLLIMATION SEG 7)
ap7_dflt_accel_steps,50000
ap7_dflt_decel_steps,50000
ap7_dflt_speed_steps,50000
ap7_fwd_enc_lim,112391
ap7_maxaccel,2.8125
ap7_maxdecel,2.8125
ap7_maxspeed,2.8125
ap7_mc,mc1
ap7_rev_enc_lim,74299
ap7_steps_per_x,35555.5555555556
ap8_100X40,46069
ap8_40X40,38027
ap8_axis,H
ap8_axis_number,8
ap8_cnts_per_x,364.088888888889
ap8_D10,21657
ap8_D20,27115
ap8_D40,32629
ap8_description,Aperture Selector (Collimator SEG 8 End)
ap8_dflt_accel_steps,50000
ap8_dflt_decel_steps,50000
ap8_dflt_speed_steps,50000
ap8_fwd_enc_lim,47639
ap8_maxaccel,2.8125
ap8_maxdecel,2.8125
ap8_maxspeed,2.8125
ap8_mc,mc1
ap8_rev_enc_lim,6791
ap8_steps_per_x,35555.5555555556
att_axis,A
att_axis_number,25
att_cnts_per_x,-1365.33333333333
att_description,4 Position linear Attenuator
att_dflt_accel_steps,15000
att_dflt_decel_steps,15000
att_dflt_speed_steps,15000
att_fwd_enc_lim,33394989
att_maxaccel,3.6
att_maxdecel,3.6
att_maxspeed,3.6
att_mc,mc4
att_pos1,33373433
att_pos2,33291514
att_pos3,33209595
att_pos4,33127674
att_pos5,33045750
att_rev_enc_lim,33021197
att_steps_per_x,-4166.66666666667
bs3_axis,C
bs3_axis_number,43
bs3_cnts_per_x,728.177777777778
bs3_description,beam stop 3
bs3_dflt_accel_steps,12500
bs3_dflt_decel_steps,12500
bs3_dflt_speed_steps,12500
bs3_fwd_enc_lim,300855
bs3_maxaccel,5.625
bs3_maxdecel,5.625
bs3_maxspeed,5.625
bs3_mc,mc6
bs3_rev_enc_lim,351548
bs3_steps_per_x,2222.22222222222
cdd_axis,F
cdd_axis_number,62
cdd_cnts_per_x,32768
cdd_description,CURTAIN DETECTOR BOTTOM TRANSLATION
cdd_dflt_accel_steps,25000
cdd_dflt_decel_steps,25000
cdd_dflt_speed_steps,150000
cdd_fwd_enc_lim,15618875
cdd_maxaccel,8
cdd_maxdecel,8
cdd_maxspeed,8
cdd_mc,mc8
cdd_rev_enc_lim,4159255
cdd_steps_per_x,100000
cdl_axis,C
cdl_axis_number,59
cdl_cnts_per_x,32768
cdl_description,CURTAIN DETECTOR WEST TRANSLATION
cdl_dflt_accel_steps,25000
cdl_dflt_decel_steps,25000
cdl_dflt_speed_steps,150000
cdl_fwd_enc_lim,17466632
cdl_maxaccel,8
cdl_maxdecel,8
cdl_maxspeed,8
cdl_mc,mc8
cdl_rev_enc_lim,5769621
cdl_steps_per_x,100000
cdr_axis,D
cdr_axis_number,60
cdr_cnts_per_x,32768
cdr_description,CURTAIN DETECTOR EAST TRANSLATION
cdr_dflt_accel_steps,25000
cdr_dflt_decel_steps,25000
cdr_dflt_speed_steps,150000
cdr_fwd_enc_lim,16104612
cdr_maxaccel,8
cdr_maxdecel,8
cdr_maxspeed,8
cdr_mc,mc8
cdr_rev_enc_lim,4371043
cdr_steps_per_x,100000
cdu_axis,E
cdu_axis_number,61
cdu_cnts_per_x,32768
cdu_description,CURTAIN DETECTOR TOP TRANSLATION
cdu_dflt_accel_steps,25000
cdu_dflt_decel_steps,25000
cdu_dflt_speed_steps,150000
cdu_fwd_enc_lim,33499670
cdu_maxaccel,8
cdu_maxdecel,8
cdu_maxspeed,8
cdu_mc,mc8
cdu_rev_enc_lim,21804679
cdu_steps_per_x,100000
col1_axis,A
col1_axis_number,9
col1_cnts_per_x,2048
col1_description,Collimator Trans (Col SEG 1) VH
col1_dflt_accel_steps,50000
col1_dflt_decel_steps,50000
col1_dflt_speed_steps,100000
col1_empty,541261
col1_fwd_enc_lim,557470
col1_guide,262369
col1_maxaccel,0.833333333333333
col1_maxdecel,0.833333333333333
col1_maxspeed,0.833333333333333
col1_mc,mc2
col1_rev_enc_lim,3902
col1_steps_per_x,150000
col2_axis,B
col2_axis_number,10
col2_cnts_per_x,2048
col2_description,Collimator Trans (Col SEG 2) VH
col2_dflt_accel_steps,50000
col2_dflt_decel_steps,50000
col2_dflt_speed_steps,100000
col2_empty,546816
col2_fwd_enc_lim,564598
col2_guide,273591
col2_maxaccel,0.833333333333333
col2_maxdecel,0.833333333333333
col2_maxspeed,0.833333333333333
col2_mc,mc2
col2_rev_enc_lim,9598
col2_steps_per_x,150000
col3_axis,C
col3_axis_number,11
col3_cnts_per_x,2048
col3_description,Collimator Trans (Col SEG 3) VH
col3_dflt_accel_steps,50000
col3_dflt_decel_steps,50000
col3_dflt_speed_steps,100000
col3_empty,558462
col3_fwd_enc_lim,578556
col3_guide,287471
col3_maxaccel,0.833333333333333
col3_maxdecel,0.833333333333333
col3_maxspeed,0.833333333333333
col3_mc,mc2
col3_rev_enc_lim,29466
col3_steps_per_x,150000
col4_axis,D
col4_axis_number,12
col4_cnts_per_x,4096
col4_description,Collimator Trans (Col SEG 4) VH
col4_dflt_accel_steps,50000
col4_dflt_decel_steps,50000
col4_dflt_speed_steps,100000
col4_empty,1062105
col4_fwd_enc_lim,1116447
col4_guide,539261
col4_maxaccel,0.833333333333333
col4_maxdecel,0.833333333333333
col4_maxspeed,0.833333333333333
col4_mc,mc2
col4_rev_enc_lim,12861
col4_steps_per_x,150000
col5_axis,E
col5_axis_number,13
col5_cnts_per_x,2048
col5_description,Collimator Trans (Col SEG 5) VH
col5_dflt_accel_steps,50000
col5_dflt_decel_steps,50000
col5_dflt_speed_steps,100000
col5_empty,904072
col5_fwd_enc_lim,928235
col5_guide,644380
col5_maxaccel,0.833333333333333
col5_maxdecel,0.833333333333333
col5_maxspeed,0.833333333333333
col5_mc,mc2
col5_rev_enc_lim,377801
col5_steps_per_x,150000
col6_axis,F
col6_axis_number,14
col6_cnts_per_x,2048
col6_description,Collimator Trans (Col SEG 6) VH
col6_dflt_accel_steps,50000
col6_dflt_decel_steps,50000
col6_dflt_speed_steps,100000
col6_empty,721132
col6_fwd_enc_lim,747130
col6_guide,457285
col6_maxaccel,0.833333333333333
col6_maxdecel,0.833333333333333
col6_maxspeed,0.833333333333333
col6_mc,mc2
col6_rev_enc_lim,191508
col6_steps_per_x,150000
col7_axis,G
col7_axis_number,15
col7_cnts_per_x,2048
col7_description,Collimator Trans (Col SEG 7) VH
col7_dflt_accel_steps,50000
col7_dflt_decel_steps,50000
col7_dflt_speed_steps,100000
col7_empty,555984
col7_fwd_enc_lim,577633
col7_guide,288216
col7_maxaccel,0.833333333333333
col7_maxdecel,0.833333333333333
col7_maxspeed,0.833333333333333
col7_mc,mc2
col7_rev_enc_lim,24810
col7_steps_per_x,150000
col8_axis,H
col8_axis_number,16
col8_cnts_per_x,2048
col8_description,Collimator Trans (Col SEG 8) VH
col8_dflt_accel_steps,50000
col8_dflt_decel_steps,50000
col8_dflt_speed_steps,100000
col8_empty,538544
col8_fwd_enc_lim,561091
col8_guide,273474
col8_maxaccel,0.833333333333333
col8_maxdecel,0.833333333333333
col8_maxspeed,0.833333333333333
col8_mc,mc2
col8_rev_enc_lim,12893
col8_steps_per_x,150000
det_axis,B
det_axis_number,58
det_cnts_per_x,524.288
det_description,CURTAIN DETECTOR CARRIAGE Y TRANS
det_dflt_accel_steps,25000
det_dflt_decel_steps,25000
det_dflt_speed_steps,100000
det_fwd_enc_lim,0
det_maxaccel,25
det_maxdecel,25
det_maxspeed,25
det_mc,mc8
det_rev_enc_lim,0
det_steps_per_x,3900
sdh_5a_in,1535698
sdh_5b_in,3747542
sdh_axis,B
sdh_axis_number,26
sdh_cnts_per_x,-12288
sdh_description,SDH Box
sdh_fwd_enc_lim,1189505
sdh_mc,mc4
sdh_rev_enc_lim,4166803
sdh_steps_per_x,37500
ss1d_axis,D
ss1d_axis_number,20
ss1d_cnts_per_x,-16384
ss1d_description,Slit System 1 - Z DOWN
ss1d_dflt_accel_steps,25000
ss1d_dflt_decel_steps,25000
ss1d_dflt_speed_steps,25000
ss1d_fwd_enc_lim,31525131
ss1d_maxaccel,1
ss1d_maxdecel,1
ss1d_maxspeed,1
ss1d_mc,mc3
ss1d_rev_enc_lim,33398312
ss1d_steps_per_x,50000
ss1l_axis,A
ss1l_axis_number,17
ss1l_cnts_per_x,16384
ss1l_description,Slit System 1 - X WEST
ss1l_dflt_accel_steps,25000
ss1l_dflt_decel_steps,25000
ss1l_dflt_speed_steps,25000
ss1l_fwd_enc_lim,31524107
ss1l_maxaccel,1
ss1l_maxdecel,1
ss1l_maxspeed,1
ss1l_mc,mc3
ss1l_rev_enc_lim,32637740
ss1l_steps_per_x,-50000
ss1r_axis,C
ss1r_axis_number,19
ss1r_cnts_per_x,16384
ss1r_description,Slit System 1 - X EAST
ss1r_dflt_accel_steps,25000
ss1r_dflt_decel_steps,25000
ss1r_dflt_speed_steps,25000
ss1r_fwd_enc_lim,32248545
ss1r_maxaccel,1
ss1r_maxdecel,1
ss1r_maxspeed,1
ss1r_mc,mc3
ss1r_rev_enc_lim,33421848
ss1r_steps_per_x,-50000
ss1u_axis,B
ss1u_axis_number,18
ss1u_cnts_per_x,-16384
ss1u_description,Slit System 1 - Z UP
ss1u_dflt_accel_steps,25000
ss1u_dflt_decel_steps,25000
ss1u_dflt_speed_steps,25000
ss1u_fwd_enc_lim,31434607
ss1u_maxaccel,1
ss1u_maxdecel,1
ss1u_maxspeed,1
ss1u_mc,mc3
ss1u_rev_enc_lim,33297987
ss1u_steps_per_x,50000
vs_axis,D
vs_axis_number,28
vs_cnts_per_x,-12288
vs_description,Velocity Selector Trans
vs_dflt_accel_steps,15000
vs_dflt_decel_steps,50000
vs_dflt_speed_steps,50000
vs_fwd_enc_lim,406690
vs_glass_in,741128
vs_maxaccel,1.33333333333333
vs_maxdecel,1.33333333333333
vs_maxspeed,1.33333333333333
vs_mc,mc4
vs_rev_enc_lim,3789130
vs_steps_per_x,37500
1 ap1_100X40 110608
2 ap1_40X40 102604
3 ap1_axis A
4 ap1_axis_number 1
5 ap1_cnts_per_x 364.088888888889
6 ap1_D10 86208
7 ap1_D20 91680
8 ap1_D40 97116
9 ap1_description Aperture Selector (Collimator SEG 1 Start)
10 ap1_dflt_accel_steps 50000
11 ap1_dflt_decel_steps 50000
12 ap1_dflt_speed_steps 50000
13 ap1_fwd_enc_lim 112188
14 ap1_maxaccel 2.8125
15 ap1_maxdecel 2.8125
16 ap1_maxspeed 2.8125
17 ap1_mc mc1
18 ap1_rev_enc_lim 73952
19 ap1_steps_per_x 35555.5555555556
20 ap2_100X40 93637
21 ap2_40X40 85637
22 ap2_axis B
23 ap2_axis_number 2
24 ap2_cnts_per_x 364.088888888889
25 ap2_D10 69193
26 ap2_D20 74677
27 ap2_D40 80149
28 ap2_description Aperture Selector (COLLIMATION SEG 2)
29 ap2_dflt_accel_steps 50000
30 ap2_dflt_decel_steps 50000
31 ap2_dflt_speed_steps 50000
32 ap2_fwd_enc_lim 95461
33 ap2_maxaccel 2.8125
34 ap2_maxdecel 2.8125
35 ap2_maxspeed 2.8125
36 ap2_mc mc1
37 ap2_rev_enc_lim 54293
38 ap2_steps_per_x 35555.5555555556
39 ap3_100X40 49584
40 ap3_40X40 41532
41 ap3_axis C
42 ap3_axis_number 3
43 ap3_cnts_per_x 364.088888888889
44 ap3_D10 25168
45 ap3_D20 30656
46 ap3_D40 36080
47 ap3_description Aperture Selector (COLLIMATION SEG 3)
48 ap3_dflt_accel_steps 50000
49 ap3_dflt_decel_steps 50000
50 ap3_dflt_speed_steps 50000
51 ap3_fwd_enc_lim 51616
52 ap3_maxaccel 2.8125
53 ap3_maxdecel 2.8125
54 ap3_maxspeed 2.8125
55 ap3_mc mc1
56 ap3_rev_enc_lim 13644
57 ap3_steps_per_x 35555.5555555556
58 ap4_100X40 43506
59 ap4_40X40 35490
60 ap4_axis D
61 ap4_axis_number 4
62 ap4_cnts_per_x 364.088888888889
63 ap4_D10 19118
64 ap4_D20 24578
65 ap4_D40 30038
66 ap4_description Aperture Selector (COLLIMATION SEG 4)
67 ap4_dflt_accel_steps 50000
68 ap4_dflt_decel_steps 50000
69 ap4_dflt_speed_steps 50000
70 ap4_fwd_enc_lim 45234
71 ap4_maxaccel 2.8125
72 ap4_maxdecel 2.8125
73 ap4_maxspeed 2.8125
74 ap4_mc mc1
75 ap4_rev_enc_lim 5666
76 ap4_steps_per_x 35555.5555555556
77 ap5_100X40 109480
78 ap5_40X40 101476
79 ap5_axis E
80 ap5_axis_number 5
81 ap5_cnts_per_x 364.088888888889
82 ap5_D10 85076
83 ap5_D20 90552
84 ap5_D40 96008
85 ap5_description Aperture Selector (COLLIMATION SEG 5)
86 ap5_dflt_accel_steps 50000
87 ap5_dflt_decel_steps 50000
88 ap5_dflt_speed_steps 50000
89 ap5_fwd_enc_lim 110696
90 ap5_maxaccel 2.8125
91 ap5_maxdecel 2.8125
92 ap5_maxspeed 2.8125
93 ap5_mc mc1
94 ap5_rev_enc_lim 72824
95 ap5_steps_per_x 35555.5555555556
96 ap6_100X40 110499
97 ap6_40X40 102419
98 ap6_axis F
99 ap6_axis_number 6
100 ap6_cnts_per_x 364.088888888889
101 ap6_D10 86097
102 ap6_D20 91587
103 ap6_D40 97011
104 ap6_description Aperture Selector (COLLIMATION SEG 6)
105 ap6_dflt_accel_steps 50000
106 ap6_dflt_decel_steps 50000
107 ap6_dflt_speed_steps 50000
108 ap6_fwd_enc_lim 112435
109 ap6_maxaccel 2.8125
110 ap6_maxdecel 2.8125
111 ap6_maxspeed 2.8125
112 ap6_mc mc1
113 ap6_rev_enc_lim 72115
114 ap6_steps_per_x 35555.5555555556
115 ap7_100X40 110371
116 ap7_40X40 102343
117 ap7_axis G
118 ap7_axis_number 7
119 ap7_cnts_per_x 364.088888888889
120 ap7_D10 85929
121 ap7_D20 91399
122 ap7_D40 96871
123 ap7_description Aperture Selector (COLLIMATION SEG 7)
124 ap7_dflt_accel_steps 50000
125 ap7_dflt_decel_steps 50000
126 ap7_dflt_speed_steps 50000
127 ap7_fwd_enc_lim 112391
128 ap7_maxaccel 2.8125
129 ap7_maxdecel 2.8125
130 ap7_maxspeed 2.8125
131 ap7_mc mc1
132 ap7_rev_enc_lim 74299
133 ap7_steps_per_x 35555.5555555556
134 ap8_100X40 46069
135 ap8_40X40 38027
136 ap8_axis H
137 ap8_axis_number 8
138 ap8_cnts_per_x 364.088888888889
139 ap8_D10 21657
140 ap8_D20 27115
141 ap8_D40 32629
142 ap8_description Aperture Selector (Collimator SEG 8 End)
143 ap8_dflt_accel_steps 50000
144 ap8_dflt_decel_steps 50000
145 ap8_dflt_speed_steps 50000
146 ap8_fwd_enc_lim 47639
147 ap8_maxaccel 2.8125
148 ap8_maxdecel 2.8125
149 ap8_maxspeed 2.8125
150 ap8_mc mc1
151 ap8_rev_enc_lim 6791
152 ap8_steps_per_x 35555.5555555556
153 att_axis A
154 att_axis_number 25
155 att_cnts_per_x -1365.33333333333
156 att_description 4 Position linear Attenuator
157 att_dflt_accel_steps 15000
158 att_dflt_decel_steps 15000
159 att_dflt_speed_steps 15000
160 att_fwd_enc_lim 33394989
161 att_maxaccel 3.6
162 att_maxdecel 3.6
163 att_maxspeed 3.6
164 att_mc mc4
165 att_pos1 33373433
166 att_pos2 33291514
167 att_pos3 33209595
168 att_pos4 33127674
169 att_pos5 33045750
170 att_rev_enc_lim 33021197
171 att_steps_per_x -4166.66666666667
172 bs3_axis C
173 bs3_axis_number 43
174 bs3_cnts_per_x 728.177777777778
175 bs3_description beam stop 3
176 bs3_dflt_accel_steps 12500
177 bs3_dflt_decel_steps 12500
178 bs3_dflt_speed_steps 12500
179 bs3_fwd_enc_lim 300855
180 bs3_maxaccel 5.625
181 bs3_maxdecel 5.625
182 bs3_maxspeed 5.625
183 bs3_mc mc6
184 bs3_rev_enc_lim 351548
185 bs3_steps_per_x 2222.22222222222
186 cdd_axis F
187 cdd_axis_number 62
188 cdd_cnts_per_x 32768
189 cdd_description CURTAIN DETECTOR BOTTOM TRANSLATION
190 cdd_dflt_accel_steps 25000
191 cdd_dflt_decel_steps 25000
192 cdd_dflt_speed_steps 150000
193 cdd_fwd_enc_lim 15618875
194 cdd_maxaccel 8
195 cdd_maxdecel 8
196 cdd_maxspeed 8
197 cdd_mc mc8
198 cdd_rev_enc_lim 4159255
199 cdd_steps_per_x 100000
200 cdl_axis C
201 cdl_axis_number 59
202 cdl_cnts_per_x 32768
203 cdl_description CURTAIN DETECTOR WEST TRANSLATION
204 cdl_dflt_accel_steps 25000
205 cdl_dflt_decel_steps 25000
206 cdl_dflt_speed_steps 150000
207 cdl_fwd_enc_lim 17466632
208 cdl_maxaccel 8
209 cdl_maxdecel 8
210 cdl_maxspeed 8
211 cdl_mc mc8
212 cdl_rev_enc_lim 5769621
213 cdl_steps_per_x 100000
214 cdr_axis D
215 cdr_axis_number 60
216 cdr_cnts_per_x 32768
217 cdr_description CURTAIN DETECTOR EAST TRANSLATION
218 cdr_dflt_accel_steps 25000
219 cdr_dflt_decel_steps 25000
220 cdr_dflt_speed_steps 150000
221 cdr_fwd_enc_lim 16104612
222 cdr_maxaccel 8
223 cdr_maxdecel 8
224 cdr_maxspeed 8
225 cdr_mc mc8
226 cdr_rev_enc_lim 4371043
227 cdr_steps_per_x 100000
228 cdu_axis E
229 cdu_axis_number 61
230 cdu_cnts_per_x 32768
231 cdu_description CURTAIN DETECTOR TOP TRANSLATION
232 cdu_dflt_accel_steps 25000
233 cdu_dflt_decel_steps 25000
234 cdu_dflt_speed_steps 150000
235 cdu_fwd_enc_lim 33499670
236 cdu_maxaccel 8
237 cdu_maxdecel 8
238 cdu_maxspeed 8
239 cdu_mc mc8
240 cdu_rev_enc_lim 21804679
241 cdu_steps_per_x 100000
242 col1_axis A
243 col1_axis_number 9
244 col1_cnts_per_x 2048
245 col1_description Collimator Trans (Col SEG 1) VH
246 col1_dflt_accel_steps 50000
247 col1_dflt_decel_steps 50000
248 col1_dflt_speed_steps 100000
249 col1_empty 541261
250 col1_fwd_enc_lim 557470
251 col1_guide 262369
252 col1_maxaccel 0.833333333333333
253 col1_maxdecel 0.833333333333333
254 col1_maxspeed 0.833333333333333
255 col1_mc mc2
256 col1_rev_enc_lim 3902
257 col1_steps_per_x 150000
258 col2_axis B
259 col2_axis_number 10
260 col2_cnts_per_x 2048
261 col2_description Collimator Trans (Col SEG 2) VH
262 col2_dflt_accel_steps 50000
263 col2_dflt_decel_steps 50000
264 col2_dflt_speed_steps 100000
265 col2_empty 546816
266 col2_fwd_enc_lim 564598
267 col2_guide 273591
268 col2_maxaccel 0.833333333333333
269 col2_maxdecel 0.833333333333333
270 col2_maxspeed 0.833333333333333
271 col2_mc mc2
272 col2_rev_enc_lim 9598
273 col2_steps_per_x 150000
274 col3_axis C
275 col3_axis_number 11
276 col3_cnts_per_x 2048
277 col3_description Collimator Trans (Col SEG 3) VH
278 col3_dflt_accel_steps 50000
279 col3_dflt_decel_steps 50000
280 col3_dflt_speed_steps 100000
281 col3_empty 558462
282 col3_fwd_enc_lim 578556
283 col3_guide 287471
284 col3_maxaccel 0.833333333333333
285 col3_maxdecel 0.833333333333333
286 col3_maxspeed 0.833333333333333
287 col3_mc mc2
288 col3_rev_enc_lim 29466
289 col3_steps_per_x 150000
290 col4_axis D
291 col4_axis_number 12
292 col4_cnts_per_x 4096
293 col4_description Collimator Trans (Col SEG 4) VH
294 col4_dflt_accel_steps 50000
295 col4_dflt_decel_steps 50000
296 col4_dflt_speed_steps 100000
297 col4_empty 1062105
298 col4_fwd_enc_lim 1116447
299 col4_guide 539261
300 col4_maxaccel 0.833333333333333
301 col4_maxdecel 0.833333333333333
302 col4_maxspeed 0.833333333333333
303 col4_mc mc2
304 col4_rev_enc_lim 12861
305 col4_steps_per_x 150000
306 col5_axis E
307 col5_axis_number 13
308 col5_cnts_per_x 2048
309 col5_description Collimator Trans (Col SEG 5) VH
310 col5_dflt_accel_steps 50000
311 col5_dflt_decel_steps 50000
312 col5_dflt_speed_steps 100000
313 col5_empty 904072
314 col5_fwd_enc_lim 928235
315 col5_guide 644380
316 col5_maxaccel 0.833333333333333
317 col5_maxdecel 0.833333333333333
318 col5_maxspeed 0.833333333333333
319 col5_mc mc2
320 col5_rev_enc_lim 377801
321 col5_steps_per_x 150000
322 col6_axis F
323 col6_axis_number 14
324 col6_cnts_per_x 2048
325 col6_description Collimator Trans (Col SEG 6) VH
326 col6_dflt_accel_steps 50000
327 col6_dflt_decel_steps 50000
328 col6_dflt_speed_steps 100000
329 col6_empty 721132
330 col6_fwd_enc_lim 747130
331 col6_guide 457285
332 col6_maxaccel 0.833333333333333
333 col6_maxdecel 0.833333333333333
334 col6_maxspeed 0.833333333333333
335 col6_mc mc2
336 col6_rev_enc_lim 191508
337 col6_steps_per_x 150000
338 col7_axis G
339 col7_axis_number 15
340 col7_cnts_per_x 2048
341 col7_description Collimator Trans (Col SEG 7) VH
342 col7_dflt_accel_steps 50000
343 col7_dflt_decel_steps 50000
344 col7_dflt_speed_steps 100000
345 col7_empty 555984
346 col7_fwd_enc_lim 577633
347 col7_guide 288216
348 col7_maxaccel 0.833333333333333
349 col7_maxdecel 0.833333333333333
350 col7_maxspeed 0.833333333333333
351 col7_mc mc2
352 col7_rev_enc_lim 24810
353 col7_steps_per_x 150000
354 col8_axis H
355 col8_axis_number 16
356 col8_cnts_per_x 2048
357 col8_description Collimator Trans (Col SEG 8) VH
358 col8_dflt_accel_steps 50000
359 col8_dflt_decel_steps 50000
360 col8_dflt_speed_steps 100000
361 col8_empty 538544
362 col8_fwd_enc_lim 561091
363 col8_guide 273474
364 col8_maxaccel 0.833333333333333
365 col8_maxdecel 0.833333333333333
366 col8_maxspeed 0.833333333333333
367 col8_mc mc2
368 col8_rev_enc_lim 12893
369 col8_steps_per_x 150000
370 det_axis B
371 det_axis_number 58
372 det_cnts_per_x 524.288
373 det_description CURTAIN DETECTOR CARRIAGE Y TRANS
374 det_dflt_accel_steps 25000
375 det_dflt_decel_steps 25000
376 det_dflt_speed_steps 100000
377 det_fwd_enc_lim 0
378 det_maxaccel 25
379 det_maxdecel 25
380 det_maxspeed 25
381 det_mc mc8
382 det_rev_enc_lim 0
383 det_steps_per_x 3900
384 sdh_5a_in 1535698
385 sdh_5b_in 3747542
386 sdh_axis B
387 sdh_axis_number 26
388 sdh_cnts_per_x -12288
389 sdh_description SDH Box
390 sdh_fwd_enc_lim 1189505
391 sdh_mc mc4
392 sdh_rev_enc_lim 4166803
393 sdh_steps_per_x 37500
394 ss1d_axis D
395 ss1d_axis_number 20
396 ss1d_cnts_per_x -16384
397 ss1d_description Slit System 1 - Z DOWN
398 ss1d_dflt_accel_steps 25000
399 ss1d_dflt_decel_steps 25000
400 ss1d_dflt_speed_steps 25000
401 ss1d_fwd_enc_lim 31525131
402 ss1d_maxaccel 1
403 ss1d_maxdecel 1
404 ss1d_maxspeed 1
405 ss1d_mc mc3
406 ss1d_rev_enc_lim 33398312
407 ss1d_steps_per_x 50000
408 ss1l_axis A
409 ss1l_axis_number 17
410 ss1l_cnts_per_x 16384
411 ss1l_description Slit System 1 - X WEST
412 ss1l_dflt_accel_steps 25000
413 ss1l_dflt_decel_steps 25000
414 ss1l_dflt_speed_steps 25000
415 ss1l_fwd_enc_lim 31524107
416 ss1l_maxaccel 1
417 ss1l_maxdecel 1
418 ss1l_maxspeed 1
419 ss1l_mc mc3
420 ss1l_rev_enc_lim 32637740
421 ss1l_steps_per_x -50000
422 ss1r_axis C
423 ss1r_axis_number 19
424 ss1r_cnts_per_x 16384
425 ss1r_description Slit System 1 - X EAST
426 ss1r_dflt_accel_steps 25000
427 ss1r_dflt_decel_steps 25000
428 ss1r_dflt_speed_steps 25000
429 ss1r_fwd_enc_lim 32248545
430 ss1r_maxaccel 1
431 ss1r_maxdecel 1
432 ss1r_maxspeed 1
433 ss1r_mc mc3
434 ss1r_rev_enc_lim 33421848
435 ss1r_steps_per_x -50000
436 ss1u_axis B
437 ss1u_axis_number 18
438 ss1u_cnts_per_x -16384
439 ss1u_description Slit System 1 - Z UP
440 ss1u_dflt_accel_steps 25000
441 ss1u_dflt_decel_steps 25000
442 ss1u_dflt_speed_steps 25000
443 ss1u_fwd_enc_lim 31434607
444 ss1u_maxaccel 1
445 ss1u_maxdecel 1
446 ss1u_maxspeed 1
447 ss1u_mc mc3
448 ss1u_rev_enc_lim 33297987
449 ss1u_steps_per_x 50000
450 vs_axis D
451 vs_axis_number 28
452 vs_cnts_per_x -12288
453 vs_description Velocity Selector Trans
454 vs_dflt_accel_steps 15000
455 vs_dflt_decel_steps 50000
456 vs_dflt_speed_steps 50000
457 vs_fwd_enc_lim 406690
458 vs_glass_in 741128
459 vs_maxaccel 1.33333333333333
460 vs_maxdecel 1.33333333333333
461 vs_maxspeed 1.33333333333333
462 vs_mc mc4
463 vs_rev_enc_lim 3789130
464 vs_steps_per_x 37500

View File

@ -0,0 +1,6 @@
The generated_motor_configuration.tcl file was generated from the following CSV files,
Bilby_motion_control_commissioning_checklist.csv: Extracted from spreadsheet of the same name
hdb_info.csv: Some parameters for hipadaba tree. Hand written.
sicsmot_attlist.csv: Extra parameters generated by the genmotconf.tcl script to complete the motor configurations.
userdef_attlist.csv: Parameters which were originally in sicsmot_attlist.csv but whose values have been changed from the defaults.

View File

@ -0,0 +1,863 @@
#### SICS motor driver configuration ####
# Generated by: ../../../util/genmotconf.tcl Bilby_motion_control_commissioning_checklist.csv hdb_info.csv sicsmot_attlist.csv userdef_attlist.csv
# Generated from the following files,
# file1: Bilby_motion_control_commissioning_checklist.csv
# file2: hdb_info.csv
# file3: sicsmot_attlist.csv
# file4: userdef_attlist.csv
# Load motor driver configuration parameters
set flist [list\
{Bilby_motion_control_commissioning_checklist.csv}\
{hdb_info.csv}\
{sicsmot_attlist.csv}\
{userdef_attlist.csv}\
]
foreach fattfile $flist {
if [catch {
set fattpath config/motors/$fattfile
set fh [open $fattpath RDONLY]
while {[gets $fh line] >= 0} {
eval "set [split $line {,}]"
}
close $fh
} msg] {
clientput ERROR: $msg
}
}
set sim_mode [SplitReply [motor_simulation]]
if {$sim_mode == true} {
set motor_driver_type asim
} else {
set motor_driver_type DMC2280
}
if {$sim_mode == false} {
MakeAsyncQueue mc1 DMC2280 [dict get $::MOTOR_HOSTPORT MC1 HOST] [dict get $::MOTOR_HOSTPORT MC1 PORT]
MakeAsyncQueue mc2 DMC2280 [dict get $::MOTOR_HOSTPORT MC2 HOST] [dict get $::MOTOR_HOSTPORT MC2 PORT]
MakeAsyncQueue mc3 DMC2280 [dict get $::MOTOR_HOSTPORT MC3 HOST] [dict get $::MOTOR_HOSTPORT MC3 PORT]
MakeAsyncQueue mc4 DMC2280 [dict get $::MOTOR_HOSTPORT MC4 HOST] [dict get $::MOTOR_HOSTPORT MC4 PORT]
MakeAsyncQueue mc6 DMC2280 [dict get $::MOTOR_HOSTPORT MC6 HOST] [dict get $::MOTOR_HOSTPORT MC6 PORT]
MakeAsyncQueue mc8 DMC2280 [dict get $::MOTOR_HOSTPORT MC8 HOST] [dict get $::MOTOR_HOSTPORT MC8 PORT]
}
# ap1 configuration
# Aperture Selector (Collimator SEG 1 Start)
# Axis number 1
Motor ap1 $motor_driver_type [params\
asyncqueue mc1\
axis A\
units $ap1_units\
hardlowerlim $ap1_rev_lim\
hardupperlim $ap1_fwd_lim\
maxSpeed $ap1_maxspeed\
maxAccel $ap1_maxaccel\
maxDecel $ap1_maxdecel\
stepsPerX $ap1_steps_per_x\
posit_count 5\
posit_1 $ap1_D10\
posit_2 $ap1_D20\
posit_3 $ap1_D40\
posit_4 $ap1_40X40\
posit_5 $ap1_100X40\
absEnc 1\
absEncHome $ap1_absenchome\
cntsPerX $ap1_cnts_per_x]
ap1 softlowerlim $ap1_rev_lim
ap1 softupperlim $ap1_fwd_lim
ap1 home $ap1_home
ap1 part $ap1_part
ap1 long_name ap1
ap1 speed $ap1_speed
ap1 accel $ap1_accel
ap1 decel $ap1_decel
# ap2 configuration
# Aperture Selector (COLLIMATION SEG 2)
# Axis number 2
Motor ap2 $motor_driver_type [params\
asyncqueue mc1\
axis B\
units $ap2_units\
hardlowerlim $ap2_rev_lim\
hardupperlim $ap2_fwd_lim\
maxSpeed $ap2_maxspeed\
maxAccel $ap2_maxaccel\
maxDecel $ap2_maxdecel\
stepsPerX $ap2_steps_per_x\
posit_count 5\
posit_1 $ap2_D10\
posit_2 $ap2_D20\
posit_3 $ap2_D40\
posit_4 $ap2_40X40\
posit_5 $ap2_100X40\
absEnc 1\
absEncHome $ap2_absenchome\
cntsPerX $ap2_cnts_per_x]
ap2 softlowerlim $ap2_rev_lim
ap2 softupperlim $ap2_fwd_lim
ap2 home $ap2_home
ap2 part $ap2_part
ap2 long_name ap2
ap2 speed $ap2_speed
ap2 accel $ap2_accel
ap2 decel $ap2_decel
# ap3 configuration
# Aperture Selector (COLLIMATION SEG 3)
# Axis number 3
Motor ap3 $motor_driver_type [params\
asyncqueue mc1\
axis C\
units $ap3_units\
hardlowerlim $ap3_rev_lim\
hardupperlim $ap3_fwd_lim\
maxSpeed $ap3_maxspeed\
maxAccel $ap3_maxaccel\
maxDecel $ap3_maxdecel\
stepsPerX $ap3_steps_per_x\
posit_count 5\
posit_1 $ap3_D10\
posit_2 $ap3_D20\
posit_3 $ap3_D40\
posit_4 $ap3_40X40\
posit_5 $ap3_100X40\
absEnc 1\
absEncHome $ap3_absenchome\
cntsPerX $ap3_cnts_per_x]
ap3 softlowerlim $ap3_rev_lim
ap3 softupperlim $ap3_fwd_lim
ap3 home $ap3_home
ap3 part $ap3_part
ap3 long_name ap3
ap3 speed $ap3_speed
ap3 accel $ap3_accel
ap3 decel $ap3_decel
# ap4 configuration
# Aperture Selector (COLLIMATION SEG 4)
# Axis number 4
Motor ap4 $motor_driver_type [params\
asyncqueue mc1\
axis D\
units $ap4_units\
hardlowerlim $ap4_rev_lim\
hardupperlim $ap4_fwd_lim\
maxSpeed $ap4_maxspeed\
maxAccel $ap4_maxaccel\
maxDecel $ap4_maxdecel\
stepsPerX $ap4_steps_per_x\
posit_count 5\
posit_1 $ap4_D10\
posit_2 $ap4_D20\
posit_3 $ap4_D40\
posit_4 $ap4_40X40\
posit_5 $ap4_100X40\
absEnc 1\
absEncHome $ap4_absenchome\
cntsPerX $ap4_cnts_per_x]
ap4 softlowerlim $ap4_rev_lim
ap4 softupperlim $ap4_fwd_lim
ap4 home $ap4_home
ap4 part $ap4_part
ap4 long_name ap4
ap4 speed $ap4_speed
ap4 accel $ap4_accel
ap4 decel $ap4_decel
# ap5 configuration
# Aperture Selector (COLLIMATION SEG 5)
# Axis number 5
Motor ap5 $motor_driver_type [params\
asyncqueue mc1\
axis E\
units $ap5_units\
hardlowerlim $ap5_rev_lim\
hardupperlim $ap5_fwd_lim\
maxSpeed $ap5_maxspeed\
maxAccel $ap5_maxaccel\
maxDecel $ap5_maxdecel\
stepsPerX $ap5_steps_per_x\
posit_count 5\
posit_1 $ap5_D10\
posit_2 $ap5_D20\
posit_3 $ap5_D40\
posit_4 $ap5_40X40\
posit_5 $ap5_100X40\
absEnc 1\
absEncHome $ap5_absenchome\
cntsPerX $ap5_cnts_per_x]
ap5 softlowerlim $ap5_rev_lim
ap5 softupperlim $ap5_fwd_lim
ap5 home $ap5_home
ap5 part $ap5_part
ap5 long_name ap5
ap5 speed $ap5_speed
ap5 accel $ap5_accel
ap5 decel $ap5_decel
# ap6 configuration
# Aperture Selector (COLLIMATION SEG 6)
# Axis number 6
Motor ap6 $motor_driver_type [params\
asyncqueue mc1\
axis F\
units $ap6_units\
hardlowerlim $ap6_rev_lim\
hardupperlim $ap6_fwd_lim\
maxSpeed $ap6_maxspeed\
maxAccel $ap6_maxaccel\
maxDecel $ap6_maxdecel\
stepsPerX $ap6_steps_per_x\
posit_count 5\
posit_1 $ap6_D10\
posit_2 $ap6_D20\
posit_3 $ap6_D40\
posit_4 $ap6_40X40\
posit_5 $ap6_100X40\
absEnc 1\
absEncHome $ap6_absenchome\
cntsPerX $ap6_cnts_per_x]
ap6 softlowerlim $ap6_rev_lim
ap6 softupperlim $ap6_fwd_lim
ap6 home $ap6_home
ap6 part $ap6_part
ap6 long_name ap6
ap6 speed $ap6_speed
ap6 accel $ap6_accel
ap6 decel $ap6_decel
# ap7 configuration
# Aperture Selector (COLLIMATION SEG 7)
# Axis number 7
Motor ap7 $motor_driver_type [params\
asyncqueue mc1\
axis G\
units $ap7_units\
hardlowerlim $ap7_rev_lim\
hardupperlim $ap7_fwd_lim\
maxSpeed $ap7_maxspeed\
maxAccel $ap7_maxaccel\
maxDecel $ap7_maxdecel\
stepsPerX $ap7_steps_per_x\
posit_count 5\
posit_1 $ap7_D10\
posit_2 $ap7_D20\
posit_3 $ap7_D40\
posit_4 $ap7_40X40\
posit_5 $ap7_100X40\
absEnc 1\
absEncHome $ap7_absenchome\
cntsPerX $ap7_cnts_per_x]
ap7 softlowerlim $ap7_rev_lim
ap7 softupperlim $ap7_fwd_lim
ap7 home $ap7_home
ap7 part $ap7_part
ap7 long_name ap7
ap7 speed $ap7_speed
ap7 accel $ap7_accel
ap7 decel $ap7_decel
# ap8 configuration
# Aperture Selector (Collimator SEG 8 End)
# Axis number 8
Motor ap8 $motor_driver_type [params\
asyncqueue mc1\
axis H\
units $ap8_units\
hardlowerlim $ap8_rev_lim\
hardupperlim $ap8_fwd_lim\
maxSpeed $ap8_maxspeed\
maxAccel $ap8_maxaccel\
maxDecel $ap8_maxdecel\
stepsPerX $ap8_steps_per_x\
posit_count 5\
posit_1 $ap8_D10\
posit_2 $ap8_D20\
posit_3 $ap8_D40\
posit_4 $ap8_40X40\
posit_5 $ap8_100X40\
absEnc 1\
absEncHome $ap8_absenchome\
cntsPerX $ap8_cnts_per_x]
ap8 softlowerlim $ap8_rev_lim
ap8 softupperlim $ap8_fwd_lim
ap8 home $ap8_home
ap8 part $ap8_part
ap8 long_name ap8
ap8 speed $ap8_speed
ap8 accel $ap8_accel
ap8 decel $ap8_decel
# att configuration
# 4 Position linear Attenuator
# Axis number 25
Motor att $motor_driver_type [params\
asyncqueue mc4\
axis A\
units $att_units\
hardlowerlim $att_rev_lim\
hardupperlim $att_fwd_lim\
maxSpeed $att_maxspeed\
maxAccel $att_maxaccel\
maxDecel $att_maxdecel\
stepsPerX $att_steps_per_x\
posit_count 5\
posit_1 $att_pos1\
posit_2 $att_pos2\
posit_3 $att_pos3\
posit_4 $att_pos4\
posit_5 $att_pos5\
absEnc 1\
absEncHome $att_absenchome\
cntsPerX $att_cnts_per_x]
att softlowerlim $att_rev_lim
att softupperlim $att_fwd_lim
att home $att_home
att part $att_part
att long_name att
att speed $att_speed
att accel $att_accel
att decel $att_decel
# bs3 configuration
# beam stop 3
# Axis number 43
Motor bs3 $motor_driver_type [params\
asyncqueue mc6\
axis C\
units $bs3_units\
hardlowerlim $bs3_rev_lim\
hardupperlim $bs3_fwd_lim\
maxSpeed $bs3_maxspeed\
maxAccel $bs3_maxaccel\
maxDecel $bs3_maxdecel\
stepsPerX $bs3_steps_per_x\
posit_count 0\
absEnc 1\
absEncHome $bs3_absenchome\
cntsPerX $bs3_cnts_per_x]
bs3 softlowerlim $bs3_rev_lim
bs3 softupperlim $bs3_fwd_lim
bs3 home $bs3_home
bs3 part $bs3_part
bs3 long_name bs3
bs3 speed $bs3_speed
bs3 accel $bs3_accel
bs3 decel $bs3_decel
# cdd configuration
# CURTAIN DETECTOR BOTTOM TRANSLATION
# Axis number 62
Motor cdd $motor_driver_type [params\
asyncqueue mc8\
axis F\
units $cdd_units\
hardlowerlim $cdd_rev_lim\
hardupperlim $cdd_fwd_lim\
maxSpeed $cdd_maxspeed\
maxAccel $cdd_maxaccel\
maxDecel $cdd_maxdecel\
stepsPerX $cdd_steps_per_x\
posit_count 0\
absEnc 1\
absEncHome $cdd_absenchome\
cntsPerX $cdd_cnts_per_x]
cdd softlowerlim $cdd_rev_lim
cdd softupperlim $cdd_fwd_lim
cdd home $cdd_home
cdd part $cdd_part
cdd long_name cdd
cdd speed $cdd_speed
cdd accel $cdd_accel
cdd decel $cdd_decel
# cdl configuration
# CURTAIN DETECTOR WEST TRANSLATION
# Axis number 59
Motor cdl $motor_driver_type [params\
asyncqueue mc8\
axis C\
units $cdl_units\
hardlowerlim $cdl_rev_lim\
hardupperlim $cdl_fwd_lim\
maxSpeed $cdl_maxspeed\
maxAccel $cdl_maxaccel\
maxDecel $cdl_maxdecel\
stepsPerX $cdl_steps_per_x\
posit_count 0\
absEnc 1\
absEncHome $cdl_absenchome\
cntsPerX $cdl_cnts_per_x]
cdl softlowerlim $cdl_rev_lim
cdl softupperlim $cdl_fwd_lim
cdl home $cdl_home
cdl part $cdl_part
cdl long_name cdl
cdl speed $cdl_speed
cdl accel $cdl_accel
cdl decel $cdl_decel
# cdr configuration
# CURTAIN DETECTOR EAST TRANSLATION
# Axis number 60
Motor cdr $motor_driver_type [params\
asyncqueue mc8\
axis D\
units $cdr_units\
hardlowerlim $cdr_rev_lim\
hardupperlim $cdr_fwd_lim\
maxSpeed $cdr_maxspeed\
maxAccel $cdr_maxaccel\
maxDecel $cdr_maxdecel\
stepsPerX $cdr_steps_per_x\
posit_count 0\
absEnc 1\
absEncHome $cdr_absenchome\
cntsPerX $cdr_cnts_per_x]
cdr softlowerlim $cdr_rev_lim
cdr softupperlim $cdr_fwd_lim
cdr home $cdr_home
cdr part $cdr_part
cdr long_name cdr
cdr speed $cdr_speed
cdr accel $cdr_accel
cdr decel $cdr_decel
# cdu configuration
# CURTAIN DETECTOR TOP TRANSLATION
# Axis number 61
Motor cdu $motor_driver_type [params\
asyncqueue mc8\
axis E\
units $cdu_units\
hardlowerlim $cdu_rev_lim\
hardupperlim $cdu_fwd_lim\
maxSpeed $cdu_maxspeed\
maxAccel $cdu_maxaccel\
maxDecel $cdu_maxdecel\
stepsPerX $cdu_steps_per_x\
posit_count 0\
absEnc 1\
absEncHome $cdu_absenchome\
cntsPerX $cdu_cnts_per_x]
cdu softlowerlim $cdu_rev_lim
cdu softupperlim $cdu_fwd_lim
cdu home $cdu_home
cdu part $cdu_part
cdu long_name cdu
cdu speed $cdu_speed
cdu accel $cdu_accel
cdu decel $cdu_decel
# col1 configuration
# Collimator Trans (Col SEG 1) VH
# Axis number 9
Motor col1 $motor_driver_type [params\
asyncqueue mc2\
axis A\
units $col1_units\
hardlowerlim $col1_rev_lim\
hardupperlim $col1_fwd_lim\
maxSpeed $col1_maxspeed\
maxAccel $col1_maxaccel\
maxDecel $col1_maxdecel\
stepsPerX $col1_steps_per_x\
posit_count 2\
posit_1 $col1_guide\
posit_2 $col1_empty\
absEnc 1\
absEncHome $col1_absenchome\
cntsPerX $col1_cnts_per_x]
col1 softlowerlim $col1_rev_lim
col1 softupperlim $col1_fwd_lim
col1 home $col1_home
col1 part $col1_part
col1 long_name col1
col1 speed $col1_speed
col1 accel $col1_accel
col1 decel $col1_decel
# col2 configuration
# Collimator Trans (Col SEG 2) VH
# Axis number 10
Motor col2 $motor_driver_type [params\
asyncqueue mc2\
axis B\
units $col2_units\
hardlowerlim $col2_rev_lim\
hardupperlim $col2_fwd_lim\
maxSpeed $col2_maxspeed\
maxAccel $col2_maxaccel\
maxDecel $col2_maxdecel\
stepsPerX $col2_steps_per_x\
posit_count 2\
posit_1 $col2_guide\
posit_2 $col2_empty\
absEnc 1\
absEncHome $col2_absenchome\
cntsPerX $col2_cnts_per_x]
col2 softlowerlim $col2_rev_lim
col2 softupperlim $col2_fwd_lim
col2 home $col2_home
col2 part $col2_part
col2 long_name col2
col2 speed $col2_speed
col2 accel $col2_accel
col2 decel $col2_decel
# col3 configuration
# Collimator Trans (Col SEG 3) VH
# Axis number 11
Motor col3 $motor_driver_type [params\
asyncqueue mc2\
axis C\
units $col3_units\
hardlowerlim $col3_rev_lim\
hardupperlim $col3_fwd_lim\
maxSpeed $col3_maxspeed\
maxAccel $col3_maxaccel\
maxDecel $col3_maxdecel\
stepsPerX $col3_steps_per_x\
posit_count 2\
posit_1 $col3_guide\
posit_2 $col3_empty\
absEnc 1\
absEncHome $col3_absenchome\
cntsPerX $col3_cnts_per_x]
col3 softlowerlim $col3_rev_lim
col3 softupperlim $col3_fwd_lim
col3 home $col3_home
col3 part $col3_part
col3 long_name col3
col3 speed $col3_speed
col3 accel $col3_accel
col3 decel $col3_decel
# col4 configuration
# Collimator Trans (Col SEG 4) VH
# Axis number 12
Motor col4 $motor_driver_type [params\
asyncqueue mc2\
axis D\
units $col4_units\
hardlowerlim $col4_rev_lim\
hardupperlim $col4_fwd_lim\
maxSpeed $col4_maxspeed\
maxAccel $col4_maxaccel\
maxDecel $col4_maxdecel\
stepsPerX $col4_steps_per_x\
posit_count 2\
posit_1 $col4_guide\
posit_2 $col4_empty\
absEnc 1\
absEncHome $col4_absenchome\
cntsPerX $col4_cnts_per_x]
col4 softlowerlim $col4_rev_lim
col4 softupperlim $col4_fwd_lim
col4 home $col4_home
col4 part $col4_part
col4 long_name col4
col4 speed $col4_speed
col4 accel $col4_accel
col4 decel $col4_decel
# col5 configuration
# Collimator Trans (Col SEG 5) VH
# Axis number 13
Motor col5 $motor_driver_type [params\
asyncqueue mc2\
axis E\
units $col5_units\
hardlowerlim $col5_rev_lim\
hardupperlim $col5_fwd_lim\
maxSpeed $col5_maxspeed\
maxAccel $col5_maxaccel\
maxDecel $col5_maxdecel\
stepsPerX $col5_steps_per_x\
posit_count 2\
posit_1 $col5_guide\
posit_2 $col5_empty\
absEnc 1\
absEncHome $col5_absenchome\
cntsPerX $col5_cnts_per_x]
col5 softlowerlim $col5_rev_lim
col5 softupperlim $col5_fwd_lim
col5 home $col5_home
col5 part $col5_part
col5 long_name col5
col5 speed $col5_speed
col5 accel $col5_accel
col5 decel $col5_decel
# col6 configuration
# Collimator Trans (Col SEG 6) VH
# Axis number 14
Motor col6 $motor_driver_type [params\
asyncqueue mc2\
axis F\
units $col6_units\
hardlowerlim $col6_rev_lim\
hardupperlim $col6_fwd_lim\
maxSpeed $col6_maxspeed\
maxAccel $col6_maxaccel\
maxDecel $col6_maxdecel\
stepsPerX $col6_steps_per_x\
posit_count 2\
posit_1 $col6_guide\
posit_2 $col6_empty\
absEnc 1\
absEncHome $col6_absenchome\
cntsPerX $col6_cnts_per_x]
col6 softlowerlim $col6_rev_lim
col6 softupperlim $col6_fwd_lim
col6 home $col6_home
col6 part $col6_part
col6 long_name col6
col6 speed $col6_speed
col6 accel $col6_accel
col6 decel $col6_decel
# col7 configuration
# Collimator Trans (Col SEG 7) VH
# Axis number 15
Motor col7 $motor_driver_type [params\
asyncqueue mc2\
axis G\
units $col7_units\
hardlowerlim $col7_rev_lim\
hardupperlim $col7_fwd_lim\
maxSpeed $col7_maxspeed\
maxAccel $col7_maxaccel\
maxDecel $col7_maxdecel\
stepsPerX $col7_steps_per_x\
posit_count 2\
posit_1 $col7_guide\
posit_2 $col7_empty\
absEnc 1\
absEncHome $col7_absenchome\
cntsPerX $col7_cnts_per_x]
col7 softlowerlim $col7_rev_lim
col7 softupperlim $col7_fwd_lim
col7 home $col7_home
col7 part $col7_part
col7 long_name col7
col7 speed $col7_speed
col7 accel $col7_accel
col7 decel $col7_decel
# col8 configuration
# Collimator Trans (Col SEG 8) VH
# Axis number 16
Motor col8 $motor_driver_type [params\
asyncqueue mc2\
axis H\
units $col8_units\
hardlowerlim $col8_rev_lim\
hardupperlim $col8_fwd_lim\
maxSpeed $col8_maxspeed\
maxAccel $col8_maxaccel\
maxDecel $col8_maxdecel\
stepsPerX $col8_steps_per_x\
posit_count 2\
posit_1 $col8_guide\
posit_2 $col8_empty\
absEnc 1\
absEncHome $col8_absenchome\
cntsPerX $col8_cnts_per_x]
col8 softlowerlim $col8_rev_lim
col8 softupperlim $col8_fwd_lim
col8 home $col8_home
col8 part $col8_part
col8 long_name col8
col8 speed $col8_speed
col8 accel $col8_accel
col8 decel $col8_decel
# det configuration
# CURTAIN DETECTOR CARRIAGE Y TRANS
# Axis number 58
Motor det $motor_driver_type [params\
asyncqueue mc8\
axis B\
units $det_units\
hardlowerlim $det_rev_lim\
hardupperlim $det_fwd_lim\
maxSpeed $det_maxspeed\
maxAccel $det_maxaccel\
maxDecel $det_maxdecel\
stepsPerX $det_steps_per_x\
posit_count 0\
absEnc 1\
absEncHome $det_absenchome\
cntsPerX $det_cnts_per_x]
det softlowerlim $det_rev_lim
det softupperlim $det_fwd_lim
det home $det_home
det part $det_part
det long_name det
det speed $det_speed
det accel $det_accel
det decel $det_decel
# sdh configuration
# SDH Box
# Axis number 26
Motor sdh $motor_driver_type [params\
asyncqueue mc4\
axis B\
units $sdh_units\
hardlowerlim $sdh_rev_lim\
hardupperlim $sdh_fwd_lim\
maxSpeed $sdh_maxspeed\
maxAccel $sdh_maxaccel\
maxDecel $sdh_maxdecel\
stepsPerX $sdh_steps_per_x\
posit_count 2\
posit_1 $sdh_5b_in\
posit_2 $sdh_5a_in\
absEnc 1\
absEncHome $sdh_absenchome\
cntsPerX $sdh_cnts_per_x]
sdh softlowerlim $sdh_rev_lim
sdh softupperlim $sdh_fwd_lim
sdh home $sdh_home
sdh part $sdh_part
sdh long_name sdh
# ss1d configuration
# Slit System 1 - Z DOWN
# Axis number 20
Motor ss1d $motor_driver_type [params\
asyncqueue mc3\
axis D\
units $ss1d_units\
hardlowerlim $ss1d_rev_lim\
hardupperlim $ss1d_fwd_lim\
maxSpeed $ss1d_maxspeed\
maxAccel $ss1d_maxaccel\
maxDecel $ss1d_maxdecel\
stepsPerX $ss1d_steps_per_x\
posit_count 0\
absEnc 1\
absEncHome $ss1d_absenchome\
cntsPerX $ss1d_cnts_per_x]
ss1d softlowerlim $ss1d_rev_lim
ss1d softupperlim $ss1d_fwd_lim
ss1d home $ss1d_home
ss1d part $ss1d_part
ss1d long_name ss1d
ss1d speed $ss1d_speed
ss1d accel $ss1d_accel
ss1d decel $ss1d_decel
# ss1l configuration
# Slit System 1 - X WEST
# Axis number 17
Motor ss1l $motor_driver_type [params\
asyncqueue mc3\
axis A\
units $ss1l_units\
hardlowerlim $ss1l_rev_lim\
hardupperlim $ss1l_fwd_lim\
maxSpeed $ss1l_maxspeed\
maxAccel $ss1l_maxaccel\
maxDecel $ss1l_maxdecel\
stepsPerX $ss1l_steps_per_x\
posit_count 0\
absEnc 1\
absEncHome $ss1l_absenchome\
cntsPerX $ss1l_cnts_per_x]
ss1l softlowerlim $ss1l_rev_lim
ss1l softupperlim $ss1l_fwd_lim
ss1l home $ss1l_home
ss1l part $ss1l_part
ss1l long_name ss1l
ss1l speed $ss1l_speed
ss1l accel $ss1l_accel
ss1l decel $ss1l_decel
# ss1r configuration
# Slit System 1 - X EAST
# Axis number 19
Motor ss1r $motor_driver_type [params\
asyncqueue mc3\
axis C\
units $ss1r_units\
hardlowerlim $ss1r_rev_lim\
hardupperlim $ss1r_fwd_lim\
maxSpeed $ss1r_maxspeed\
maxAccel $ss1r_maxaccel\
maxDecel $ss1r_maxdecel\
stepsPerX $ss1r_steps_per_x\
posit_count 0\
absEnc 1\
absEncHome $ss1r_absenchome\
cntsPerX $ss1r_cnts_per_x]
ss1r softlowerlim $ss1r_rev_lim
ss1r softupperlim $ss1r_fwd_lim
ss1r home $ss1r_home
ss1r part $ss1r_part
ss1r long_name ss1r
ss1r speed $ss1r_speed
ss1r accel $ss1r_accel
ss1r decel $ss1r_decel
# ss1u configuration
# Slit System 1 - Z UP
# Axis number 18
Motor ss1u $motor_driver_type [params\
asyncqueue mc3\
axis B\
units $ss1u_units\
hardlowerlim $ss1u_rev_lim\
hardupperlim $ss1u_fwd_lim\
maxSpeed $ss1u_maxspeed\
maxAccel $ss1u_maxaccel\
maxDecel $ss1u_maxdecel\
stepsPerX $ss1u_steps_per_x\
posit_count 0\
absEnc 1\
absEncHome $ss1u_absenchome\
cntsPerX $ss1u_cnts_per_x]
ss1u softlowerlim $ss1u_rev_lim
ss1u softupperlim $ss1u_fwd_lim
ss1u home $ss1u_home
ss1u part $ss1u_part
ss1u long_name ss1u
ss1u speed $ss1u_speed
ss1u accel $ss1u_accel
ss1u decel $ss1u_decel
# vs configuration
# Velocity Selector Trans
# Axis number 28
Motor vs $motor_driver_type [params\
asyncqueue mc4\
axis D\
units $vs_units\
hardlowerlim $vs_rev_lim\
hardupperlim $vs_fwd_lim\
maxSpeed $vs_maxspeed\
maxAccel $vs_maxaccel\
maxDecel $vs_maxdecel\
stepsPerX $vs_steps_per_x\
posit_count 1\
posit_1 $vs_glass_in\
absEnc 1\
absEncHome $vs_absenchome\
cntsPerX $vs_cnts_per_x]
vs softlowerlim $vs_rev_lim
vs softupperlim $vs_fwd_lim
vs home $vs_home
vs part $vs_part
vs long_name vs
vs speed $vs_speed
vs accel $vs_accel
vs decel $vs_decel
proc motor_set_sobj_attributes {} {}

View File

@ -0,0 +1,88 @@
ap1_part,collimator
ap1_units,degrees
ap2_part,collimator
ap2_units,degrees
ap3_part,collimator
ap3_units,degrees
ap4_part,collimator
ap4_units,degrees
ap5_part,collimator
ap5_units,degrees
ap6_part,collimator
ap6_units,degrees
ap7_part,collimator
ap7_units,degrees
ap8_part,collimator
ap8_units,degrees
att_part,instrument
att_units,mm
bs1_part,detector
bs1_units,degrees
bs2_part,detector
bs2_units,degrees
bs3_part,detector
bs3_units,degrees
cdd_part,detector
cdd_units,mm
cdl_part,detector
cdl_units,mm
cdr_part,detector
cdr_units,mm
cdu_part,detector
cdu_units,mm
col1_part,collimator
col1_units,mm
col2_part,collimator
col2_units,mm
col3_part,collimator
col3_units,mm
col4_part,collimator
col4_units,mm
col5_part,collimator
col5_units,mm
col6_part,collimator
col6_units,mm
col7_part,collimator
col7_units,mm
col8_part,collimator
col8_units,mm
det_part,detector
det_units,mm
mdy_part,detector
mdy_units,mm
mirr1_part,disk_chopper
mirr1_units,xxx
mirr2_part,disk_chopper
mirr2_units,xxx
sap_part,sample
sap_units,mm
schi_part,sample
schi_units,degrees
sdh_part,instrument
sdh_units,mm
som_part,sample
som_units,degrees
sphi_part,sample
sphi_units,degrees
ss1d_part,collimator
ss1d_units,mm
ss1l_part,collimator
ss1l_units,mm
ss1r_part,collimator
ss1r_units,mm
ss1u_part,collimator
ss1u_units,mm
ss2d_part,collimator
ss2d_units,mm
ss2l_part,collimator
ss2l_units,mm
ss2r_part,collimator
ss2r_units,mm
ss2u_part,collimator
ss2u_units,mm
sx_part,sample
sx_units,mm
sy_part,sample
sy_units,mm
vs_part,instrument
vs_units,mm
1 ap1_part collimator
2 ap1_units degrees
3 ap2_part collimator
4 ap2_units degrees
5 ap3_part collimator
6 ap3_units degrees
7 ap4_part collimator
8 ap4_units degrees
9 ap5_part collimator
10 ap5_units degrees
11 ap6_part collimator
12 ap6_units degrees
13 ap7_part collimator
14 ap7_units degrees
15 ap8_part collimator
16 ap8_units degrees
17 att_part instrument
18 att_units mm
19 bs1_part detector
20 bs1_units degrees
21 bs2_part detector
22 bs2_units degrees
23 bs3_part detector
24 bs3_units degrees
25 cdd_part detector
26 cdd_units mm
27 cdl_part detector
28 cdl_units mm
29 cdr_part detector
30 cdr_units mm
31 cdu_part detector
32 cdu_units mm
33 col1_part collimator
34 col1_units mm
35 col2_part collimator
36 col2_units mm
37 col3_part collimator
38 col3_units mm
39 col4_part collimator
40 col4_units mm
41 col5_part collimator
42 col5_units mm
43 col6_part collimator
44 col6_units mm
45 col7_part collimator
46 col7_units mm
47 col8_part collimator
48 col8_units mm
49 det_part detector
50 det_units mm
51 mdy_part detector
52 mdy_units mm
53 mirr1_part disk_chopper
54 mirr1_units xxx
55 mirr2_part disk_chopper
56 mirr2_units xxx
57 sap_part sample
58 sap_units mm
59 schi_part sample
60 schi_units degrees
61 sdh_part instrument
62 sdh_units mm
63 som_part sample
64 som_units degrees
65 sphi_part sample
66 sphi_units degrees
67 ss1d_part collimator
68 ss1d_units mm
69 ss1l_part collimator
70 ss1l_units mm
71 ss1r_part collimator
72 ss1r_units mm
73 ss1u_part collimator
74 ss1u_units mm
75 ss2d_part collimator
76 ss2d_units mm
77 ss2l_part collimator
78 ss2l_units mm
79 ss2r_part collimator
80 ss2r_units mm
81 ss2u_part collimator
82 ss2u_units mm
83 sx_part sample
84 sx_units mm
85 sy_part sample
86 sy_units mm
87 vs_part instrument
88 vs_units mm

View File

@ -0,0 +1,23 @@
# @file Loads the generated_motor_configuration.tcl file which is created by util/genmotconf.tcl from CSV files.
fileeval config/motors/generated_motor_configuration.tcl
fileeval config/motors/sct_shutters.tcl
fileeval config/motors/sct_tank.tcl
add_shutters shutters aqadapter mc4
add_tank tank aqadapter mc8
# Motors which should not be driven should be set as "fixed" here.
# Configurable virtual motors can be defined here.
# Eg, mot fixed 1
# Define "proc motor_set_sobj_attributes {}" if we need to define extra sicslist attributes for some motors.
for {set n 1} {$n <= 8} {incr n} {
make_coll_motor_1 c$n c$n col$n count
make_coll_motor_1 a$n a$n ap$n count
}
# Make a position-motor for the attenuator
make_coll_motor_1 att_pos att_pos att count
sicslist setatt att_pos klass instrument
# make gap/offset motors for the slits
make_gap_motors ss1hg gap ss1ho offset ss1r ss1l mm first/horizontal
make_gap_motors ss1vg gap ss1vo offset ss1u ss1d mm first/vertical

View File

@ -0,0 +1,317 @@
# Generated driver for shutters
# vim: ft=tcl tabstop=8 softtabstop=2 shiftwidth=2 nocindent smartindent
#
namespace eval ::scobj::shutters {
set debug_threshold 0
}
proc ::scobj::shutters::debug_log {debug_level debug_string} {
set catch_status [ catch {
if {${debug_level} >= ${::scobj::shutters::debug_threshold}} {
set fd [open "/tmp/shutters.log" "a"]
set line "[clock format [clock seconds] -format "%T"] ${debug_string}"
puts ${fd} "${line}"
close ${fd}
}
} catch_message ]
}
# check function for hset change
proc ::scobj::shutters::checkrange {tc_root} {
set catch_status [ catch {
debug_log 1 "checkrange tc_root=${tc_root} sct=[sct] target=[sct target]"
set setpoint [sct target]
if { [hpropexists [sct] lowerlimit] } {
set lolimit [sct lowerlimit]
} else {
# lowerlimit not set, use target
set lolimit [sct target]
}
if { [hpropexists [sct] upperlimit] } {
set hilimit [sct upperlimit]
} else {
# upperlimit not set, use target
set hilimit [sct target]
}
# hook code goes here
if { ${setpoint} < ${lolimit} || ${setpoint} > ${hilimit} } {
error "setpoint ${setpoint} violates limits (${lolimit}..${hilimit}) on [sct]"
}
return OK
} catch_message ]
handle_exception ${catch_status} ${catch_message}
}
# function to request the read of a parameter on a device
proc ::scobj::shutters::getValue {tc_root nextState cmd_str} {
set catch_status [ catch {
debug_log 1 "getValue tc_root=${tc_root} sct=[sct] cmd=${cmd_str}"
if { [hpropexists [sct] geterror] } {
hdelprop [sct] geterror
}
set cmd "${cmd_str}"
# hook code goes here
debug_log 1 "getValue sct send ${cmd}"
if {![string equal -nocase -length 10 ${cmd} "@@NOSEND@@"]} {
sct send "${cmd}"
}
return ${nextState}
} catch_message ]
handle_exception ${catch_status} ${catch_message}
}
# function to check the write parameter on a device
proc ::scobj::shutters::noResponse {tc_root} {
set catch_status [ catch {
debug_log 1 "noResponse tc_root=${tc_root} sct=[sct] resp=[sct result]"
# hook code goes here
return "idle"
} catch_message ]
handle_exception ${catch_status} ${catch_message}
}
# function to parse the read of a parameter on a device
proc ::scobj::shutters::read_switch_pair {tc_root} {
set catch_status [ catch {
debug_log 1 "read_switch_pair tc_root=${tc_root} sct=[sct] result=[sct result]"
if { [hpropexists [sct] geterror] } {
hdelprop [sct] geterror
}
set data [sct result]
set nextState "idle"
if {[string equal -nocase -length 7 ${data} "ASCERR:"]} {
# the protocol driver has reported an error
sct geterror "${data}"
error "[sct geterror]"
}
# hook code starts
if { [string equal -nocase -length 1 "${data}" "?"] } {
sct geterror "Galil error in: '${data}'"
} else {
set data_list [split [string trim "${data}"]]
if { [llength ${data_list}] > 2 && [lindex ${data_list} end] == ":" } {
set data_list [lrange ${data_list} 0 1]
}
if { [llength ${data_list}] == 2 } {
set left [expr [lindex ${data_list} 0]]
set right [expr [lindex ${data_list} 1]]
if { ${left} == 1 && ${right} == 0 } { # open
set data "out"
} elseif { ${left} == 0 && ${right} == 1 } { # closed
set data "in"
} else { # indeterminate
set data "moving"
}
} else {
sct geterror "Syntax error in: '${data}'=>'${data_list}'"
}
}
# hook code ends
if { [hpropexists [sct] geterror] } {
debug_log 1 "[sct] error: [sct geterror]"
error "[sct geterror]"
}
if { ${data} != [sct oldval] } {
debug_log 1 "[sct] changed to new:${data}, from old:[sct oldval]"
sct oldval ${data}
sct update ${data}
sct utime readtime
}
return ${nextState}
} catch_message ]
handle_exception ${catch_status} ${catch_message}
}
# function to write a parameter value on a device
proc ::scobj::shutters::setValue {tc_root nextState cmd_str} {
set catch_status [ catch {
debug_log 1 "setValue tc_root=${tc_root} sct=[sct] cmd=${cmd_str}"
if { [hpropexists [sct] geterror] } {
hdelprop [sct] geterror
}
set par [sct target]
set cmd "${cmd_str}${par}"
# hook code goes here
if { [hpropexists [sct] driving] } {
if { [hpropexists [sct] writestatus] && [sct writestatus] == "start" } {
sct driving 1
}
}
debug_log 1 "setValue sct send ${cmd}"
if {![string equal -nocase -length 10 ${cmd} "@@NOSEND@@"]} {
sct send "${cmd}"
}
return ${nextState}
} catch_message ]
handle_exception ${catch_status} ${catch_message}
}
# function to write a parameter value on a device
proc ::scobj::shutters::write_switch {tc_root nextState cmd_str} {
set catch_status [ catch {
debug_log 1 "write_switch tc_root=${tc_root} sct=[sct] cmd=${cmd_str}"
if { [hpropexists [sct] geterror] } {
hdelprop [sct] geterror
}
set par [sct target]
set cmd "${cmd_str}${par}"
# hook code starts
if { [string equal -nocase -length 2 "${par}" "in"] } {
set cmd "SB${cmd_str}"
} elseif { [string equal -nocase -length 2 "${par}" "out"] } {
set cmd "CB${cmd_str}"
} else {
sct geterror "Value error: '${par}' not in ('in', 'out')"
}
# hook code ends
if { [hpropexists [sct] geterror] } {
debug_log 1 "[sct] error: [sct geterror]"
error "[sct geterror]"
}
if { [hpropexists [sct] driving] } {
if { [hpropexists [sct] writestatus] && [sct writestatus] == "start" } {
sct driving 1
}
}
debug_log 1 "write_switch sct send ${cmd}"
if {![string equal -nocase -length 10 ${cmd} "@@NOSEND@@"]} {
sct send "${cmd}"
}
return ${nextState}
} catch_message ]
handle_exception ${catch_status} ${catch_message}
}
proc ::scobj::shutters::mk_sct_shutters { sct_controller name } {
debug_log 1 "mk_sct_shutters for ${name}"
set ns "[namespace current]"
set catch_status [ catch {
MakeSICSObj ${name} SCT_OBJECT
sicslist setatt ${name} klass instrument
sicslist setatt ${name} long_name ${name}
set scobj_hpath /sics/${name}
hfactory ${scobj_hpath}/fast_shutter plain user text
hsetprop ${scobj_hpath}/fast_shutter read ${ns}::getValue ${scobj_hpath} read_switch_pair {MG @IN[5], @IN[6]}
hsetprop ${scobj_hpath}/fast_shutter read_switch_pair ${ns}::read_switch_pair ${scobj_hpath}
hsetprop ${scobj_hpath}/fast_shutter control true
hsetprop ${scobj_hpath}/fast_shutter data true
hsetprop ${scobj_hpath}/fast_shutter mutable false
hsetprop ${scobj_hpath}/fast_shutter nxsave true
hsetprop ${scobj_hpath}/fast_shutter oldval UNKNOWN
hsetprop ${scobj_hpath}/fast_shutter klass "collimator"
hsetprop ${scobj_hpath}/fast_shutter nxalias "fast_shutter"
hsetprop ${scobj_hpath}/fast_shutter sdsinfo "::nexus::scobj::sdsinfo"
hsetprop ${scobj_hpath}/fast_shutter type "part"
hfactory ${scobj_hpath}/rough_100 plain user text
hsetprop ${scobj_hpath}/rough_100 read ${ns}::getValue ${scobj_hpath} read_switch_pair {MG @IN[15], @IN[16]}
hsetprop ${scobj_hpath}/rough_100 read_switch_pair ${ns}::read_switch_pair ${scobj_hpath}
hsetprop ${scobj_hpath}/rough_100 write ${ns}::write_switch ${scobj_hpath} noResponse {11}
hsetprop ${scobj_hpath}/rough_100 noResponse ${ns}::noResponse ${scobj_hpath}
hsetprop ${scobj_hpath}/rough_100 check ${ns}::checkrange ${scobj_hpath}
hsetprop ${scobj_hpath}/rough_100 control true
hsetprop ${scobj_hpath}/rough_100 data true
hsetprop ${scobj_hpath}/rough_100 mutable false
hsetprop ${scobj_hpath}/rough_100 nxsave true
hsetprop ${scobj_hpath}/rough_100 values in,out
hsetprop ${scobj_hpath}/rough_100 oldval UNKNOWN
hsetprop ${scobj_hpath}/rough_100 klass "collimator"
hsetprop ${scobj_hpath}/rough_100 nxalias "rough_100"
hsetprop ${scobj_hpath}/rough_100 sdsinfo "::nexus::scobj::sdsinfo"
hsetprop ${scobj_hpath}/rough_100 type "part"
hfactory ${scobj_hpath}/rough_40 plain user text
hsetprop ${scobj_hpath}/rough_40 read ${ns}::getValue ${scobj_hpath} read_switch_pair {MG @IN[13], @IN[14]}
hsetprop ${scobj_hpath}/rough_40 read_switch_pair ${ns}::read_switch_pair ${scobj_hpath}
hsetprop ${scobj_hpath}/rough_40 write ${ns}::write_switch ${scobj_hpath} noResponse {10}
hsetprop ${scobj_hpath}/rough_40 noResponse ${ns}::noResponse ${scobj_hpath}
hsetprop ${scobj_hpath}/rough_40 check ${ns}::checkrange ${scobj_hpath}
hsetprop ${scobj_hpath}/rough_40 control true
hsetprop ${scobj_hpath}/rough_40 data true
hsetprop ${scobj_hpath}/rough_40 mutable false
hsetprop ${scobj_hpath}/rough_40 nxsave true
hsetprop ${scobj_hpath}/rough_40 values in,out
hsetprop ${scobj_hpath}/rough_40 oldval UNKNOWN
hsetprop ${scobj_hpath}/rough_40 klass "collimator"
hsetprop ${scobj_hpath}/rough_40 nxalias "rough_40"
hsetprop ${scobj_hpath}/rough_40 sdsinfo "::nexus::scobj::sdsinfo"
hsetprop ${scobj_hpath}/rough_40 type "part"
hsetprop ${scobj_hpath} data "true"
hsetprop ${scobj_hpath} nxsave "true"
if {[SplitReply [motor_simulation]]=="false"} {
${sct_controller} poll ${scobj_hpath}/fast_shutter 1
${sct_controller} poll ${scobj_hpath}/rough_100 1
${sct_controller} poll ${scobj_hpath}/rough_40 1
${sct_controller} write ${scobj_hpath}/rough_100
${sct_controller} write ${scobj_hpath}/rough_40
}
hsetprop ${scobj_hpath} klass instrument
# hook code starts
# hook code ends
} catch_message ]
handle_exception ${catch_status} ${catch_message}
}
namespace eval ::scobj::shutters {
namespace export debug_log
namespace export mk_sct_shutters
}
proc add_shutters {name IP port} {
set catch_status [ catch {
set ns "::scobj::shutters"
${ns}::debug_log 1 "add_shutters ${name} ${IP} ${port}"
if {[SplitReply [motor_simulation]]=="false"} {
if {[string equal -nocase "aqadapter" "${IP}"]} {
${ns}::debug_log 1 "makesctcontroller sct_${name} aqadapter ${port}"
makesctcontroller sct_${name} aqadapter ${port}
} else {
${ns}::debug_log 1 "makesctcontroller sct_${name} dmc2280 ${IP}:${port}"
makesctcontroller sct_${name} dmc2280 ${IP}:${port}
}
}
${ns}::debug_log 1 "mk_sct_shutters sct_${name} ${name}"
${ns}::mk_sct_shutters sct_${name} ${name}
} catch_message ]
handle_exception ${catch_status} ${catch_message}
}
puts stdout "file evaluation of sct_shutters.tcl"
::scobj::shutters::debug_log 1 "file evaluation of sct_shutters.tcl"
proc ::scobj::shutters::read_config {} {
set catch_status [ catch {
set ns "::scobj::shutters"
${ns}::debug_log 1 "Processing Config"
dict for {k v} $::config_dict {
${ns}::debug_log 1 "Inspecting $k:$v"
if { [dict exists $v "driver"] } {
${ns}::debug_log 1 "Has driver [dict get $v driver]"
if { [dict get $v "driver"] == "shutters" } {
${ns}::debug_log 1 "Correct driver, enabled = [dict get $v enabled]"
if { [dict get $v enabled] } {
set IP [dict get $v ip]
set PORT [dict get $v port]
set name [dict get $v name]
MakeAsyncProtocol ${name}_protocol
MakeAsyncQueue ${name}_queue ${name}_protocol ${IP} ${PORT}
add_shutters ${name} "aqadapter" ${name}_queue
}
}
}
}
} catch_message ]
handle_exception ${catch_status} ${catch_message}
}
if { [info exists ::config_dict] } {
::scobj::shutters::read_config
} else {
::scobj::shutters:debug_log 1 "No config dict"
}

View File

@ -0,0 +1,282 @@
# Generated driver for tank
# vim: ft=tcl tabstop=8 softtabstop=2 shiftwidth=2 nocindent smartindent
#
namespace eval ::scobj::tank {
set debug_threshold 0
}
proc ::scobj::tank::debug_log {debug_level debug_string} {
set catch_status [ catch {
if {${debug_level} >= ${::scobj::tank::debug_threshold}} {
set fd [open "/tmp/tank.log" "a"]
set line "[clock format [clock seconds] -format "%T"] ${debug_string}"
puts ${fd} "${line}"
close ${fd}
}
} catch_message ]
}
# check function for hset change
proc ::scobj::tank::checkrange {tc_root} {
set catch_status [ catch {
debug_log 1 "checkrange tc_root=${tc_root} sct=[sct] target=[sct target]"
set setpoint [sct target]
if { [hpropexists [sct] lowerlimit] } {
set lolimit [sct lowerlimit]
} else {
# lowerlimit not set, use target
set lolimit [sct target]
}
if { [hpropexists [sct] upperlimit] } {
set hilimit [sct upperlimit]
} else {
# upperlimit not set, use target
set hilimit [sct target]
}
# hook code goes here
if { ${setpoint} < ${lolimit} || ${setpoint} > ${hilimit} } {
error "setpoint ${setpoint} violates limits (${lolimit}..${hilimit}) on [sct]"
}
return OK
} catch_message ]
handle_exception ${catch_status} ${catch_message}
}
# function to request the read of a parameter on a device
proc ::scobj::tank::getValue {tc_root nextState cmd_str} {
set catch_status [ catch {
debug_log 1 "getValue tc_root=${tc_root} sct=[sct] cmd=${cmd_str}"
if { [hpropexists [sct] geterror] } {
hdelprop [sct] geterror
}
set cmd "${cmd_str}"
# hook code goes here
debug_log 1 "getValue sct send ${cmd}"
if {![string equal -nocase -length 10 ${cmd} "@@NOSEND@@"]} {
sct send "${cmd}"
}
return ${nextState}
} catch_message ]
handle_exception ${catch_status} ${catch_message}
}
# function to check the write parameter on a device
proc ::scobj::tank::noResponse {tc_root} {
set catch_status [ catch {
debug_log 1 "noResponse tc_root=${tc_root} sct=[sct] resp=[sct result]"
# hook code goes here
return "idle"
} catch_message ]
handle_exception ${catch_status} ${catch_message}
}
# function to parse the read of a parameter on a device
proc ::scobj::tank::read_switch {tc_root} {
set catch_status [ catch {
debug_log 1 "read_switch tc_root=${tc_root} sct=[sct] result=[sct result]"
if { [hpropexists [sct] geterror] } {
hdelprop [sct] geterror
}
set data [sct result]
set nextState "idle"
if {[string equal -nocase -length 7 ${data} "ASCERR:"]} {
# the protocol driver has reported an error
sct geterror "${data}"
error "[sct geterror]"
}
# hook code starts
if { [string equal -nocase -length 1 "${data}" "?"] } {
sct geterror "Galil error in: '${data}'"
} else {
set data_list [split [string trim "${data}"]]
if { [llength ${data_list}] > 1 && [lindex ${data_list} end] == ":" } {
set data_list [lrange ${data_list} 0 0]
}
if { [llength ${data_list}] == 1 } {
set left [expr [lindex ${data_list} 0]]
if { ${left} == 1 } { # open
set data "open"
} else { # closed
set data "closed"
}
} else {
sct geterror "Syntax error in: '${data}'=>'${data_list}'"
}
}
# hook code ends
if { [hpropexists [sct] geterror] } {
debug_log 1 "[sct] error: [sct geterror]"
error "[sct geterror]"
}
if { ${data} != [sct oldval] } {
debug_log 1 "[sct] changed to new:${data}, from old:[sct oldval]"
sct oldval ${data}
sct update ${data}
sct utime readtime
}
return ${nextState}
} catch_message ]
handle_exception ${catch_status} ${catch_message}
}
# function to write a parameter value on a device
proc ::scobj::tank::setValue {tc_root nextState cmd_str} {
set catch_status [ catch {
debug_log 1 "setValue tc_root=${tc_root} sct=[sct] cmd=${cmd_str}"
if { [hpropexists [sct] geterror] } {
hdelprop [sct] geterror
}
set par [sct target]
set cmd "${cmd_str}${par}"
# hook code goes here
if { [hpropexists [sct] driving] } {
if { [hpropexists [sct] writestatus] && [sct writestatus] == "start" } {
sct driving 1
}
}
debug_log 1 "setValue sct send ${cmd}"
if {![string equal -nocase -length 10 ${cmd} "@@NOSEND@@"]} {
sct send "${cmd}"
}
return ${nextState}
} catch_message ]
handle_exception ${catch_status} ${catch_message}
}
proc ::scobj::tank::mk_sct_tank { sct_controller name } {
debug_log 1 "mk_sct_tank for ${name}"
set ns "[namespace current]"
set catch_status [ catch {
MakeSICSObj ${name} SCT_OBJECT
sicslist setatt ${name} klass instrument
sicslist setatt ${name} long_name ${name}
set scobj_hpath /sics/${name}
hfactory ${scobj_hpath}/limits plain spy none
hfactory ${scobj_hpath}/limits/forward plain user text
hsetprop ${scobj_hpath}/limits/forward read ${ns}::getValue ${scobj_hpath} read_switch {MG _LFH}
hsetprop ${scobj_hpath}/limits/forward read_switch ${ns}::read_switch ${scobj_hpath}
hsetprop ${scobj_hpath}/limits/forward control true
hsetprop ${scobj_hpath}/limits/forward data true
hsetprop ${scobj_hpath}/limits/forward mutable false
hsetprop ${scobj_hpath}/limits/forward nxsave true
hsetprop ${scobj_hpath}/limits/forward oldval UNKNOWN
hsetprop ${scobj_hpath}/limits/forward sdsinfo "::nexus::scobj::sdsinfo"
hsetprop ${scobj_hpath}/limits/forward type "part"
hsetprop ${scobj_hpath}/limits/forward nxalias "${name}_limits_forward"
hfactory ${scobj_hpath}/limits/reverse plain user text
hsetprop ${scobj_hpath}/limits/reverse read ${ns}::getValue ${scobj_hpath} read_switch {MG _LRH}
hsetprop ${scobj_hpath}/limits/reverse read_switch ${ns}::read_switch ${scobj_hpath}
hsetprop ${scobj_hpath}/limits/reverse control true
hsetprop ${scobj_hpath}/limits/reverse data true
hsetprop ${scobj_hpath}/limits/reverse mutable false
hsetprop ${scobj_hpath}/limits/reverse nxsave true
hsetprop ${scobj_hpath}/limits/reverse oldval UNKNOWN
hsetprop ${scobj_hpath}/limits/reverse sdsinfo "::nexus::scobj::sdsinfo"
hsetprop ${scobj_hpath}/limits/reverse type "part"
hsetprop ${scobj_hpath}/limits/reverse nxalias "${name}_limits_reverse"
if {[SplitReply [motor_simulation]]=="false"} {
${sct_controller} poll ${scobj_hpath}/limits/forward 1
${sct_controller} poll ${scobj_hpath}/limits/reverse 1
}
hfactory ${scobj_hpath}/switches plain spy none
hfactory ${scobj_hpath}/switches/forward plain user text
hsetprop ${scobj_hpath}/switches/forward read ${ns}::getValue ${scobj_hpath} read_switch {MG @IN[5]}
hsetprop ${scobj_hpath}/switches/forward read_switch ${ns}::read_switch ${scobj_hpath}
hsetprop ${scobj_hpath}/switches/forward control true
hsetprop ${scobj_hpath}/switches/forward data true
hsetprop ${scobj_hpath}/switches/forward mutable false
hsetprop ${scobj_hpath}/switches/forward nxsave true
hsetprop ${scobj_hpath}/switches/forward oldval UNKNOWN
hsetprop ${scobj_hpath}/switches/forward sdsinfo "::nexus::scobj::sdsinfo"
hsetprop ${scobj_hpath}/switches/forward type "part"
hsetprop ${scobj_hpath}/switches/forward nxalias "${name}_switches_forward"
hfactory ${scobj_hpath}/switches/reverse plain user text
hsetprop ${scobj_hpath}/switches/reverse read ${ns}::getValue ${scobj_hpath} read_switch {MG @IN[6]}
hsetprop ${scobj_hpath}/switches/reverse read_switch ${ns}::read_switch ${scobj_hpath}
hsetprop ${scobj_hpath}/switches/reverse control true
hsetprop ${scobj_hpath}/switches/reverse data true
hsetprop ${scobj_hpath}/switches/reverse mutable false
hsetprop ${scobj_hpath}/switches/reverse nxsave true
hsetprop ${scobj_hpath}/switches/reverse oldval UNKNOWN
hsetprop ${scobj_hpath}/switches/reverse sdsinfo "::nexus::scobj::sdsinfo"
hsetprop ${scobj_hpath}/switches/reverse type "part"
hsetprop ${scobj_hpath}/switches/reverse nxalias "${name}_switches_reverse"
if {[SplitReply [motor_simulation]]=="false"} {
${sct_controller} poll ${scobj_hpath}/switches/forward 1
${sct_controller} poll ${scobj_hpath}/switches/reverse 1
}
hsetprop ${scobj_hpath} klass instrument
# hook code starts
# hook code ends
} catch_message ]
handle_exception ${catch_status} ${catch_message}
}
namespace eval ::scobj::tank {
namespace export debug_log
namespace export mk_sct_tank
}
proc add_tank {name IP port} {
set catch_status [ catch {
set ns "::scobj::tank"
${ns}::debug_log 1 "add_tank ${name} ${IP} ${port}"
if {[SplitReply [motor_simulation]]=="false"} {
if {[string equal -nocase "aqadapter" "${IP}"]} {
${ns}::debug_log 1 "makesctcontroller sct_${name} aqadapter ${port}"
makesctcontroller sct_${name} aqadapter ${port}
} else {
${ns}::debug_log 1 "makesctcontroller sct_${name} dmc2280 ${IP}:${port}"
makesctcontroller sct_${name} dmc2280 ${IP}:${port}
}
}
${ns}::debug_log 1 "mk_sct_tank sct_${name} ${name}"
${ns}::mk_sct_tank sct_${name} ${name}
} catch_message ]
handle_exception ${catch_status} ${catch_message}
}
puts stdout "file evaluation of sct_tank.tcl"
::scobj::tank::debug_log 1 "file evaluation of sct_tank.tcl"
proc ::scobj::tank::read_config {} {
set catch_status [ catch {
set ns "::scobj::tank"
${ns}::debug_log 1 "Processing Config"
dict for {k v} $::config_dict {
${ns}::debug_log 1 "Inspecting $k:$v"
if { [dict exists $v "driver"] } {
${ns}::debug_log 1 "Has driver [dict get $v driver]"
if { [dict get $v "driver"] == "tank" } {
${ns}::debug_log 1 "Correct driver, enabled = [dict get $v enabled]"
if { [dict get $v enabled] } {
set IP [dict get $v ip]
set PORT [dict get $v port]
set name [dict get $v name]
MakeAsyncProtocol ${name}_protocol
MakeAsyncQueue ${name}_queue ${name}_protocol ${IP} ${PORT}
add_tank ${name} "aqadapter" ${name}_queue
}
}
}
}
} catch_message ]
handle_exception ${catch_status} ${catch_message}
}
if { [info exists ::config_dict] } {
::scobj::tank::read_config
} else {
::scobj::tank:debug_log 1 "No config dict"
}

View File

@ -0,0 +1,92 @@
#
# Simple driver generator for the non-motor galil controls on mc4
# vim: ts=8 sts=2 sw=2 expandtab autoindent smartindent nocindent
#
driver shutters = {
vendor = galil; device = mc4; protocol = dmc2280;
class = instrument
simulation_group = motor_simulation
#
# Unnamed group has variables at device level
#
#
# The named group is at the device level, variables below that
#
group = {
type = text
priv = user
group_property 'data' = 'true'
group_property 'nxsave' = 'true'
property 'type' = 'part'
property 'klass' = 'collimator'
property 'sdsinfo' = '::nexus::scobj::sdsinfo'
var fast_shutter = {
readable = 1
read_command = 'MG @IN[5], @IN[6]'
read_function = read_switch_pair
property 'nxalias' = 'fast_shutter'
}
var rough_40 = {
readable = 1;
read_function = read_switch_pair;
read_command = 'MG @IN[13], @IN[14]'
writeable = 1
write_function = write_switch;
write_command = '10'
allowed = 'in,out'
property 'nxalias' = 'rough_40'
}
var rough_100 = {
readable = 1;
read_function = read_switch_pair;
read_command = 'MG @IN[15], @IN[16]'
writeable = 1
write_function = write_switch;
write_command = '11'
allowed = 'in,out'
property 'nxalias' = 'rough_100'
}
};
#
# Code lines start with '@' which is stripped before being emitted
# The code is emitted at the appropriate place in the given function
#
code read_function read_switch_pair = {
@ if { [string equal -nocase -length 1 "${data}" "?"] } {
@ sct geterror "Galil error in: '${data}'"
@ } else {
@ set data_list [split [string trim "${data}"]]
@ if { [llength ${data_list}] > 2 && [lindex ${data_list} end] == ":" } {
@ set data_list [lrange ${data_list} 0 1]
@ }
@ if { [llength ${data_list}] == 2 } {
@ set left [expr [lindex ${data_list} 0]]
@ set right [expr [lindex ${data_list} 1]]
@ if { ${left} == 1 && ${right} == 0 } { # open
@ set data "out"
@ } elseif { ${left} == 0 && ${right} == 1 } { # closed
@ set data "in"
@ } else { # indeterminate
@ set data "moving"
@ }
@ } else {
@ sct geterror "Syntax error in: '${data}'=>'${data_list}'"
@ }
@ }
}
code write_function write_switch = {
@ if { [string equal -nocase -length 2 "${par}" "in"] } {
@ set cmd "SB${cmd_str}"
@ } elseif { [string equal -nocase -length 2 "${par}" "out"] } {
@ set cmd "CB${cmd_str}"
@ } else {
@ sct geterror "Value error: '${par}' not in ('in', 'out')"
@ }
}
#
# This code is after database creation
#
code mkDriver = {
}
};

View File

@ -0,0 +1,203 @@
ap1_absenchome,73952.0000
ap1_accel,1.4062
ap1_decel,1.4062
ap1_fwd_lim,105.0183
ap1_home,0.0000
ap1_rev_lim,0.0000
ap1_speed,1.4062
ap2_absenchome,54293.0000
ap2_accel,1.4062
ap2_decel,1.4062
ap2_fwd_lim,113.0713
ap2_home,0.0000
ap2_rev_lim,0.0000
ap2_speed,1.4062
ap3_absenchome,13644.0000
ap3_accel,1.4062
ap3_decel,1.4062
ap3_fwd_lim,104.2932
ap3_home,0.0000
ap3_rev_lim,0.0000
ap3_speed,1.4062
ap4_absenchome,5666.0000
ap4_accel,1.4062
ap4_decel,1.4062
ap4_fwd_lim,108.6768
ap4_home,0.0000
ap4_rev_lim,0.0000
ap4_speed,1.4062
ap5_absenchome,72824.0000
ap5_accel,1.4062
ap5_decel,1.4062
ap5_fwd_lim,104.0186
ap5_home,0.0000
ap5_rev_lim,0.0000
ap5_speed,1.4062
ap6_absenchome,72115.0000
ap6_accel,1.4062
ap6_decel,1.4062
ap6_fwd_lim,110.7422
ap6_home,0.0000
ap6_rev_lim,0.0000
ap6_speed,1.4062
ap7_absenchome,74299.0000
ap7_accel,1.4062
ap7_decel,1.4062
ap7_fwd_lim,104.6228
ap7_home,0.0000
ap7_rev_lim,0.0000
ap7_speed,1.4062
ap8_absenchome,6791.0000
ap8_accel,1.4062
ap8_decel,1.4062
ap8_fwd_lim,112.1924
ap8_home,0.0000
ap8_rev_lim,0.0000
ap8_speed,1.4062
att_absenchome,33394989.0000
att_accel,3.6000
att_decel,3.6000
att_fwd_lim,273.7734
att_home,0.0000
att_rev_lim,0.0000
att_speed,3.6000
bs3_absenchome,351548.0000
bs3_accel,5.6250
bs3_decel,5.6250
bs3_fwd_lim,-69.6162
bs3_home,0.0000
bs3_rev_lim,0.0000
bs3_speed,5.6250
cdd_absenchome,4159255.0000
cdd_accel,0.2500
cdd_decel,0.2500
cdd_fwd_lim,349.7198
cdd_home,0.0000
cdd_rev_lim,0.0000
cdd_speed,1.5000
cdl_absenchome,5769621.0000
cdl_accel,0.2500
cdl_decel,0.2500
cdl_fwd_lim,356.9644
cdl_home,0.0000
cdl_rev_lim,0.0000
cdl_speed,1.5000
cdr_absenchome,4371043.0000
cdr_accel,0.2500
cdr_decel,0.2500
cdr_fwd_lim,358.0801
cdr_home,0.0000
cdr_rev_lim,0.0000
cdr_speed,1.5000
cdu_absenchome,21804679.0000
cdu_accel,0.2500
cdu_decel,0.2500
cdu_fwd_lim,356.9028
cdu_home,0.0000
cdu_rev_lim,0.0000
cdu_speed,1.5000
col1_absenchome,3902.0000
col1_accel,0.3333
col1_decel,0.3333
col1_fwd_lim,270.2969
col1_home,0.0000
col1_rev_lim,0.0000
col1_speed,0.6667
col2_absenchome,9598.0000
col2_accel,0.3333
col2_decel,0.3333
col2_fwd_lim,270.9961
col2_home,0.0000
col2_rev_lim,0.0000
col2_speed,0.6667
col3_absenchome,29466.0000
col3_accel,0.3333
col3_decel,0.3333
col3_fwd_lim,268.1104
col3_home,0.0000
col3_rev_lim,0.0000
col3_speed,0.6667
col4_absenchome,12861.0000
col4_accel,0.3333
col4_decel,0.3333
col4_fwd_lim,269.4302
col4_home,0.0000
col4_rev_lim,0.0000
col4_speed,0.6667
col5_absenchome,377801.0000
col5_accel,0.3333
col5_decel,0.3333
col5_fwd_lim,268.7666
col5_home,0.0000
col5_rev_lim,0.0000
col5_speed,0.6667
col6_absenchome,191508.0000
col6_accel,0.3333
col6_decel,0.3333
col6_fwd_lim,271.2998
col6_home,0.0000
col6_rev_lim,0.0000
col6_speed,0.6667
col7_absenchome,24810.0000
col7_accel,0.3333
col7_decel,0.3333
col7_fwd_lim,269.9331
col7_home,0.0000
col7_rev_lim,0.0000
col7_speed,0.6667
col8_absenchome,12893.0000
col8_accel,0.3333
col8_decel,0.3333
col8_fwd_lim,267.6748
col8_home,0.0000
col8_rev_lim,0.0000
col8_speed,0.6667
det_absenchome,0.0000
det_accel,6.4103
det_decel,6.4103
det_fwd_lim,0.0000
det_home,0.0000
det_rev_lim,0.0000
det_speed,25.6410
sdh_absenchome,4166803.0000
sdh_fwd_lim,242.2931
sdh_home,0.0000
sdh_maxaccel,1.0000
sdh_maxdecel,1.0000
sdh_maxspeed,1.0000
sdh_rev_lim,0.0000
ss1d_absenchome,33398312.0000
ss1d_accel,0.5000
ss1d_decel,0.5000
ss1d_fwd_lim,114.3299
ss1d_home,0.0000
ss1d_rev_lim,0.0000
ss1d_speed,0.5000
ss1l_absenchome,31524107.0000
ss1l_accel,0.5000
ss1l_decel,0.5000
ss1l_fwd_lim,67.9708
ss1l_home,0.0000
ss1l_rev_lim,0.0000
ss1l_speed,0.5000
ss1r_absenchome,32248545.0000
ss1r_accel,0.5000
ss1r_decel,0.5000
ss1r_fwd_lim,71.6127
ss1r_home,0.0000
ss1r_rev_lim,0.0000
ss1r_speed,0.5000
ss1u_absenchome,33297987.0000
ss1u_accel,0.5000
ss1u_decel,0.5000
ss1u_fwd_lim,113.7317
ss1u_home,0.0000
ss1u_rev_lim,0.0000
ss1u_speed,0.5000
vs_absenchome,3789130.0000
vs_accel,0.4000
vs_decel,1.3333
vs_fwd_lim,275.2637
vs_home,0.0000
vs_rev_lim,0.0000
vs_speed,1.3333
1 ap1_absenchome 73952.0000
2 ap1_accel 1.4062
3 ap1_decel 1.4062
4 ap1_fwd_lim 105.0183
5 ap1_home 0.0000
6 ap1_rev_lim 0.0000
7 ap1_speed 1.4062
8 ap2_absenchome 54293.0000
9 ap2_accel 1.4062
10 ap2_decel 1.4062
11 ap2_fwd_lim 113.0713
12 ap2_home 0.0000
13 ap2_rev_lim 0.0000
14 ap2_speed 1.4062
15 ap3_absenchome 13644.0000
16 ap3_accel 1.4062
17 ap3_decel 1.4062
18 ap3_fwd_lim 104.2932
19 ap3_home 0.0000
20 ap3_rev_lim 0.0000
21 ap3_speed 1.4062
22 ap4_absenchome 5666.0000
23 ap4_accel 1.4062
24 ap4_decel 1.4062
25 ap4_fwd_lim 108.6768
26 ap4_home 0.0000
27 ap4_rev_lim 0.0000
28 ap4_speed 1.4062
29 ap5_absenchome 72824.0000
30 ap5_accel 1.4062
31 ap5_decel 1.4062
32 ap5_fwd_lim 104.0186
33 ap5_home 0.0000
34 ap5_rev_lim 0.0000
35 ap5_speed 1.4062
36 ap6_absenchome 72115.0000
37 ap6_accel 1.4062
38 ap6_decel 1.4062
39 ap6_fwd_lim 110.7422
40 ap6_home 0.0000
41 ap6_rev_lim 0.0000
42 ap6_speed 1.4062
43 ap7_absenchome 74299.0000
44 ap7_accel 1.4062
45 ap7_decel 1.4062
46 ap7_fwd_lim 104.6228
47 ap7_home 0.0000
48 ap7_rev_lim 0.0000
49 ap7_speed 1.4062
50 ap8_absenchome 6791.0000
51 ap8_accel 1.4062
52 ap8_decel 1.4062
53 ap8_fwd_lim 112.1924
54 ap8_home 0.0000
55 ap8_rev_lim 0.0000
56 ap8_speed 1.4062
57 att_absenchome 33394989.0000
58 att_accel 3.6000
59 att_decel 3.6000
60 att_fwd_lim 273.7734
61 att_home 0.0000
62 att_rev_lim 0.0000
63 att_speed 3.6000
64 bs3_absenchome 351548.0000
65 bs3_accel 5.6250
66 bs3_decel 5.6250
67 bs3_fwd_lim -69.6162
68 bs3_home 0.0000
69 bs3_rev_lim 0.0000
70 bs3_speed 5.6250
71 cdd_absenchome 4159255.0000
72 cdd_accel 0.2500
73 cdd_decel 0.2500
74 cdd_fwd_lim 349.7198
75 cdd_home 0.0000
76 cdd_rev_lim 0.0000
77 cdd_speed 1.5000
78 cdl_absenchome 5769621.0000
79 cdl_accel 0.2500
80 cdl_decel 0.2500
81 cdl_fwd_lim 356.9644
82 cdl_home 0.0000
83 cdl_rev_lim 0.0000
84 cdl_speed 1.5000
85 cdr_absenchome 4371043.0000
86 cdr_accel 0.2500
87 cdr_decel 0.2500
88 cdr_fwd_lim 358.0801
89 cdr_home 0.0000
90 cdr_rev_lim 0.0000
91 cdr_speed 1.5000
92 cdu_absenchome 21804679.0000
93 cdu_accel 0.2500
94 cdu_decel 0.2500
95 cdu_fwd_lim 356.9028
96 cdu_home 0.0000
97 cdu_rev_lim 0.0000
98 cdu_speed 1.5000
99 col1_absenchome 3902.0000
100 col1_accel 0.3333
101 col1_decel 0.3333
102 col1_fwd_lim 270.2969
103 col1_home 0.0000
104 col1_rev_lim 0.0000
105 col1_speed 0.6667
106 col2_absenchome 9598.0000
107 col2_accel 0.3333
108 col2_decel 0.3333
109 col2_fwd_lim 270.9961
110 col2_home 0.0000
111 col2_rev_lim 0.0000
112 col2_speed 0.6667
113 col3_absenchome 29466.0000
114 col3_accel 0.3333
115 col3_decel 0.3333
116 col3_fwd_lim 268.1104
117 col3_home 0.0000
118 col3_rev_lim 0.0000
119 col3_speed 0.6667
120 col4_absenchome 12861.0000
121 col4_accel 0.3333
122 col4_decel 0.3333
123 col4_fwd_lim 269.4302
124 col4_home 0.0000
125 col4_rev_lim 0.0000
126 col4_speed 0.6667
127 col5_absenchome 377801.0000
128 col5_accel 0.3333
129 col5_decel 0.3333
130 col5_fwd_lim 268.7666
131 col5_home 0.0000
132 col5_rev_lim 0.0000
133 col5_speed 0.6667
134 col6_absenchome 191508.0000
135 col6_accel 0.3333
136 col6_decel 0.3333
137 col6_fwd_lim 271.2998
138 col6_home 0.0000
139 col6_rev_lim 0.0000
140 col6_speed 0.6667
141 col7_absenchome 24810.0000
142 col7_accel 0.3333
143 col7_decel 0.3333
144 col7_fwd_lim 269.9331
145 col7_home 0.0000
146 col7_rev_lim 0.0000
147 col7_speed 0.6667
148 col8_absenchome 12893.0000
149 col8_accel 0.3333
150 col8_decel 0.3333
151 col8_fwd_lim 267.6748
152 col8_home 0.0000
153 col8_rev_lim 0.0000
154 col8_speed 0.6667
155 det_absenchome 0.0000
156 det_accel 6.4103
157 det_decel 6.4103
158 det_fwd_lim 0.0000
159 det_home 0.0000
160 det_rev_lim 0.0000
161 det_speed 25.6410
162 sdh_absenchome 4166803.0000
163 sdh_fwd_lim 242.2931
164 sdh_home 0.0000
165 sdh_maxaccel 1.0000
166 sdh_maxdecel 1.0000
167 sdh_maxspeed 1.0000
168 sdh_rev_lim 0.0000
169 ss1d_absenchome 33398312.0000
170 ss1d_accel 0.5000
171 ss1d_decel 0.5000
172 ss1d_fwd_lim 114.3299
173 ss1d_home 0.0000
174 ss1d_rev_lim 0.0000
175 ss1d_speed 0.5000
176 ss1l_absenchome 31524107.0000
177 ss1l_accel 0.5000
178 ss1l_decel 0.5000
179 ss1l_fwd_lim 67.9708
180 ss1l_home 0.0000
181 ss1l_rev_lim 0.0000
182 ss1l_speed 0.5000
183 ss1r_absenchome 32248545.0000
184 ss1r_accel 0.5000
185 ss1r_decel 0.5000
186 ss1r_fwd_lim 71.6127
187 ss1r_home 0.0000
188 ss1r_rev_lim 0.0000
189 ss1r_speed 0.5000
190 ss1u_absenchome 33297987.0000
191 ss1u_accel 0.5000
192 ss1u_decel 0.5000
193 ss1u_fwd_lim 113.7317
194 ss1u_home 0.0000
195 ss1u_rev_lim 0.0000
196 ss1u_speed 0.5000
197 vs_absenchome 3789130.0000
198 vs_accel 0.4000
199 vs_decel 1.3333
200 vs_fwd_lim 275.2637
201 vs_home 0.0000
202 vs_rev_lim 0.0000
203 vs_speed 1.3333

View File

@ -0,0 +1,69 @@
#
# Simple driver generator for the non-motor galil controls on mc8
# vim: ts=8 sts=2 sw=2 expandtab autoindent smartindent nocindent
#
driver tank = {
vendor = galil; device = mc8; protocol = dmc2280;
class = instrument
simulation_group = motor_simulation
#
# Unnamed group has variables at device level
#
#
# The named group is at the device level, variables below that
#
group switches = {
type = text;
priv = user;
readable = 1;
read_function = read_switch;
var forward = {
read_command = 'MG @IN[5]'
}
var reverse = {
read_command = 'MG @IN[6]'
}
};
group limits = {
type = text;
priv = user;
readable = 1;
read_function = read_switch;
var forward = {
read_command = 'MG _LFH'
}
var reverse = {
read_command = 'MG _LRH'
}
};
#
# Code lines start with '@' which is stripped before being emitted
# The code is emitted at the appropriate place in the given function
#
code read_function read_switch = {
@ if { [string equal -nocase -length 1 "${data}" "?"] } {
@ sct geterror "Galil error in: '${data}'"
@ } else {
@ set data_list [split [string trim "${data}"]]
@ if { [llength ${data_list}] > 1 && [lindex ${data_list} end] == ":" } {
@ set data_list [lrange ${data_list} 0 0]
@ }
@ if { [llength ${data_list}] == 1 } {
@ set left [expr [lindex ${data_list} 0]]
@ if { ${left} == 1 } { # open
@ set data "open"
@ } else { # closed
@ set data "closed"
@ }
@ } else {
@ sct geterror "Syntax error in: '${data}'=>'${data_list}'"
@ }
@ }
}
#
# This code is after database creation
#
code mkDriver = {
}
};

View File

@ -0,0 +1,24 @@
col1_maxaccel,0.75
col1_maxdecel,0.75
col1_maxspeed,0.75
col2_maxaccel,0.75
col2_maxdecel,0.75
col2_maxspeed,0.75
col3_maxaccel,0.75
col3_maxdecel,0.75
col3_maxspeed,0.75
col4_maxaccel,0.75
col4_maxdecel,0.75
col4_maxspeed,0.75
col5_maxaccel,0.75
col5_maxdecel,0.75
col5_maxspeed,0.75
col6_maxaccel,0.75
col6_maxdecel,0.75
col6_maxspeed,0.75
col7_maxaccel,0.75
col7_maxdecel,0.75
col7_maxspeed,0.75
col8_maxaccel,0.75
col8_maxdecel,0.75
col8_maxspeed,0.75
1 col1_maxaccel 0.75
2 col1_maxdecel 0.75
3 col1_maxspeed 0.75
4 col2_maxaccel 0.75
5 col2_maxdecel 0.75
6 col2_maxspeed 0.75
7 col3_maxaccel 0.75
8 col3_maxdecel 0.75
9 col3_maxspeed 0.75
10 col4_maxaccel 0.75
11 col4_maxdecel 0.75
12 col4_maxspeed 0.75
13 col5_maxaccel 0.75
14 col5_maxdecel 0.75
15 col5_maxspeed 0.75
16 col6_maxaccel 0.75
17 col6_maxdecel 0.75
18 col6_maxspeed 0.75
19 col7_maxaccel 0.75
20 col7_maxdecel 0.75
21 col7_maxspeed 0.75
22 col8_maxaccel 0.75
23 col8_maxdecel 0.75
24 col8_maxspeed 0.75

View File

@ -0,0 +1,4 @@
source $cfPath(nexus)/nxscripts_common_1.tcl
proc ::nexus::isc_initialize {} {
::nexus::ic_initialize
}

View File

@ -0,0 +1 @@
Optical Components: Neutron Guides, Apertures, Polariser, Focussing Lenses and Prisms

View File

@ -0,0 +1,94 @@
namespace eval optics {
array set AttRotLookupTable {
0 { 0.0 1 }
30 { 1.3 0.498782 }
60 { 3.3 0.176433 }
90 { 4.9 0.0761367 }
120 { 6.4 0.0353985 }
150 { 8.3 0.0137137 }
180 { 9.6 0.00614167 }
210 {11.2 0.00264554 }
240 {13.1 0.000994504 }
270 {15.0 0.000358897 }
300 {18.0 7.2845e-05 }
330 {25.0 1.67827e-06 }
}
array set EApLookupTable {
0 { 5 circ}
30 {10 circ}
60 {20 circ}
90 {30 circ}
120 {40 circ}
150 {50 circ}
180 {50 squ }
210 {open open}
240 {open open}
270 {open open}
300 {open open}
330 {open open}
}
}
proc ::optics::AttRotLookup {angle column tol} {
variable AttRotLookupTable
set catch_status [ catch {
set foundit false
foreach vangle [array names AttRotLookupTable] {
if {$vangle >= [expr {$angle-$tol}] && $vangle <= [expr {$angle+$tol}]} {
set foundit true
break
}
}
if {$foundit == true} {
switch $column {
"plex" { set index 0 }
"attfactor" { set index 1 }
default { error "$column is unknown, allowed values are plex or attfactor" }
}
return [lindex $AttRotLookupTable($vangle) $index]
} else {
return -1
}
} message ]
handle_exception $catch_status $message
}
proc ::optics::EApLookUp {angle param tol} {
variable EApLookupTable
set foundit false
if [ catch {
if {$param == "size"} {
set cgf [SplitReply [GuideConfig]]
if {[string first $cgf "g1 g2 g3 g4 g5 g6 g7 g8 g9 p1 p2 p3 p4 p5 p6 p7 p8 p9"] != -1} {
return 50
}
}
switch $param {
"size" {set index 0}
"shape" {set index 1}
default {
error "ERROR: Invalid lookup parameter $param"
}
}
foreach vangle [array names EApLookupTable] {
if {$vangle >= [expr {$angle-$tol}] && $vangle <= [expr {$angle+$tol}]} {
set foundit true
break
}
}
if {$foundit == true} {
return [lindex $EApLookupTable($vangle) $index]
} else {
switch $param {
"size" {return 0}
"shape" {return "UNKNOWN"}
}
}
} message ] {
if {$::errorCode == "NONE"} {return $message}
return -code error "$message"
}
}

View File

@ -0,0 +1,66 @@
##
# @file
# A guide configuration table where each line describes the setup
# for a mode of operation.
# The table will have a corresponding interpretation list which provides
# commands to setup the instrument.
namespace eval optics {
##
# @brief These arrays map the component identifiers (G, MT, etc) to the
# position index for each guide motor (c1, c2 ... c9)
array set c1_map {G 1 MT 2 P 3}
array set c2_map {MT 1 G 2 A 3}
array set c3_map {MT 1 G 2 A 3}
array set c4_map {MT 1 G 2 A 3}
array set c5_map {MT 1 G 2 A 3}
array set c6_map {MT 1 G 2 A 3}
array set c7_map {MT 1 G 2 A 3}
array set c8_map {MT 1 G 2 A 3}
array set c9_map {L 1 MT 2 G 3 A 4 LP 5}
# The guide configuration table is indexed by a configuration
# identifier (ga, mt, lp, etc). Each row has two elements,
# 1. A list of components selected for each guide (MT A ... etc)
# 2. The entrance aperature position in mm
# Eg $guide_configuration(p2) returns the following list
# {{P G A A A A A A A } 6934}
array set guide_configuration {
ga {{MT A A A A A A A A } 675}
mt {{MT MT MT MT MT MT MT MT MT} 675}
lp {{MT MT MT MT MT MT MT MT LP} 675}
lens {{MT A A A A A A A L } 675}
p1 {{P A MT MT MT MT MT MT MT} 4621}
p1lp {{P A MT MT MT MT MT MT LP} 4621}
p1lens {{P A MT MT MT MT MT MT L } 4621}
g1 {{G A A A A A A A A } 4929}
p2 {{P G A A A A A A A } 6934}
g2 {{G G A A A A A A A } 6934}
p3 {{P G G A A A A A A } 8949}
g3 {{G G G A A A A A A } 8949}
p4 {{P G G G A A A A A } 10955}
g4 {{G G G G A A A A A } 10955}
p5 {{P G G G G A A A A } 12943}
g5 {{G G G G G A A A A } 12943}
p6 {{P G G G G G A A A } 14970}
g6 {{G G G G G G A A A } 14970}
p7 {{P G G G G G G A A } 16971}
g7 {{G G G G G G G A A } 16971}
p8 {{P G G G G G G G A } 18937}
g8 {{G G G G G G G G A } 18937}
p9 {{P G G G G G G G G } 19925}
g9 {{G G G G G G G G G } 19925}
}
# This list maps the motor names to columns of the
# guide_configuration table.
set guide_configuration_columns {
c1 c2 c3 c4 c5 c6 c7 c8 c9
}
}
namespace eval optics {
variable guide_configuration
variable guide_configuration_columns
}

View File

@ -0,0 +1,2 @@
fileeval $cfPath(optics)/guide_configuration.tcl
fileeval $cfPath(optics)/aperture_configuration.tcl

View File

@ -0,0 +1,7 @@
set sim_mode [SplitReply [plc_simulation]]
if {$sim_mode == "false"} {
MakeAsyncQueue plc_chan SafetyPLC [dict get $::PLC_HOSTPORT HOST] [dict get $::PLC_HOSTPORT PORT]
MakeSafetyPLC plc plc_chan 0
}
source $cfPath(plc)/plc_common_1.tcl

View File

@ -0,0 +1,6 @@
source $cfPath(scan)/scan_common_1.tcl
proc ::scan::pre_hmm_scan_prepare {} {}
proc ::scan::isc_initialize {} {
::scan::ic_initialize
}

View File

@ -0,0 +1,52 @@
# MOTOR HOST AND PORT
foreach {mc host port} {
MC1 mc1-bilby 1034
MC2 mc2-bilby 1034
MC3 mc3-bilby 1034
MC4 mc4-bilby 1034
MC5 mc5-bilby 1034
MC6 mc6-bilby 1034
MC7 mc7-bilby 1034
MC8 mc8-bilby 1034
} {
dict set MOTOR_HOSTPORT $mc HOST $host
dict set MOTOR_HOSTPORT $mc PORT $port
}
# BEAM MONITOR HOST AND PORT
foreach {bm host port} {
MONITOR_1 das1-bilby 30000
} {
dict set MONITOR_HOSTPORT $bm HOST $host
dict set MONITOR_HOSTPORT $bm PORT $port
}
# HISTOGRAM SERVER HOST AND PORT
# TODO HV control
foreach {key host port} {
HMM das1-bilby.nbi.ansto.gov.au 8080
HMSTAT das1-bilby.nbi.ansto.gov.au 8081
ORDELA 137.157.202.71 4001
NHQ200 ca1-bilby 4002
} {
dict set HISTMEM_HOSTPORT $key HOST $host
dict set HISTMEM_HOSTPORT $key PORT $port
}
# VELOCITY SELECTOR HOST AND PORT
# TODO
foreach {key host port} {
NVS IP 10000
} {
dict set VELSEL_HOSTPORT $key HOST $host
dict set VELSEL_HOSTPORT $key PORT $port
}
# Safety Interlock System
# TODO
foreach {host port} {
IP PORT
} {
dict set PLC_HOSTPORT HOST $host
dict set PLC_HOSTPORT PORT $port
}

View File

@ -0,0 +1,52 @@
# Specify NONE for HOST and PORT if there is no fake device to talk to.
# TEST MOTOR HOST AND PORT
foreach {key host port} {
MC1 localhost 63030
MC2 localhost 63031
MC3 localhost 63032
MC4 localhost 63033
MC5 localhost 63034
MC6 localhost 63035
MC7 localhost 63036
MC8 localhost 63037
} {
dict set MOTOR_HOSTPORT $key HOST $host
dict set MOTOR_HOSTPORT $key PORT $port
}
# TEST BEAM MONITOR HOST AND PORT
foreach {key host port} {
MONITOR_1 localhost 30000
} {
dict set MONITOR_HOSTPORT $key HOST $host
dict set MONITOR_HOSTPORT $key PORT $port
}
# TEST HISTOGRAM SERVER HOST AND PORT
foreach {key host port} {
HMM das1-test.nbi.ansto.gov.au 8080
HMSTAT das1-test.nbi.ansto.gov.au 8081
ORDELA localhost 4001
NHQ200 localhost 4002
} {
dict set HISTMEM_HOSTPORT $key HOST $host
dict set HISTMEM_HOSTPORT $key PORT $port
}
# VELOCITY SELECTOR HOST AND PORT
foreach {key host port} {
NVS localhost 10000
} {
dict set VELSEL_HOSTPORT $key HOST $host
dict set VELSEL_HOSTPORT $key PORT $port
}
# Safety Interlock System
# TODO
foreach {host port} {
NONE NONE
} {
dict set PLC_HOSTPORT HOST $host
dict set PLC_HOSTPORT PORT $port
}

View File

@ -0,0 +1,3 @@
inst_user = 'bilby_sics'
inst_name = 'bilby'
inst_config = 'bilby_configuration.tcl'

View File

@ -1,10 +1,6 @@
# Author: Ferdi Franceschini (ffr@ansto.gov.au)
# TODO Handle sequencing when simultaneously moving multiple axes
# TODO Handle functional dependencies (just write your own tcl script)
# or get the generic acscript to call a user proc
# FIXME The anticollider module does not report the error messages from the
# anticollision script, we currently get around this by using broadcast.
AntiCollisionInstall
namespace eval anticollider {
@ -13,11 +9,41 @@ namespace eval anticollider {
array unset ::anticollider::veto_region
array set ::anticollider::veto_region ""
# Don't show 'acscript' call on error. This is done by the anticollider
# module.
proc handle_acscript_exception {status message args} {
switch $status {
0 {
# TCL_OK, This is raised when you just drop out of the
# bottom of a 'catch' command.
return -code ok
}
1 {
# TCL_ERROR
return -code error "$message: $args"
}
2 {
# TCL_RETURN
return -code return "$message"
}
3 {
# TCL_BREAK
return -code break
}
4 {
# TCL_CONTINUE
return -code continue
}
default {
# Propogate user defined return codes with message
return -code $status "$message"
}
}
}
##
# @brief Load an anticollider script
proc ::anticollider::loadscript {args} {
variable prog
set prog ""
variable veto_rules
set fh [open $::cfPath(anticollider)/[lindex $args 0] RDONLY ]
while {[gets $fh line] >= 0} {
@ -25,7 +51,7 @@ proc ::anticollider::loadscript {args} {
if [regexp {^\s*$|^ *#} $line] {
continue
}
lappend prog $line
lappend veto_rules $line
}
}
@ -33,7 +59,7 @@ proc ::anticollider::loadscript {args} {
# @brief Compile compile an anticollider declaration into a veto region table
# for the anticollider script.
#
# @param vprog, an anticollider declaration as a list of quote enclosed lines.
# @param veto_rules, an anticollider declaration as a list of quote enclosed lines.
# @return Generates the ::anticollider::veto_region lookup table.
#
# Example\n
@ -44,14 +70,16 @@ proc ::anticollider::loadscript {args} {
# for sphi forbid { {0 5} {10 15} } when schi in { {5 10} {15 20} }\n
# forbid {-inf 5} when mtth in {0 10} for sphi\n
# forbid {0 10} for samx whenall { samrot in {0 5} samy in {0 15} }\n
proc ::anticollider::genveto {vprog} {
proc ::anticollider::genveto {veto_rules} {
variable veto_region
array unset veto_region
set lnum 1
foreach line $vprog {
foreach line $veto_rules {
array unset vp
array set vp $line
clientput "::anticollider::veto_rule: $line"
if [info exists vp(whenall)] {
foreach {mot in range} $vp(whenall) {
# if {[llength [join $range]] != 2} {
@ -88,16 +116,14 @@ proc ::anticollider::enable {args} {
#
# The ::anticollider::veto_region is a hash indexed by the names of the motors
# which have been registered with the anticollision module.
proc ::anticollider::acscript {args} {
proc ::anticollider::veto_region_acscript {args} {
variable veto_region
if {[::anticollider::enable $args] == "false"} {
set catch_status [ catch {
foreach {regmot target} $args {
anticollision add 0 $regmot $target
if { ! [info exists veto_region($regmot)] } {
continue
}
return
}
foreach {regmot target} $args {
foreach row $veto_region($regmot) {
if { [lindex $row 1] == "@and"} {
set forbid [lindex $row 0]
@ -116,7 +142,6 @@ proc ::anticollider::acscript {args} {
} else {
foreach {min max} $forbid {}
if {$min <= $target && $target <= $max} {
broadcast "ERROR:The range ($forbid) is forbidden for $regmot when [lindex $row 2]"
error "ERROR:The range ($forbid) is forbidden for $regmot when [lindex $row 2]"
}
}
@ -126,17 +151,14 @@ proc ::anticollider::acscript {args} {
if {$obstrange == "@all"} {
foreach {min max} [join $forbidden_range] {
if {$min <= $target && $target <= $max} {
broadcast "ERROR: $regmot target ($target) is in the forbidden region ($forbidden_range)"
error "ERROR: $regmot target ($target) is in the forbidden region ($forbidden_range)"
}
}
} else {
broadcast "ERROR: veto table must use @all with @any"
error "ERROR: veto table must use @all with @any"
}
} else {
if {$obstrange == "@all"} {
broadcast "ERROR: veto table must use @any with @all"
error "ERROR: veto table must use @any with @all"
} else {
foreach {lower upper} [join $obstrange] {
@ -144,7 +166,6 @@ proc ::anticollider::acscript {args} {
if {$lower <= $pos && $pos <= $upper} {
foreach {min max} [join $forbidden_range] {
if {$min <= $target && $target <= $max} {
broadcast "ERROR:The range $min to $max is forbidden for $regmot when $obstmot is in this region ($obstrange)"
error "ERROR:The range $min to $max is forbidden for $regmot when $obstmot is in this region ($obstrange)"
}
@ -156,8 +177,9 @@ proc ::anticollider::acscript {args} {
}
}
}
anticollision add 0 $regmot $target
}
} message ]
handle_exception $catch_status $message
}
##
@ -166,16 +188,37 @@ proc ::anticollider::init {} {
variable evp
variable veto_region
if [ catch {
::anticollider::genveto $::anticollider::prog
set catch_status [ catch {
if { ![info exists ::anticollider::veto_rules] } {
return
}
clientput Load anticollider rules:
if { [info procs ::anticollider::load_acrules] == "::anticollider::load_acrules" } {
::anticollider::load_acrules
}
::anticollider::genveto $::anticollider::veto_rules
foreach motor [array names veto_region] {
anticollision register $motor
}
} message ] {
clientput [info level 0] ERROR: $message
if {$::errorCode=="NONE"} {return $message}
return -code error $message
} message ]
handle_exception $catch_status $message
}
lappend ::anticollider::scripts ::anticollider::veto_region_acscript
proc ::anticollider::acscript {args} {
set catch_status [ catch {
if {[::anticollider::enable $args] == "false"} {
return
} else {
foreach {regmot target} $args {
anticollision add 0 $regmot $target
}
}
foreach script $::anticollider::scripts {
$script {*}$args
}
} message ]
handle_acscript_exception $catch_status $message
}
publish ::anticollider::acscript user

View File

@ -60,6 +60,7 @@ proc ::counter::ic_initialize {} {
::utility::macro::getset float monitor_counts {} {
bm status
return "monitor_counts = [SplitReply [bm getcounts]]"
}
sicslist setatt monitor_counts klass monitor
@ -67,6 +68,7 @@ proc ::counter::ic_initialize {} {
sicslist setatt monitor_counts mutable true
::utility::macro::getset float monitor_time {} {
bm status
return "monitor_time = [SplitReply [bm gettime]]"
}
sicslist setatt monitor_time klass monitor
@ -77,6 +79,7 @@ proc ::counter::ic_initialize {} {
set bm_counts bm${bm_num}_counts
set bmon bm${bm_num}
::utility::macro::getset int $bm_counts {} [subst -nocommands {
$bmon status
return "[$bmon getcounts]"
}]
sicslist setatt $bm_counts klass monitor
@ -86,6 +89,7 @@ proc ::counter::ic_initialize {} {
set bm_time bm${bm_num}_time
set bmon bm${bm_num}
::utility::macro::getset float $bm_time {} [subst -nocommands {
$bmon status
return "[$bmon gettime]"
}]
sicslist setatt $bm_time klass monitor

View File

@ -0,0 +1,302 @@
#
# Simple driver generator for the Hiden Isochema XCS vapour delivery system
# vim: ts=8 sts=2 sw=2 expandtab autoindent smartindent nocindent
#
driver hiden_xcs = {
# driver_property douglas = clowes
vendor = hiden; device = xcs; protocol = std;
class = environment
simulation_group = environment_simulation
add_args = 'terminator {tol 0.5}';
make_args = 'tol';
protocol_args = '${terminator}';
#
# Unnamed group has variables at device level
#
group = {
# group_property douglas = clowes
type = float
priv = user
group_property 'data' = 'true'
group_property 'nxsave' = 'true'
property 'klass' = 'environment'
property 'sdsinfo' = '::nexus::scobj::sdsinfo'
var enabled = {
type = int;
priv = user;
readable = 10;
writeable = 1;
read_function = read_digital;
write_Function = write_digital;
read_command = '?DOUT,2';
write_command = '!DOUT,2,';
allowed = '0,1';
readable = 10;
# property junk = junk;
}
var flow = {
driveable = flow
mutable = true
readable = 1
read_command = 'None'
fetch_function = fetch_flow
read_function = read_flow
write_function = write_flow
lowerlimit = 0
upperlimit = 500
tolerance = 1
pid_function = pid_flow
property pid_error = 0
property pid_deriv = 0
property pid_integ = 0
property pid_pvalue = 0.2
property pid_ivalue = 0.1
property pid_dvalue = 0.0
property pid_imax = 30
}
var humidity = {
driveable = humidity
mutable = true
readable = 1
read_command = '?ALL DATA'
read_function = read_all_data
write_function = write_humidity
checkrange_function = chkrange_function
value = 50
lowerlimit = 10
upperlimit = 90
tolerance = 1
pid_function = pid_humidity
property pid_error = 0
property pid_deriv = 0
property pid_integ = 0
property pid_pvalue = 0.2
property pid_ivalue = 0.1
property pid_dvalue = 0.0
property pid_imax = 30
property settle_time = 5.250
}
var gas_factor = { value = 1.0; }
control = false
data = false
nxsave = false
var temperature
var flow1
var flow2
var flow3
}
#
# The named group is at the device level, variables below that
#
group analog = {
# group_property 'data' = true
type = float;
priv = user;
control = false
data = false
nxsave = false
readable = 5;
read_function = read_sixteen;
property base = 0; # applies to all following vars
var pv1 = { read_command = '?AIN,0'; property span = 500; }; # ain0
var pv2 = { read_command = '?AIN,1'; property span = 500; }; # ain1
var pv3 = { read_command = '?AIN,2'; property span = 500; }; # ain2
var rhtemp = { read_command = '?AIN,8'; property span = 100; }; # ain8
var rhsense = { read_command = '?AIN,9'; property span = 100; }; # ain9
var ansto_temp = { read_command = '?AIN,12'; property span = 100; }; # ain12
writeable = 1;
read_function = read_twelve;
write_function = write_twelve;
var sp1 = { read_command = '?AOUT,0'; write_command = '!AOUT,0,'; property span = 500; } # aout0
var sp2 = { read_command = '?AOUT,1'; write_command = '!AOUT,1,'; property span = 500; } # aout1
var sp3 = { read_command = '?AOUT,2'; write_command = '!AOUT,2,'; property span = 500; } # aout2
};
#
# Code lines start with '@' which is stripped before being emitted into generated driver
# The code is emitted at the appropriate place in the given function
#
code read_function read_digital = {
@ if { [string equal -nocase -length 5 "${data}" "DOUT ="] } {
@ set result [scan "${data}" "DOUT = %d OK" val]
@ if { ${result} == 1 } {
@ set data ${val}
@ } else {
@ sct geterror "Syntax error (Result=${result}) in: '${data}'"
@ }
@ } else {
@ sct geterror "Syntax error in: '${data}'"
@ }
}
code read_function read_twelve = {
@ if { [string equal -nocase -length 5 "${data}" "AOUT ="] } {
@ set result [scan "${data}" "AOUT = %d OK" val]
@ if { ${result} == 1 } {
@ if { [hpropexists [sct] base] } {
@ set base [sct base]
@ } else {
@ set base 0.0
@ }
@ if { [hpropexists [sct] span] } {
@ set span [sct span]
@ } else {
@ set span 500.0
@ }
@ set data [expr (${span} * (${val} - ${base})) / 4095.0]
@ } else {
@ sct geterror "Syntax (Result=${result}) error in: '${data}'"
@ }
@ } else {
@ sct geterror "Syntax error in: '${data}'"
@ }
}
code read_function read_sixteen = {
@ if { [string equal -nocase -length 5 "${data}" "AIN ="] } {
@ set result [scan "${data}" "AIN = %d OK" val]
@ if { ${result} == 1 } {
@ if { [hpropexists [sct] base] } {
@ set base [sct base]
@ } else {
@ set base 0.0
@ }
@ if { [hpropexists [sct] span] } {
@ set span [sct span]
@ } else {
@ set span 500.0
@ }
@ set data [expr (${span} * (${val} - ${base})) / 65535.0]
@ } else {
@ sct geterror "Syntax error (Result=${result}) in: '${data}'"
@ }
@ } else {
@ sct geterror "Syntax error in: '${data}'"
@ }
}
code read_function read_all_data = {
@ if { [string equal -nocase -length 2 "${data}" "A "] } {
@ set data_list [split [string range "${data}" 2 end-3] ',']
@ if { [llength ${data_list}] == 8 } {
@ set data [expr [lindex ${data_list} 0]]
@ hupdate ${tc_root}/temperature [expr [lindex ${data_list} 1]]
@ hupdate ${tc_root}/flow1 [expr [lindex ${data_list} 3] / [hval ${tc_root}/gas_factor]]
@ hupdate ${tc_root}/flow2 [expr [lindex ${data_list} 4] / [hval ${tc_root}/gas_factor]]
@ hupdate ${tc_root}/flow3 [expr [lindex ${data_list} 5] / [hval ${tc_root}/gas_factor]]
@ } else {
@ sct geterror "Syntax error (Result=${result}) in: '${data}'"
@ }
@ } else {
@ sct geterror "Syntax error for read_all_data in: '${data}'"
@ }
@ if { [hpropexists [sct] target] } {
@ set pid [pid_humidity ${tc_root} [sct target] ${data}]
@ }
}
code pid_function pid_humidity = {
@ set path [pathname [sct]]
@ set sign 1
@ foreach node [list analog/sp1 analog/sp2] {
@ set sign [expr -${sign}]
@ set signed_pid [expr ${sign} * ${pid}]
@ hsetprop ${path}/${node} bias_humidity ${signed_pid}
@ if { [hpropexists ${path}/${node} target] } {
@ hset ${path}/${node} [hgetpropval ${path}/${node} target]
@ } else {
@ hset ${path}/${node} [hval ${path}/${node}]
@ }
@ }
@ }
}
code fetch_function fetch_flow = {
@ set data 0.0
@ set targets 0.0
@ set path [pathname [sct]]
@ foreach node [list flow1 flow2] {
@ set data [expr ${data} + [hval ${path}/${node}]]
@ }
@ sct result ${data}
@ foreach node [list analog/sp1 analog/sp2] {
@ set targets [expr ${targets} + [hval ${path}/${node}]]
@ }
@ sct targets ${targets}
@ if { [hpropexists [sct] target] } {
@ set pid [pid_flow ${tc_root} [sct target] ${data}]
@ }
@# cut this function short
@ return ${nextState}
}
code pid_function pid_flow = {
@ set path [pathname [sct]]
@ foreach node [list analog/sp1 analog/sp2] {
@ hsetprop ${path}/${node} bias_flow ${pid}
@ if { [hpropexists ${path}/${node} target] } {
@ hset ${path}/${node} [hgetpropval ${path}/${node} target]
@ } else {
@ hset ${path}/${node} [hval ${path}/${node}]
@ }
@ }
@ }
}
code write_function write_digital = {
}
code write_function write_twelve = {
@ if { [hpropexists [sct] base] } {
@ set base [sct base]
@ } else {
@ set base 0.0
@ }
@ if { [hpropexists [sct] span] } {
@ set span [sct span]
@ } else {
@ set span 500.0
@ }
@ if { [hpropexists [sct] bias_humidity] } {
@ set par [expr ${par} + [sct bias_humidity]]
@ }
@ if { [hpropexists [sct] bias_flow] } {
@ set par [expr ${par} + [sct bias_flow]]
@ }
@ if { ${par} < 0.0 } {
@ set par 0.0
@ }
@ if { ${par} > ${span} } {
@ set par ${span}
@ }
@ set par [expr int(${base} + (4095.0 * ${par} / ${span}))]
@ set cmd "${cmd_str}${par}"
}
code write_function write_flow = {
@ if { [hpropexists ${tc_root}/humidity target] } {
@ set humidity_target [hgetpropval ${tc_root}/humidity target]
@ } else {
@ set humidity_target [hval ${tc_root}/humidity]
@ }
@ set flow1_target [expr (0.01 * (100.0 - ${humidity_target})) * [sct target]]
@ set flow2_target [expr (0.01 * ( ${humidity_target})) * [sct target]]
@ hset ${tc_root}/analog/sp1 ${flow1_target}
@ hset ${tc_root}/analog/sp2 ${flow2_target}
@ set cmd "@@NOSEND@@"
}
code write_function write_humidity = {
@ if { [hpropexists ${tc_root}/flow target] } {
@ set flow_target [hgetpropval ${tc_root}/flow target]
@ } else {
@ set flow_target [hval ${tc_root}/flow]
@ }
@ set flow1_target [expr (0.01 * (100.0 - [sct target])) * ${flow_target}]
@ set flow2_target [expr (0.01 * ( [sct target])) * ${flow_target}]
@ hset ${tc_root}/analog/sp1 ${flow1_target}
@ hset ${tc_root}/analog/sp2 ${flow2_target}
@ set cmd "@@NOSEND@@"
}
code write_function no_op = {
@ set cmd "@@NOSEND@@"
}
#
# This code is after database creation
#
code mkDriver = {
}
code chkrange_function = {
@ # hooked
}
};

View File

@ -0,0 +1,57 @@
# Simple driver generator for the ISOTECH Power Supply
# vim: ts=8 sts=2 sw=2 expandtab autoindent smartindent
#
driver isotech_ps = {
vendor = isotech; device = ps; protocol = std;
class = environment;
simulation_group = environment_simulation;
protocol_args = '"\r"';
group = {
readable = 5
mutable = true
var relay = {
type = int;
read_command = 'F';
read_function = read_relay;
writeable = 1
write_command = 'KO';
write_function = write_relay;
}
var amps = {
type = float;
read_command = 'A';
units = 'A'
}
var volts = {
type = float;
read_command = 'V';
writeable = 1;
write_command = 'SV';
write_function = write_voltage;
units = 'V'
}
}
code read_function rdValue = {
@ set data [string range [sct result] 1 end]
}
code read_function read_relay = {
@ if { [string equal -nocase -length 2 "F1" "${data}"] } {
@ set data 1
@ } elseif { [string equal -nocase -length 2 "F0" "${data}"] } {
@ set data 0
@ } else {
@ sct geterror "Unexpected response '${data}' not 'F1' nor 'F0'"
@ }
}
code write_function write_relay = {
@ if { ${par} == 0 } {
@ set cmd "KOD"
@ } else {
@ set cmd "KOE"
@ }
}
code write_function write_voltage = {
@ set par "[format "%05.2f" [sct target]]"
@ set cmd "SV ${par}"
}
}

View File

@ -1125,7 +1125,7 @@ proc createNode {scobj_hpath sct_controller cmdGroup varName readable writable p
if {$drivable == 1} {
hsetprop $nodeName check ${ns}::check $scobj_hpath 1
hsetprop $nodeName driving 0
hsetprop $nodeName checklimits ${ns}::check $scobj_hpath
hsetprop $nodeName checklimits ${ns}::check $scobj_hpath 1
hsetprop $nodeName checkstatus ${ns}::drivestatus $scobj_hpath
hsetprop $nodeName halt ${ns}::halt $scobj_hpath
}
@ -1322,6 +1322,7 @@ proc mk_sct_bruker_BEC1 {sct_controller klasse tempobj tol} {
# Changed ffr 20100625: do not call hinitprops to avoid a conflict with a change in SICServer vers. 2_5
#::scobj::hinitprops $tempobj/sensor nominal_outp_current
hsetprop $scobj_hpath/pwrctrl/statusByte control false
hsetprop $scobj_hpath/sensor/desired_current type drivable
ansto_makesctdrive ${tempobj}_driveable $scobj_hpath/sensor/desired_current $scobj_hpath/sensor/nominal_outp_current $sct_controller

View File

@ -16,26 +16,6 @@ namespace eval ::scobj::cybaman {
close $fd
}
proc basename {node} {
set point [string last "/" $node]
if { $point < 0 } {
return $node
} else {
incr point
return "[string range $node $point end]"
}
}
proc pathname {node} {
set point [string last "/" $node]
if { $point < 0 } {
return ""
} else {
incr point -1
return "[string range $node 0 $point]"
}
return "[join [lrange [split $node '/'] 0 end-1] '/']"
}
proc splitxml {str} {
set my_list [list]
set idx 0

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,357 @@
# Generated driver for isotech_ps
# vim: ft=tcl tabstop=8 softtabstop=2 shiftwidth=2 nocindent smartindent
#
namespace eval ::scobj::isotech_ps {
set debug_threshold 0
}
proc ::scobj::isotech_ps::debug_log {debug_level debug_string} {
set catch_status [ catch {
if {${debug_level} >= ${::scobj::isotech_ps::debug_threshold}} {
set fd [open "/tmp/isotech_ps.log" "a"]
set line "[clock format [clock seconds] -format "%T"] ${debug_string}"
puts ${fd} "${line}"
close ${fd}
}
} catch_message ]
}
# check function for hset change
proc ::scobj::isotech_ps::checkrange {tc_root} {
set catch_status [ catch {
debug_log 1 "checkrange tc_root=${tc_root} sct=[sct] target=[sct target]"
set setpoint [sct target]
if { [hpropexists [sct] lowerlimit] } {
set lolimit [sct lowerlimit]
} else {
# lowerlimit not set, use target
set lolimit [sct target]
}
if { [hpropexists [sct] upperlimit] } {
set hilimit [sct upperlimit]
} else {
# upperlimit not set, use target
set hilimit [sct target]
}
# hook code goes here
if { ${setpoint} < ${lolimit} || ${setpoint} > ${hilimit} } {
error "setpoint ${setpoint} violates limits (${lolimit}..${hilimit}) on [sct]"
}
return OK
} catch_message ]
handle_exception ${catch_status} ${catch_message}
}
# function to request the read of a parameter on a device
proc ::scobj::isotech_ps::getValue {tc_root nextState cmd_str} {
set catch_status [ catch {
debug_log 1 "getValue tc_root=${tc_root} sct=[sct] cmd=${cmd_str}"
if { [hpropexists [sct] geterror] } {
hdelprop [sct] geterror
}
set cmd "${cmd_str}"
# hook code goes here
debug_log 1 "getValue sct send ${cmd}"
if {![string equal -nocase -length 10 ${cmd} "@@NOSEND@@"]} {
sct send "${cmd}"
}
return ${nextState}
} catch_message ]
handle_exception ${catch_status} ${catch_message}
}
# function to check the write parameter on a device
proc ::scobj::isotech_ps::noResponse {tc_root} {
set catch_status [ catch {
debug_log 1 "noResponse tc_root=${tc_root} sct=[sct] resp=[sct result]"
# hook code goes here
return "idle"
} catch_message ]
handle_exception ${catch_status} ${catch_message}
}
# function to parse the read of a parameter on a device
proc ::scobj::isotech_ps::rdValue {tc_root} {
set catch_status [ catch {
debug_log 1 "rdValue tc_root=${tc_root} sct=[sct] result=[sct result]"
if { [hpropexists [sct] geterror] } {
hdelprop [sct] geterror
}
set data [sct result]
set nextState "idle"
if {[string equal -nocase -length 7 ${data} "ASCERR:"]} {
# the protocol driver has reported an error
sct geterror "${data}"
error "[sct geterror]"
}
# hook code starts
set data [string range [sct result] 1 end]
# hook code ends
if { [hpropexists [sct] geterror] } {
debug_log 1 "[sct] error: [sct geterror]"
error "[sct geterror]"
}
if { ${data} != [sct oldval] } {
debug_log 1 "[sct] changed to new:${data}, from old:[sct oldval]"
sct oldval ${data}
sct update ${data}
sct utime readtime
}
return ${nextState}
} catch_message ]
handle_exception ${catch_status} ${catch_message}
}
# function to parse the read of a parameter on a device
proc ::scobj::isotech_ps::read_relay {tc_root} {
set catch_status [ catch {
debug_log 1 "read_relay tc_root=${tc_root} sct=[sct] result=[sct result]"
if { [hpropexists [sct] geterror] } {
hdelprop [sct] geterror
}
set data [sct result]
set nextState "idle"
if {[string equal -nocase -length 7 ${data} "ASCERR:"]} {
# the protocol driver has reported an error
sct geterror "${data}"
error "[sct geterror]"
}
# hook code starts
if { [string equal -nocase -length 2 "F1" "${data}"] } {
set data 1
} elseif { [string equal -nocase -length 2 "F0" "${data}"] } {
set data 0
} else {
sct geterror "Unexpected response '${data}' not 'F1' nor 'F0'"
}
# hook code ends
if { [hpropexists [sct] geterror] } {
debug_log 1 "[sct] error: [sct geterror]"
error "[sct geterror]"
}
if { ${data} != [sct oldval] } {
debug_log 1 "[sct] changed to new:${data}, from old:[sct oldval]"
sct oldval ${data}
sct update ${data}
sct utime readtime
}
return ${nextState}
} catch_message ]
handle_exception ${catch_status} ${catch_message}
}
# function to write a parameter value on a device
proc ::scobj::isotech_ps::setValue {tc_root nextState cmd_str} {
set catch_status [ catch {
debug_log 1 "setValue tc_root=${tc_root} sct=[sct] cmd=${cmd_str}"
if { [hpropexists [sct] geterror] } {
hdelprop [sct] geterror
}
set par [sct target]
set cmd "${cmd_str}${par}"
# hook code goes here
if { [hpropexists [sct] driving] } {
if { [hpropexists [sct] writestatus] && [sct writestatus] == "start" } {
sct driving 1
}
}
debug_log 1 "setValue sct send ${cmd}"
if {![string equal -nocase -length 10 ${cmd} "@@NOSEND@@"]} {
sct send "${cmd}"
}
return ${nextState}
} catch_message ]
handle_exception ${catch_status} ${catch_message}
}
# function to write a parameter value on a device
proc ::scobj::isotech_ps::write_relay {tc_root nextState cmd_str} {
set catch_status [ catch {
debug_log 1 "write_relay tc_root=${tc_root} sct=[sct] cmd=${cmd_str}"
if { [hpropexists [sct] geterror] } {
hdelprop [sct] geterror
}
set par [sct target]
set cmd "${cmd_str}${par}"
# hook code starts
if { ${par} == 0 } {
set cmd "KOD"
} else {
set cmd "KOE"
}
# hook code ends
if { [hpropexists [sct] geterror] } {
debug_log 1 "[sct] error: [sct geterror]"
error "[sct geterror]"
}
if { [hpropexists [sct] driving] } {
if { [hpropexists [sct] writestatus] && [sct writestatus] == "start" } {
sct driving 1
}
}
debug_log 1 "write_relay sct send ${cmd}"
if {![string equal -nocase -length 10 ${cmd} "@@NOSEND@@"]} {
sct send "${cmd}"
}
return ${nextState}
} catch_message ]
handle_exception ${catch_status} ${catch_message}
}
# function to write a parameter value on a device
proc ::scobj::isotech_ps::write_voltage {tc_root nextState cmd_str} {
set catch_status [ catch {
debug_log 1 "write_voltage tc_root=${tc_root} sct=[sct] cmd=${cmd_str}"
if { [hpropexists [sct] geterror] } {
hdelprop [sct] geterror
}
set par [sct target]
set cmd "${cmd_str}${par}"
# hook code starts
set par "[format "%05.2f" [sct target]]"
set cmd "SV ${par}"
# hook code ends
if { [hpropexists [sct] geterror] } {
debug_log 1 "[sct] error: [sct geterror]"
error "[sct geterror]"
}
if { [hpropexists [sct] driving] } {
if { [hpropexists [sct] writestatus] && [sct writestatus] == "start" } {
sct driving 1
}
}
debug_log 1 "write_voltage sct send ${cmd}"
if {![string equal -nocase -length 10 ${cmd} "@@NOSEND@@"]} {
sct send "${cmd}"
}
return ${nextState}
} catch_message ]
handle_exception ${catch_status} ${catch_message}
}
proc ::scobj::isotech_ps::mk_sct_isotech_ps { sct_controller name } {
debug_log 1 "mk_sct_isotech_ps for ${name}"
set ns "[namespace current]"
set catch_status [ catch {
MakeSICSObj ${name} SCT_OBJECT
sicslist setatt ${name} klass environment
sicslist setatt ${name} long_name ${name}
set scobj_hpath /sics/${name}
hfactory ${scobj_hpath}/amps plain user float
hsetprop ${scobj_hpath}/amps read ${ns}::getValue ${scobj_hpath} rdValue {A}
hsetprop ${scobj_hpath}/amps rdValue ${ns}::rdValue ${scobj_hpath}
hsetprop ${scobj_hpath}/amps control true
hsetprop ${scobj_hpath}/amps data true
hsetprop ${scobj_hpath}/amps mutable true
hsetprop ${scobj_hpath}/amps nxsave true
hsetprop ${scobj_hpath}/amps units A
hsetprop ${scobj_hpath}/amps oldval 0.0
hsetprop ${scobj_hpath}/amps sdsinfo "::nexus::scobj::sdsinfo"
hsetprop ${scobj_hpath}/amps type "part"
hsetprop ${scobj_hpath}/amps nxalias "${name}_amps"
hfactory ${scobj_hpath}/relay plain user int
hsetprop ${scobj_hpath}/relay read ${ns}::getValue ${scobj_hpath} read_relay {F}
hsetprop ${scobj_hpath}/relay read_relay ${ns}::read_relay ${scobj_hpath}
hsetprop ${scobj_hpath}/relay write ${ns}::write_relay ${scobj_hpath} noResponse {KO}
hsetprop ${scobj_hpath}/relay noResponse ${ns}::noResponse ${scobj_hpath}
hsetprop ${scobj_hpath}/relay check ${ns}::checkrange ${scobj_hpath}
hsetprop ${scobj_hpath}/relay control true
hsetprop ${scobj_hpath}/relay data true
hsetprop ${scobj_hpath}/relay mutable true
hsetprop ${scobj_hpath}/relay nxsave true
hsetprop ${scobj_hpath}/relay oldval 0
hsetprop ${scobj_hpath}/relay sdsinfo "::nexus::scobj::sdsinfo"
hsetprop ${scobj_hpath}/relay type "part"
hsetprop ${scobj_hpath}/relay nxalias "${name}_relay"
hfactory ${scobj_hpath}/volts plain user float
hsetprop ${scobj_hpath}/volts read ${ns}::getValue ${scobj_hpath} rdValue {V}
hsetprop ${scobj_hpath}/volts rdValue ${ns}::rdValue ${scobj_hpath}
hsetprop ${scobj_hpath}/volts write ${ns}::write_voltage ${scobj_hpath} noResponse {SV}
hsetprop ${scobj_hpath}/volts noResponse ${ns}::noResponse ${scobj_hpath}
hsetprop ${scobj_hpath}/volts check ${ns}::checkrange ${scobj_hpath}
hsetprop ${scobj_hpath}/volts control true
hsetprop ${scobj_hpath}/volts data true
hsetprop ${scobj_hpath}/volts mutable true
hsetprop ${scobj_hpath}/volts nxsave true
hsetprop ${scobj_hpath}/volts units V
hsetprop ${scobj_hpath}/volts oldval 0.0
hsetprop ${scobj_hpath}/volts sdsinfo "::nexus::scobj::sdsinfo"
hsetprop ${scobj_hpath}/volts type "part"
hsetprop ${scobj_hpath}/volts nxalias "${name}_volts"
if {[SplitReply [environment_simulation]]=="false"} {
${sct_controller} poll ${scobj_hpath}/amps 5
${sct_controller} poll ${scobj_hpath}/relay 5
${sct_controller} poll ${scobj_hpath}/volts 5
${sct_controller} write ${scobj_hpath}/relay
${sct_controller} write ${scobj_hpath}/volts
}
hsetprop ${scobj_hpath} klass environment
# hook code goes here
} catch_message ]
handle_exception ${catch_status} ${catch_message}
}
namespace eval ::scobj::isotech_ps {
namespace export debug_log
namespace export mk_sct_isotech_ps
}
proc add_isotech_ps {name IP port} {
set catch_status [ catch {
set ns "::scobj::isotech_ps"
${ns}::debug_log 1 "add_isotech_ps ${name} ${IP} ${port}"
if {[SplitReply [environment_simulation]]=="false"} {
if {[string equal -nocase "aqadapter" "${IP}"]} {
${ns}::debug_log 1 "makesctcontroller sct_${name} aqadapter ${port}"
makesctcontroller sct_${name} aqadapter ${port}
} else {
${ns}::debug_log 1 "makesctcontroller sct_${name} std ${IP}:${port} \"\\r\""
makesctcontroller sct_${name} std ${IP}:${port} "\r"
}
}
${ns}::debug_log 1 "mk_sct_isotech_ps sct_${name} ${name}"
${ns}::mk_sct_isotech_ps sct_${name} ${name}
} catch_message ]
handle_exception ${catch_status} ${catch_message}
}
puts stdout "file evaluation of sct_isotech_ps.tcl"
::scobj::isotech_ps::debug_log 1 "file evaluation of sct_isotech_ps.tcl"
proc ::scobj::isotech_ps::read_config {} {
set catch_status [ catch {
set ns "::scobj::isotech_ps"
${ns}::debug_log 1 "Processing Config"
dict for {k v} $::config_dict {
${ns}::debug_log 1 "Inspecting $k:$v"
if { [dict exists $v "driver"] } {
${ns}::debug_log 1 "Has driver [dict get $v driver]"
if { [dict get $v "driver"] == "isotech_ps" } {
${ns}::debug_log 1 "Correct driver, enabled = [dict get $v enabled]"
if { [dict get $v enabled] } {
set IP [dict get $v ip]
set PORT [dict get $v port]
set name [dict get $v name]
MakeAsyncProtocol ${name}_protocol
MakeAsyncQueue ${name}_queue ${name}_protocol ${IP} ${PORT}
add_isotech_ps ${name} "aqadapter" ${name}_queue
}
}
}
}
} catch_message ]
handle_exception ${catch_status} ${catch_message}
}
if { [info exists ::config_dict] } {
::scobj::isotech_ps::read_config
} else {
::scobj::isotech_ps:debug_log 1 "No config dict"
}

View File

@ -468,7 +468,7 @@ sct print "halt $tc_root"
proc createNode {scobj_hpath sct_controller cmdGroup varName readable writable nexus gumtree\
drivable dataType permission rdCmd rdFunc wrCmd\
wrFunc allowedValues klass} {
debug_log "createNode cmdGroup = $cmdGroup"
set catch_status [ catch {
set ns "[namespace current]"
set nodeName "$scobj_hpath/$cmdGroup/$varName"
@ -568,11 +568,11 @@ debug_log "Registering node $nodeName for write callback"
}
set num_pumps 2
for {set i 0} { i < $num_pumps } { incr i } {
for {set i 0} { $i < $num_pumps } { incr i } {
set cmdGroup "Pump[set i]"
hfactory $scobj_hpath/[set cmdGroup] plain spy none
foreach {cmdGroup varName readable writable nexus gumtree drivable dataType permission rdCmd rdFunc wrCmd wrFunc allowedValues} $deviceCommand {
createNode $scobj_hpath $sct_controller $cmdGroup $varName $readable $writable $nexus $gumtree $drivable $dataType $permission $rdCmd $rdFunc $wrCmd $wrFunc $allowedValues $klass
createNode $scobj_hpath $sct_controller ${cmdGroup}$i $varName $readable $writable $nexus $gumtree $drivable $dataType $permission $rdCmd $rdFunc $wrCmd $wrFunc $allowedValues $klass
}
}

View File

@ -0,0 +1,111 @@
#
# Simple driver generator for the Julabo LH45
# vim: ts=8 sts=2 sw=2 expandtab autoindent smartindent nocindent
#
driver julabo_lh45_gen = {
vendor = julabo; device = lh45; protocol = std;
class = environment
simulation_group = environment_simulation
add_args = '{sensor "bath"} {tol 5.0}';
make_args = 'sensor tol';
protocol_args = '"\r"';
#
# Unnamed group has variables at device level
#
group = {
priv = user
type = float
var setpoint = {
driveable = sensor/'value'
readable = 1
read_command = 'in_sp_00'
write_function = setPoint
write_command = 'out_sp_00'
lowerlimit = 10
upperlimit = 90
tolerance = 2
}
var overtemp_warnlimit = {
readable = 1
read_command = 'in_sp_03'
#write_command = 'out_sp_03'
}
var subtemp_warnlimit = {
readable = 1
read_command = 'in_sp_04'
#write_command = 'out_sp_04'
}
var heating_power_percent = {
readable = 1
read_command = 'in_pv_01';
};
var power = {
readable = 1
read_command = 'in_mode_05';
writeable = 1;
write_command = 'out_mode_05';
};
var lh45_state = {
readable = 1
read_command = 'status';
fetch_function = getState
read_function = rdState
}
var lh45_lasterror = { type = text; }
var remote_ctrl = { type = text; priv = spy; }
}
#
# The named group is at the device level, variables below that
#
group sensor = {
type = float;
priv = internal;
readable = 1;
var 'value' = { read_command = 'in_pv_00'; units = 'C' };
var bathtemp = { read_command = 'in_pv_00'; units = 'C' };
};
#
# Code lines start with '@' which is stripped before being emitted into generated driver
# The code is emitted at the appropriate place in the given function
#
code read_function rdValue = {
}
code Write_function setPoint = {
}
#
# This code is after database creation
#
code mkDriver = {
@# TODO use the ${sensor} and ${tol} arguments
}
code read_function rdState = {
@ if {${data} != [sct oldval]} {
@ debug_log 1 "[sct] changed to new:${data}, from old:[sct oldval]"
@ sct oldval ${data}
@ sct update ${data}
@ sct utime readtime
@ switch -- [lindex ${data} 0] {
@ "00" {
@ hset ${tc_root}/remote_ctrl False
@ }
@ "01" {
@ hset ${tc_root}/remote_ctrl False
@ }
@ "02" {
@ hset ${tc_root}/remote_ctrl True
@ }
@ "03" {
@ hset ${tc_root}/remote_ctrl True
@ }
@ default {
@ hset ${tc_root}/remote_ctrl UNKNOWN
@ hset ${tc_root}/lh45_lasterror ${data}
@ sct geterror ${data}
@ }
@ }
@ }
}
};

View File

@ -78,11 +78,9 @@ proc ::scobj::ls218::rdValue {nodeName varName idx} {
set replyData [string trimright [sct result] " \r\n"]
if {[string first "ASCERR" $replyData] != -1} {
#broadcast "Error in LS218 Response: ASCERR:"
sct geterror $replyData
return -code error "Error in LS218 Response: $replyData"
} elseif {[string length $replyData] < 1} {
#broadcast "Error in LS218 Response: no message returned from device"
return -code error "Error in LS218: no message returned from device"
} else {
set fields [split $replyData ,]
@ -119,7 +117,6 @@ proc ::scobj::ls218::rdValue {nodeName varName idx} {
}
}
"Celsius" { hset $nodeName [lindex $fields 0]
#append $logString " Celsius - $fields;"
set curValue [lindex $fields 0]
}
"CurveHd" { hset $nodeName/curve [lindex $fields 0]
@ -193,33 +190,34 @@ proc ::scobj::ls218::rdValue {nodeName varName idx} {
}
}
"mnmxValue" { hset $nodeName "[lindex $fields 0] , [lindex $fields 1]"}
"status" { hset $nodeName ""
"status" {
# RDGST? chID Reads input status returns an integer with the following meaning
# Bit Weighting StatusIndicator
# 4 16 temp underrange
# 5 32 temp overrange
# 6 64 units under range
# 7 128 untis over range
set curValue $fields
set field [string trimleft $fields 0]
if {[string length $field] == 0} {
set field 0
}
set stateString ""
set str ""
set i [format %x $field]
set i [expr 0x$i >> 4]
set bitValue [expr 0x$i & 0x01]
if {$bitValue == 1} { append $stateString "temp underrange; " }
if {$bitValue == 1} { append str "temp underrange, " }
set i [expr 0x$i >> 1]
set bitValue [expr 0x$i & 0x01]
if {$bitValue == 1} { append $stateString "temp overrange; " }
if {$bitValue == 1} { append str "temp overrange, " }
set i [expr 0x$i >> 1]
set bitValue [expr 0x$i & 0x01]
if {$bitValue == 1} { append $stateString "units under range; " }
if {$bitValue == 1} { append str "units under range, " }
set i [expr 0x$i >> 1]
set bitValue [expr 0x$i & 0x01]
if {$bitValue == 1} { append $stateString "untis over range; " }
hset $nodeName $stateString
if {$bitValue == 1} { append str "untis over range" }
hset $nodeName $str
}
"SensorUnitValue" { hset $nodeName $fields
#append $logString " SensorUnitValue - $fields;"
@ -350,7 +348,7 @@ proc createNode {scobj_hpath idx sct_controller cmdGroup varName readable pollEn
if {$pollEnabled == 1} {
if {[SplitReply [environment_simulation]]=="false"} {
# puts "enabling polling for $nodeName"
$sct_controller poll $nodeName
$sct_controller poll $nodeName 3
}
}
} message ]} {
@ -622,14 +620,16 @@ proc ::scobj::ls218::mkLS218 {argList} {
# @internal time internal in polling the nodes
# @return nothing (well, the sct object)
MakeAsyncProtocol std
MakeAsyncQueue ls218 std 137.157.202.214 4002
::scobj::ls218::mkLS218 {
name ls218
IP 137.157.202.214
PORT 4002
IP aqadapter
PORT ls218
tuning 1
interval 5
inputChan {1 2}
outputChan {}
relayChan {}
inputChan {1 2 3 4 5 6 7 8}
outputChan {1 2}
relayChan {1 2 3 4 5 6 7 8}
}

View File

@ -1579,7 +1579,7 @@ proc createNode {scobj_hpath sct_controller cmdGroup varName readable writable p
# @param tempobj short name for the temperature controller scriptcontext object (typ. tc1 or tc2)
# @param tol temperature tolerance in Kelvin (typ. 1)
# @return nothing (well, the sct object)
proc mk_sct_lakeshore_336 {sct_controller klasse tempobj tol1 tol2 verbose} {
proc mk_sct_lakeshore_336 {sct_controller klasse tempobj CID CTYPE tol1 tol2 verbose} {
if {[ catch {
MakeSICSObj $tempobj SCT_OBJECT
sicslist setatt $tempobj klass $klasse
@ -1846,7 +1846,22 @@ proc createNode {scobj_hpath sct_controller cmdGroup varName readable writable p
# Problem: Does not write non-numbers to the hdf file unless told differently - but how?
# How can I make it write the NAME (or any character/string variable) to the hdf file?
# ::scobj::hinitprops $tempobj/sensor sampleSensor
hsetprop $scobj_hpath/sensor/setpoint1 permlink data_set ${CTYPE}${CID}SP1
hsetprop $scobj_hpath/sensor/setpoint1 @description ${CTYPE}${CID}SP1
hsetprop $scobj_hpath/sensor/setpoint2 permlink data_set ${CTYPE}${CID}SP2
hsetprop $scobj_hpath/sensor/setpoint2 @description ${CTYPE}${CID}SP2
hsetprop $scobj_hpath/sensor/sensorValueA permlink data_set ${CTYPE}${CID}S1
hsetprop $scobj_hpath/sensor/sensorValueA @description ${CTYPE}${CID}S1
hsetprop $scobj_hpath/sensor/sensorValueB permlink data_set ${CTYPE}${CID}S2
hsetprop $scobj_hpath/sensor/sensorValueB @description ${CTYPE}${CID}S2
hsetprop $scobj_hpath/sensor/sensorValueC permlink data_set ${CTYPE}${CID}S3
hsetprop $scobj_hpath/sensor/sensorValueC @description ${CTYPE}${CID}S3
hsetprop $scobj_hpath/sensor/sensorValueD permlink data_set ${CTYPE}${CID}S4
hsetprop $scobj_hpath/sensor/sensorValueD @description ${CTYPE}${CID}S4
hsetprop $scobj_hpath/sensor/setpoint1 type drivable
hsetprop $scobj_hpath/sensor/setpoint2 type drivable
ansto_makesctdrive ${tempobj}_driveable $scobj_hpath/sensor/setpoint1 $scobj_hpath/sensor/ctrlLp1_value $sct_controller
ansto_makesctdrive ${tempobj}_driveable2 $scobj_hpath/sensor/setpoint2 $scobj_hpath/sensor/ctrlLp2_value $sct_controller
@ -1871,7 +1886,7 @@ proc createNode {scobj_hpath sct_controller cmdGroup varName readable writable p
# @param port port number on the moxabox (typ. 4001, 4002, 4003, or 4004)
# @param tol temperature tolerance in Kelvin (typ. 1)
# @return nothing (well, the sct object)
proc add_sct_ls336 {name IP port terminator {_tol1 1.0} {_tol2 1.0} {_verbose 0} } {
proc add_sct_ls336 {name IP port terminator {_tol1 1.0} {_tol2 1.0} {CID 1} {CTYPE T} {_verbose 0} } {
# ffr 2009-11-09, Don't create a temperature controller for the script validator, this causes the
# lakeshore to lock up.
# NOTE: I put this outside the catch block because "return" raises an exception
@ -1885,9 +1900,9 @@ proc add_sct_ls336 {name IP port terminator {_tol1 1.0} {_tol2 1.0} {_verbose 0}
makesctcontroller sct_ls336_$name aqadapter ${port}
} else {
puts "\nadd_ls336: makesctcontroller sct_ls336_$name std ${IP}:$port $terminator for Lakeshore model 336"
makesctcontroller sct_ls336_$name std ${IP}:$port $terminator
makesctcontroller sct_ls336_$name std ${IP}:$port {*}$terminator
}
mk_sct_lakeshore_336 sct_ls336_$name environment $name $_tol1 $_tol2 $_verbose
::scobj::ls336::mk_sct_lakeshore_336 sct_ls336_$name environment $name $CID $CTYPE $_tol1 $_tol2 $_verbose
makesctemon $name /sics/$name/emon/monMode_Lp1 /sics/$name/emon/isInTolerance_Lp1 /sics/$name/emon/errhandler
# set m2 "_2"
# makesctemon $name$m2 /sics/$name/emon/monMode_Lp2 /sics/$name/emon/isInTolerance_Lp2 /sics/$name/emon/errhandler
@ -1896,4 +1911,34 @@ proc add_sct_ls336 {name IP port terminator {_tol1 1.0} {_tol2 1.0} {_verbose 0}
}
}
if {[ catch {
if { [ info exists ::config_dict ] } {
if { [ dict get $::config_dict ls336_1 enabled ] } {
set IP [dict get $::config_dict ls336_1 ip]
set PORT [dict get $::config_dict ls336_1 port]
set name [dict get $::config_dict ls336_1 name]
set ctype [dict get $::config_dict ls336_1 type]
set cid [dict get $::config_dict ls336_1 id]
set term [dict get $::config_dict ls336_1 terminator]
set tol1 [dict get $::config_dict ls336_1 tol1]
set tol2 [dict get $::config_dict ls336_1 tol2]
add_sct_ls336 $name $IP $PORT $term $tol1 $tol2 $cid $ctype
}
if { [ dict get $::config_dict ls336_2 enabled ] } {
set IP [dict get $::config_dict ls336_2 ip]
set PORT [dict get $::config_dict ls336_2 port]
set name [dict get $::config_dict ls336_2 name]
set ctype [dict get $::config_dict ls336_2 type]
set cid [dict get $::config_dict ls336_2 id]
set term [dict get $::config_dict ls336_2 terminator]
set tol1 [dict get $::config_dict ls336_2 tol1]
set tol2 [dict get $::config_dict ls336_2 tol2]
add_sct_ls336 $name $IP $PORT $term $tol1 $tol2 $cid $ctype
}
}
} message ]} {
puts "ERROR: $message"
}
namespace import ::scobj::ls336::*

View File

@ -1755,7 +1755,7 @@ proc createNode {scobj_hpath sct_controller cmdGroup varName readable writable p
# @param tempobj short name for the temperature controller scriptcontext object (typ. tc1 or tc2)
# @param tol temperature tolerance in Kelvin (typ. 1)
# @return nothing (well, the sct object)
proc mk_sct_lakeshore_340 {sct_controller klasse tempobj LSmodel tol1 tol2 verbose} {
proc mk_sct_lakeshore_340 {sct_controller klasse tempobj CID CTYPE LSmodel tol1 tol2 verbose} {
if {[ catch {
set ::scobj::ls340::ls340_driveTolerance1 $tol1
set ::scobj::ls340::ls340_driveTolerance2 $tol2
@ -2050,6 +2050,19 @@ proc createNode {scobj_hpath sct_controller cmdGroup varName readable writable p
# Problem: Does not write non-numbers to the hdf file unless told differently - but how?
# How can I make it write the NAME (or any character/string variable) to the hdf file?
# ::scobj::hinitprops $tempobj/sensor sampleSensor
hsetprop $scobj_hpath/sensor/setpoint1 permlink data_set ${CTYPE}${CID}SP1
hsetprop $scobj_hpath/sensor/setpoint1 @description ${CTYPE}${CID}SP1
hsetprop $scobj_hpath/sensor/setpoint2 permlink data_set ${CTYPE}${CID}SP2
hsetprop $scobj_hpath/sensor/setpoint2 @description ${CTYPE}${CID}SP2
hsetprop $scobj_hpath/sensor/sensorValueA permlink data_set ${CTYPE}${CID}S1
hsetprop $scobj_hpath/sensor/sensorValueA @description ${CTYPE}${CID}S1
hsetprop $scobj_hpath/sensor/sensorValueB permlink data_set ${CTYPE}${CID}S2
hsetprop $scobj_hpath/sensor/sensorValueB @description ${CTYPE}${CID}S2
hsetprop $scobj_hpath/sensor/sensorValueC permlink data_set ${CTYPE}${CID}S3
hsetprop $scobj_hpath/sensor/sensorValueC @description ${CTYPE}${CID}S3
hsetprop $scobj_hpath/sensor/sensorValueD permlink data_set ${CTYPE}${CID}S4
hsetprop $scobj_hpath/sensor/sensorValueD @description ${CTYPE}${CID}S4
hsetprop $scobj_hpath/sensor/setpoint1 type drivable
hsetprop $scobj_hpath/sensor/setpoint2 type drivable
@ -2077,7 +2090,7 @@ proc createNode {scobj_hpath sct_controller cmdGroup varName readable writable p
# @param port port number on the moxabox (typ. 4001, 4002, 4003, or 4004)
# @param tol temperature tolerance in Kelvin (typ. 1)
# @return nothing (well, the sct object)
proc add_sct_ls340 {name IP port terminator {_tol1 1.0} {_tol2 1.0} {_verbose 0} } {
proc add_sct_ls340 {name IP port terminator {_tol1 1.0} {_tol2 1.0} {CID 1} {CTYPE T} {_verbose 0} } {
# ffr 2009-11-09, Don't create a temperature controller for the script validator, this causes the
# lakeshore to lock up.
# NOTE: I put this outside the catch block because "return" raises an exception
@ -2091,9 +2104,9 @@ proc add_sct_ls340 {name IP port terminator {_tol1 1.0} {_tol2 1.0} {_verbose 0}
makesctcontroller sct_ls340_$name aqadapter ${port}
} else {
puts "\nadd_ls340: makesctcontroller sct_ls340_$name std ${IP}:$port $terminator for Lakeshore model 340"
makesctcontroller sct_ls340_$name std ${IP}:$port $terminator
makesctcontroller sct_ls340_$name std ${IP}:$port {*}$terminator
}
mk_sct_lakeshore_340 sct_ls340_$name environment $name $_ls340_LSmodel $_tol1 $_tol2 $_verbose
::scobj::ls340::mk_sct_lakeshore_340 sct_ls340_$name environment $name $CID $CTYPE $_ls340_LSmodel $_tol1 $_tol2 $_verbose
makesctemon $name /sics/$name/emon/monMode_Lp1 /sics/$name/emon/isInTolerance_Lp1 /sics/$name/emon/errhandler
# set m2 "_2"
# makesctemon $name$m2 /sics/$name/emon/monMode_Lp2 /sics/$name/emon/isInTolerance_Lp2 /sics/$name/emon/errhandler
@ -2102,16 +2115,34 @@ proc add_sct_ls340 {name IP port terminator {_tol1 1.0} {_tol2 1.0} {_verbose 0}
}
}
if {[ catch {
if { [ info exists ::config_dict ] } {
if { [ dict get $::config_dict ls340_1 enabled ] } {
set IP [dict get $::config_dict ls340_1 ip]
set PORT [dict get $::config_dict ls340_1 port]
set name [dict get $::config_dict ls340_1 name]
set ctype [dict get $::config_dict ls340_1 type]
set cid [dict get $::config_dict ls340_1 id]
set term [dict get $::config_dict ls340_1 terminator]
set tol1 [dict get $::config_dict ls340_1 tol1]
set tol2 [dict get $::config_dict ls340_1 tol2]
add_sct_ls340 $name $IP $PORT $term $tol1 $tol2
add_sct_ls340 $name $IP $PORT $term $tol1 $tol2 $cid $ctype
}
if { [ dict get $::config_dict ls340_2 enabled ] } {
set IP [dict get $::config_dict ls340_2 ip]
set PORT [dict get $::config_dict ls340_2 port]
set name [dict get $::config_dict ls340_2 name]
set ctype [dict get $::config_dict ls340_2 type]
set cid [dict get $::config_dict ls340_2 id]
set term [dict get $::config_dict ls340_2 terminator]
set tol1 [dict get $::config_dict ls340_2 tol1]
set tol2 [dict get $::config_dict ls340_2 tol2]
add_sct_ls340 $name $IP $PORT $term $tol1 $tol2 $cid $ctype
}
}
} message ]} {
puts "ERROR: $message"
}
namespace import ::scobj::ls340::*

View File

@ -74,25 +74,6 @@ namespace eval ::scobj::[set vendor]_[set device] {
debug_log 1 "Extract channel $result from argument $arg"
return $result
}
proc basename {node} {
set point [string last "/" $node]
if { $point < 0 } {
return $node
} else {
incr point
return "[string range $node $point end]"
}
}
proc pathname {node} {
set point [string last "/" $node]
if { $point < 0 } {
return ""
} else {
incr point -1
return "[string range $node 0 $point]"
}
return "[join [lrange [split $node '/'] 0 end-1] '/']"
}
proc setValue {tc_root nextState cmd} {
# send a command to set a value
@ -948,13 +929,13 @@ namespace import ::scobj::[set vendor]_[set device]::*
# add_lakeshore_370 "tc371" 127.0.0.1 7371 2.0
if { [ info exists ::config_dict ] && [ dict get $::config_dict ls370_2 enabled ] } {
if { [ info exists ::config_dict ] && [ dict get $::config_dict ls370 enabled ] } {
puts "ADD LAKESHORE 370"
set IP [dict get $::config_dict ls370_2 ip]
set PORT [dict get $::config_dict ls370_2 port]
set NAME [dict get $::config_dict ls370_2 name]
set TOL [dict get $::config_dict ls370_2 tol]
set TERM [dict get $::config_dict ls370_2 terminator]
set IP [dict get $::config_dict ls370 ip]
set PORT [dict get $::config_dict ls370 port]
set NAME [dict get $::config_dict ls370 name]
set TOL [dict get $::config_dict ls370 tol]
set TERM [dict get $::config_dict ls370 terminator]
add_lakeshore_370 $NAME $IP $PORT $TOL
}

View File

@ -80,25 +80,6 @@ namespace eval ::scobj::[set vendor]_[set device] {
debug_log 1 "Extract channel $result from argument $arg"
return $result
}
proc basename {node} {
set point [string last "/" $node]
if { $point < 0 } {
return $node
} else {
incr point
return "[string range $node $point end]"
}
}
proc pathname {node} {
set point [string last "/" $node]
if { $point < 0 } {
return ""
} else {
incr point -1
return "[string range $node 0 $point]"
}
return "[join [lrange [split $node '/'] 0 end-1] '/']"
}
proc setPoint {tc_root nextState cmd} {
# send a command to set a value
@ -703,8 +684,8 @@ namespace eval ::scobj::[set vendor]_[set device] {
return OK
}
proc mk_sct_driver {sct_controller the_klass the_name tol} {
debug_log 1 "mk_sct_driver $sct_controller $the_klass $the_name $tol"
proc mk_sct_driver {sct_controller the_klass the_name tol CID CTYPE} {
debug_log 1 "mk_sct_driver $sct_controller $the_klass $the_name $tol $CID $CTYPE"
set catch_status [ catch {
MakeSICSObj $the_name SCT_OBJECT
@ -845,7 +826,31 @@ if {0} {
debug_log 5 "error in [ns]::mk_sct_driver($point) $catch_message_2"
return -code error "in [ns]::mk_sct_driver($point) $catch_message_2"
}
hsetprop $scobj_hpath/Loop1/setpoint permlink data_set ${CTYPE}${CID}SP1
hsetprop $scobj_hpath/Loop1/setpoint @description ${CTYPE}${CID}SP1
hsetprop $scobj_hpath/Loop1/setpoint permlink data_set ${CTYPE}${CID}SP1
hsetprop $scobj_hpath/Loop1/setpoint @description ${CTYPE}${CID}SP1
hsetprop $scobj_hpath/Loop2/setpoint permlink data_set ${CTYPE}${CID}SP2
hsetprop $scobj_hpath/Loop2/setpoint @description ${CTYPE}${CID}SP2
hsetprop $scobj_hpath/Loop3/setpoint permlink data_set ${CTYPE}${CID}SP3
hsetprop $scobj_hpath/Loop3/setpoint @description ${CTYPE}${CID}SP3
hsetprop $scobj_hpath/Loop4/setpoint permlink data_set ${CTYPE}${CID}SP4
hsetprop $scobj_hpath/Loop4/setpoint @description ${CTYPE}${CID}SP4
hsetprop $scobj_hpath/Loop1/sensor permlink data_set ${CTYPE}${CID}S1
hsetprop $scobj_hpath/Loop1/sensor @description ${CTYPE}${CID}S1
hsetprop $scobj_hpath/Loop2/sensor permlink data_set ${CTYPE}${CID}S2
hsetprop $scobj_hpath/Loop2/sensor @description ${CTYPE}${CID}S2
hsetprop $scobj_hpath/Loop3/sensor permlink data_set ${CTYPE}${CID}S3
hsetprop $scobj_hpath/Loop3/sensor @description ${CTYPE}${CID}S3
hsetprop $scobj_hpath/Loop4/sensor permlink data_set ${CTYPE}${CID}S4
hsetprop $scobj_hpath/Loop4/sensor @description ${CTYPE}${CID}S4
if {[SplitReply [environment_simulation]]=="false"} {
hsetprop $scobj_hpath/Loop1/setpoint type drivable
hsetprop $scobj_hpath/Loop2/setpoint type drivable
hsetprop $scobj_hpath/Loop3/setpoint type drivable
hsetprop $scobj_hpath/Loop4/setpoint type drivable
ansto_makesctdrive ${the_name}_loop1 $scobj_hpath/Loop1/setpoint $scobj_hpath/Loop1/sensor $sct_controller
ansto_makesctdrive ${the_name}_loop2 $scobj_hpath/Loop2/setpoint $scobj_hpath/Loop2/sensor $sct_controller
ansto_makesctdrive ${the_name}_loop3 $scobj_hpath/Loop3/setpoint $scobj_hpath/Loop3/sensor $sct_controller
@ -858,9 +863,9 @@ if {0} {
}
}
proc add_[set vendor]_[set device] {the_name IP port {_tol 5.0}} {
proc add_[set vendor]_[set device] {the_name IP port CID CTYPE terminator {_tol 5.0}} {
set [ns]::log_file "/tmp/[set [ns]::ven_dev]_[set the_name].log"
set fd [open [ns]::log_file "w"]
set fd [open [set [ns]::log_file] "w"]
close $fd
debug_log 1 "add_[set [ns]::vendor]_[set [ns]::device] ${the_name} ${IP} ${port} ${_tol}"
puts "Namespace: [namespace current]"
@ -872,10 +877,10 @@ if {0} {
puts "[namespace current]::log_file [set [namespace current]::log_file]"
if {[SplitReply [environment_simulation]]=="false"} {
debug_log 1 "makesctcontroller sct_${the_name} std ${IP}:${port}"
makesctcontroller sct_${the_name} std ${IP}:${port} "\r\n"
makesctcontroller sct_${the_name} std ${IP}:${port} {*}$terminator
}
debug_log 1 "mk_sct_driver sct_${the_name} environment ${the_name} ${_tol}"
mk_sct_driver sct_${the_name} environment ${the_name} ${_tol}
debug_log 1 "::scobj::oxford_mercury::mk_sct_driver sct_${the_name} environment ${the_name} ${_tol} $CID $CTYPE"
::scobj::oxford_mercury::mk_sct_driver sct_${the_name} environment ${the_name} ${_tol} $CID $CTYPE
}
@ -890,8 +895,11 @@ if { [ info exists ::config_dict ] && [ dict get $::config_dict mercury_scipi en
puts "ADD MERCURY SCIPI MODE"
set IP [dict get $::config_dict mercury_scipi ip]
set PORT [dict get $::config_dict mercury_scipi port]
set NAME [dict get $::config_dict mercury_scipi name]
set TOL [dict get $::config_dict mercury_scipi tol]
add_oxford_mercury $NAME $IP $PORT 2.0 "\r"
set name [dict get $::config_dict mercury_scipi name]
set ctype [dict get $::config_dict mercury_scipi type]
set cid [dict get $::config_dict mercury_scipi id]
set tol [dict get $::config_dict mercury_scipi tol]
set term [dict get $::config_dict mercury_scipi terminator]
add_oxford_mercury $name $IP $PORT $cid $ctype {*}$term $tol
}

View File

@ -62,7 +62,7 @@ debug_log "rdValue [sct] [sct result]"
hsetprop $tc_root/setpoint driving 1
}
# ANSTO special temperature
set temp [expr {10.0 * [sct target]}]
set temp [expr {20.0 * [sct target]}]
set cmd "STT[format %04X [expr {int($temp)}]]"
debug_log "sct send $cmd"
sct send "$cmd"
@ -103,7 +103,7 @@ debug_log "rdValue [sct] [sct result]"
debug_log "scan [string range $data 3 6] %4x data"
set rslt [scan [string range $data 3 6] %4x data]
# ANSTO special temp
set data [format "%.1f" [expr {0.1 * $data}]]
set data [format "%.1f" [expr {$data / 20.0}]]
debug_log "scan result rslt=$rslt, data=$data, oldval=[sct oldval]"
if {"$data" ne "[sct oldval]"} {
debug_log "$data != [sct oldval] => [expr {"$data" != "[sct oldval]"}]"
@ -436,7 +436,7 @@ debug_log "rdVisc [sct] [sct result]"
close $f
set f [open "[sct datafile].csv" "a"]
set my_time [expr {[sct test_time] + int($the_t / 45.0)}]
set my_temp [expr {0.1 * $the_c}]
set my_temp [expr {$the_c / 20.0}]
if {$the_v > 0x7FFFFF} {
set my_visc [expr {$the_v - 0x1000000}]
} else {
@ -547,12 +547,12 @@ debug_log "setPoint $cmd $par"
set the_valu [lindex $parts 2]
set the_ramp [lindex $parts 3]
if {$the_type == "I"} {
set the_valu [expr {round($the_valu * 10.0)}]
set the_ramp [expr {round($the_ramp * 10.0)}]
set the_valu [expr {round($the_valu * 20.0)}]
set the_ramp [expr {round($the_ramp * 20.0)}]
} elseif {$the_type == "S"} {
} elseif {$the_type == "T"} {
set the_valu [expr {round($the_valu * 10.0)}]
set the_ramp [expr {round($the_ramp * 10.0 /45 * 32768)}]
set the_valu [expr {round($the_valu * 20.0)}]
set the_ramp [expr {round($the_ramp * 20.0 /45 * 32768)}]
} else {
sct geterror "Profile error: $line"
sct print "Profile error: $line"
@ -580,7 +580,7 @@ debug_log "setPoint $cmd $par"
}
set rslt [scan $line "LT%2x%1s%6x%4x%4x" the_line the_type the_time the_valu the_ramp]
if {"$the_type" == "I"} {
set dec_temp [format "%.1f" [expr {0.1 * $the_valu}]]
set dec_temp [format "%.1f" [expr {$the_valu / 20.0}]]
}
set dec_time [expr {$the_time / 45.0}]
lappend lines $line

View File

@ -179,6 +179,7 @@ debug_log "setValue $dev:16:$cmd $par"
if {[string first "ASCERR:" $data] >=0} {
sct geterror $data
} elseif {$data != [sct oldval]} {
hdelprop [sct] geterror
sct oldval $data
sct update $data
sct utime readtime
@ -221,6 +222,13 @@ debug_log "setValue $dev:16:$cmd $par"
proc setSP {tc_root nextState cmd} {
debug_log "setSP $tc_root $nextState $cmd [sct]=[sct target] [hget [sct]]"
debug_log "setSP sct = [sct], sct writestatus = [sct writestatus]"
if {[sct writestatus] == "start"} {
# Called by drive adapter
hset $tc_root/status "busy"
debug_log "setSP hsetprop $tc_root/setpoint driving 1"
hsetprop $tc_root/setpoint driving 1
}
hset $tc_root/Loop1/setpoint [sct target]
return idle
}
@ -502,7 +510,7 @@ proc createNode {scobj_hpath sct_controller cmdGroup varName readable writable\
}
::scobj::hinitprops $tempobj
hsetprop $scobj_hpath klass NXenvironment
hsetprop $scobj_hpath klass environment
::scobj::set_required_props $scobj_hpath
foreach {rootpath hpath klass priv} "
$scobj_hpath sensor NXsensor spy
@ -523,6 +531,7 @@ proc createNode {scobj_hpath sct_controller cmdGroup varName readable writable\
hsetprop $scobj_hpath privilege spy
::scobj::hinitprops $tempobj setpoint
hsetprop $scobj_hpath/setpoint data true
hsetprop $scobj_hpath/setpoint type drivable
if {[SplitReply [environment_simulation]]=="false"} {
ansto_makesctdrive ${tempobj}_driveable $scobj_hpath/setpoint $scobj_hpath/sensor/value $sct_controller
}

View File

@ -27,7 +27,7 @@ set instrument_dictionary [subst {
property {data true control true nxsave false klass @none type graphset}
}
instrument {
sobj {@any instrument @any NXvelocity_selector @any NXaperture @any NXcollimator @any NXdetector @any NXdisk_chopper @any NXfermi_chopper}
sobj {@any instrument @any NXvelocity_selector @any NXaperture @any NXcollimator @any NXdetector @any NXdisk_chopper @any NXfermi_chopper @any NXsource}
privilege spy
datatype @none
property {data true control true nxsave false klass NXinstrument type instrument}
@ -211,6 +211,12 @@ set instrument_dictionary [subst {
datatype @none
property {data true control true nxsave false klass @none type part}
}
control {
privilege spy
sobj {@any control}
datatype @none
property {data false control true nxsave false klass @none type nxvgroup}
}
data {
privilege spy
sobj {@any data}

View File

@ -888,6 +888,16 @@ proc ::hdb::prune {instdict} {
return
}
proc ::hdb::alias {parent linkpath NXtarget name } {
set catch_status [ catch {
if {$NXtarget != "data_set"} {
return -code error "Unhandled target alias $NXtarget"
}
hfactory $parent/$name alias $linkpath
} message ]
handle_exception $catch_status $message
}
##
# @brief Traverse the instrument dictionary and construct the hipadaba database.
#
@ -913,6 +923,13 @@ upvar #0 $instDict dictionary
}
}
}
foreach node [hmatchprop / permlink *] {
set plink [hgetpropval $node permlink]
set target [lindex $plink 0]
if {$target == "data_set" && [hgetpropval $node control]} {
::hdb::alias "/control" $node {*}$plink
}
}
} message ]
handle_exception $catch_status $message
}

View File

@ -11,7 +11,7 @@ set boolean {true false}
#}
# SICS OBJECTS MUST PROVIDE THE FOLLOWING INFORMATION
set sobj_klass_list {@none aperture attenuator collimator command crystal data detector disk_chopper entry environment experiment fermi_chopper graphics instrument slits monitor monochromator parameter plc reduce sample scan sensor source user}
set sobj_klass_list {@none aperture attenuator collimator command control crystal data detector disk_chopper entry environment experiment fermi_chopper graphics instrument slits monitor monochromator parameter plc reduce sample scan sensor source user}
set sobj_sicstype_list {chopperadapter environment_controller sicsvariable macro motor configurablevirtualmotor tasmot singlecounter histmem nxscript sicsdata scanobject sct_object}
# Different kinds of things are added to the hdb in different ways.
# command: This is something a client can run with hset /a/b/c start, it may have parameters and feedback.

View File

@ -36,7 +36,7 @@ namespace eval histogram_memory {
if [ catch {
set ic_fsrce_values [ list INTERNAL EXTERNAL ]
set ic_count_methods [concat [list time unlimited period count frame] $::counter::isc_beam_monitor_list ]
set ic_count_methods [concat [list time unlimited period count frame count_roi] $::counter::isc_beam_monitor_list ]
if {$histmem_simulation == "true"} {
MakeHM hmm SIM
hmm configure daq Stopped
@ -79,6 +79,8 @@ namespace eval histogram_memory {
lyrebird INTERNAL
kookaburra INTERNAL
dingo INTERNAL
bilby INTERNAL
emu INTERNAL
}
array set default_frame_source_always_internal {
@ -93,6 +95,8 @@ namespace eval histogram_memory {
lyrebird "false"
kookaburra "false"
dingo "false"
bilby "false"
emu "false"
}
::utility::mkVar detector_active_height_mm Float user active_height true detector true true
@ -834,7 +838,7 @@ proc CAT_TABLE {args} {
#
proc FAT_TABLE {args} {
if [ catch {
set attributes { FRAME_FREQUENCY FRAME_BUFFER FRAME_DUTYCYCLE SIZE_PERIOD NOS_PERIODS COUNT_METHOD COUNT_SIZE READ_DATA_TYPE VIEW_MAG_X VIEW_MAG_Y HISTO_STREAMING P7888_PLL_FREQ_CARD_X P7888_PLL_FREQ_CARD_Y P7888_CARD_MODE_X P7888_CARD_MODE_Y RAW_HISTO_XMIN RAW_HISTO_XMAX RAW_HISTO_YMIN RAW_HISTO_YMAX TEST_HISTO_1D_SIZES TEST_HISTO_2D_SIZES P7888_PLL_SYNC_METHOD }
set attributes { FRAME_FREQUENCY FRAME_BUFFER FRAME_DUTYCYCLE SIZE_PERIOD NOS_PERIODS COUNT_METHOD COUNT_SIZE READ_DATA_TYPE VIEW_MAG_X VIEW_MAG_Y HISTO_STREAMING P7888_PLL_FREQ_CARD_X P7888_PLL_FREQ_CARD_Y P7888_CARD_MODE_X P7888_CARD_MODE_Y RAW_HISTO_XMIN RAW_HISTO_XMAX RAW_HISTO_YMIN RAW_HISTO_YMAX TEST_HISTO_1D_SIZES TEST_HISTO_2D_SIZES P7888_PLL_SYNC_METHOD COUNT_ROI_XMIN COUNT_ROI_XMAX COUNT_ROI_YMIN COUNT_ROI_YMAX COUNT_ROI_TMIN COUNT_ROI_TMAX COUNT_ROI_TYPE COUNT_ROI_REGION COUNT_ROI_K1 }
set elements {{ }}

View File

@ -35,26 +35,6 @@ namespace eval ::scobj::[set vendor]_[set device] {
} catch_message ]
}
proc basename {node} {
set point [string last "/" $node]
if { $point < 0 } {
return $node
} else {
incr point
return "[string range $node $point end]"
}
}
proc pathname {node} {
set point [string last "/" $node]
if { $point < 0 } {
return ""
} else {
incr point -1
return "[string range $node 0 $point]"
}
return "[join [lrange [split $node '/'] 0 end-1] '/']"
}
proc ns {} {
return "[namespace current]"
}

View File

@ -54,6 +54,8 @@ namespace eval nexus {
"taipan" "simple"
"kookaburra" "simple"
"dingo" "simple"
"bilby" "simple"
"emu" "simple"
}
}
namespace eval ::nexus::histmem {}
@ -120,7 +122,7 @@ proc ::nexus::datapath {} {
# @param postfix This is the filename suffix, must be one of: nx.hdf, hdf, h5, nx5, xml
proc newFileName {idNum postfix} {
if [ catch {
array set inst_mnem {quokka QKK wombat WBT echidna ECH kowari KWR koala KOL taipan TPN platypus PLP pelican PLN lyrebird LBD kookaburra KKB dingo DNG}
array set inst_mnem {quokka QKK wombat WBT echidna ECH kowari KWR koala KOL taipan TPN platypus PLP pelican PLN lyrebird LBD kookaburra KKB dingo DNG bilby BBY emu EMU}
# set prefix [SplitReply [sicsdataprefix]]
set date_time_arr [split [sicstime] " "]
set isodate [lindex $date_time_arr 0]
@ -132,22 +134,47 @@ proc newFileName {idNum postfix} {
return $fmtStr
}
##
# @brief Make a link in the nexus file
# With two arguments the target name = the link name
# With three arguments you can give the target a new name.
# two args: arg0 = target, arg1 = link
# three args: arg0 = target, arg1 = new name, arg2 = link
proc ::nexus::link {args} {
set nargs [llength $args]
switch $nargs {
2 { nxscript makelink [lindex $args 0] [lindex $args 1] }
3 { nxscript makenamedlink [lindex $args 0] [lindex $args 2] [lindex $args 1] }
}
}
proc ::nexus::process_filetype_policy {filetype} {
if [ catch {
if {$filetype == "BEAM_MONITOR"} {
::hdb::set_save / true
::hdb::set_save $::histogram_memory::HP_HMM false
set ::counter::HP_BM [getatt monitor_counts hdb_path]
if [sicslist exists monitor_counts linkname] {
hsetprop $::counter::HP_BM link data_set [getatt monitor_counts linkname]
} else {
hsetprop $::counter::HP_BM link data_set
}
hsetprop $::counter::HP_BM @signal 1
set nvars [SplitReply [bmonscan noscanvar]]
if {$nvars == 0} {
set axes "run_number"
} else {
for { set i 0 } { $i < $nvars } { incr i } {
set axis_name [lindex [split [lindex [split [bmonscan getvarpar $i]] 0] "."] 1]
set node_name [SplitReply [sicslist $axis_name hdb_path]]
if [sicslist exists $axis_name linkname] {
hsetprop $node_name link data_set [getatt $axis_name linkname]
} else {
hsetprop $node_name link data_set
}
lappend axes_list $axis_name
}
set axes [join $axes_list ":"]
}
hsetprop $::counter::HP_BM @axes $axes
} else {
::hdb::set_save / true
@ -156,11 +183,19 @@ proc newFileName {idNum postfix} {
::histogram_memory::set_axes $filetype
}
foreach sobj [sicslist link data_set] {
if [sicslist exists $sobj linkname] {
hsetprop [getatt $sobj hdb_path] link data_set [getatt $sobj linkname]
} else {
hsetprop [getatt $sobj hdb_path] link data_set
}
}
foreach sobj [sicslist link parameters_group] {
if [sicslist exists $sobj linkname] {
hsetprop [getatt $sobj hdb_path] link parameters_group [getatt $sobj linkname]
} else {
hsetprop [getatt $sobj hdb_path] link parameters_group
}
}
} message ] {
return -code error "([info level 0]) $message"
}
@ -629,10 +664,10 @@ proc ::nexus::savetree {hpath pt filestatus} {
}
if {$filestatus == "newfile"} {
if {[info exists p_arr(link)] && ($p_arr(link) != "@none")} {
nxscript makelink $p_arr(link) $p_arr(nxalias)
::nexus::link {*}$p_arr(link) $p_arr(nxalias)
}
if {[info exists p_arr(permlink)] && ($p_arr(permlink) != "@none")} {
nxscript makelink $p_arr(permlink) $p_arr(nxalias)
::nexus::link {*}$p_arr(permlink) $p_arr(nxalias)
}
}
}
@ -884,7 +919,7 @@ proc ::nexus::histmem::save {hm nxalias hpath data_type filestatus args} {
if {$filestatus == "newfile"} {
if [hpropexists $hpath link] {
set link [hgetpropval $hpath link]
nxscript makelink $link $nxalias
::nexus::link {*}$link $nxalias
}
nxscript putattribute $nxalias axes $axes
nxscript putattribute $nxalias signal $signal
@ -919,7 +954,7 @@ proc ::nexus::motor::save {motor nxalias hpath data_type filestatus args} {
if {$filestatus == "newfile"} {
if [hpropexists $hpath link] {
set link [hgetpropval $hpath link]
nxscript makelink $link $nxalias
::nexus::link {*}$link $nxalias
}
foreach {propName propValue} [hfindprop $hpath @*] {
set attName [string range $propName 1 end]
@ -980,7 +1015,7 @@ proc ::nexus::macro::getset_save {sobj nxalias hpath data_type filestatus args}
if {$filestatus == "newfile"} {
if [hpropexists $hpath link] {
set link [hgetpropval $hpath link]
nxscript makelink $link $nxalias
::nexus::link {*}$link $nxalias
}
foreach {propName propValue} [hfindprop $hpath @*] {
set attName [string range $propName 1 end]
@ -1029,7 +1064,7 @@ proc ::nexus::environment_controller::save {evc nxalias hpath data_type filestat
if {$filestatus == "newfile"} {
if [hpropexists $hpath link] {
set link [hgetpropval $hpath link]
nxscript makelink $link $nxalias
::nexus::link {*}$link $nxalias
}
foreach {propName propValue} [hfindprop $hpath @*] {
set attName [string range $propName 1 end]
@ -1088,7 +1123,7 @@ proc ::nexus::sicsvariable::save {svar nxalias hpath data_type filestatus args}
if {$filestatus == "newfile"} {
if [hpropexists $hpath link] {
set link [hgetpropval $hpath link]
nxscript makelink $link $nxalias
::nexus::link {*}$link $nxalias
}
foreach {propName propValue} [hfindprop $hpath @*] {
set attName [string range $propName 1 end]
@ -1176,7 +1211,7 @@ proc ::nexus::chopperadapter::save {sobj nxalias hpath data_type filestatus args
if {$filestatus == "newfile"} {
if [hpropexists $hpath link] {
set link [hgetpropval $hpath link]
nxscript makelink $link $nxalias
::nexus::link {*}$link $nxalias
}
foreach {propName propValue} [hfindprop $hpath @*] {
set attName [string range $propName 1 end]
@ -1244,7 +1279,7 @@ proc ::nexus::script::save {script nxalias hpath data_type filestatus args} {
if {$filestatus == "newfile"} {
if [hpropexists $hpath link] {
set link [hgetpropval $hpath link]
nxscript makelink $link $nxalias
::nexus::link {*}$link $nxalias
}
foreach {propName propValue} [hfindprop $hpath @*] {
set attName [string range $propName 1 end]

View File

@ -192,7 +192,7 @@ proc ::scan::check_scanvar {sobj uobj} {
return -code error "ERROR: Can't drive scan variable, $scan_variable position is set to 'fixed'"
} else {
set mtype [getatt $scan_variable mtype]
if {$mtype != "tlcmot" && $check_thread0 && [SplitReply [$scan_variable thread0]] == -1} {
if {$mtype != "tclmot" && $check_thread0 && [SplitReply [$scan_variable thread0]] == -1} {
return -code error "ERROR: Can't scan ${scan_variable}. Thread zero has stopped running on the motion controller"
}
}

View File

@ -0,0 +1,50 @@
# vim: ts=8 sts=2 sw=2 expandtab autoindent smartindent nocindent
# http://neutron.ansto.gov.au/Bragg/proposal/reactor.jsp?type=ALL
# Power: 19.198232; CNS Out: 29.26; TG123: 1; CG123: 1; TG4: 3
driver reactor_status = {
protocol = std;
class = NXsource;
simulation_group = opal_simulation;
group = {
group_property 'data' = 'true';
group_property 'control' = 'true';
var status = {
type = text;
priv = spy;
readable = 10;
read_command = 'GET /Bragg/proposal/reactor.jsp?type=ALL HTTP/1.0';
read_function = rdAll;
fetch_function = getState;
data = false;
control = false;
}
var power = { type = float; priv = spy; mutable = true; property klass = source;}
var cns_out = { type = float; priv = spy; mutable = true; property klass = source;}
var tg123 = { type = float; priv = spy; mutable = true; property klass = source;}
var cg123 = { type = float; priv = spy; mutable = true; property klass = source;}
var tg4 = { type = float; priv = spy; mutable = true; property klass = source;}
}
code read_function rdValue = {
}
code Write_function setPoint = {
}
code mkDriver = {
}
code read_function rdAll = {
@ set data [lindex [split [string trim ${data}] "\r\n"] end]
@ if {${data} != [sct oldval]} {
@ foreach {n v} [regexp -all -inline {[A-Z][A-Za-z0-9 ]+|[0-9][0-9.]*} ${data}] {
@ switch $n {
@ "Power" { hset ${tc_root}/power $v }
@ "CNS Out" { hset ${tc_root}/cns_out $v }
@ "TG123" { hset ${tc_root}/tg123 $v }
@ "CG123" { hset ${tc_root}/cg123 $v }
@ "TG4" { hset ${tc_root}/tg4 $v }
@ }
@ }
@ }
}
}

View File

@ -0,0 +1,356 @@
# Generated driver for reactor_status
# vim: ft=tcl tabstop=8 softtabstop=2 shiftwidth=2 nocindent smartindent
#
namespace eval ::scobj::reactor_status {
set debug_threshold 0
}
proc ::scobj::reactor_status::debug_log {debug_level debug_string} {
set catch_status [ catch {
if {${debug_level} >= ${::scobj::reactor_status::debug_threshold}} {
set fd [open "/tmp/reactor_status.log" "a"]
set line "[clock format [clock seconds] -format "%T"] ${debug_string}"
puts ${fd} "${line}"
close ${fd}
}
} catch_message ]
}
# check function for hset change
proc ::scobj::reactor_status::checkrange {tc_root} {
set catch_status [ catch {
debug_log 1 "checkrange tc_root=${tc_root} sct=[sct] target=[sct target]"
set setpoint [sct target]
if { [hpropexists [sct] lowerlimit] } {
set lolimit [sct lowerlimit]
} else {
# lowerlimit not set, use target
set lolimit [sct target]
}
if { [hpropexists [sct] upperlimit] } {
set hilimit [sct upperlimit]
} else {
# upperlimit not set, use target
set hilimit [sct target]
}
# hook code goes here
if { ${setpoint} < ${lolimit} || ${setpoint} > ${hilimit} } {
error "setpoint ${setpoint} violates limits (${lolimit}..${hilimit}) on [sct]"
}
return OK
} catch_message ]
handle_exception ${catch_status} ${catch_message}
}
# function to request the read of a parameter on a device
proc ::scobj::reactor_status::getState {tc_root nextState cmd_str} {
set catch_status [ catch {
debug_log 1 "getState tc_root=${tc_root} sct=[sct] cmd=${cmd_str}"
if { [hpropexists [sct] geterror] } {
hdelprop [sct] geterror
}
set cmd "${cmd_str}"
# hook code goes here
debug_log 1 "getState sct send ${cmd}"
if {![string equal -nocase -length 10 ${cmd} "@@NOSEND@@"]} {
sct send "${cmd}"
}
return ${nextState}
} catch_message ]
handle_exception ${catch_status} ${catch_message}
}
# function to request the read of a parameter on a device
proc ::scobj::reactor_status::getValue {tc_root nextState cmd_str} {
set catch_status [ catch {
debug_log 1 "getValue tc_root=${tc_root} sct=[sct] cmd=${cmd_str}"
if { [hpropexists [sct] geterror] } {
hdelprop [sct] geterror
}
set cmd "${cmd_str}"
# hook code goes here
debug_log 1 "getValue sct send ${cmd}"
if {![string equal -nocase -length 10 ${cmd} "@@NOSEND@@"]} {
sct send "${cmd}"
}
return ${nextState}
} catch_message ]
handle_exception ${catch_status} ${catch_message}
}
# function to check the write parameter on a device
proc ::scobj::reactor_status::noResponse {tc_root} {
set catch_status [ catch {
debug_log 1 "noResponse tc_root=${tc_root} sct=[sct] resp=[sct result]"
# hook code goes here
return "idle"
} catch_message ]
handle_exception ${catch_status} ${catch_message}
}
# function to parse the read of a parameter on a device
proc ::scobj::reactor_status::rdAll {tc_root} {
set catch_status [ catch {
debug_log 1 "rdAll tc_root=${tc_root} sct=[sct] result=[sct result]"
if { [hpropexists [sct] geterror] } {
hdelprop [sct] geterror
}
set data [sct result]
set nextState "idle"
if {[string equal -nocase -length 7 ${data} "ASCERR:"]} {
# the protocol driver has reported an error
sct geterror "${data}"
error "[sct geterror]"
}
# hook code starts
set data [lindex [split [string trim ${data}] "\r\n"] end]
if {${data} != [sct oldval]} {
foreach {n v} [regexp -all -inline {[A-Z][A-Za-z0-9 ]+|[0-9][0-9.]*} ${data}] {
switch $n {
"Power" { hset ${tc_root}/power $v }
"CNS Out" { hset ${tc_root}/cns_out $v }
"TG123" { hset ${tc_root}/tg123 $v }
"CG123" { hset ${tc_root}/cg123 $v }
"TG4" { hset ${tc_root}/tg4 $v }
}
}
}
# hook code ends
if { [hpropexists [sct] geterror] } {
debug_log 1 "[sct] error: [sct geterror]"
error "[sct geterror]"
}
if { ${data} != [sct oldval] } {
debug_log 1 "[sct] changed to new:${data}, from old:[sct oldval]"
sct oldval ${data}
sct update ${data}
sct utime readtime
}
return ${nextState}
} catch_message ]
handle_exception ${catch_status} ${catch_message}
}
# function to parse the read of a parameter on a device
proc ::scobj::reactor_status::rdValue {tc_root} {
set catch_status [ catch {
debug_log 1 "rdValue tc_root=${tc_root} sct=[sct] result=[sct result]"
if { [hpropexists [sct] geterror] } {
hdelprop [sct] geterror
}
set data [sct result]
set nextState "idle"
if {[string equal -nocase -length 7 ${data} "ASCERR:"]} {
# the protocol driver has reported an error
sct geterror "${data}"
error "[sct geterror]"
}
# hook code goes here
if { ${data} != [sct oldval] } {
debug_log 1 "[sct] changed to new:${data}, from old:[sct oldval]"
sct oldval ${data}
sct update ${data}
sct utime readtime
}
return ${nextState}
} catch_message ]
handle_exception ${catch_status} ${catch_message}
}
# function to write a parameter value on a device
proc ::scobj::reactor_status::setPoint {tc_root nextState cmd_str} {
set catch_status [ catch {
debug_log 1 "setPoint tc_root=${tc_root} sct=[sct] cmd=${cmd_str}"
if { [hpropexists [sct] geterror] } {
hdelprop [sct] geterror
}
set par [sct target]
set cmd "${cmd_str}${par}"
# hook code goes here
if { [hpropexists [sct] driving] } {
if { [hpropexists [sct] writestatus] && [sct writestatus] == "start" } {
sct driving 1
}
}
debug_log 1 "setPoint sct send ${cmd}"
if {![string equal -nocase -length 10 ${cmd} "@@NOSEND@@"]} {
sct send "${cmd}"
}
return ${nextState}
} catch_message ]
handle_exception ${catch_status} ${catch_message}
}
# function to write a parameter value on a device
proc ::scobj::reactor_status::setValue {tc_root nextState cmd_str} {
set catch_status [ catch {
debug_log 1 "setValue tc_root=${tc_root} sct=[sct] cmd=${cmd_str}"
if { [hpropexists [sct] geterror] } {
hdelprop [sct] geterror
}
set par [sct target]
set cmd "${cmd_str}${par}"
# hook code goes here
if { [hpropexists [sct] driving] } {
if { [hpropexists [sct] writestatus] && [sct writestatus] == "start" } {
sct driving 1
}
}
debug_log 1 "setValue sct send ${cmd}"
if {![string equal -nocase -length 10 ${cmd} "@@NOSEND@@"]} {
sct send "${cmd}"
}
return ${nextState}
} catch_message ]
handle_exception ${catch_status} ${catch_message}
}
proc ::scobj::reactor_status::mk_sct_reactor_status { sct_controller name } {
debug_log 1 "mk_sct_reactor_status for ${name}"
set ns "[namespace current]"
set catch_status [ catch {
MakeSICSObj ${name} SCT_OBJECT
sicslist setatt ${name} klass NXsource
sicslist setatt ${name} long_name ${name}
set scobj_hpath /sics/${name}
hfactory ${scobj_hpath}/cg123 plain spy float
hsetprop ${scobj_hpath}/cg123 control true
hsetprop ${scobj_hpath}/cg123 data true
hsetprop ${scobj_hpath}/cg123 mutable true
hsetprop ${scobj_hpath}/cg123 nxsave true
hsetprop ${scobj_hpath}/cg123 oldval 0.0
hsetprop ${scobj_hpath}/cg123 klass "source"
hsetprop ${scobj_hpath}/cg123 sdsinfo "::nexus::scobj::sdsinfo"
hsetprop ${scobj_hpath}/cg123 type "part"
hsetprop ${scobj_hpath}/cg123 nxalias "${name}_cg123"
hfactory ${scobj_hpath}/cns_out plain spy float
hsetprop ${scobj_hpath}/cns_out control true
hsetprop ${scobj_hpath}/cns_out data true
hsetprop ${scobj_hpath}/cns_out mutable true
hsetprop ${scobj_hpath}/cns_out nxsave true
hsetprop ${scobj_hpath}/cns_out oldval 0.0
hsetprop ${scobj_hpath}/cns_out klass "source"
hsetprop ${scobj_hpath}/cns_out sdsinfo "::nexus::scobj::sdsinfo"
hsetprop ${scobj_hpath}/cns_out type "part"
hsetprop ${scobj_hpath}/cns_out nxalias "${name}_cns_out"
hfactory ${scobj_hpath}/power plain spy float
hsetprop ${scobj_hpath}/power control true
hsetprop ${scobj_hpath}/power data true
hsetprop ${scobj_hpath}/power mutable true
hsetprop ${scobj_hpath}/power nxsave true
hsetprop ${scobj_hpath}/power oldval 0.0
hsetprop ${scobj_hpath}/power klass "source"
hsetprop ${scobj_hpath}/power sdsinfo "::nexus::scobj::sdsinfo"
hsetprop ${scobj_hpath}/power type "part"
hsetprop ${scobj_hpath}/power nxalias "${name}_power"
hfactory ${scobj_hpath}/status plain spy text
hsetprop ${scobj_hpath}/status read ${ns}::getState ${scobj_hpath} rdAll {GET /Bragg/proposal/reactor.jsp?type=ALL HTTP/1.0}
hsetprop ${scobj_hpath}/status rdAll ${ns}::rdAll ${scobj_hpath}
hsetprop ${scobj_hpath}/status control false
hsetprop ${scobj_hpath}/status data false
hsetprop ${scobj_hpath}/status mutable false
hsetprop ${scobj_hpath}/status nxsave true
hsetprop ${scobj_hpath}/status oldval UNKNOWN
hsetprop ${scobj_hpath}/status sdsinfo "::nexus::scobj::sdsinfo"
hsetprop ${scobj_hpath}/status type "part"
hsetprop ${scobj_hpath}/status nxalias "${name}_status"
hfactory ${scobj_hpath}/tg123 plain spy float
hsetprop ${scobj_hpath}/tg123 control true
hsetprop ${scobj_hpath}/tg123 data true
hsetprop ${scobj_hpath}/tg123 mutable true
hsetprop ${scobj_hpath}/tg123 nxsave true
hsetprop ${scobj_hpath}/tg123 oldval 0.0
hsetprop ${scobj_hpath}/tg123 klass "source"
hsetprop ${scobj_hpath}/tg123 sdsinfo "::nexus::scobj::sdsinfo"
hsetprop ${scobj_hpath}/tg123 type "part"
hsetprop ${scobj_hpath}/tg123 nxalias "${name}_tg123"
hfactory ${scobj_hpath}/tg4 plain spy float
hsetprop ${scobj_hpath}/tg4 control true
hsetprop ${scobj_hpath}/tg4 data true
hsetprop ${scobj_hpath}/tg4 mutable true
hsetprop ${scobj_hpath}/tg4 nxsave true
hsetprop ${scobj_hpath}/tg4 oldval 0.0
hsetprop ${scobj_hpath}/tg4 klass "source"
hsetprop ${scobj_hpath}/tg4 sdsinfo "::nexus::scobj::sdsinfo"
hsetprop ${scobj_hpath}/tg4 type "part"
hsetprop ${scobj_hpath}/tg4 nxalias "${name}_tg4"
hsetprop ${scobj_hpath} control "true"
hsetprop ${scobj_hpath} data "true"
if {[SplitReply [opal_simulation]]=="false"} {
${sct_controller} poll ${scobj_hpath}/status 10
}
hsetprop ${scobj_hpath} klass NXsource
# hook code starts
# hook code ends
} catch_message ]
handle_exception ${catch_status} ${catch_message}
}
namespace eval ::scobj::reactor_status {
namespace export debug_log
namespace export mk_sct_reactor_status
}
proc add_reactor_status {name IP port} {
set catch_status [ catch {
set ns "::scobj::reactor_status"
${ns}::debug_log 1 "add_reactor_status ${name} ${IP} ${port}"
if {[SplitReply [opal_simulation]]=="false"} {
if {[string equal -nocase "aqadapter" "${IP}"]} {
${ns}::debug_log 1 "makesctcontroller sct_${name} aqadapter ${port}"
makesctcontroller sct_${name} aqadapter ${port}
} else {
${ns}::debug_log 1 "makesctcontroller sct_${name} std ${IP}:${port}"
makesctcontroller sct_${name} std ${IP}:${port}
}
}
${ns}::debug_log 1 "mk_sct_reactor_status sct_${name} ${name}"
${ns}::mk_sct_reactor_status sct_${name} ${name}
} catch_message ]
handle_exception ${catch_status} ${catch_message}
}
puts stdout "file evaluation of sct_reactor_status.tcl"
::scobj::reactor_status::debug_log 1 "file evaluation of sct_reactor_status.tcl"
proc ::scobj::reactor_status::read_config {} {
set catch_status [ catch {
set ns "::scobj::reactor_status"
${ns}::debug_log 1 "Processing Config"
dict for {k v} $::config_dict {
${ns}::debug_log 1 "Inspecting $k:$v"
if { [dict exists $v "driver"] } {
${ns}::debug_log 1 "Has driver [dict get $v driver]"
if { [dict get $v "driver"] == "reactor_status" } {
${ns}::debug_log 1 "Correct driver, enabled = [dict get $v enabled]"
if { [dict get $v enabled] } {
set IP [dict get $v ip]
set PORT [dict get $v port]
set name [dict get $v name]
MakeAsyncProtocol ${name}_protocol
MakeAsyncQueue ${name}_queue ${name}_protocol ${IP} ${PORT}
add_reactor_status ${name} "aqadapter" ${name}_queue
}
}
}
}
} catch_message ]
handle_exception ${catch_status} ${catch_message}
}
if { [info exists ::config_dict] } {
::scobj::reactor_status::read_config
} else {
::scobj::reactor_status:debug_log 1 "No config dict"
}

View File

@ -0,0 +1,16 @@
fileeval $cfPath(source)/sct_reactor_status.tcl
if {[SplitReply [opal_simulation]]=="false"} {
MakeAsyncProtocol std
std sendterminator \r\n\r\n
std replyterminator 0x03
MakeAsyncQueue aqreactor std portal.nbi.ansto.gov.au 80
aqreactor timeout 2000
}
add_reactor_status source aqadapter aqreactor
namespace eval ::source {
proc isc_initialize {} {
}
}

View File

@ -152,6 +152,14 @@ dingo|dingo)
INSTRUMENT=dingo
DESTHOST=${2:-ics1-dingo.nbi.ansto.gov.au}
INSTSRC=$SRCDIR/dingo;;
bilby|bilby)
INSTRUMENT=bilby
DESTHOST=${2:-ics1-bilby.nbi.ansto.gov.au}
INSTSRC=$SRCDIR/bilby;;
emu|emu)
INSTRUMENT=emu
DESTHOST=${2:-ics1-emu.nbi.ansto.gov.au}
INSTSRC=$SRCDIR/emu;;
esac
INSTCFDIR=$INSTSRC/config

View File

@ -1,4 +1,5 @@
config/source/source_common.tcl
config/source/sct_reactor_status.tcl
config/source/source.tcl
config/anticollider/anticollider_common.tcl
config/plc/plc_common_1.tcl
config/counter/counter_common_1.tcl

View File

@ -1,8 +0,0 @@
# Author Jing Chen (jgn@ansto.gov.au)
source $cfPath(source)/source_common.tcl
proc ::source::isc_initialize {} {
::source::ic_initialize "thermal"
}

View File

@ -2,13 +2,25 @@ proc getdataType {path} {
return [lindex [split [hinfo $path] ,] 0]
}
proc encode {str} {
set result [string map -nocase {
{"} {&quot;}
{'} {&apos;}
{<} {&lt;}
{>} {&gt;}
{&} {&amp;}
} $str]
return $result
}
proc make_nodes {path result indent} {
set nodename [file tail $path];
set type [getdataType $path]
set prefix [string repeat " " $indent]
set newIndent [expr $indent + 2]
set control "true"
foreach {key value} [string map {= " "} [hlistprop $path tcl]] {
foreach {key rvalue} [string map {= " "} [hlistprop $path tcl]] {
set value [encode $rvalue]
if {[string compare -nocase $key "control"] == 0} {
if {[string compare -nocase $value "false"] == 0} {
set control "false"
@ -30,7 +42,8 @@ set control "true"
proc property_elements {path indent} {
set prefix [string repeat " " $indent]
foreach {key value} [string map {= " "} [hlistprop $path tcl]] {
foreach {key rvalue} [string map {= " "} [hlistprop $path tcl]] {
set value [encode $rvalue]
if {[string compare -nocase $key "control"] == 0} {continue}
lappend proplist "$prefix<property id=\"$key\">\n"
if {[string compare -nocase $key "help"] == 0} {

View File

@ -1,4 +1,5 @@
config/source/source_common.tcl
config/source/sct_reactor_status.tcl
config/source/source.tcl
config/anticollider/anticollider_common.tcl
config/plc/plc_common_1.tcl
config/counter/counter_common_1.tcl

View File

@ -1,7 +1,8 @@
# This must be loaded by motor_configuration.tcl
set ephi_Home 6647698
set echi_Home 8919294
set ephi_Home 26575217
set echi_Home 24224381
#set echi_Home 8919294
set eom_Home 23165482
# Sample Tilt 1, euler omega stage
@ -11,9 +12,9 @@ Motor eom $motor_driver_type [params \
units degrees\
hardlowerlim -45\
hardupperlim 80\
maxSpeed 1\
maxAccel 1\
maxDecel 1\
maxSpeed 2\
maxAccel 2\
maxDecel 2\
stepsPerX 25000\
absEnc 1\
absEncHome $eom_Home\
@ -30,18 +31,18 @@ Motor echi $motor_driver_type [params \
asyncqueue mc2\
axis B\
units degrees\
hardlowerlim -32\
hardupperlim 97\
maxSpeed 1\
maxAccel 1\
maxDecel 1\
hardlowerlim -45\
hardupperlim 100\
maxSpeed 2\
maxAccel 2\
maxDecel 2\
stepsPerX -25000\
absEnc 1\
absEncHome $echi_Home\
cntsPerX 8192]
setHomeandRange -motor echi -home 0 -lowrange 10 -uprange 95
echi softlowerlim -10
echi softupperlim 90
echi softupperlim 99
echi home 0
echi speed 1
echi movecount $move_count
@ -52,7 +53,7 @@ echi long_name euler_chi
# Sample Trans 1, upper, y
Motor ephi $motor_driver_type [params \
asyncqueue mc2\
axis C\
axis D\
units degrees\
hardlowerlim -185\
hardupperlim 185\
@ -72,3 +73,96 @@ ephi movecount $move_count
ephi precision 0.01
ephi part sample
ephi long_name euler_phi
# dummy motors for UB
Motor fake_eom asim [params \
asyncqueue mc2\
axis A\
units degrees\
hardlowerlim -370\
hardupperlim 370\
maxSpeed 2\
maxAccel 2\
maxDecel 2\
stepsPerX 25000\
absEnc 1\
absEncHome $eom_Home\
cntsPerX -8192]
setHomeandRange -motor fake_eom -home 0 -lowrange -370 -uprange 370
fake_eom softlowerlim -370
fake_eom softupperlim 370
fake_eom speed 1
fake_eom movecount $move_count
fake_eom precision 0.01
fake_eom part sample
fake_eom long_name fake_euler_omega
Motor fake_ephi asim [params \
asyncqueue mc2\
axis A\
units degrees\
hardlowerlim -370\
hardupperlim 370\
maxSpeed 2\
maxAccel 2\
maxDecel 2\
stepsPerX 25000\
absEnc 1\
absEncHome $eom_Home\
cntsPerX -8192]
setHomeandRange -motor fake_ephi -home 0 -lowrange -370 -uprange 370
fake_ephi softlowerlim -370
fake_ephi softupperlim 370
fake_ephi speed 1
fake_ephi movecount $move_count
fake_ephi precision 0.01
fake_ephi part sample
fake_ephi long_name fake_euler_phi
Motor fake_twotheta asim [params \
asyncqueue mc2\
axis A\
units degrees\
hardlowerlim -370\
hardupperlim 370\
maxSpeed 2\
maxAccel 2\
maxDecel 2\
stepsPerX 25000\
absEnc 1\
absEncHome $eom_Home\
cntsPerX -8192]
setHomeandRange -motor fake_twotheta -home 0 -lowrange -370 -uprange 370
fake_twotheta softlowerlim -370
fake_twotheta softupperlim 370
fake_twotheta speed 1
fake_twotheta movecount $move_count
fake_twotheta precision 0.01
fake_twotheta part sample
fake_twotheta long_name fake_euler_twotheta
Motor fake_echi asim [params \
asyncqueue mc2\
axis A\
units degrees\
hardlowerlim -370\
hardupperlim 370\
maxSpeed 2\
maxAccel 2\
maxDecel 2\
stepsPerX 25000\
absEnc 1\
absEncHome $eom_Home\
cntsPerX -8192]
setHomeandRange -motor fake_echi -home 0 -lowrange -370 -uprange 370
fake_echi softlowerlim -370
fake_echi softupperlim 370
fake_echi speed 1
fake_echi movecount $move_count
fake_echi precision 0.01
fake_echi part sample
fake_echi long_name fake_euler_echi

View File

@ -0,0 +1,168 @@
# This must be loaded by motor_configuration.tcl
set ephi_Home 31706258
set echi_Home 24224381
#set echi_Home 8919294
set eom_Home 23165482
# Sample Tilt 1, euler omega stage
Motor eom $motor_driver_type [params \
asyncqueue mc2\
axis A\
units degrees\
hardlowerlim -45\
hardupperlim 80\
maxSpeed 2\
maxAccel 2\
maxDecel 2\
stepsPerX 25000\
absEnc 1\
absEncHome $eom_Home\
cntsPerX -8192]
setHomeandRange -motor eom -home 0 -lowrange 35 -uprange 80
eom speed 1
eom movecount $move_count
eom precision 0.01
eom part sample
eom long_name euler_omega
# Sample Tilt 2, euler chi stage
Motor echi $motor_driver_type [params \
asyncqueue mc2\
axis B\
units degrees\
hardlowerlim -32\
hardupperlim 97\
maxSpeed 2\
maxAccel 2\
maxDecel 2\
stepsPerX -25000\
absEnc 1\
absEncHome $echi_Home\
cntsPerX 8192]
setHomeandRange -motor echi -home 0 -lowrange 10 -uprange 95
echi softlowerlim -10
echi softupperlim 90
echi home 0
echi speed 1
echi movecount $move_count
echi precision 0.01
echi part sample
echi long_name euler_chi
# Sample Trans 1, upper, y
Motor ephi $motor_driver_type [params \
asyncqueue mc2\
axis C\
units degrees\
hardlowerlim -360000\
hardupperlim 360000\
maxSpeed 5\
maxAccel 5\
maxDecel 1\
stepsPerX -12500\
absEnc 1\
absEncHome $ephi_Home\
cntsPerX -4096]
setHomeandRange -motor ephi -home 0 -lowrange 180 -uprange 180
ephi softlowerlim -360000
ephi softupperlim 360000
ephi home 0
ephi speed 1
ephi movecount $move_count
ephi precision 0.01
ephi part sample
ephi long_name euler_phi
# dummy motors for UB
Motor fake_eom asim [params \
asyncqueue mc2\
axis A\
units degrees\
hardlowerlim -370\
hardupperlim 370\
maxSpeed 2\
maxAccel 2\
maxDecel 2\
stepsPerX 25000\
absEnc 1\
absEncHome $eom_Home\
cntsPerX -8192]
setHomeandRange -motor fake_eom -home 0 -lowrange -370 -uprange 370
fake_eom softlowerlim -370
fake_eom softupperlim 370
fake_eom speed 1
fake_eom movecount $move_count
fake_eom precision 0.01
fake_eom part sample
fake_eom long_name fake_euler_omega
Motor fake_ephi asim [params \
asyncqueue mc2\
axis A\
units degrees\
hardlowerlim -370\
hardupperlim 370\
maxSpeed 2\
maxAccel 2\
maxDecel 2\
stepsPerX 25000\
absEnc 1\
absEncHome $eom_Home\
cntsPerX -8192]
setHomeandRange -motor fake_ephi -home 0 -lowrange -370 -uprange 370
fake_ephi softlowerlim -370
fake_ephi softupperlim 370
fake_ephi speed 1
fake_ephi movecount $move_count
fake_ephi precision 0.01
fake_ephi part sample
fake_ephi long_name fake_euler_phi
Motor fake_twotheta asim [params \
asyncqueue mc2\
axis A\
units degrees\
hardlowerlim -370\
hardupperlim 370\
maxSpeed 2\
maxAccel 2\
maxDecel 2\
stepsPerX 25000\
absEnc 1\
absEncHome $eom_Home\
cntsPerX -8192]
setHomeandRange -motor fake_twotheta -home 0 -lowrange -370 -uprange 370
fake_twotheta softlowerlim -370
fake_twotheta softupperlim 370
fake_twotheta speed 1
fake_twotheta movecount $move_count
fake_twotheta precision 0.01
fake_twotheta part sample
fake_twotheta long_name fake_euler_twotheta
Motor fake_echi asim [params \
asyncqueue mc2\
axis A\
units degrees\
hardlowerlim -370\
hardupperlim 370\
maxSpeed 2\
maxAccel 2\
maxDecel 2\
stepsPerX 25000\
absEnc 1\
absEncHome $eom_Home\
cntsPerX -8192]
setHomeandRange -motor fake_echi -home 0 -lowrange -370 -uprange 370
fake_echi softlowerlim -370
fake_echi softupperlim 370
fake_echi speed 1
fake_echi movecount $move_count
fake_echi precision 0.01
fake_echi part sample
fake_echi long_name fake_euler_echi

View File

@ -0,0 +1,19 @@
set magmot "som"
Motor $magmot $motor_driver_type [params \
asyncqueue mc2\
axis D\
units degrees\
hardlowerlim -1440\
hardupperlim 1440\
maxSpeed 1\
maxAccel 1\
maxDecel 1\
stepsPerX [expr 67.0 * 25000 / 360]\
absEnc 1\
absEncHome 31275743\
cntsPerX [expr 67.0 * 8192 / 360]]
$magmot part sample
$magmot long_name $magmot
$magmot softlowerlim -180
$magmot softupperlim 180
$magmot home 0

View File

@ -24,7 +24,8 @@ if {$sim_mode == "true"} {
#set mx_Home 23263535
set mx_Home 8390583
#set mom_Home 9274794
set mom_Home 8391038
#set mom_Home 8391038
set mom_Home 8147038
set mtth_Home 19927837
#set mphi_Home 7613516
#set mphi_Home 27847793
@ -35,7 +36,8 @@ set mchi_Home 8389526
#set my_Home 6767221
set my_Home 8378212
set som_Home 17214054
set stth_Home 2896180
set stth_Home 1036498
#set stth_Home 32855991
set oct_Home 7743768
#Measured or computed slit motor steps per millimetre
@ -97,11 +99,46 @@ set move_count 10
# CHOOSE HERE for sample stage configuration
##########################################
# Set axis_config as follows to use different axis configurations
# 0: tilt stage configuration
# 1: eulerian cradle
# 2: small omega
# 3: Oxford magnet sample stick
set axis_config 0
switch $axis_config {
0 {
set sample_stage_rotate "som"
fileeval $cfPath(motors)/tilt_configuration.tcl
}
1 {
set sample_stage_rotate "som"
fileeval $cfPath(motors)/euler_configuration.tcl
}
2 {
set sample_stage_rotate "som"
fileeval $cfPath(motors)/small_omega_config.tcl
}
3 {
# Rename the sample stage som to somss because
# som now controls the magnet sample stick
set sample_stage_rotate "somss"
fileeval $cfPath(motors)/magnet_configuration.tcl
}
}
#fileeval $cfPath(motors)/tilt_configuration.tcl
fileeval $cfPath(motors)/euler_configuration.tcl
#fileeval $cfPath(motors)/euler_configuration.tcl
#fileeval $cfPath(motors)/small_omega_config.tcl
#use this next one ONLY if you have NO fridge on the euler
#cradle and you know what you're doing. This is a fudge that
#allows ephi to do lots of rotations
#fileeval $cfPath(motors)/eulinf_configuration.tcl
############################
# Motor Controller 1
@ -201,8 +238,8 @@ Motor mx $motor_driver_type [params \
asyncqueue mc1\
axis D\
units mm\
hardlowerlim -10\
hardupperlim 10\
hardlowerlim -15\
hardupperlim 15\
maxSpeed 1\
maxAccel 1\
maxDecel 1\
@ -223,7 +260,7 @@ Motor mom $motor_driver_type [params \
axis E\
units degrees\
hardlowerlim -5\
hardupperlim 103\
hardupperlim 173\
maxSpeed 1\
maxAccel 1\
maxDecel 1\
@ -231,7 +268,8 @@ Motor mom $motor_driver_type [params \
absEnc 1\
absEncHome $mom_Home\
cntsPerX -2048]
setHomeandRange -motor mom -home 0 -lowrange 5 -uprange 95
setHomeandRange -motor mom -home 0 -lowrange 5 -uprange 165
#setHomeandRange -motor mom -home 60.08 -lowrange 5 -uprange 165
mom speed 1
mom movecount $move_count
mom precision 0.01
@ -277,12 +315,12 @@ mtth long_name takeoff_angle
# Motor Controller 2
############################
# Sample Omega, rotate
Motor som $motor_driver_type [params \
Motor $sample_stage_rotate $motor_driver_type [params \
asyncqueue mc2\
axis E\
units degrees\
hardlowerlim -110\
hardupperlim 160\
hardlowerlim -71\
hardupperlim 111\
maxSpeed 5\
maxAccel 1\
maxDecel 1\
@ -290,29 +328,33 @@ Motor som $motor_driver_type [params \
absEnc 1\
absEncHome $som_Home\
cntsPerX 4096]
setHomeandRange -motor som -home 0 -lowrange -71 -uprange 111
som speed 1
som precision 0.02
som part sample
som long_name rotate
setHomeandRange -motor $sample_stage_rotate -home 0 -lowrange -70 -uprange 110
$sample_stage_rotate speed 1
$sample_stage_rotate precision 0.02
$sample_stage_rotate part sample
$sample_stage_rotate long_name rotate
# Sample two-theta, detector rotate
Motor stth $motor_driver_type [params \
asyncqueue mc2\
axis F\
units degrees\
hardlowerlim -0.3\
hardupperlim 30\
hardlowerlim 15.8\
hardupperlim 29.7\
maxSpeed 0.5\
maxAccel 0.1\
maxDecel 0.1\
stepsPerX 125000\
absEnc 1\
absEncHome $stth_Home\
bias_bits 25\
bias_bias 932070\
cntsPerX -93207]
stth softlowerlim -0.3
stth softupperlim 30
stth home 0
stth softlowerlim 15.9
stth softupperlim 29.6
stth home 28.481113
#stth home 18.981113
#stth home 32
stth speed 0.5
stth movecount $move_count
stth precision 0.01
@ -324,20 +366,20 @@ Motor oct $motor_driver_type [params \
asyncqueue mc2\
axis G\
units degrees\
hardlowerlim -2\
hardupperlim 4.2\
hardlowerlim -1.5\
hardupperlim 2.5\
maxSpeed 2.0\
maxAccel 5.0\
maxDecel 5.0\
stepsPerX 56762\
stepsPerX 58762\
absEnc 1\
absEncHome $oct_Home\
cntsPerX -465]
oct softlowerlim -2
oct softupperlim 4
oct softlowerlim -1.4
oct softupperlim 2.4
oct home 0
oct speed 0.5
oct precision 0.01
oct precision 0.02
oct part collimator
oct long_name oct
@ -370,6 +412,14 @@ oct long_name oct
#mf1 long_name mf1
# Monochromator Focusing (Ge)
## ffr 31/7/2012
## absEncHome was found to be 16777217 on 31/7/2012 when the
## encoder clocked over to 114 counts to give a posn
## reading of 4793.458008
## The encoder has a 12bit resolution (ie 12bits/turn 4096)
## and has a 24bit range (ie max cnt=16777216)
## I set a bias of 10000 counts with absenchome = 10000
## so that SICS can drive the axis to the allowed limits.
Motor mf2 $motor_driver_type [params \
asyncqueue mc3\
axis A\
@ -381,7 +431,9 @@ Motor mf2 $motor_driver_type [params \
maxDecel 0.1\
stepsPerX 22000\
absEnc 1\
absEncHome 8384341\
absEncHome 42768\
bias_bits 24\
bias_bias 10000\
cntsPerX -3500]
setHomeandRange -motor mf2 -home 0 -lowrange 0 -uprange 2
mf2 speed 0.02

View File

@ -0,0 +1,91 @@
# This must be loaded by motor_configuration.tcl
set sphi_Home 7937974
set schi_Home 7585956
set sy_Home 7557524
set sx_Home 7557304
# Sample Tilt 1, upper, phi
Motor sphi $motor_driver_type [params \
asyncqueue mc2\
axis A\
units degrees\
hardlowerlim -360\
hardupperlim 360\
maxSpeed 3\
maxAccel 2\
maxDecel 2\
stepsPerX 25000\
absEnc 0\
absEncHome $sphi_Home\
cntsPerX -8192]
setHomeandRange -motor sphi -home 0 -lowrange -360 -uprange 360
sphi speed 2
sphi movecount $move_count
sphi precision 0.02
sphi part sample
sphi long_name phi
# Sample Tilt 2, lower, chi
Motor schi $motor_driver_type [params \
asyncqueue mc2\
axis B\
units degrees\
hardlowerlim 75\
hardupperlim 105\
maxSpeed 1\
maxAccel 1\
maxDecel 1\
stepsPerX 25000\
absEnc 1\
absEncHome $schi_Home\
cntsPerX 8192]
setHomeandRange -motor schi -home 90 -lowrange 15 -uprange 15
schi speed 1
schi movecount $move_count
schi precision 0.01
schi part sample
schi long_name chi
# Sample Trans 1, upper, y
Motor sy $motor_driver_type [params \
asyncqueue mc2\
axis C\
units mm\
hardlowerlim -20\
hardupperlim 20\
maxSpeed 1\
maxAccel 1\
maxDecel 1\
stepsPerX 25000\
absEnc 1\
absEncHome $sy_Home\
cntsPerX 8192]
setHomeandRange -motor sy -home 0 -lowrange 20 -uprange 20
sy speed 1
sy movecount $move_count
sy precision 0.01
sy part sample
sy long_name translate_y
# Sample Trans2, lower, x
Motor sx $motor_driver_type [params \
asyncqueue mc2\
axis D\
units mm\
hardlowerlim -20\
hardupperlim 20\
maxSpeed 1\
maxAccel 1\
maxDecel 1\
stepsPerX -25000\
absEnc 1\
absEncHome $sx_Home\
cntsPerX -8192]
setHomeandRange -motor sx -home 0 -lowrange 20 -uprange 20
sx speed 1
sx movecount $move_count
sx precision 0.01
sx part sample
sx long_name translate_x

View File

@ -10,8 +10,8 @@ Motor sphi $motor_driver_type [params \
asyncqueue mc2\
axis A\
units degrees\
hardlowerlim -360\
hardupperlim 360\
hardlowerlim -15\
hardupperlim 15\
maxSpeed 1\
maxAccel 1\
maxDecel 1\

View File

@ -1,5 +0,0 @@
source $cfPath(source)/source_common.tcl
proc ::source::isc_initialize {} {
::source::ic_initialize "thermal"
}

Some files were not shown because too many files have changed in this diff Show More