diff --git a/drive.c b/drive.c index 51a6fcdd..27a575be 100644 --- a/drive.c +++ b/drive.c @@ -153,6 +153,7 @@ int Start2Run(SConnection * pCon, SicsInterp * pInter, char *name, int iRet; float fDelta; long lTime; + float target; assert(pCon); assert(pInter); diff --git a/hmcontrol.c b/hmcontrol.c index 21036ecb..aed00d55 100644 --- a/hmcontrol.c +++ b/hmcontrol.c @@ -16,12 +16,19 @@ image is invalid. This is not what is wanted. Mark Koennecke, July 2011 + + Made a special status function for BOA which aborts the CCD when the + camera overruns the counter for more then 120 seconds and repeats the + measurement. + + Mark Koennecke, July 2012 -------------------------------------------------------------------------*/ #include #include #include #include +#include #include "fortify.h" #include "hmcontrol.h" #include "HistMem.h" @@ -119,47 +126,92 @@ static int HMCStatus(void *pData, SConnection * pCon) assert(self); if(self->checkSlaves == 0) { - status = self->slaves[0]->CheckCountStatus(self->slaveData[0], pCon); - /* - Warning: this assumes that slaves 1 - MAXSLAVE are histogram memories. - If this assumption does not hold, change this code to check if this - is really a histogram memory. - */ - for (i = 1; i < MAXSLAVE; i++) { - if (self->slaves[i] != NULL) { - HistDirty((pHistMem) self->slaveData[i]); - } - } - if (status == HWIdle || status == HWFault) { - /* - stop counting on slaves when finished or when an error - occurred. - */ - if(self->stopSlaves){ - HMCHalt(self); - } - ReleaseCountLock(self->pCount); - self->checkSlaves = 1; - status = HWBusy; - } + status = self->slaves[0]->CheckCountStatus(self->slaveData[0], pCon); + /* + Warning: this assumes that slaves 1 - MAXSLAVE are histogram memories. + If this assumption does not hold, change this code to check if this + is really a histogram memory. + */ + for (i = 1; i < MAXSLAVE; i++) { + if (self->slaves[i] != NULL) { + HistDirty((pHistMem) self->slaveData[i]); + } + } + if (status == HWIdle || status == HWFault) { + /* + stop counting on slaves when finished or when an error + occurred. + */ + if(self->stopSlaves){ + HMCHalt(self); + } + ReleaseCountLock(self->pCount); + self->checkSlaves = 1; + status = HWBusy; + } } else { - /* - * wait for the detectors to report finish too. Otherwise, with the second - * generation HM data may not be fully transferred. - */ - for(i = 1; i < self->nSlaves; i++){ - status = self->slaves[i]->CheckCountStatus(self->slaveData[i], pCon); - if(status != HWIdle || status != HWFault){ - return status; - } - } - status = HWIdle; - InvokeCallBack(self->pCall, COUNTEND, pCon); - self->checkSlaves = 0; + /* + * wait for the detectors to report finish too. Otherwise, with the second + * generation HM data may not be fully transferred. + */ + for(i = 1; i < self->nSlaves; i++){ + status = self->slaves[i]->CheckCountStatus(self->slaveData[i], pCon); + if(status != HWIdle || status != HWFault){ + return status; + } + } + status = HWIdle; + InvokeCallBack(self->pCall, COUNTEND, pCon); + self->checkSlaves = 0; } return status; } +/*----------------------------------------------------------------------*/ +static int HMCBoaStatus(void *pData, SConnection * pCon) +{ + int status, i, j; + pHMcontrol self = NULL; + self = (pHMcontrol) pData; + assert(self); + + /* check counter */ + if(self->checkSlaves == 0) { + status = self->slaves[0]->CheckCountStatus(self->slaveData[0], pCon); + if (status == HWIdle || status == HWFault) { + ReleaseCountLock(self->pCount); + self->checkSlaves = 1; + self->counterStop = time(NULL); + status = HWBusy; + } + } else { + /* check HM */ + for(i = 1; i < self->nSlaves; i++){ + status = self->slaves[i]->CheckCountStatus(self->slaveData[i], pCon); + if(status != HWIdle || status != HWFault){ + if(time(NULL) > self->counterStop + 100) { + SCWrite(pCon,"WARNING: CCD overrun, restarting counting...", eLogError); + HMCHalt(self); + ReleaseCountLock(self->pCount); + self->checkSlaves = 0; + for(j = 0; j < 100; j++){ + SicsWait(1); + status = self->slaves[i]->CheckCountStatus(self->slaveData[i], pCon); + if(status == HWIdle || status == HWFault) { + HMCStart(self, pCon); + return HWBusy; + } + } + } + return status; + } + } + status = HWIdle; + InvokeCallBack(self->pCall, COUNTEND, pCon); + self->checkSlaves = 0; + } + return status; +} /*-------------------------------------------------------------------------*/ static int HMCPause(void *pData, SConnection * pCon) { @@ -357,7 +409,7 @@ int HMControlAction(SConnection * pCon, SicsInterp * pSics, /* checks - */ + */ self = (pHMcontrol) pData; assert(self); if (argc < 2) { @@ -367,14 +419,14 @@ int HMControlAction(SConnection * pCon, SicsInterp * pSics, } strtolower(argv[1]); if (strcmp(argv[1], "start") == 0) { - if (argc < 4) { - snprintf(pBueffel, 131, "ERROR: Usage %s start preset mode", argv[0]); - SCWrite(pCon, pBueffel, eError); - return 0; - } - /* - interpret count parameters - */ + if (argc < 4) { + snprintf(pBueffel, 131, "ERROR: Usage %s start preset mode", argv[0]); + SCWrite(pCon, pBueffel, eError); + return 0; + } + /* + interpret count parameters + */ status = Tcl_GetDouble(pSics->pTcl, argv[2], &dPreset); if (status != TCL_OK) { snprintf(pBueffel,sizeof(pBueffel)-1, "ERROR: failed to convert %s to number", argv[2]); @@ -393,8 +445,8 @@ int HMControlAction(SConnection * pCon, SicsInterp * pSics, } /* - set count parameters and go - */ + set count parameters and go + */ self->pCount->SetCountParameters(self, (float) dPreset, eMode); status = StartDevice(pServ->pExecutor, "hmcontrol", self->pDes, self, pCon, RUNRUN, 99); @@ -405,14 +457,18 @@ int HMControlAction(SConnection * pCon, SicsInterp * pSics, InvokeCallBack(self->pCall, COUNTSTART, pCon); SCSendOK(pCon); }else if(strcmp(argv[1],"stopslaves") == 0){ - if(argc < 3){ - SCPrintf(pCon,eValue,"hm.stopslaves = %d", self->stopSlaves); - return 1; - } else { - self->stopSlaves = atoi(argv[2]); - SCPrintf(pCon,eValue,"hm.stopslaves = %d", self->stopSlaves); - return 1; - } + if(argc < 3){ + SCPrintf(pCon,eValue,"hm.stopslaves = %d", self->stopSlaves); + return 1; + } else { + self->stopSlaves = atoi(argv[2]); + SCPrintf(pCon,eValue,"hm.stopslaves = %d", self->stopSlaves); + return 1; + } + }else if(strcmp(argv[1],"boamode") == 0){ + self->pCount->CheckCountStatus = HMCBoaStatus; + SCSendOK(pCon); + return 1; } else { SCWrite(pCon, "ERROR: subcommand not recognized", eError); return 0; diff --git a/hmcontrol.h b/hmcontrol.h index 92500bf0..c9113182 100644 --- a/hmcontrol.h +++ b/hmcontrol.h @@ -34,6 +34,7 @@ typedef struct { pICallBack pCall; int checkSlaves; int stopSlaves; + time_t counterStop; } HMcontrol, *pHMcontrol; diff --git a/macro.c b/macro.c index 446537ba..b3a3e03a 100644 --- a/macro.c +++ b/macro.c @@ -765,15 +765,6 @@ int ClientLog(SConnection * pCon, SicsInterp * pInter, void *pData, free(pMessage); return 1; } -/*----------------------------------------------------------------------- - A heartbeat command ............. - ------------------------------------------------------------------------*/ -int Poch(SConnection * pCon, SicsInterp * pInter, void *pData, - int argc, char *argv[]) -{ - SCPureSockWrite(pCon,"Poch", eLog); - return 1; -} /*-----------------------------------------------------------------------*/ int GumPut(SConnection * pCon, SicsInterp * pInter, void *pData, int argc, char *argv[]) diff --git a/motorsec.c b/motorsec.c index cc5ae903..b77643de 100644 --- a/motorsec.c +++ b/motorsec.c @@ -123,7 +123,7 @@ static long SecMotorRun(void *sulf, SConnection * pCon, float fNew) static int SecMotorCheckBoundary(pMotor self, float fVal, float *fTarget, char *pError, int iErrLen) { - double fZero, fixed, lowerlim, upperlim, sign; + double fZero, fixed, lowerlim, upperlim, sign, offset; float fHard, hupper, hlower; char pBueffel[512]; hdbValue v; @@ -134,6 +134,8 @@ static int SecMotorCheckBoundary(pMotor self, float fVal, float *fTarget, fixed = v.v.doubleValue; assert(SICSHdbGetPar(self, NULL, "softzero", &v) == 1); fZero = v.v.doubleValue; + assert(SICSHdbGetPar(self, NULL, "staticoffset", &v) == 1); + offset = v.v.doubleValue; assert(SICSHdbGetPar(self, NULL, "softlowerlim", &v) == 1); lowerlim = v.v.doubleValue; assert(SICSHdbGetPar(self, NULL, "softupperlim", &v) == 1); @@ -165,6 +167,7 @@ static int SecMotorCheckBoundary(pMotor self, float fVal, float *fTarget, } /* correct for zero point */ + fZero += offset; fZero = -fZero; fHard = fVal - fZero; @@ -392,15 +395,16 @@ static void AddMotorPar(pHdb node, int priv, char *name) /*---------------------------------------------------------------------------*/ static float hardToSoftPosition(pMotor self, float hard) { - float sign, zero, fVal; + float sign, zero, fVal, offset; SecMotorGetPar(self, "sign", &sign); SecMotorGetPar(self, "softzero", &zero); + SecMotorGetPar(self, "staticoffset", &offset); fVal = hard; if (sign < 0) { - fVal += zero; + fVal += zero + offset; } else { - fVal -= zero; + fVal -= zero + offset; } fVal *= sign; return fVal; @@ -728,6 +732,11 @@ pMotor SecMotorInit(char *name) SetHdbProperty(child, "__save", "true"); AddHipadabaChild(node, child, NULL); + child = MakeSICSHdbPar("staticoffset", usMugger, + MakeHdbFloat((double) 0.0)); + SetHdbProperty(child, "__save", "true"); + AddHipadabaChild(node, child, NULL); + child = MakeHipadabaNode("status", HIPTEXT, 1); SetHdbProperty(child, "motname", name); AddHipadabaChild(node, child, NULL); diff --git a/nread.c b/nread.c index b4676c9a..a7948974 100644 --- a/nread.c +++ b/nread.c @@ -1035,6 +1035,9 @@ static int testAndInvokeInterrupt(pCommandCBData self, int handle) "ERROR: insufficient privilege to invoke Interrupt", eError); } return 1; + } else if(strstr(pPtr,"Poch") != NULL){ + SCPureSockWrite(self->pCon,"Poch\r\n", eLog); + return 1; } return 0; } diff --git a/ofac.c b/ofac.c index 6c293fc0..25fec993 100644 --- a/ofac.c +++ b/ofac.c @@ -69,7 +69,6 @@ static void InitIniCommands(SicsInterp * pInter) PCMD("Capture", CaptureAction); PCMD("ClientPut", ClientPut); PCMD("ClientLog", ClientLog); - PCMD("Poch", Poch); PCMD("config", ConfigCon); PCMD("db", SICSDebug); PCMD("Dir", ListObjects); diff --git a/reflist.c b/reflist.c index 19a9e78f..3a5426b1 100644 --- a/reflist.c +++ b/reflist.c @@ -240,9 +240,11 @@ static void AddRowIntern(pSICSOBJ refl, double hkl[], double ang[], if(child != NULL){ UpdateHipadabaPar(child, MakeHdbFloat(ang[3]),NULL); } - child = child->next; if(child != NULL){ - UpdateHipadabaPar(child, MakeHdbFloat(ang[4]),NULL); + child = child->next; + if(child != NULL){ + UpdateHipadabaPar(child, MakeHdbFloat(ang[4]),NULL); + } } runObjFunction(refl, pCon, node); } @@ -318,13 +320,15 @@ static int AddIndexesAnglesCmd(pSICSOBJ self, SConnection * pCon, } else if(node!= NULL) { UpdateHipadabaPar(node, v, pCon); } - node = node->next; - if(node != NULL && nPar > 7){ + if(node != NULL){ + node = node->next; + if(node != NULL && nPar > 7){ UpdateHipadabaPar(node, par[7]->value, pCon); - } else if(node!= NULL) { + } else if(node!= NULL) { UpdateHipadabaPar(node, v, pCon); - } - + } + } + return runObjFunction(self, pCon, addrowNode); } /*-----------------------------------------------------------------------*/ diff --git a/sicshipadaba.c b/sicshipadaba.c index eeffe81a..2de06507 100644 --- a/sicshipadaba.c +++ b/sicshipadaba.c @@ -634,7 +634,8 @@ static hdbCallbackReturn SICSNotifyCallback(pHdb node, void *userData, } formatNameValue(protocol, pPath, GetCharArray(printedData), result, mm->v->dataType); - SCWrite(cbInfo->pCon, GetCharArray(result), outCode); + /* SCWrite(cbInfo->pCon, GetCharArray(result), outCode); */ + SCPureSockWrite(cbInfo->pCon, GetCharArray(result), outCode); DeleteDynString(printedData); } else { formatNameValue(protocol, pPath, "!!datachange!!", result, HIPTEXT); diff --git a/tasdrive.c b/tasdrive.c index 505a781e..87c14a53 100644 --- a/tasdrive.c +++ b/tasdrive.c @@ -284,18 +284,14 @@ static int startTASMotor(pMotor mot, SConnection * pCon, char *name, mot->stopped = 0; if (ABS(val - target) > MOTPREC) { pDriv = GetDrivableInterface(mot); - /* SCStartBuffering(pCon); */ status = pDriv->SetValue(mot, pCon, (float) target); + if(status != OKOK){ + SCPrintf(pCon,eLog,"ERROR: failed to drive %s to %f", name, target); + } /* to force updates on targets */ InvokeNewTarget(pServ->pExecutor, name, target); - /*mes = SCEndBuffering(pCon); - if (status != OKOK) { - SCPrintf(pCon,eLogError, GetCharArray(mes)); - return status; - } - */ } writeMotPos(pCon, silent, name, val, target); return status; @@ -611,7 +607,8 @@ static int TASGetStatus(void *pData, SConnection * pCon) if (self->math->mustDrive == 1) { status = calculateAndDrive(self, pCon); if (status != OKOK) { - return HWFault; + TASHalt(pData); + return HWBusy; } else { return HWBusy; } diff --git a/test/DataNumber b/test/DataNumber index 00ce41bb..00597567 100644 --- a/test/DataNumber +++ b/test/DataNumber @@ -1,3 +1,3 @@ - 340 + 348 NEVER, EVER modify or delete this file You'll risk eternal damnation and a reincarnation as a cockroach! diff --git a/test/sicsstat.tcl b/test/sicsstat.tcl index 3c750926..5d8a7f5c 100644 --- a/test/sicsstat.tcl +++ b/test/sicsstat.tcl @@ -270,18 +270,18 @@ simidx anglim 0.5 simi preset 0 simi mode monitor - -nano targetposition -50 -nano sign 1 -nano softzero 0 -nano softlowerlim -10000 -nano softupperlim 10000 -nano fixed -1 -nano interruptmode 0 -nano precision 0.01 -nano accesscode 2 -nano failafter 3 -nano maxretry 3 -nano ignorefault 0 -nano movecount 10 +eva targetposition 5 +eva sign -1 +eva softzero -2 +eva softlowerlim -38 +eva softupperlim 38 +eva fixed -1 +eva interruptmode 0 +eva precision 0.01 +eva accesscode 2 +eva failafter 3 +eva maxretry 3 +eva ignorefault 0 +eva movecount 10 +eva staticoffset -3 diff --git a/test/testini.tcl b/test/testini.tcl index ee794e04..728b91df 100644 --- a/test/testini.tcl +++ b/test/testini.tcl @@ -807,7 +807,7 @@ jvlsct debug -1 jvl::make ja 2 jvlsct -10000 10000 120 } -set nanotec 1 +set nanotec 0 if {$nanotec == 1} { source ../sim/boa_sics/nanotec.tcl @@ -815,3 +815,20 @@ makesctcontroller nanosct std localhost:8080 \r 1 \r nanosct debug -1 nanotec::make nano 1 nanosct -100000 100000 120 } + +set agilent 0 + +if {$agilent == 1} { + source ../tcl/stddrive.tcl + source ../tmp/agilent.tcl + makesctcontroller agi std 129.129.195.78:5025 \n 2 \n \n + agilent::make agi +} + +set secmot 1 + +if {$secmot == 1} { + source ../sim/sicscommon/secsim.tcl + MakeSecSim eva -40 40 .3 +} +