- Reworked mesure for four circle to new specifications

* reworked table
  * added psd mode
- exe now allows absolute paths
- added getRS232Timeout to rs232controller
- Fixed a couple of "guessed" return values
This commit is contained in:
koennecke
2005-03-16 07:58:52 +00:00
parent 5cd7d30d62
commit b8fea0bc38
16 changed files with 331 additions and 2633 deletions

View File

@ -407,9 +407,12 @@ extern pServer pServ;
free(pVictim->pSock);
}
for(i = 0; i < pVictim->iFiles; i++)
{
if(pVictim->pFiles[i] != NULL)
{
fclose(pVictim->pFiles[i]);
}
}
RemoveCommand(pServ->pSics,ConName(pVictim->ident));
@ -1664,12 +1667,7 @@ static void writeToLogFiles(SConnection *self, char *buffer)
}
return 1;
}
/*--------------------------------------------------------------------------
The only command currently understood is: put args
writes the args to the client
*/
/*--------------------------------------------------------------------------*/
int ConSicsAction(SConnection *pCon, SicsInterp *pSics, void *pData,
int argc, char *argv[])
{

View File

@ -336,6 +336,9 @@ static int DiffScanTask(void *pData){
check for interrupt
*/
if(SCGetInterrupt(self->scanObject->pCon) >= eAbortScan){
pCount->pDriv->Halt(pCount->pDriv);
pVar->pInter->Halt(pVar->pObject);
SicsWait(1);
finish = 0;
}

View File

@ -139,6 +139,18 @@ static pDynString locateBatchBuffer(pExeMan self, char *name){
return NULL;
}
/*
do not try to convert absolute paths
*/
if(name[0] == '/'){
DynStringCopy(result,name);
if(fileExists(GetCharArray(result))){
return result;
} else {
return NULL;
}
}
pPtr = self->batchPath;
while((pPtr = stptok(pPtr,pPath,131,":")) != NULL){
DynStringCopy(result,pPath);
@ -540,7 +552,8 @@ static int infoHandler(pExeMan self, SConnection *pCon,
return 1;
}
}
return 1; /* statement inserted, guessed return value M.Z. */
SCWrite(pCon,"Nothing to execute",eValue);
return 1;
} else {
strtolower(argv[2]);
if(strcmp(argv[2],"stack") == 0){
@ -554,7 +567,7 @@ static int infoHandler(pExeMan self, SConnection *pCon,
return 1;
} else {
SCWrite(pCon,"ERROR: subcommand to info unknown",eError);
return 0; /* statement inserted, guessed return value M.Z. */
return 0;
}
}
}

View File

@ -17,10 +17,10 @@
#include "fourtable.h"
/*====================== table entry ===================================*/
typedef struct {
double twoThetaStart;
double twoThetaEnd;
double step;
char scanVar[30];
double step;
int np;
}FourTableEntry, *pFourTableEntry;
/*==================== functions =======================================*/
int MakeFourCircleTable(){
@ -51,8 +51,8 @@ static void printList(int handle, SConnection *pCon){
status = LLDnodePtr2First(handle);
while(status == 1) {
LLDnodeDataTo(handle,&entry);
snprintf(pBueffel,131,"%8.3f %8.3f %s %8.3f\n", entry.twoThetaStart, entry.twoThetaEnd,
entry.scanVar,entry.step);
snprintf(pBueffel,131,"%8.3f %s %8.3f %d\n", entry.twoThetaEnd,
entry.scanVar,entry.step, entry.np);
Tcl_DStringAppend(&list,pBueffel,-1);
printed = 1;
status = LLDnodePtr2Next(handle);
@ -63,6 +63,58 @@ static void printList(int handle, SConnection *pCon){
SCWrite(pCon,Tcl_DStringValue(&list), eValue);
Tcl_DStringFree(&list);
}
/*---------------------------------------------------------------------
Make sure that the entry is added in a sorted way according to two_theta
----------------------------------------------------------------------*/
static void insertEntry(int list, FourTableEntry newEntry){
int status, count = 0, pos;
FourTableEntry test;
/*
locate the last entry bigger then us
*/
status = LLDnodePtr2First(list);
while(status == 1){
LLDnodeDataTo(list,&test);
count++;
if(test.twoThetaEnd == newEntry.twoThetaEnd){
LLDnodeDataFrom(list,&newEntry);
return;
}
if(test.twoThetaEnd > newEntry.twoThetaEnd){
break;
}
status = LLDnodePtr2Next(list);
}
/*
special case: empty list
*/
if(count == 0){
LLDnodeAppendFrom(list,&newEntry);
return;
}
/*
special case: append after last
*/
LLDnodePtr2Last(list);
LLDnodeDataTo(list,&test);
if(newEntry.twoThetaEnd > test.twoThetaEnd){
LLDnodeAppendFrom(list,&newEntry);
return;
}
status = LLDnodePtr2First(list);
pos = 0;
while(status == 1){
LLDnodeDataTo(list,&test);
pos++;
if(pos == count){
LLDnodeInsertFrom(list,&newEntry);
return;
}
status = LLDnodePtr2Next(list);
}
}
/*-----------------------------------------------------------------------*/
static int addToList(int handle, SConnection *pCon, int argc, char *argv[]){
FourTableEntry entry;
@ -74,29 +126,33 @@ static int addToList(int handle, SConnection *pCon, int argc, char *argv[]){
}
if(isNumeric(argv[3])){
entry.twoThetaStart = atof(argv[3]);
entry.twoThetaEnd = atof(argv[3]);
} else {
snprintf(pBueffel,131,"ERROR: expected numeric argument, received %s", argv[3]);
SCWrite(pCon,pBueffel,eError);
return 0;
}
if(isNumeric(argv[4])){
entry.twoThetaEnd = atof(argv[4]);
strncpy(entry.scanVar,argv[4],29);
strtolower(entry.scanVar);
if(strcmp(entry.scanVar,"om") != 0 && strcmp(entry.scanVar,"o2t") != 0){
SCWrite(pCon,"ERROR: Invalied scan variable specified, only om, o2t allowed",eError);
return 0;
}
if(isNumeric(argv[5])){
entry.step = atof(argv[5]);
} else {
snprintf(pBueffel,131,"ERROR: expected numeric argument, received %s", argv[4]);
SCWrite(pCon,pBueffel,eError);
return 0;
}
strncpy(entry.scanVar,argv[5],29);
if(isNumeric(argv[6])){
entry.step = atof(argv[6]);
entry.np = atoi(argv[6]);
} else {
snprintf(pBueffel,131,"ERROR: expected numeric argument, received %s", argv[6]);
SCWrite(pCon,pBueffel,eError);
return 0;
}
LLDnodePrependFrom(handle,&entry);
insertEntry(handle,entry);
return 1;
}
/*-----------------------------------------------------------------------*/
@ -141,6 +197,7 @@ int HandleFourCircleCommands(int handle, SConnection *pCon,
return 1;
}
clearTable(handle);
SCparChange(pCon);
SCSendOK(pCon);
} else if (strcmp(argv[2],"list") == 0){
printList(handle,pCon);
@ -152,6 +209,7 @@ int HandleFourCircleCommands(int handle, SConnection *pCon,
*err = addToList(handle,pCon,argc,argv);
if(*err != 0)
{
SCparChange(pCon);
SCSendOK(pCon);
}
} else if(strcmp(argv[2],"del") == 0){
@ -165,6 +223,7 @@ int HandleFourCircleCommands(int handle, SConnection *pCon,
} else {
if(isNumeric(argv[3])){
delEntry(handle, atoi(argv[3]));
SCparChange(pCon);
SCSendOK(pCon);
} else {
SCWrite(pCon,"ERROR: bad argument: expected numeric argument to table del",eError);
@ -181,15 +240,17 @@ int HandleFourCircleCommands(int handle, SConnection *pCon,
/*-----------------------------------------------------------------------*/
static FourTableEntry findEntry(int handle, double two_theta){
int status;
FourTableEntry entry;
FourTableEntry entry, prevEntry;
status = LLDnodePtr2First(handle);
LLDnodeDataTo(handle,&prevEntry);
while(status == 1) {
LLDnodeDataTo(handle,&entry);
if(two_theta > entry.twoThetaStart && two_theta <= entry.twoThetaEnd){
return entry;
if(entry.twoThetaEnd > two_theta){
return prevEntry;
}
status = LLDnodePtr2Next(handle);
prevEntry = entry;
}
strcpy(entry.scanVar,"NOT FOUND");
return entry;
@ -213,6 +274,17 @@ double GetFourCircleStep(int handle, double two_theta){
}
}
/*------------------------------------------------------------------------*/
int GetFourCircleScanNP(int handle, double two_theta){
FourTableEntry entry;
entry = findEntry(handle,two_theta);
if(strcmp(entry.scanVar,"NOT FOUND") == 0){
return -999;
} else {
return entry.np;
}
}
/*------------------------------------------------------------------------*/
int SaveFourCircleTable(int handle, char *objName, FILE *fd){
FourTableEntry entry;
int status;
@ -221,9 +293,9 @@ int SaveFourCircleTable(int handle, char *objName, FILE *fd){
status = LLDnodePtr2Last(handle);
while(status != 0) {
LLDnodeDataTo(handle,&entry);
fprintf(fd,"%s table add %f %f %s %f\n",objName,
entry.twoThetaStart, entry.twoThetaEnd,entry.scanVar,
entry.step);
fprintf(fd,"%s table add %f %s %f %d\n",objName,
entry.twoThetaEnd,entry.scanVar,
entry.step,entry.np);
status = LLDnodePtr2Prev(handle);
}
return 1;

View File

@ -16,6 +16,7 @@
int HandleFourCircleCommands(int handle, SConnection *pCon,
int argc, char *argv[], int *err);
char *GetFourCircleScanVar(int handle, double two_theta);
int GetFourCircleScanNP(int handle, double two_theta);
double GetFourCircleStep(int handle, double two_theta);
int SaveFourCircleTable(int handle, char *objName, FILE *fd);

199
mesure.c
View File

@ -74,6 +74,7 @@
remeasured */
int fastScan; /* flag for using fastscans for scanning reflections */
int psiMode; /* 1 for psi scan mode, 0 else */
int psd; /* a flag for making 2D detector scans */
int stepTable; /* mapping of two theta ranges to step width and
variable to scan */
} Mesure;
@ -96,6 +97,7 @@ static int SaveMesure(void *pData, char *name, FILE *fd)
fprintf(fd,"%s step %f\n", name, self->fStep);
fprintf(fd,"%s weakthreshold %ld\n", name, self->weakThreshold);
fprintf(fd,"%s compact %d\n", name, self->iCompact);
fprintf(fd,"%s psd %d\n", name, self->psd);
fprintf(fd,"%s weak %d\n", name, self->weak);
fprintf(fd,"%s fastscan %d\n", name, self->fastScan);
SaveFourCircleTable(self->stepTable,name,fd);
@ -127,6 +129,8 @@ static void ListMesure(pMesure self, char *name, SConnection *pCon)
Tcl_DStringAppend(&list,pBuffer,-1);
snprintf(pBuffer,131,"%s.compact %d\n", name, self->iCompact);
Tcl_DStringAppend(&list,pBuffer,-1);
snprintf(pBuffer,131,"%s.psd %d\n", name, self->psd);
Tcl_DStringAppend(&list,pBuffer,-1);
snprintf(pBuffer,131,"%s.weak %d\n", name, self->weak);
Tcl_DStringAppend(&list,pBuffer,-1);
snprintf(pBuffer,131,"%s.fastscan %d\n", name, self->fastScan);
@ -177,6 +181,7 @@ static void ListMesure(pMesure self, char *name, SConnection *pCon)
pNew->fStep = 0.05;
pNew->fPreset = 2;
pNew->iCompact = 1;
pNew->psd = 0;
pNew->weak = 0;
pNew->weakThreshold = 99999;
pNew->fastScan = 0;
@ -395,6 +400,16 @@ static void ListMesure(pMesure self, char *name, SConnection *pCon)
return 1;
}
/*------------------------------------------------------------------------*/
static int getMesureNP(pMesure self, double twoTheta)
{
int np;
np = GetFourCircleScanNP(self->stepTable,twoTheta);
if(np < -800){
np = self->np;
}
return np;
}
/*-------------------------------------------------------------------------
This is slightly tricky: the crystallography module has a scan tolerance.
This is supposed to be automatically set. In order to do so, I need
@ -406,7 +421,7 @@ static void ListMesure(pMesure self, char *name, SConnection *pCon)
static int MesureCalculateSettings(pMesure self, float fHKL[3], float fSet[4],
float fPsi, SConnection *pCon)
{
int status;
int status, np;
float step, tolerance;
SetHKLScanTolerance(self->pCryst,.0);
@ -419,7 +434,8 @@ static int MesureCalculateSettings(pMesure self, float fHKL[3], float fSet[4],
if(step < -900.){
step = self->fStep;
}
tolerance = (step * (float)self->np)/2. + .2;
np = getMesureNP(self,(double)fSet[0]);
tolerance = (step * (float)np)/2. + .2;
SetHKLScanTolerance(self->pCryst,tolerance);
return CalculateSettings(self->pCryst,fHKL,fPsi,0,fSet,pCon);
}
@ -481,19 +497,21 @@ static int DriveToReflection(pMesure self, float fSet[4], SConnection *pCon)
/*-----------------------------------------------------------------------
test if this scan has to be remeasured because it is weak
------------------------------------------------------------------------*/
int weakScan(pMesure self)
int weakScan(pMesure self, double twoTheta)
{
int i;
int i, np;
long low = 99999, high = -99999;
/*
ths scan is always OK if we do not test for weak conditions
the scan is always OK if we do not test for weak conditions or we are in psd mode
*/
if(self->weak == 0){
if(self->weak == 0 || self->psd == 1){
return 0;
}
GetScanCounts(self->pScanner,self->lCounts,self->np);
for(i = 0; i < self->np; i++)
np = getMesureNP(self,twoTheta);
GetScanCounts(self->pScanner,self->lCounts,np);
for(i = 0; i < np; i++)
{
if(self->lCounts[i] < low)
{
@ -517,11 +535,43 @@ int weakScan(pMesure self)
return 1;
}
}
/*-----------------------------------------------------------------------*/
static int PerformPSDScan(pMesure self, char *scanVar, float fStart, float step, int np)
{
int status;
char pCommand[1024];
char countMode[20];
Tcl_Interp *pTcl;
/*
PSD scans are done by calling the routine Tcl procedure tricsscan with the
appropriate parameters. tricsscan does only omega scans!
*/
if(self->CountMode == eTimer)
{
strcpy(countMode,"timer");
}
else
{
strcpy(countMode,"monitor");
}
snprintf(pCommand,1023,"tricsscan %f %f %d %s %f", fStart, step, np,countMode,self->fPreset);
pTcl = InterpGetTcl(pServ->pSics);
status = Tcl_Eval(pTcl,pCommand);
if(status != TCL_OK)
{
return 0;
}
else
{
return 1;
}
}
/*------------------------------------------------------------------------*/
static int ScanReflection(pMesure self, float twoTheta, SConnection *pCon)
{
float fStart, stepWidth;
int iRet;
int iRet, np;
char pBueffel[132];
char *scanVar = NULL;
@ -540,21 +590,54 @@ static int ScanReflection(pMesure self, float twoTheta, SConnection *pCon)
} else {
stepWidth = GetFourCircleStep(self->stepTable,(double)twoTheta);
}
np = getMesureNP(self,(double)twoTheta);
if(stepWidth != self->fStep)
{
snprintf(pBueffel,130,"Using stepwidth %f",stepWidth);
snprintf(pBueffel,130,"Using stepwidth %f, %d points",stepWidth,np);
SCWrite(pCon,pBueffel,eWarning);
}
fStart -= (self->np/2)*stepWidth;
fStart -= (np/2)*stepWidth;
/* set the scan up */
/*
spcial case: psd mode
*/
if(self->psd == 1)
{
iRet = PerformPSDScan(self,scanVar,fStart, stepWidth, np);
free(scanVar);
return iRet;
}
/*
below is the code for a single counter scan.
TODO: (maybe) make this clearer and separte this into another subroutine
Set the scan up
*/
ClearScanVar(self->pScanner);
AddScanVar(self->pScanner, pServ->pSics,pCon,scanVar,
fStart, stepWidth);
free(scanVar);
/*
as np can change, we have to reallocate enough space
*/
if(self->lCounts != NULL){
free(self->lCounts);
self->lCounts = (long *)malloc(np*sizeof(long));
if(self->lCounts == NULL){
SCWrite(pCon,"ERROR: out of memory for scan scan data",eError);
SCSetInterrupt(pCon,eAbortScan);
return 0;
}
memset(self->lCounts,0,np*sizeof(long));
}
/* do the scan */
snprintf(pBueffel,131,"Scanning %s, step %f, np = %d",scanVar, stepWidth, np);
SCWrite(pCon,pBueffel,eWarning);
free(scanVar);
if(self->iCompact)
{
self->pScanner->CollectScanData = CompactScanData;
@ -563,9 +646,9 @@ static int ScanReflection(pMesure self, float twoTheta, SConnection *pCon)
{
self->pScanner->ScanDrive = ScanFastDrive;
}
iRet = SilentScan(self->pScanner,self->np,self->CountMode,
iRet = SilentScan(self->pScanner,np,self->CountMode,
self->fPreset,pServ->pSics,pCon);
if(weakScan(self))
if(weakScan(self,twoTheta))
{
/*
look for interrupts before restarting scan
@ -585,7 +668,7 @@ static int ScanReflection(pMesure self, float twoTheta, SConnection *pCon)
redo scan with preset * 5
*/
SCWrite(pCon,"Remeasuring weak reflection",eWarning);
iRet = SilentScan(self->pScanner,self->np,self->CountMode,
iRet = SilentScan(self->pScanner,np,self->CountMode,
self->fPreset*5.,pServ->pSics,pCon);
}
@ -651,10 +734,20 @@ static int ScanReflection(pMesure self, float twoTheta, SConnection *pCon)
strcat(pFilename,"log");
self->iLogFile = SCAddLogFile(pCon,pFilename);
self->pCon = pCon;
sprintf(pBueffel,"Writing to %s.log, .ccl, .rfl",pRoot);
/*
we do not need reflection files when doing a PSD scan
*/
if(self->psd == 1)
{
sprintf(pBueffel,"Logging to %s.log", pRoot);
SCWrite(pCon,pBueffel,eValue);
return 1;
}
/* open the reflection file */
sprintf(pBueffel,"Writing to %s.log, .ccl, .rfl",pRoot);
SCWrite(pCon,pBueffel,eValue);
strcpy(pFilename,pRoot);
strcat(pFilename,"ccl");
self->fRefl = fopen(pFilename,"w");
@ -666,10 +759,6 @@ static int ScanReflection(pMesure self, float twoTheta, SConnection *pCon)
SCSetInterrupt(pCon,eAbortBatch);
return 0;
}
/* put filename
fputs(pFilename,self->fRefl);
fputs("\n",self->fRefl);
*/
/* open hkl-data file */
strcpy(pFilename,pRoot);
@ -688,15 +777,10 @@ static int ScanReflection(pMesure self, float twoTheta, SConnection *pCon)
/* write some header data */
SNXFormatTime(pBueffel,1024);
/* fprintf(self->fRefl,"filetime = %s\n",pBueffel); */
fprintf(self->fHKL,"filetime = %s\n",pBueffel);
GetLambda(self->pCryst,&fVal);
/* fprintf(self->fRefl,"lambda = %f Angstroem\n",fVal); */
fprintf(self->fHKL,"lambda = %f Angstroem\n",fVal);
GetUB(self->pCryst,fUB);
/* fprintf(self->fRefl,
"UB = %7.6f %7.6f %7.6f %7.6f %7.6f %7.6f %7.6f %7.6f %7.6f\n",
fUB[0], fUB[1],fUB[2],fUB[3],fUB[4],fUB[5],fUB[6],fUB[7],fUB[8]); */
fprintf(self->fHKL,
"UB = %7.6f %7.6f %7.6f %7.6f %7.6f %7.6f %7.6f %7.6f %7.6f\n",
fUB[0], fUB[1],fUB[2],fUB[3],fUB[4],fUB[5],fUB[6],fUB[7],fUB[8]);
@ -738,6 +822,22 @@ static int ScanReflection(pMesure self, float twoTheta, SConnection *pCon)
MesureClose(self);
}
/* log file */
strcpy(pFile,self->pFileRoot);
strcat(pFile,"/");
strcat(pFile,fileroot);
strcat(pFile,".log");
self->iLogFile = SCAddLogFile(pCon,pFile);
self->pCon = pCon;
/*
No reopening of reflection files in psd mode
*/
if(self->psd == 1)
{
return 1;
}
/* check if this is possible */
strcpy(pFile,self->pFileRoot);
strcat(pFile,"/");
@ -764,13 +864,6 @@ static int ScanReflection(pMesure self, float twoTheta, SConnection *pCon)
strcat(pFile,".rfl");
self->fHKL = fopen(pFile,"a");
/* log file */
strcpy(pFile,self->pFileRoot);
strcat(pFile,"/");
strcat(pFile,fileroot);
strcat(pFile,".log");
self->iLogFile = SCAddLogFile(pCon,pFile);
self->pCon = pCon;
return 1;
}
@ -779,6 +872,16 @@ static int ScanReflection(pMesure self, float twoTheta, SConnection *pCon)
{
assert(self);
SCDelLogFile(self->pCon,self->iLogFile);
if(self->psd == 1)
{
self->pCon = NULL;
self->iLogFile = -1;
if(self->pCurrentFile)
free(self->pCurrentFile);
return 1;
}
if(self->fRefl)
{
fclose(self->fRefl);
@ -789,7 +892,6 @@ static int ScanReflection(pMesure self, float twoTheta, SConnection *pCon)
fclose(self->fHKL);
self->fHKL = NULL;
}
SCDelLogFile(self->pCon,self->iLogFile);
self->pCon = NULL;
self->iLogFile = -1;
if(self->pCurrentFile)
@ -819,6 +921,14 @@ static int ScanReflection(pMesure self, float twoTheta, SConnection *pCon)
}
#endif
/*
no writing in PSD mode
*/
if(self->psd == 1)
{
return 1;
}
/* get necessary data */
fSum = 0.;
fSigma = 0.;
@ -850,7 +960,8 @@ static int ScanReflection(pMesure self, float twoTheta, SConnection *pCon)
}
SCWrite(pCon,pBueffel,eWarning);
}
GetScanCounts(self->pScanner,self->lCounts,self->np);
iNP = GetScanNP(self->pScanner);
GetScanCounts(self->pScanner,self->lCounts,iNP);
/* write it */
if(self->fRefl)
@ -891,7 +1002,6 @@ static int ScanReflection(pMesure self, float twoTheta, SConnection *pCon)
/* collect data */
SNXFormatTime(pBueffel,512);
GetScanVarStep(self->pScanner,0,&fStep);
iNP = GetScanNP(self->pScanner);
fPreset = GetScanPreset(self->pScanner);
fprintf(self->fRefl,"%3d %7.3f %9.0f %7.3f %s\n",iNP,fStep,
fPreset,fTemp,pBueffel);
@ -1226,6 +1336,18 @@ static int ScanReflection(pMesure self, float twoTheta, SConnection *pCon)
}
return 1;
}
else if(strcmp(name,"psd") == 0)
{
if(fVal >= 1.)
{
self->psd = 1;
}
else
{
self->psd = 0;
}
return 1;
}
else if(strcmp(name,"weak") == 0)
{
if(fVal >= 1.)
@ -1307,6 +1429,11 @@ static int ScanReflection(pMesure self, float twoTheta, SConnection *pCon)
*fVal = self->iCompact;
return 1;
}
else if(strcmp(name,"psd") == 0)
{
*fVal = self->psd;
return 1;
}
else if(strcmp(name,"fastscan") == 0)
{
*fVal = (float)self->fastScan;

61
motor.c
View File

@ -62,20 +62,18 @@
#define INTBATCH 2.
#define INTHALT 3.
#define HLOW 0
#define HUPP 1
#define SLOW 2
#define SUPP 3
#define SZERO 4
#define FIX 5
#define INT 6
#define PREC 7
#define USRIGHTS 8
#define SIGN 9
#define ECOUNT 10
#define POSCOUNT 11
#define IGNOREFAULT 12
#define MOVECOUNT 13
#define SLOW 0
#define SUPP 1
#define SZERO 2
#define FIX 3
#define INT 4
#define PREC 5
#define USRIGHTS 6
#define SIGN 7
#define ECOUNT 8
#define POSCOUNT 9
#define IGNOREFAULT 10
#define MOVECOUNT 11
/*------------------------------------------------------------------------
a tiny structure used in CallBack work
@ -327,6 +325,10 @@ static int evaluateStatus(pMotor self, SConnection *pCon)
{
newStatus = HWPosFault;
}
if(newStatus == HWIdle || newStatus == OKOK)
{
finishDriving(self,pCon);
}
break;
case HWBusy:
newStatus = HWBusy;
@ -398,14 +400,12 @@ static void handleMoveCallback(pMotor self, SConnection *pCon)
/* create and initialize parameters */
pM->ParArray = ObParCreate(14);
pM->ParArray = ObParCreate(12);
if(!pM->ParArray)
{
free(pM);
return NULL;
}
ObParInit(pM->ParArray,HLOW,"hardlowerlim",pDriv->fLower,usMugger);
ObParInit(pM->ParArray,HUPP,"hardupperlim",pDriv->fUpper,usMugger);
ObParInit(pM->ParArray,SLOW,"softlowerlim",pDriv->fLower,usUser);
ObParInit(pM->ParArray,SUPP,"softupperlim",pDriv->fUpper,usUser);
ObParInit(pM->ParArray,SZERO,"softzero",ZEROINACTIVE,usUser);
@ -522,6 +522,17 @@ extern void KillPiPiezo(void *pData);
ObPar *pPar = NULL;
assert(self);
if(strcmp(name,"hardupperlim") == 0)
{
*fVal = self->pDriver->fUpper;
return 1;
}
if(strcmp(name,"hardlowerlim") == 0)
{
*fVal = self->pDriver->fLower;
return 1;
}
pPar = ObParFind(self->ParArray,name);
if(pPar)
{
@ -674,17 +685,17 @@ extern void KillPiPiezo(void *pData);
fHard = fHard*ObVal(self->ParArray,SIGN);
/* check for hardware limits */
if(fHard > ObVal(self->ParArray,HUPP))
if(fHard > self->pDriver->fUpper)
{
sprintf(pBueffel,"%f violates upper hardware limit %f on %s",
fVal,ObVal(self->ParArray,HUPP),self->name);
fVal,self->pDriver->fUpper,self->name);
strncpy(pError,pBueffel,iErrLen);
return 0;
}
if(fHard < ObVal(self->ParArray,HLOW))
if(fHard < self->pDriver->fLower)
{
sprintf(pBueffel,"%f violates lower hardware limit %f on %s",
fVal,ObVal(self->ParArray,HLOW),self->name);
fVal,self->pDriver->fLower,self->name);
strncpy(pError,pBueffel,iErrLen);
return 0;
}
@ -980,8 +991,6 @@ extern MotorDriver *MakePiPiezo(Tcl_Interp *pTcl, char *pArray);
SCWrite(pCon,pBueffel,eError);
return 0;
}
pNew->ParArray[HLOW].iCode = usUser;
pNew->ParArray[HUPP].iCode = usUser;
}
else
{
@ -1018,6 +1027,12 @@ extern MotorDriver *MakePiPiezo(Tcl_Interp *pTcl, char *pArray);
iLen = ObParLength(self->ParArray);
sprintf(pBueffel,"Parameter Listing for motor %s\n",self->name);
SCWrite(pCon,pBueffel,eStatus);
snprintf(pBueffel,511,"%s.hardupperlim = %f",self->name,
self->pDriver->fUpper);
SCWrite(pCon,pBueffel,eValue);
snprintf(pBueffel,511,"%s.hardlowerlim = %f",self->name,
self->pDriver->fLower);
SCWrite(pCon,pBueffel,eValue);
for(i = 0; i < iLen; i++)
{
sprintf(pBueffel,"%s.%s = %f\n",self->name,

4
mumo.c
View File

@ -452,7 +452,7 @@ static int SaveMumo(void *pData, char *name, FILE *fd)
SCWrite(pCon,"ERROR: Incomplete command",eError);
return 0;
}
return 1; /* inserted return statement, guessed return value M.Z.*/
return 1;
}
/*--------------------------------------------------------------------------
@ -619,7 +619,7 @@ static int SaveMumo(void *pData, char *name, FILE *fd)
return 0;
}
}
return 1; /* inserted return statement, guessed return value M.Z */
return 1;
}
/*-------------------------------------------------------------------------*/
static int CheckPermission(SConnection *pCon, pMulMot self)

View File

@ -596,6 +596,7 @@
char *pText;
int iCode;
} TokDat;
#define TERMSDS 100
#define TERMVG 200
#define TERMLINK 300
@ -719,7 +720,7 @@
sStat->pToken[i] = '\0';
/*--------- try to find word in Tokenlist */
for(i = 0; i < 10; i++)
for(i = 0; i < 11; i++)
{
if(strcmp(sStat->pToken,TokenList[i].pText) == 0)
{

View File

@ -48,6 +48,7 @@
NXstatus NXDgetalias(NXhandle file, NXdict dict,
char *alias, void *pData);
NXstatus NXDgetdef(NXhandle file, NXdict dict, char *pDefString, void *pData);
NXstatus NXDdefget(NXdict handle, char *pKey, char *pBuffer, int iBufLen);
NXstatus NXDaliaslink(NXhandle file, NXdict dict,
char *pAlias1, char *pAlias2);

2537
nxdict.w

File diff suppressed because it is too large Load Diff

View File

@ -664,7 +664,7 @@ static void putArray(SConnection *pCon, SicsInterp *pSics,
get array length
*/
status = Tcl_GetInt(tcl,argv[4],&length);
if(status == TCL_OK){
if(status != TCL_OK){
sprintf(buffer,"ERROR: failed to convert %s to integer",argv[4]);
SCWrite(pCon,buffer,eError);
return;
@ -690,7 +690,7 @@ static void putArray(SConnection *pCon, SicsInterp *pSics,
varData = (char *)Tcl_GetVar2(tcl,argv[3],num,0);
if(varData != NULL){
status = Tcl_GetDouble(tcl,varData,&dVal);
if(status == TCL_OK){
if(status != TCL_OK){
sprintf(buffer,"ERROR: failed to convert %s to double",
varData);
SCWrite(pCon,buffer,eError);

2
o2t.c
View File

@ -144,7 +144,7 @@
iRet = pDrivInt->SetValue(self->pTheta,pCon, fVal);
return iRet;
}
return 0; /* inserted statement, guessed return value M.Z. */
return 0;
}
/*-------------------------------------------------------------------------*/
static int O2TCheckStatus(void *pData, SConnection *pCon)

View File

@ -403,6 +403,10 @@ void getRS232Error(int iCode, char *errorBuffer,
}
}
/*--------------------------------------------------------------------*/
int getRS232Timeout(prs232 self){
return self->timeout;
}
/*--------------------------------------------------------------------*/
int initRS232(prs232 self)
{
int iRet;

View File

@ -63,7 +63,7 @@
void getRS232Error(int iCode, char *errorBuffer,
int errorBufferLen);
int getRS232Timeout(prs232 self);
int initRS232(prs232 self);
void closeRS232(prs232 self);
prs232 createRS232(char *host, int iPort);

View File

@ -67,7 +67,7 @@ The following interface functions are provided:
void getRS232Error(int iCode, char *errorBuffer,
int errorBufferLen);
int getRS232Timeout(prs232 self);
int initRS232(prs232 self);
void closeRS232(prs232 self);
prs232 createRS232(char *host, int iPort);