- 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

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