- Fixed a couple of compiler found bugs generated by the new C compiler

- Added support to tasinit for status display part of tas-application
This commit is contained in:
cvs
2001-01-15 10:05:43 +00:00
parent d3b8f38ced
commit e64773949d
26 changed files with 155 additions and 55 deletions

View File

@ -1017,7 +1017,7 @@
/* only manager may use this */
if(!SCMatchRights(pCon,usMugger))
{
return;
return 0;
}
Arg2Text(argc-2,&argv[2],pError,79);
iRet = self->pDriv->Send(self->pDriv,pError,pBueffel,255);

View File

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

View File

@ -561,7 +561,7 @@
*/
if(self->iStop == 1)
{
return;
return 0;
}
else
{

View File

@ -173,6 +173,7 @@
int iRet, iCode, iFix;
char pBueffel[256], pError[132];
static int iCount;
static int callCount;
self = (pEVControl)pData;
assert(self);
@ -229,6 +230,15 @@
fDelta = - fDelta;
}
/* handle callback */
callCount++;
if(callCount >= 10)
{
sprintf(pBueffel,"%s = %f", self->pName, fPos);
InvokeCallBack(self->pCall, VALUECHANGE,pBueffel);
callCount = 0;
}
/* based on this: logic ! */
if(fDelta <= ObVal(self->pParam, TOLERANCE)) /* done */
{
@ -548,6 +558,14 @@
{
return 0;
}
/* deal with callbacks */
self->callCount++;
if(self->callCount >= 20)
{
sprintf(pBueffel,"%s = %F", self->pName, fPos);
InvokeCallBack(self->pCall,VALUECHANGE, pBueffel);
self->callCount = 0;
}
}
else if(iRet == -1) /* pending */
{
@ -644,6 +662,16 @@
pRes->pEnvir->IsInTolerance = EVIIsInTolerance;
pRes->pEnvir->HandleError = EVIErrHandler;
/* callback interface */
pRes->pCall = CreateCallBackInterface();
if(!pRes->pCall)
{
free(pRes->pDrivInt);
DeleteDescriptor(pRes->pDes);
free(pRes);
return NULL;
}
/* new parameter space */
pRes->pParam = ObParCreate(7);
if(!pRes->pParam)
@ -711,6 +739,10 @@
{
free(self->pEnvir);
}
if(self->pCall)
{
DeleteCallBackInterface(self->pCall);
}
if(self->KillPrivate)
{
self->KillPrivate(self->pPrivate);
@ -894,6 +926,20 @@
return 1;
}
/*-------------------------------------------------------------------------*/
static int EVCallBack(int iEvent, void *pEventData, void *pUserData)
{
char *pBuf = (char *)pEventData;
SConnection *pCon = (SConnection *)pUserData;
char pBueffel[132];
if(iEvent == VALUECHANGE)
{
SCWrite(pCon,pBuf,eValue);
return 1;
}
return 1;
}
/*---------------------------------------------------------------------------
The wrapper understands the following syntax:
EVControl : print current value
@ -913,6 +959,7 @@
double dVal;
float fPos;
int iRet;
long lID;
self = (pEVControl)pData;
assert(self);
@ -943,6 +990,21 @@
SCWrite(pCon,pReply,eValue);
return iRet;
}
/* install automatic notification */
else if(strcmp(argv[1],"interest") == 0)
{
lID = RegisterCallback(self->pCall, VALUECHANGE, EVCallBack,
pCon, NULL);
SCRegister(pCon,pSics, self->pCall,lID);
SCSendOK(pCon);
return 1;
}
else if(strcmp(argv[1],"uninterest") == 0)
{
RemoveCallback2(self->pCall,pCon);
SCSendOK(pCon);
return 1;
}
else if(strcmp(argv[1],"log") == 0) /* log commands */
{
if(argc < 3)

View File

@ -1,5 +1,5 @@
#line 208 "evcontroller.w"
#line 211 "evcontroller.w"
/*--------------------------------------------------------------------------
E N V I R O N M E N T C O N T R O L L E R
@ -14,7 +14,7 @@
#define SICSEVCONTROL
#include "varlog.h"
#line 130 "evcontroller.w"
#line 133 "evcontroller.w"
/*--------------------------- live & death --------------------------------*/
typedef struct __EVControl *pEVControl;
@ -44,6 +44,6 @@
#line 221 "evcontroller.w"
#line 224 "evcontroller.w"
#endif

View File

@ -1,5 +1,5 @@
#line 225 "evcontroller.w"
#line 228 "evcontroller.w"
/*-------------------------------------------------------------------------
Environment controller datastructure
@ -23,6 +23,8 @@
pObjectDescriptor pDes;
pIDrivable pDrivInt;
pEVInterface pEnvir;
pICallBack pCall;
int callCount;
pEVDriver pDriv;
EVMode eMode;
float fTarget;
@ -37,5 +39,5 @@
void (*KillPrivate)(void *pData);
} EVControl;
#line 241 "evcontroller.w"
#line 244 "evcontroller.w"

View File

@ -36,6 +36,8 @@ $\langle$evdata {\footnotesize ?}$\rangle\equiv$
\mbox{}\verb@ pObjectDescriptor pDes;@\\
\mbox{}\verb@ pIDrivable pDrivInt;@\\
\mbox{}\verb@ pEVInterface pEnvir;@\\
\mbox{}\verb@ pICallBack pCall;@\\
\mbox{}\verb@ int callCount;@\\
\mbox{}\verb@ pEVDriver pDriv;@\\
\mbox{}\verb@ EVMode eMode;@\\
\mbox{}\verb@ float fTarget;@\\
@ -63,7 +65,8 @@ the second field a pointer to an Drivable interface. Each environment
controller needs to implement that in order to allow SICS drive the device
to a new value. The third field is a pointer to an environment interface.
This is needed in order to enable monitoring of the device when it has
reached its target value. The fourth field is a pointer to the driver for
reached its target value. Then there is a pointer to a callback
interface. The fifth field is a pointer to the driver for
the actual hardware. Next is the mode the device is in. Of course there
must be floating point value which defines the current target value for the
device. pName is a pointer to a string representing the name of the

View File

@ -31,6 +31,8 @@ used by EVControl:
pObjectDescriptor pDes;
pIDrivable pDrivInt;
pEVInterface pEnvir;
pICallBack pCall;
int callCount;
pEVDriver pDriv;
EVMode eMode;
float fTarget;
@ -51,7 +53,8 @@ the second field a pointer to an Drivable interface. Each environment
controller needs to implement that in order to allow SICS drive the device
to a new value. The third field is a pointer to an environment interface.
This is needed in order to enable monitoring of the device when it has
reached its target value. The fourth field is a pointer to the driver for
reached its target value. Then there is a pointer to a callback
interface. The fifth field is a pointer to the driver for
the actual hardware. Next is the mode the device is in. Of course there
must be floating point value which defines the current target value for the
device. pName is a pointer to a string representing the name of the

View File

@ -1,5 +1,5 @@
#line 244 "evcontroller.w"
#line 247 "evcontroller.w"
/*-------------------------------------------------------------------------
Environment device driver datastructure
@ -12,7 +12,7 @@
#define DEVREDO 2
#line 73 "evcontroller.w"
#line 76 "evcontroller.w"
typedef struct __EVDriver {
int (*SetValue)(pEVDriver self, float fNew);
@ -28,19 +28,8 @@
void (*KillPrivate)(void *pData);
} EVDriver;
#line 255 "evcontroller.w"
#line 258 "evcontroller.w"
/*-------------------- life & death of a driver --------------------------*/
pEVDriver CreateEVDriver(int argc, char *argv[]);
void DeleteEVDriver(pEVDriver pDriv);

2
hkl.c
View File

@ -1393,7 +1393,7 @@ ente:
iRet = GetCurrentPosition(self,pCon,fSet);
if(iRet == 0)
{
return;
return 0;
}
angle2HKL(self,(double)fSet[0],(double)fSet[1],
(double)fSet[2],(double)fSet[3],fHKL);

View File

@ -63,7 +63,7 @@
self = (pLin2Ang)pData;
if(!self)
return;
return 0;
fprintf(fd,"%s.length %f\n",name, self->length);
return 1;

View File

@ -428,7 +428,7 @@ CreateSocketAdress(
return 0;
}
close(self->sockid);
iRet = close(self->sockid);
self->iType = 0;
self->sockid = 0;
if(iRet < 0)

View File

@ -153,7 +153,7 @@ extern VerifyChannel(mkChannel *self); /* defined in network.c */
assert(self);
if(self->lMagic != NRMAGIC)
{
return;
return 0;
}
/* find the entry to remove */
@ -190,7 +190,7 @@ extern VerifyChannel(mkChannel *self); /* defined in network.c */
if(pNew)
{
/* create connection object */
pRes = SCreateConnection(self->pMain->pSics,pNew,iRet);
pRes = SCreateConnection(self->pMain->pSics,pNew,3);
if(!pRes)
{
SICSLogWrite("Failure to allocate new Connection",eInternal);

View File

@ -72,7 +72,7 @@
iRet = NXDinitfromfile(AMORDICT,&hdict);
if(iRet != NX_OK)
{
sprintf(pBueffel,"ERROR: cannot open dictionary file %s");
sprintf(pBueffel,"ERROR: cannot open dictionary file %s",AMORDICT);
SCWrite(pCon,pBueffel,eError);
return 0;
}
@ -193,14 +193,14 @@
iRet = NXopen(file,NXACC_RDWR,&hfil);
if(iRet != NX_OK)
{
sprintf(pBueffel,"ERROR: cannot open file %s for writing");
sprintf(pBueffel,"ERROR: cannot open file %s for writing",file);
SCWrite(pCon,pBueffel,eError);
return 0;
}
iRet = NXDinitfromfile(AMORDICT,&hdict);
if(iRet != NX_OK)
{
sprintf(pBueffel,"ERROR: cannot open dictionary file %s");
sprintf(pBueffel,"ERROR: cannot open dictionary file %s",AMORDICT);
SCWrite(pCon,pBueffel,eError);
return 0;
}
@ -319,14 +319,14 @@
iRet = NXopen(file,NXACC_RDWR,&hfil);
if(iRet != NX_OK)
{
sprintf(pBueffel,"ERROR: cannot open file %s for writing");
sprintf(pBueffel,"ERROR: cannot open file %s for writing",file);
SCWrite(pCon,pBueffel,eError);
return 0;
}
iRet = NXDinitfromfile(AMORDICT,&hdict);
if(iRet != NX_OK)
{
sprintf(pBueffel,"ERROR: cannot open dictionary file %s");
sprintf(pBueffel,"ERROR: cannot open dictionary file %s",AMORDICT);
SCWrite(pCon,pBueffel,eError);
return 0;
}

View File

@ -529,7 +529,7 @@
self = (pC804Driv)pMot->pDriver;
assert(self);
sprintf(pCommand,"%1.1dTY\r",self->iMotor,iVal);
sprintf(pCommand,"%1.1dTY\r",self->iMotor);
iRet = SerialWriteRead(&self->pSerial,pCommand,pReply,79);
if(iRet != 1)
{

View File

@ -344,7 +344,7 @@
if(iRet != 1)
{
pPriv->iError = BADINPUT;
return;
return 0;
}
return CookerSetPar(self,parname,fValue);

1
scan.c
View File

@ -1,3 +1,4 @@
/*--------------------------------------------------------------------------
S C A N

View File

@ -1,3 +1,5 @@
scaninfo 9,en,2.800000,0.050000
scaninfo setAccess 0
sicsdatapath /data/koenneck/src/sics/tmp/
sicsdatapath setAccess 1
arx2 4.290000
@ -24,13 +26,13 @@ etam 0.000000
etam setAccess 2
wav 0.000000
wav setAccess 2
den 0.100000
den 0.050000
den setAccess 2
dql 0.010000
dql 0.000000
dql setAccess 2
dqk 0.000000
dqk setAccess 2
dqh 0.010000
dqh 0.000000
dqh setAccess 2
dkf 0.000000
dkf setAccess 2
@ -94,11 +96,11 @@ alf2 3.000000
alf2 setAccess 2
alf1 11.000000
alf1 setAccess 2
local Berty Chimney
local Mordahl Schlawadini
local setAccess 2
output a1,a2,a3,a4
output setAccess 2
lastcommand sc qh 0 0 2 3 dqh 0.01 0.0 0.01 .1
lastcommand sc qh 2 0 0 3 dqh 0 0 0 .05 ti 2 np 9
lastcommand setAccess 2
user Billy Looser
user setAccess 2
@ -144,21 +146,21 @@ da 3.354000
da setAccess 1
dm 3.354000
dm setAccess 1
en 3.400000
en 3.000000
en setAccess 2
ql 2.040000
ql 0.000000
ql setAccess 2
qk 0.000000
qk setAccess 2
qh 0.040000
qh 2.000000
qh setAccess 2
kf 1.964944
kf setAccess 2
ef 8.000000
ef setAccess 2
ki 2.345619
ki 2.304101
ki setAccess 2
ei 11.400000
ei 11.000000
ei setAccess 2
bz 1.000000
bz setAccess 2

View File

@ -650,7 +650,7 @@
pPtr16 = (SQint16 *)pData;
for(i = 0; i < iEnd; i++)
{
plData[i] = (HistInt)pPtr[i];
plData[i] = (HistInt)pPtr16[i];
}
break;
case 4:

4
tas.h
View File

@ -106,8 +106,9 @@
#define OUT 90
#define LOC 91
#define SWUNIT 92
#define SINFO 93
#define MAXPAR 93
#define MAXPAR 94
#define MAXADD 20
/* --------------------- data structure -------------------------------*/
@ -123,6 +124,7 @@ typedef struct {
int addCount;
int iFileNO;
int iFast;
char scanVar[80];
}TASdata, *pTASdata;

6
tas.w
View File

@ -45,6 +45,7 @@ typedef struct {
int addCount;
int iFileNO;
int iFast;
char scanVar[80];
}TASdata, *pTASdata;
@}
\begin{description}
@ -64,6 +65,8 @@ variables. This can be 0 for simple variables or 1 for a motor.
\item[iFileNO] is the number of the current data file.
\item[iFast] is a flag denoting a fast scan. In a fast scan there is
no wait for the motors to finish driving.
\item[scanVar] memorizes the first scan variable with a step of greater
zero.
\end{description}
The constants for the parameters are defined in the header file.
@ -189,8 +192,9 @@ These are mainly the interpreter interface functions:
#define OUT 90
#define LOC 91
#define SWUNIT 92
#define SINFO 93
#define MAXPAR 93
#define MAXPAR 94
#define MAXADD 20
/* --------------------- data structure -------------------------------*/

View File

@ -33,6 +33,7 @@ if { [info exists tasinit] == 0 } {
Publish log User
Publish sz User
Publish sw User
Publish scaninfo Spy
}
#--------------------------------------------------------------------------
@ -980,3 +981,4 @@ proc sw args {
clientput [prsw]
}
}

View File

@ -257,7 +257,7 @@ int TASDrive(SConnection *pCon, SicsInterp *pSics, void *pData,
{
SCSetInterrupt(pCon,eContinue);
SCSetError(pCon,OKOK);
sprintf(pBueffel,"Driving %aborted");
sprintf(pBueffel,"Driving aborted");
SCWrite(pCon,pBueffel,eStatus);
}
return 0;

View File

@ -149,6 +149,7 @@ extern char *tasVariableOrder[] = {
"output",
"local",
"swunit",
"scaninfo",
NULL};
/*---------------------------------------------------------------------
There is a special feauture in MAD where the count mode is determined

View File

@ -466,7 +466,7 @@ static int TASScanPoint(pScanData self, int iPoint)
*/
m1 = GetMonitor(self->pCounterData,1,self->pCon);
m2 = GetMonitor(self->pCounterData,2,self->pCon);
m1 = GetMonitor(self->pCounterData,3,self->pCon);
m3 = GetMonitor(self->pCounterData,3,self->pCon);
cnts = GetCounts(self->pCounterData,self->pCon);
fVal = GetCountTime(self->pCounterData, self->pCon);
sprintf(pWork,"%8d %8d %9.4f %8d %8d ",m1,m2,fVal, cnts, m3);
@ -576,7 +576,7 @@ static int TASScanDrive(pScanData self, int iPoint)
status = TASCalc(pTAS,self->pCon,tasMask,
tasTargets, tasTargetMask);
if(!status)
return;
return 0;
TASStart(pTAS,self->pCon,
self->pSics,tasTargets,tasTargetMask);
/*
@ -974,7 +974,7 @@ static int EnterScanVar(pTASdata pTAS, char *name, float fCenter,
{
int iPtr;
char pIncrement[30], pError[132];
float fIncrement, fStart;
float fIncrement, fStart, fTemp;
/*
get increment
@ -996,6 +996,18 @@ static int EnterScanVar(pTASdata pTAS, char *name, float fCenter,
*/
fStart = fCenter - (pTAS->pScan->iNP/2) * fIncrement;
/*
If step > 0 save it for scaninfo
*/
if(fIncrement < 0)
fTemp = -fIncrement;
else
fTemp = fIncrement;
if(fTemp > .001 && strlen(pTAS->scanVar) < 2)
{
sprintf(pTAS->scanVar,"%s,%f,%f",name,fStart,fIncrement);
}
/*
put it in
*/
@ -1272,6 +1284,7 @@ int TASScan(SConnection *pCon, SicsInterp *pSics, void *pData,
clear out old scan
*/
ClearScanVar(pTAS->pScan);
pTAS->scanVar[0] = '\0';
/*
at this stage all simple variables have been set. Now we get the values
@ -1292,6 +1305,22 @@ int TASScan(SConnection *pCon, SicsInterp *pSics, void *pData,
if(!status)
return status;
/*
check if there is something to scan
*/
if(pTAS->pScan->iScanVar < 1)
{
SCWrite(pCon,"ERROR: nothing to scan",eError);
return 0;
}
/*
now there is enough information to set the scaninfo variable which
is needed to help the status display.
*/
sprintf(pWork,"%d,%s",pTAS->pScan->iNP,pTAS->scanVar);
VarSetText(pTAS->tasPar[SINFO],pWork,0);
/*
parse the output variable in order to get additional stuff to write
*/

View File

@ -422,7 +422,7 @@ typedef enum {eStart, eRegel, eHalted} eVeloMode;
strcpy(pBueffel,pHelp);
sprintf(pHelp,"State: %s\n",sStatus.rm);
strcat(pBueffel,pHelp);
sprintf(pHelp,"Current: %f\n",sStatus.pwr);
sprintf(pHelp,"Current: %d\n",sStatus.pwr);
strcat(pBueffel,pHelp);
sprintf(pHelp,"Rotor T: %d, Housing T: %d\n",sStatus.rot_temp,
sStatus.cont_temp);