- 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;
float fDelta;
long lTime;
float target;
assert(pCon);
assert(pInter);

View File

@ -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 <stdlib.h>
#include <assert.h>
#include <tcl.h>
#include <unistd.h>
#include <time.h>
#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;

View File

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

View File

@ -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[])

View File

@ -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);

View File

@ -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;
}

1
ofac.c
View File

@ -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);

View File

@ -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);
}
/*-----------------------------------------------------------------------*/

View File

@ -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);

View File

@ -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;
}

View File

@ -1,3 +1,3 @@
340
348
NEVER, EVER modify or delete this file
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 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

View File

@ -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
}