- Added a boa recount mode in hmcontrol. Soemtimes the CCD overruns

- Added a staticoffset to motorsec.c in order to allow the use of softzero
  for physics purposes.
- When a triple axis motor fails to start, the whole shit needs to be stopped.
  This has now been implemented into tasdrive.c
- There were crashes in adding NB reflections to a reflection list. This has
  been fixed.
This commit is contained in:
koennecke
2012-07-11 06:34:48 +00:00
parent c3509cc5ed
commit 3e5773a446
13 changed files with 180 additions and 101 deletions

View File

@ -153,6 +153,7 @@ int Start2Run(SConnection * pCon, SicsInterp * pInter, char *name,
int iRet; int iRet;
float fDelta; float fDelta;
long lTime; long lTime;
float target;
assert(pCon); assert(pCon);
assert(pInter); assert(pInter);

View File

@ -16,12 +16,19 @@
image is invalid. This is not what is wanted. image is invalid. This is not what is wanted.
Mark Koennecke, July 2011 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 <stdlib.h> #include <stdlib.h>
#include <assert.h> #include <assert.h>
#include <tcl.h> #include <tcl.h>
#include <unistd.h> #include <unistd.h>
#include <time.h>
#include "fortify.h" #include "fortify.h"
#include "hmcontrol.h" #include "hmcontrol.h"
#include "HistMem.h" #include "HistMem.h"
@ -119,47 +126,92 @@ static int HMCStatus(void *pData, SConnection * pCon)
assert(self); assert(self);
if(self->checkSlaves == 0) { if(self->checkSlaves == 0) {
status = self->slaves[0]->CheckCountStatus(self->slaveData[0], pCon); status = self->slaves[0]->CheckCountStatus(self->slaveData[0], pCon);
/* /*
Warning: this assumes that slaves 1 - MAXSLAVE are histogram memories. Warning: this assumes that slaves 1 - MAXSLAVE are histogram memories.
If this assumption does not hold, change this code to check if this If this assumption does not hold, change this code to check if this
is really a histogram memory. is really a histogram memory.
*/ */
for (i = 1; i < MAXSLAVE; i++) { for (i = 1; i < MAXSLAVE; i++) {
if (self->slaves[i] != NULL) { if (self->slaves[i] != NULL) {
HistDirty((pHistMem) self->slaveData[i]); HistDirty((pHistMem) self->slaveData[i]);
} }
} }
if (status == HWIdle || status == HWFault) { if (status == HWIdle || status == HWFault) {
/* /*
stop counting on slaves when finished or when an error stop counting on slaves when finished or when an error
occurred. occurred.
*/ */
if(self->stopSlaves){ if(self->stopSlaves){
HMCHalt(self); HMCHalt(self);
} }
ReleaseCountLock(self->pCount); ReleaseCountLock(self->pCount);
self->checkSlaves = 1; self->checkSlaves = 1;
status = HWBusy; status = HWBusy;
} }
} else { } else {
/* /*
* wait for the detectors to report finish too. Otherwise, with the second * wait for the detectors to report finish too. Otherwise, with the second
* generation HM data may not be fully transferred. * generation HM data may not be fully transferred.
*/ */
for(i = 1; i < self->nSlaves; i++){ for(i = 1; i < self->nSlaves; i++){
status = self->slaves[i]->CheckCountStatus(self->slaveData[i], pCon); status = self->slaves[i]->CheckCountStatus(self->slaveData[i], pCon);
if(status != HWIdle || status != HWFault){ if(status != HWIdle || status != HWFault){
return status; return status;
} }
} }
status = HWIdle; status = HWIdle;
InvokeCallBack(self->pCall, COUNTEND, pCon); InvokeCallBack(self->pCall, COUNTEND, pCon);
self->checkSlaves = 0; self->checkSlaves = 0;
} }
return status; 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) static int HMCPause(void *pData, SConnection * pCon)
{ {
@ -357,7 +409,7 @@ int HMControlAction(SConnection * pCon, SicsInterp * pSics,
/* /*
checks checks
*/ */
self = (pHMcontrol) pData; self = (pHMcontrol) pData;
assert(self); assert(self);
if (argc < 2) { if (argc < 2) {
@ -367,14 +419,14 @@ int HMControlAction(SConnection * pCon, SicsInterp * pSics,
} }
strtolower(argv[1]); strtolower(argv[1]);
if (strcmp(argv[1], "start") == 0) { if (strcmp(argv[1], "start") == 0) {
if (argc < 4) { if (argc < 4) {
snprintf(pBueffel, 131, "ERROR: Usage %s start preset mode", argv[0]); snprintf(pBueffel, 131, "ERROR: Usage %s start preset mode", argv[0]);
SCWrite(pCon, pBueffel, eError); SCWrite(pCon, pBueffel, eError);
return 0; return 0;
} }
/* /*
interpret count parameters interpret count parameters
*/ */
status = Tcl_GetDouble(pSics->pTcl, argv[2], &dPreset); status = Tcl_GetDouble(pSics->pTcl, argv[2], &dPreset);
if (status != TCL_OK) { if (status != TCL_OK) {
snprintf(pBueffel,sizeof(pBueffel)-1, "ERROR: failed to convert %s to number", argv[2]); 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); self->pCount->SetCountParameters(self, (float) dPreset, eMode);
status = StartDevice(pServ->pExecutor, "hmcontrol", self->pDes, status = StartDevice(pServ->pExecutor, "hmcontrol", self->pDes,
self, pCon, RUNRUN, 99); self, pCon, RUNRUN, 99);
@ -405,14 +457,18 @@ int HMControlAction(SConnection * pCon, SicsInterp * pSics,
InvokeCallBack(self->pCall, COUNTSTART, pCon); InvokeCallBack(self->pCall, COUNTSTART, pCon);
SCSendOK(pCon); SCSendOK(pCon);
}else if(strcmp(argv[1],"stopslaves") == 0){ }else if(strcmp(argv[1],"stopslaves") == 0){
if(argc < 3){ if(argc < 3){
SCPrintf(pCon,eValue,"hm.stopslaves = %d", self->stopSlaves); SCPrintf(pCon,eValue,"hm.stopslaves = %d", self->stopSlaves);
return 1; return 1;
} else { } else {
self->stopSlaves = atoi(argv[2]); self->stopSlaves = atoi(argv[2]);
SCPrintf(pCon,eValue,"hm.stopslaves = %d", self->stopSlaves); SCPrintf(pCon,eValue,"hm.stopslaves = %d", self->stopSlaves);
return 1; return 1;
} }
}else if(strcmp(argv[1],"boamode") == 0){
self->pCount->CheckCountStatus = HMCBoaStatus;
SCSendOK(pCon);
return 1;
} else { } else {
SCWrite(pCon, "ERROR: subcommand not recognized", eError); SCWrite(pCon, "ERROR: subcommand not recognized", eError);
return 0; return 0;

View File

@ -34,6 +34,7 @@ typedef struct {
pICallBack pCall; pICallBack pCall;
int checkSlaves; int checkSlaves;
int stopSlaves; int stopSlaves;
time_t counterStop;
} HMcontrol, *pHMcontrol; } HMcontrol, *pHMcontrol;

View File

@ -765,15 +765,6 @@ int ClientLog(SConnection * pCon, SicsInterp * pInter, void *pData,
free(pMessage); free(pMessage);
return 1; 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 GumPut(SConnection * pCon, SicsInterp * pInter, void *pData,
int argc, char *argv[]) int argc, char *argv[])

View File

@ -123,7 +123,7 @@ static long SecMotorRun(void *sulf, SConnection * pCon, float fNew)
static int SecMotorCheckBoundary(pMotor self, float fVal, float *fTarget, static int SecMotorCheckBoundary(pMotor self, float fVal, float *fTarget,
char *pError, int iErrLen) char *pError, int iErrLen)
{ {
double fZero, fixed, lowerlim, upperlim, sign; double fZero, fixed, lowerlim, upperlim, sign, offset;
float fHard, hupper, hlower; float fHard, hupper, hlower;
char pBueffel[512]; char pBueffel[512];
hdbValue v; hdbValue v;
@ -134,6 +134,8 @@ static int SecMotorCheckBoundary(pMotor self, float fVal, float *fTarget,
fixed = v.v.doubleValue; fixed = v.v.doubleValue;
assert(SICSHdbGetPar(self, NULL, "softzero", &v) == 1); assert(SICSHdbGetPar(self, NULL, "softzero", &v) == 1);
fZero = v.v.doubleValue; fZero = v.v.doubleValue;
assert(SICSHdbGetPar(self, NULL, "staticoffset", &v) == 1);
offset = v.v.doubleValue;
assert(SICSHdbGetPar(self, NULL, "softlowerlim", &v) == 1); assert(SICSHdbGetPar(self, NULL, "softlowerlim", &v) == 1);
lowerlim = v.v.doubleValue; lowerlim = v.v.doubleValue;
assert(SICSHdbGetPar(self, NULL, "softupperlim", &v) == 1); assert(SICSHdbGetPar(self, NULL, "softupperlim", &v) == 1);
@ -165,6 +167,7 @@ static int SecMotorCheckBoundary(pMotor self, float fVal, float *fTarget,
} }
/* correct for zero point */ /* correct for zero point */
fZero += offset;
fZero = -fZero; fZero = -fZero;
fHard = fVal - fZero; fHard = fVal - fZero;
@ -392,15 +395,16 @@ static void AddMotorPar(pHdb node, int priv, char *name)
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static float hardToSoftPosition(pMotor self, float hard) static float hardToSoftPosition(pMotor self, float hard)
{ {
float sign, zero, fVal; float sign, zero, fVal, offset;
SecMotorGetPar(self, "sign", &sign); SecMotorGetPar(self, "sign", &sign);
SecMotorGetPar(self, "softzero", &zero); SecMotorGetPar(self, "softzero", &zero);
SecMotorGetPar(self, "staticoffset", &offset);
fVal = hard; fVal = hard;
if (sign < 0) { if (sign < 0) {
fVal += zero; fVal += zero + offset;
} else { } else {
fVal -= zero; fVal -= zero + offset;
} }
fVal *= sign; fVal *= sign;
return fVal; return fVal;
@ -728,6 +732,11 @@ pMotor SecMotorInit(char *name)
SetHdbProperty(child, "__save", "true"); SetHdbProperty(child, "__save", "true");
AddHipadabaChild(node, child, NULL); 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); child = MakeHipadabaNode("status", HIPTEXT, 1);
SetHdbProperty(child, "motname", name); SetHdbProperty(child, "motname", name);
AddHipadabaChild(node, child, NULL); AddHipadabaChild(node, child, NULL);

View File

@ -1035,6 +1035,9 @@ static int testAndInvokeInterrupt(pCommandCBData self, int handle)
"ERROR: insufficient privilege to invoke Interrupt", eError); "ERROR: insufficient privilege to invoke Interrupt", eError);
} }
return 1; return 1;
} else if(strstr(pPtr,"Poch") != NULL){
SCPureSockWrite(self->pCon,"Poch\r\n", eLog);
return 1;
} }
return 0; return 0;
} }

1
ofac.c
View File

@ -69,7 +69,6 @@ static void InitIniCommands(SicsInterp * pInter)
PCMD("Capture", CaptureAction); PCMD("Capture", CaptureAction);
PCMD("ClientPut", ClientPut); PCMD("ClientPut", ClientPut);
PCMD("ClientLog", ClientLog); PCMD("ClientLog", ClientLog);
PCMD("Poch", Poch);
PCMD("config", ConfigCon); PCMD("config", ConfigCon);
PCMD("db", SICSDebug); PCMD("db", SICSDebug);
PCMD("Dir", ListObjects); PCMD("Dir", ListObjects);

View File

@ -240,9 +240,11 @@ static void AddRowIntern(pSICSOBJ refl, double hkl[], double ang[],
if(child != NULL){ if(child != NULL){
UpdateHipadabaPar(child, MakeHdbFloat(ang[3]),NULL); UpdateHipadabaPar(child, MakeHdbFloat(ang[3]),NULL);
} }
child = child->next;
if(child != NULL){ 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); runObjFunction(refl, pCon, node);
} }
@ -318,11 +320,13 @@ static int AddIndexesAnglesCmd(pSICSOBJ self, SConnection * pCon,
} else if(node!= NULL) { } else if(node!= NULL) {
UpdateHipadabaPar(node, v, pCon); UpdateHipadabaPar(node, v, pCon);
} }
node = node->next; if(node != NULL){
if(node != NULL && nPar > 7){ node = node->next;
if(node != NULL && nPar > 7){
UpdateHipadabaPar(node, par[7]->value, pCon); UpdateHipadabaPar(node, par[7]->value, pCon);
} else if(node!= NULL) { } else if(node!= NULL) {
UpdateHipadabaPar(node, v, pCon); UpdateHipadabaPar(node, v, pCon);
}
} }
return runObjFunction(self, pCon, addrowNode); return runObjFunction(self, pCon, addrowNode);

View File

@ -634,7 +634,8 @@ static hdbCallbackReturn SICSNotifyCallback(pHdb node, void *userData,
} }
formatNameValue(protocol, pPath, GetCharArray(printedData), result, formatNameValue(protocol, pPath, GetCharArray(printedData), result,
mm->v->dataType); mm->v->dataType);
SCWrite(cbInfo->pCon, GetCharArray(result), outCode); /* SCWrite(cbInfo->pCon, GetCharArray(result), outCode); */
SCPureSockWrite(cbInfo->pCon, GetCharArray(result), outCode);
DeleteDynString(printedData); DeleteDynString(printedData);
} else { } else {
formatNameValue(protocol, pPath, "!!datachange!!", result, HIPTEXT); formatNameValue(protocol, pPath, "!!datachange!!", result, HIPTEXT);

View File

@ -284,18 +284,14 @@ static int startTASMotor(pMotor mot, SConnection * pCon, char *name,
mot->stopped = 0; mot->stopped = 0;
if (ABS(val - target) > MOTPREC) { if (ABS(val - target) > MOTPREC) {
pDriv = GetDrivableInterface(mot); pDriv = GetDrivableInterface(mot);
/* SCStartBuffering(pCon); */
status = pDriv->SetValue(mot, pCon, (float) target); 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 to force updates on targets
*/ */
InvokeNewTarget(pServ->pExecutor, name, target); InvokeNewTarget(pServ->pExecutor, name, target);
/*mes = SCEndBuffering(pCon);
if (status != OKOK) {
SCPrintf(pCon,eLogError, GetCharArray(mes));
return status;
}
*/
} }
writeMotPos(pCon, silent, name, val, target); writeMotPos(pCon, silent, name, val, target);
return status; return status;
@ -611,7 +607,8 @@ static int TASGetStatus(void *pData, SConnection * pCon)
if (self->math->mustDrive == 1) { if (self->math->mustDrive == 1) {
status = calculateAndDrive(self, pCon); status = calculateAndDrive(self, pCon);
if (status != OKOK) { if (status != OKOK) {
return HWFault; TASHalt(pData);
return HWBusy;
} else { } else {
return HWBusy; return HWBusy;
} }

View File

@ -1,3 +1,3 @@
340 348
NEVER, EVER modify or delete this file NEVER, EVER modify or delete this file
You'll risk eternal damnation and a reincarnation as a cockroach! You'll risk eternal damnation and a reincarnation as a cockroach!

View File

@ -270,18 +270,18 @@ simidx anglim 0.5
simi preset 0 simi preset 0
simi mode monitor simi mode monitor
eva targetposition 5
nano targetposition -50 eva sign -1
nano sign 1 eva softzero -2
nano softzero 0 eva softlowerlim -38
nano softlowerlim -10000 eva softupperlim 38
nano softupperlim 10000 eva fixed -1
nano fixed -1 eva interruptmode 0
nano interruptmode 0 eva precision 0.01
nano precision 0.01 eva accesscode 2
nano accesscode 2 eva failafter 3
nano failafter 3 eva maxretry 3
nano maxretry 3 eva ignorefault 0
nano ignorefault 0 eva movecount 10
nano movecount 10 eva staticoffset -3

View File

@ -807,7 +807,7 @@ jvlsct debug -1
jvl::make ja 2 jvlsct -10000 10000 120 jvl::make ja 2 jvlsct -10000 10000 120
} }
set nanotec 1 set nanotec 0
if {$nanotec == 1} { if {$nanotec == 1} {
source ../sim/boa_sics/nanotec.tcl source ../sim/boa_sics/nanotec.tcl
@ -815,3 +815,20 @@ makesctcontroller nanosct std localhost:8080 \r 1 \r
nanosct debug -1 nanosct debug -1
nanotec::make nano 1 nanosct -100000 100000 120 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
}