- Added Sycamore protocol and command context to SICS
- Added sinfo to SICS - Added driver for TCP/IP Astrium velocity selector - Added driver for TCP/IP Astrium chopper controller
This commit is contained in:
26
amor2t.c
26
amor2t.c
@ -674,7 +674,7 @@
|
||||
pAmor2T pNew, pAOM = NULL;
|
||||
int i, iRet;
|
||||
char pBueffel[512];
|
||||
char *pMot = NULL;
|
||||
const char *pMot = NULL;
|
||||
|
||||
if(argc < 4)
|
||||
{
|
||||
@ -710,7 +710,7 @@
|
||||
A2TKill(pNew);
|
||||
return 0;
|
||||
}
|
||||
pNew->aEngine[MOTMOM] = FindMotor(pSics,pMot);
|
||||
pNew->aEngine[MOTMOM] = FindMotor(pSics,(char *)pMot);
|
||||
if(!pNew->aEngine[MOTMOM])
|
||||
{
|
||||
sprintf(pBueffel,"ERROR: motor %s NOT found!", pMot);
|
||||
@ -726,7 +726,7 @@
|
||||
A2TKill(pNew);
|
||||
return 0;
|
||||
}
|
||||
pNew->aEngine[MOTSOM] = FindMotor(pSics,pMot);
|
||||
pNew->aEngine[MOTSOM] = FindMotor(pSics,(char *)pMot);
|
||||
if(!pNew->aEngine[MOTSOM])
|
||||
{
|
||||
sprintf(pBueffel,"ERROR: motor %s NOT found!", pMot);
|
||||
@ -742,7 +742,7 @@
|
||||
A2TKill(pNew);
|
||||
return 0;
|
||||
}
|
||||
pNew->aEngine[MOTCOZ] = FindMotor(pSics,pMot);
|
||||
pNew->aEngine[MOTCOZ] = FindMotor(pSics,(char *)pMot);
|
||||
if(!pNew->aEngine[MOTCOZ])
|
||||
{
|
||||
sprintf(pBueffel,"ERROR: motor %s NOT found!", pMot);
|
||||
@ -758,7 +758,7 @@
|
||||
A2TKill(pNew);
|
||||
return 0;
|
||||
}
|
||||
pNew->aEngine[MOTCOX] = FindMotor(pSics,pMot);
|
||||
pNew->aEngine[MOTCOX] = FindMotor(pSics,(char *)pMot);
|
||||
if(!pNew->aEngine[MOTCOX])
|
||||
{
|
||||
sprintf(pBueffel,"ERROR: motor %s NOT found!", pMot);
|
||||
@ -774,7 +774,7 @@
|
||||
A2TKill(pNew);
|
||||
return 0;
|
||||
}
|
||||
pNew->aEngine[MOTSTZ] = FindMotor(pSics,pMot);
|
||||
pNew->aEngine[MOTSTZ] = FindMotor(pSics,(char *)pMot);
|
||||
if(!pNew->aEngine[MOTSTZ])
|
||||
{
|
||||
sprintf(pBueffel,"ERROR: motor %s NOT found!", pMot);
|
||||
@ -790,7 +790,7 @@
|
||||
A2TKill(pNew);
|
||||
return 0;
|
||||
}
|
||||
pNew->aEngine[MOTSOZ] = FindMotor(pSics,pMot);
|
||||
pNew->aEngine[MOTSOZ] = FindMotor(pSics,(char *)pMot);
|
||||
if(!pNew->aEngine[MOTSOZ])
|
||||
{
|
||||
sprintf(pBueffel,"ERROR: motor %s NOT found!", pMot);
|
||||
@ -806,7 +806,7 @@
|
||||
A2TKill(pNew);
|
||||
return 0;
|
||||
}
|
||||
pNew->aEngine[MOTD4B] = FindMotor(pSics,pMot);
|
||||
pNew->aEngine[MOTD4B] = FindMotor(pSics,(char *)pMot);
|
||||
if(!pNew->aEngine[MOTD4B])
|
||||
{
|
||||
sprintf(pBueffel,"ERROR: motor %s NOT found!", pMot);
|
||||
@ -822,7 +822,7 @@
|
||||
A2TKill(pNew);
|
||||
return 0;
|
||||
}
|
||||
pNew->aEngine[MOTD5B] = FindMotor(pSics,pMot);
|
||||
pNew->aEngine[MOTD5B] = FindMotor(pSics,(char *)pMot);
|
||||
if(!pNew->aEngine[MOTD5B])
|
||||
{
|
||||
sprintf(pBueffel,"ERROR: motor %s NOT found!", pMot);
|
||||
@ -838,7 +838,7 @@
|
||||
A2TKill(pNew);
|
||||
return 0;
|
||||
}
|
||||
pNew->aEngine[MOTCOM] = FindMotor(pSics,pMot);
|
||||
pNew->aEngine[MOTCOM] = FindMotor(pSics,(char *)pMot);
|
||||
if(!pNew->aEngine[MOTCOM])
|
||||
{
|
||||
sprintf(pBueffel,"ERROR: motor %s NOT found!", pMot);
|
||||
@ -854,7 +854,7 @@
|
||||
A2TKill(pNew);
|
||||
return 0;
|
||||
}
|
||||
pNew->aEngine[MOTAOZ] = FindMotor(pSics,pMot);
|
||||
pNew->aEngine[MOTAOZ] = FindMotor(pSics,(char *)pMot);
|
||||
if(!pNew->aEngine[MOTAOZ])
|
||||
{
|
||||
sprintf(pBueffel,"ERROR: motor %s NOT found!", pMot);
|
||||
@ -870,7 +870,7 @@
|
||||
A2TKill(pNew);
|
||||
return 0;
|
||||
}
|
||||
pNew->aEngine[MOTAOM] = FindMotor(pSics,pMot);
|
||||
pNew->aEngine[MOTAOM] = FindMotor(pSics,(char *)pMot);
|
||||
if(!pNew->aEngine[MOTAOM])
|
||||
{
|
||||
sprintf(pBueffel,"ERROR: motor %s NOT found!", pMot);
|
||||
@ -886,7 +886,7 @@
|
||||
A2TKill(pNew);
|
||||
return 0;
|
||||
}
|
||||
pNew->aEngine[MOTC3Z] = FindMotor(pSics,pMot);
|
||||
pNew->aEngine[MOTC3Z] = FindMotor(pSics,(char *)pMot);
|
||||
if(!pNew->aEngine[MOTC3Z])
|
||||
{
|
||||
sprintf(pBueffel,"ERROR: motor %s NOT found!", pMot);
|
||||
|
40
amorstat.c
40
amorstat.c
@ -50,7 +50,8 @@
|
||||
static int iTOF = 0;
|
||||
static pHistMem pHMHM = NULL;
|
||||
/*-------------------------------------------------------------------------*/
|
||||
static int HMCountStartCallback(int iEvent, void *pEvent, void *pUser)
|
||||
static int HMCountStartCallback(int iEvent, void *pEvent, void *pUser,
|
||||
commandContext cc)
|
||||
{
|
||||
SConnection *pCon = (SConnection *)pUser;
|
||||
const float *fTime = NULL;
|
||||
@ -75,15 +76,18 @@
|
||||
iTime[i+1] = htonl((int)((fTime[i]/10.)*65536.));
|
||||
}
|
||||
/* send new time binning to all clients */
|
||||
SCPushContext2(pCon,cc);
|
||||
SCWrite(pCon,"TOFClear",eError);
|
||||
SCWriteUUencoded(pCon,"arrowaxis_time",iTime,
|
||||
(iLength+1)*sizeof(int));
|
||||
SCPopContext(pCon);
|
||||
free(iTime);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
/*-------------------------------------------------------------------------*/
|
||||
static int ScanStartCallback(int iEvent, void *pEvent, void *pUser)
|
||||
static int ScanStartCallback(int iEvent, void *pEvent, void *pUser,
|
||||
commandContext cc)
|
||||
{
|
||||
float *fAxis = NULL;
|
||||
int *iAxis = NULL;
|
||||
@ -116,16 +120,19 @@
|
||||
iAxis[i+1] = htonl((int)(fAxis[i]*65536.));
|
||||
}
|
||||
/* send new axis to client */
|
||||
SCPushContext2(pCon,cc);
|
||||
SCWrite(pCon,"SCANClear",eError);
|
||||
SCWriteUUencoded(pCon,pBueffel,iAxis,
|
||||
(iLength+1)*sizeof(int));
|
||||
SCPopContext(pCon);
|
||||
free(iAxis);
|
||||
free(fAxis);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
/*------------------------------------------------------------------------*/
|
||||
static int ScanPointCallback(int iEvent, void *pEvent, void *pUser)
|
||||
static int ScanPointCallback(int iEvent, void *pEvent, void *pUser,
|
||||
commandContext cc)
|
||||
{
|
||||
long *lData = NULL;
|
||||
int *iData = NULL;
|
||||
@ -155,6 +162,7 @@
|
||||
iData[i+1] = htonl((int)(lData[i]));
|
||||
}
|
||||
/* send counts to client */
|
||||
SCPushContext2(pCon,cc);
|
||||
SCWriteUUencoded(pCon,"arrow_spinupup",iData,
|
||||
(iLength+1)*sizeof(int));
|
||||
/* send counts for other detector */
|
||||
@ -166,6 +174,7 @@
|
||||
SCWriteUUencoded(pCon,"arrow_spinuplo",iData,
|
||||
(iLength+1)*sizeof(int));
|
||||
/* to do: check for polarization and send spinlo */
|
||||
SCPopContext(pCon);
|
||||
free(iData);
|
||||
free(lData);
|
||||
}
|
||||
@ -201,7 +210,8 @@
|
||||
return 0;
|
||||
}
|
||||
/*------------------------------------------------------------------------*/
|
||||
static int LoadCallback(int iEvent, void *pEvent, void *pUser)
|
||||
static int LoadCallback(int iEvent, void *pEvent, void *pUser,
|
||||
commandContext cc)
|
||||
{
|
||||
pAmorStat pAS = NULL;
|
||||
SConnection *pCon = NULL;
|
||||
@ -212,7 +222,9 @@
|
||||
pCon = (SConnection *)pUser;
|
||||
assert(pAS);
|
||||
assert(pCon);
|
||||
SCPushContext2(pCon,cc);
|
||||
SendLoadedData(pAS,pCon);
|
||||
SCPopContext(pCon);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
@ -378,6 +390,7 @@
|
||||
long lID;
|
||||
pDummy pDum = NULL;
|
||||
pICallBack pCall = NULL;
|
||||
commandContext comCon;
|
||||
|
||||
assert(self);
|
||||
assert(pCon);
|
||||
@ -386,8 +399,9 @@
|
||||
iTOF invoke the apropriate callbacks in order to force
|
||||
an initial update.
|
||||
*/
|
||||
comCon = SCGetContext(pCon);
|
||||
/* file load callback */
|
||||
lID = RegisterCallback(self->pCall, FILELOADED, LoadCallback,
|
||||
lID = RegisterCallback(self->pCall, comCon,FILELOADED, LoadCallback,
|
||||
pCon, NULL);
|
||||
SCRegister(pCon,pServ->pSics, self->pCall,lID);
|
||||
SendLoadedData(self,pCon);
|
||||
@ -397,31 +411,31 @@
|
||||
pCall = pDum->pDescriptor->GetInterface(pDum,CALLBACKINTERFACE);
|
||||
if(pCall)
|
||||
{
|
||||
lID = RegisterCallback(pCall,SCANSTART,ScanStartCallback,
|
||||
lID = RegisterCallback(pCall,comCon,SCANSTART,ScanStartCallback,
|
||||
pCon, NULL);
|
||||
SCRegister(pCon,pServ->pSics,pCall,lID);
|
||||
lID = RegisterCallback(pCall,SCANPOINT,ScanPointCallback,
|
||||
lID = RegisterCallback(pCall,comCon,SCANPOINT,ScanPointCallback,
|
||||
pCon, NULL);
|
||||
SCRegister(pCon,pServ->pSics,pCall,lID);
|
||||
lID = RegisterCallback(pCall,SCANEND,ScanPointCallback,
|
||||
lID = RegisterCallback(pCall,comCon,SCANEND,ScanPointCallback,
|
||||
pCon, NULL);
|
||||
SCRegister(pCon,pServ->pSics,pCall,lID);
|
||||
if(iTOF == 0)
|
||||
{
|
||||
ScanStartCallback(SCANSTART,pDum,pCon);
|
||||
ScanPointCallback(SCANPOINT,pDum,pCon);
|
||||
ScanStartCallback(SCANSTART,pDum,pCon,SCGetContext(pCon));
|
||||
ScanPointCallback(SCANPOINT,pDum,pCon,SCGetContext(pCon));
|
||||
}
|
||||
}
|
||||
pDum = (pDummy)self->pHM;
|
||||
pCall = pDum->pDescriptor->GetInterface(pDum,CALLBACKINTERFACE);
|
||||
if(pCall)
|
||||
{
|
||||
lID = RegisterCallback(pCall,COUNTSTART,HMCountStartCallback,
|
||||
lID = RegisterCallback(pCall,comCon,COUNTSTART,HMCountStartCallback,
|
||||
pCon, NULL);
|
||||
SCRegister(pCon,pServ->pSics,pCall,lID);
|
||||
if(iTOF == 1)
|
||||
{
|
||||
HMCountStartCallback(COUNTSTART,pDum,pCon);
|
||||
HMCountStartCallback(COUNTSTART,pDum,pCon,SCGetContext(pCon));
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
@ -1001,7 +1015,7 @@
|
||||
}
|
||||
else if(strcmp(argv[1],"tofmode") == 0)
|
||||
{
|
||||
HMCountStartCallback(COUNTSTART,NULL,pCon);
|
||||
HMCountStartCallback(COUNTSTART,NULL,pCon,SCGetContext(pCon));
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
|
@ -595,7 +595,7 @@ static int DornierStatNew(pVelSelDriv self, int *iCode, float *fCur){
|
||||
{
|
||||
pVelSelDriv pNew = NULL;
|
||||
pDornier pDorn = NULL;
|
||||
char *pPtr = NULL;
|
||||
const char *pPtr = NULL;
|
||||
int iVal, iRet, iPort;
|
||||
char pHost[132];
|
||||
|
||||
|
4
ecb.c
4
ecb.c
@ -24,7 +24,7 @@
|
||||
#define READ_BYTES 3
|
||||
#define WRITE_BYTES 4
|
||||
#define DMAREAD 5
|
||||
#define ECB_BYTES 65536L
|
||||
#define ECB_BYTES 65535
|
||||
|
||||
typedef union /* Used to swap bytes in 'address' and 'byte_count' */
|
||||
{
|
||||
@ -112,7 +112,7 @@ static int ecbPrepareIO(pECB self, int func, unsigned short address,
|
||||
Swap save, adr, count;
|
||||
int status, bytes;
|
||||
|
||||
if(byteCount > ECB_BYTES){
|
||||
if(byteCount >= ECB_BYTES){
|
||||
self->lastError = ECBOVERFLOW;
|
||||
return 0;
|
||||
}
|
||||
|
45
el734hp.c
45
el734hp.c
@ -392,6 +392,27 @@ static void EL734Error(void *pData, int *iCode, char *error, int errLen){
|
||||
}
|
||||
}
|
||||
/*----------------------------------------------------------------------*/
|
||||
static int EL734Halt(void *pData){
|
||||
pEL734Driv self = NULL;
|
||||
int status;
|
||||
char pCommand[50],pReply[80];
|
||||
|
||||
self = (pEL734Driv)pData;
|
||||
assert(self);
|
||||
|
||||
snprintf(pCommand,79,"s %d\r",self->iMotor);
|
||||
status = transactEL734(self->controller,pCommand,strlen(pCommand),
|
||||
pReply,79);
|
||||
if(status != 1){
|
||||
self->errorCode = status;
|
||||
return 0;
|
||||
}
|
||||
if(!checkResponse(self,pReply)){
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
/*----------------------------------------------------------------------*/
|
||||
static int EL734Fix(void *pData, int iCode, float fValue){
|
||||
pEL734Driv self = NULL;
|
||||
int status, msr, i, len = 49;
|
||||
@ -404,7 +425,10 @@ static int EL734Fix(void *pData, int iCode, float fValue){
|
||||
case BADADR:
|
||||
case BADCMD:
|
||||
case BADPAR:
|
||||
return MOTREDO;
|
||||
case BADBSY:
|
||||
EL734Halt(pData);
|
||||
SicsWait(1);
|
||||
return MOTREDO;
|
||||
case TIMEOUT:
|
||||
for(i = 0; i < 3; i++){
|
||||
@ -466,27 +490,6 @@ static int EL734Fix(void *pData, int iCode, float fValue){
|
||||
}
|
||||
return MOTFAIL;
|
||||
}
|
||||
/*----------------------------------------------------------------------*/
|
||||
static int EL734Halt(void *pData){
|
||||
pEL734Driv self = NULL;
|
||||
int status;
|
||||
char pCommand[50],pReply[80];
|
||||
|
||||
self = (pEL734Driv)pData;
|
||||
assert(self);
|
||||
|
||||
snprintf(pCommand,79,"s %d\r",self->iMotor);
|
||||
status = transactEL734(self->controller,pCommand,strlen(pCommand),
|
||||
pReply,79);
|
||||
if(status != 1){
|
||||
self->errorCode = status;
|
||||
return 0;
|
||||
}
|
||||
if(!checkResponse(self,pReply)){
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
/*--------------------------------------------------------------------*/
|
||||
static int EL734GetPar(void *pData, char *name,
|
||||
float *fValue){
|
||||
|
13
fowrite.c
13
fowrite.c
@ -67,7 +67,8 @@
|
||||
|
||||
|
||||
/*------------------ The Countstart Callback Function ----------------------*/
|
||||
static int Countstartcallback(int iEvent, void *pEventData, void *pUser)
|
||||
static int Countstartcallback(int iEvent, void *pEventData, void *pUser,
|
||||
commandContext cc)
|
||||
{
|
||||
pFoWrite self = NULL;
|
||||
|
||||
@ -85,7 +86,8 @@
|
||||
return 1;
|
||||
}
|
||||
/*------------------ The Countend Callback Function ----------------------*/
|
||||
static int Countendcallback(int iEvent, void *pEventData, void *pUser)
|
||||
static int Countendcallback(int iEvent, void *pEventData, void *pUser,
|
||||
commandContext cc)
|
||||
{
|
||||
pFoWrite self = NULL;
|
||||
|
||||
@ -941,6 +943,7 @@
|
||||
pICallBack pCall = NULL;
|
||||
pDummy pDum;
|
||||
pHMcontrol pHMC = NULL;
|
||||
commandContext comCon;
|
||||
|
||||
/* check arguments */
|
||||
if(argc < 4 )
|
||||
@ -1026,8 +1029,10 @@
|
||||
pNew->pCount = (pCounter)pCom->pData;
|
||||
}
|
||||
|
||||
RegisterCallback(pHMC->pCall,COUNTSTART,Countstartcallback,pNew,NULL);
|
||||
RegisterCallback(pHMC->pCall,COUNTEND,Countendcallback,pNew,NULL);
|
||||
comCon.transID = 0;
|
||||
strncpy(comCon.deviceID,"internal",SCDEVIDLEN);
|
||||
RegisterCallback(pHMC->pCall,comCon,COUNTSTART,Countstartcallback,pNew,NULL);
|
||||
RegisterCallback(pHMC->pCall,comCon,COUNTEND,Countendcallback,pNew,NULL);
|
||||
|
||||
/* install command */
|
||||
AddCommand(pSics,"StoreFocus",FoAction,KillFoWrite,pNew);
|
||||
|
6
make_gen
6
make_gen
@ -16,10 +16,10 @@ OBJ=psi.o buffer.o ruli.o dmc.o nxsans.o nextrics.o sps.o pimotor.o \
|
||||
el755driv.o amorscan.o serial.o scontroller.o t_update.o \
|
||||
t_rlp.o t_conv.o el737hpdriv.o dornier2.o el734hp.o \
|
||||
el737hpv2driv.o swmotor2.o tricssupport.o amorcomp.o \
|
||||
$(MZOBJ) amordrive.o amorset.o \
|
||||
dgrambroadcast.o sinq.o tabledrive.o
|
||||
$(MZOBJ) amordrive.o amorset.o tcpdornier.o\
|
||||
dgrambroadcast.o sinq.o tabledrive.o tcpdocho.o
|
||||
|
||||
MZOBJ=fsm.o logger.o sugar.o pardef.o ease.o strobj.o oxinst.o logreader.o \
|
||||
MZOBJ=fsm.o logger.o sugar.o pardef.o ease.o strobj.o oxinst.o \
|
||||
ipsdriv.o ilmdriv.o itcdriv.o ighdriv.o euro2kdriv.o modbus.o
|
||||
|
||||
libpsi.a: $(OBJ)
|
||||
|
@ -1339,7 +1339,7 @@ name of hkl object holding crystallographic information
|
||||
return iRet;
|
||||
}
|
||||
/*-------------------------------------------------------------------------*/
|
||||
static int FrameInterest(int iEvent, void *pEvent, void *pUser)
|
||||
static int FrameInterest(int iEvent, void *pEvent, void *pUser, commandContext cc)
|
||||
{
|
||||
SConnection *pCon = NULL;
|
||||
int *iFrame;
|
||||
@ -1354,7 +1354,9 @@ name of hkl object holding crystallographic information
|
||||
iFrame = (int *)pEvent;
|
||||
assert(pCon);
|
||||
sprintf(pBueffel,"framenumber = %d",*iFrame);
|
||||
SCPushContext2(pCon,cc);
|
||||
SCWrite(pCon,pBueffel,eWarning);
|
||||
SCPopContext(pCon);
|
||||
return 1;
|
||||
}
|
||||
/*-------------------------------------------------------------------------
|
||||
@ -1454,6 +1456,7 @@ name of hkl object holding crystallographic information
|
||||
char pBueffel[1024];
|
||||
int iRet, iDet, iFrame;
|
||||
long lID;
|
||||
commandContext comCon;
|
||||
|
||||
self = (pNexTrics)pData;
|
||||
assert(self);
|
||||
@ -1470,6 +1473,7 @@ name of hkl object holding crystallographic information
|
||||
/* install an error handler */
|
||||
NXMSetError((void *)pCon,SNError);
|
||||
|
||||
comCon = SCGetContext(pCon);
|
||||
strtolower(argv[1]);
|
||||
if(strcmp(argv[1],"start") == 0)
|
||||
{
|
||||
@ -1505,7 +1509,7 @@ name of hkl object holding crystallographic information
|
||||
}
|
||||
else if(strcmp(argv[1],"interest") == 0)
|
||||
{
|
||||
lID = RegisterCallback(self->pCall, NEWFRAME, FrameInterest,
|
||||
lID = RegisterCallback(self->pCall, comCon, NEWFRAME, FrameInterest,
|
||||
pCon, NULL);
|
||||
SCRegister(pCon,pSics, self->pCall,lID);
|
||||
SCSendOK(pCon);
|
||||
|
7
pardef.c
7
pardef.c
@ -239,12 +239,15 @@ int ParLog(void *object) {
|
||||
return next;
|
||||
}
|
||||
/*-------------------------------------------------------------------------*/
|
||||
static int ParCallBack(int event, void *eventData, void *userData) {
|
||||
static int ParCallBack(int event, void *eventData, void *userData,
|
||||
commandContext cc) {
|
||||
char *pBuf = (char *)eventData;
|
||||
SConnection *con = (SConnection *)userData;
|
||||
|
||||
if (event == VALUECHANGE) {
|
||||
SCPushContext2(con,cc);
|
||||
SCWrite(con,pBuf,eValue);
|
||||
SCPopContext(con);
|
||||
return 1;
|
||||
}
|
||||
return 1;
|
||||
@ -356,7 +359,7 @@ static int ParExecute(SConnection *con, SicsInterp *sics, void *object, int argc
|
||||
o->pCall = CreateCallBackInterface();
|
||||
}
|
||||
assert(o->pCall);
|
||||
id = RegisterCallback(o->pCall, VALUECHANGE, ParCallBack, con, NULL);
|
||||
id = RegisterCallback(o->pCall, SCGetContext(con),VALUECHANGE, ParCallBack, con, NULL);
|
||||
SCRegister(con, pServ->pSics, o->pCall, id);
|
||||
SCSendOK(con);
|
||||
return 1;
|
||||
|
@ -297,7 +297,7 @@
|
||||
pC804Driv pNew = NULL;
|
||||
int iRet, iVal, iTmo;
|
||||
double dVal;
|
||||
char *pPar = NULL;
|
||||
const char *pPar = NULL;
|
||||
char pCommand[20], pReply[40];
|
||||
|
||||
/* allocate space: the final frontier */
|
||||
|
@ -284,7 +284,7 @@
|
||||
pPiPiezo pNew = NULL;
|
||||
int iRet, iVal, iTmo;
|
||||
double dVal;
|
||||
char *pPar = NULL;
|
||||
const char *pPar = NULL;
|
||||
char pCommand[20], pReply[40];
|
||||
|
||||
/* allocate space: the final frontier */
|
||||
|
@ -53,7 +53,8 @@ typedef struct {
|
||||
static void PoldiUpdate(pPolterdi self, SConnection *pCon);
|
||||
|
||||
/*------------------ The Countstart Callback Function ----------------------*/
|
||||
static int Countstartcallback(int iEvent, void *pEventData, void *pUser)
|
||||
static int Countstartcallback(int iEvent, void *pEventData, void *pUser,
|
||||
commandContext cc)
|
||||
{
|
||||
pPolterdi self = NULL;
|
||||
|
||||
@ -71,7 +72,8 @@ typedef struct {
|
||||
return 1;
|
||||
}
|
||||
/*------------------ The Countend Callback Function ----------------------*/
|
||||
static int Countendcallback(int iEvent, void *pEventData, void *pUser)
|
||||
static int Countendcallback(int iEvent, void *pEventData, void *pUser,
|
||||
commandContext cc)
|
||||
{
|
||||
pPolterdi self = NULL;
|
||||
|
||||
@ -665,6 +667,7 @@ int PolterInstall(SConnection *pCon, SicsInterp *pSics,
|
||||
pICallBack pCall = NULL;
|
||||
pDummy pDum;
|
||||
pHistMem pHist = NULL;
|
||||
commandContext comCon;
|
||||
|
||||
/* configure fortify */
|
||||
/*
|
||||
@ -711,8 +714,10 @@ int PolterInstall(SConnection *pCon, SicsInterp *pSics,
|
||||
KillPolterdi(pNew);
|
||||
return 0;
|
||||
}
|
||||
RegisterCallback(pCall,COUNTSTART,Countstartcallback,pNew,NULL);
|
||||
RegisterCallback(pCall,COUNTEND,Countendcallback,pNew,NULL);
|
||||
comCon.transID = 0;
|
||||
strncpy(comCon.deviceID,"internal",SCDEVIDLEN);
|
||||
RegisterCallback(pCall,comCon,COUNTSTART,Countstartcallback,pNew,NULL);
|
||||
RegisterCallback(pCall,comCon,COUNTEND,Countendcallback,pNew,NULL);
|
||||
|
||||
AddCommand(pSics,"storedata",PolterAction,KillPolterdi,pNew);
|
||||
return 1;
|
||||
|
18
psi.c
18
psi.c
@ -55,6 +55,12 @@
|
||||
#include "tabledrive.h"
|
||||
#include "amorset.h"
|
||||
|
||||
/*
|
||||
from tcpdornier.c
|
||||
*/
|
||||
extern int VelSelTcpFactory(SConnection *pCon, SicsInterp *pSics, void *pData,
|
||||
int argc, char *argv[]);
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
void SiteInit(void) {
|
||||
|
||||
@ -62,7 +68,6 @@ void SiteInit(void) {
|
||||
|
||||
/* insert here initialization routines ... */
|
||||
|
||||
INIT(LogReaderInit);
|
||||
INIT(IlmStartup);
|
||||
INIT(IpsStartup);
|
||||
INIT(ItcStartup);
|
||||
@ -102,6 +107,7 @@ static void AddPsiCommands(SicsInterp *pInter){
|
||||
AddCommand(pInter,"MakeSinq",SinqFactory,NULL,NULL);
|
||||
AddCommand(pInter,"MakeTableDrive",TableDriveFactory,NULL,NULL);
|
||||
AddCommand(pInter,"MakeAmorSet",AmorSetFactory,NULL,NULL);
|
||||
AddCommand(pInter,"MakeTCPSelector",VelSelTcpFactory,NULL,NULL);
|
||||
/*
|
||||
AddCommand(pInter,"MakeDifrac",MakeDifrac,NULL,NULL);
|
||||
*/
|
||||
@ -121,6 +127,7 @@ static void RemovePsiCommands(SicsInterp *pSics){
|
||||
RemoveCommand(pSics,"MakeAmor2T");
|
||||
RemoveCommand(pSics,"MakeStoreAmor");
|
||||
RemoveCommand(pSics,"MakeAmorStatus");
|
||||
RemoveCommand(pSics,"MakeTCPSelector");
|
||||
/*
|
||||
RemoveCommand(pSics,"MakeDifrac");
|
||||
*/
|
||||
@ -273,6 +280,8 @@ static pVelSelDriv CreatePsiVelSelDriv(char *name, char *array,
|
||||
extern pCodri MakeDoChoDriver(char *pHost, int iPort, int iChannel,
|
||||
int iSingle);
|
||||
extern pCodri MakeCookerDriver(char *pHost, int iPort, int iChannel);
|
||||
extern pCodri MakeTcpDoChoDriver(char *tclArray, SConnection *pCon);
|
||||
|
||||
/*-------------------------------------------------------------------*/
|
||||
static pCodri CreatePsiController(SConnection *pCon,int argc, char *argv[]){
|
||||
pCodri pNew = NULL;
|
||||
@ -312,6 +321,13 @@ static pCodri CreatePsiController(SConnection *pCon,int argc, char *argv[]){
|
||||
}
|
||||
}
|
||||
pNew = MakeDoChoDriver(argv[1],iPort,iChannel,iSingle);
|
||||
} else if(strcmp(argv[0],"tcpdocho") == 0){
|
||||
if(argc < 2){
|
||||
SCWrite(pCon,"ERROR: insufficient number of argumets for creating TcpDoCho",
|
||||
eError);
|
||||
return NULL;
|
||||
}
|
||||
return MakeTcpDoChoDriver(argv[1], pCon);
|
||||
}else if(strcmp(argv[0],"sanscook") == 0) {
|
||||
if(argc < 4){
|
||||
SCWrite(pCon,
|
||||
|
@ -43,7 +43,7 @@ EXTERN void SerialMurder(ClientData pData)
|
||||
}
|
||||
/*------------------ a forward declaration -----------------------------*/
|
||||
EXTERN int SurielSend(ClientData clientData, Tcl_Interp *interp,
|
||||
int argc, char *argv[]);
|
||||
int argc, const char *argv[]);
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
Controller is the main entry point for this stuff. It connects to a motor
|
||||
@ -143,7 +143,7 @@ int Controller(ClientData clientData, Tcl_Interp *interp,
|
||||
|
||||
----------------------------------------------------------------------------*/
|
||||
EXTERN int SurielSend(ClientData clientData, Tcl_Interp *interp,
|
||||
int argc, char *argv[])
|
||||
int argc, const char *argv[])
|
||||
{
|
||||
char pBueffel[256];
|
||||
char pAnswer[256];
|
||||
@ -183,7 +183,7 @@ EXTERN int SurielSend(ClientData clientData, Tcl_Interp *interp,
|
||||
Tcl_AppendResult(interp, "Expected parameter after -tmo",NULL);
|
||||
return TCL_ERROR;
|
||||
}
|
||||
iRet = SerialSendTerm(&(pData),argv[2]);
|
||||
iRet = SerialSendTerm(&(pData),(char *)argv[2]);
|
||||
if(iRet != 1)
|
||||
{
|
||||
Tcl_AppendResult(interp,"To many characters for terminator",NULL);
|
||||
@ -198,7 +198,7 @@ EXTERN int SurielSend(ClientData clientData, Tcl_Interp *interp,
|
||||
Tcl_AppendResult(interp, "Expected parameter after -tmo",NULL);
|
||||
return TCL_ERROR;
|
||||
}
|
||||
iRet = SerialATerm(&(pData),argv[2]);
|
||||
iRet = SerialATerm(&(pData),(char *)argv[2]);
|
||||
if(!iRet)
|
||||
{
|
||||
Tcl_AppendResult(interp,"To many characters for terminator",NULL);
|
||||
|
2
serial.c
2
serial.c
@ -12,7 +12,7 @@
|
||||
#include "sics.h"
|
||||
|
||||
extern int Controller(ClientData pData, Tcl_Interp *pInter,
|
||||
int argc, char *argv[]);
|
||||
int argc, const char *argv[]);
|
||||
|
||||
int SerialInit(SConnection *pCon,SicsInterp *pSics, void *pData,
|
||||
int argc, char *argv[])
|
||||
|
18
tasinit.c
18
tasinit.c
@ -261,7 +261,8 @@ static int TasSaveStatus(void *self, char *name, FILE *fd)
|
||||
used on the variables which switch the counter box into the appropriate
|
||||
mode.
|
||||
-----------------------------------------------------------------------*/
|
||||
static int MonitorCallback(int iEvent, void *pEvent, void *pUser)
|
||||
static int MonitorCallback(int iEvent, void *pEvent, void *pUser,
|
||||
commandContext cc)
|
||||
{
|
||||
pTASdata self = (pTASdata)pUser;
|
||||
assert(self);
|
||||
@ -274,7 +275,8 @@ static int MonitorCallback(int iEvent, void *pEvent, void *pUser)
|
||||
return 1;
|
||||
}
|
||||
/*---------------------------------------------------------------------*/
|
||||
static int TimerCallback(int iEvent, void *pEvent, void *pUser)
|
||||
static int TimerCallback(int iEvent, void *pEvent, void *pUser,
|
||||
commandContext cc)
|
||||
{
|
||||
pTASdata self = (pTASdata)pUser;
|
||||
assert(self);
|
||||
@ -309,7 +311,8 @@ static int RecalcAction(SConnection *pCon, SicsInterp *pSics, void *pData,
|
||||
to allow for the analyzer shielding to settle down. This is done
|
||||
through this callback function
|
||||
---------------------------------------------------------------------------*/
|
||||
static int A6WaitCallback(int iEvent, void *pEventData, void *pUserData)
|
||||
static int A6WaitCallback(int iEvent, void *pEventData, void *pUserData,
|
||||
commandContext cc)
|
||||
{
|
||||
if(iEvent == MOTEND)
|
||||
{
|
||||
@ -340,6 +343,7 @@ int TASFactory(SConnection *pCon, SicsInterp *pSics, void *pData,
|
||||
pSicsVariable pVar = NULL;
|
||||
CommandList *pCom = NULL;
|
||||
pMotor pMot = NULL;
|
||||
commandContext comCon;
|
||||
|
||||
/* check arguments*/
|
||||
if(argc < 2)
|
||||
@ -404,14 +408,16 @@ int TASFactory(SConnection *pCon, SicsInterp *pSics, void *pData,
|
||||
the variables should have been accessed earlier on.
|
||||
*/
|
||||
pVar = FindVariable(pSics,"MN");
|
||||
comCon.transID = 0;
|
||||
strncpy(comCon.deviceID,"internal",SCDEVIDLEN);
|
||||
if(pVar)
|
||||
{
|
||||
RegisterCallback(pVar->pCall,VALUECHANGE,MonitorCallback,pNew,NULL);
|
||||
RegisterCallback(pVar->pCall,comCon,VALUECHANGE,MonitorCallback,pNew,NULL);
|
||||
}
|
||||
pVar = FindVariable(pSics,"TI");
|
||||
if(pVar)
|
||||
{
|
||||
RegisterCallback(pVar->pCall,VALUECHANGE,TimerCallback,pNew,NULL);
|
||||
RegisterCallback(pVar->pCall,comCon,VALUECHANGE,TimerCallback,pNew,NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -420,7 +426,7 @@ int TASFactory(SConnection *pCon, SicsInterp *pSics, void *pData,
|
||||
pMot = FindMotor(pSics,"a6");
|
||||
if(pMot != NULL)
|
||||
{
|
||||
RegisterCallback(pMot->pCall,MOTEND,A6WaitCallback,NULL,NULL);
|
||||
RegisterCallback(pMot->pCall,comCon,MOTEND,A6WaitCallback,NULL,NULL);
|
||||
}
|
||||
|
||||
|
||||
|
@ -599,7 +599,7 @@ static int TASScanPoint(pScanData self, int iPoint)
|
||||
static void fixPowder(unsigned char tasTargetMask[20]){
|
||||
char *pPtr = NULL;
|
||||
|
||||
pPtr = Tcl_GetVar(pServ->pSics->pTcl,"powder",TCL_GLOBAL_ONLY);
|
||||
pPtr = (char *)Tcl_GetVar(pServ->pSics->pTcl,"powder",TCL_GLOBAL_ONLY);
|
||||
if(pPtr){
|
||||
if(strstr(pPtr,"1") != NULL){
|
||||
tasTargetMask[2] = 0;
|
||||
|
929
tcpdocho.c
Normal file
929
tcpdocho.c
Normal file
@ -0,0 +1,929 @@
|
||||
/*--------------------------------------------------------------
|
||||
This is a driver for the newer Astrium == Dornier chopper
|
||||
systems which use a TCP/IP server for communication.
|
||||
This driver has to take care of some ugliness:
|
||||
- As of december 2005, the communication is in unicode!
|
||||
To go from ASCII to unicode and back one has to
|
||||
add a 0x00 before each character or to remove it.
|
||||
- The controller is slow in responding and the controller
|
||||
must be watched in the environment monitor. This is taken
|
||||
care of by a special SICS task which updates the status
|
||||
regularly and returning cached values anytime else.
|
||||
|
||||
|
||||
Inititial Implementation: Mark Koennecke, December 2005
|
||||
------------------------------------------------------------*/
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
#include <time.h>
|
||||
#include <fortify.h>
|
||||
#include <sics.h>
|
||||
#include <stringdict.h>
|
||||
#include <rs232controller.h>
|
||||
#include <codri.h>
|
||||
#include <stptok.h>
|
||||
#include <commandlog.h>
|
||||
/*========================================================================
|
||||
Our private data structure
|
||||
========================================================================*/
|
||||
#define ASYNMODE 0
|
||||
#define SYNCMODE 1
|
||||
|
||||
typedef struct{
|
||||
prs232 controller;
|
||||
int iRefreshIntervall;
|
||||
time_t nextRefresh;
|
||||
long lTask;
|
||||
pStringDict parameters;
|
||||
int lastError;
|
||||
int numChoppers;
|
||||
int mode;
|
||||
int timeout;
|
||||
char user[132];
|
||||
char pword[132];
|
||||
int stop;
|
||||
int busy;
|
||||
char *config;
|
||||
}TcpDoCho, *pTcpDoCho;
|
||||
/*-----------------------------------------------------------------------
|
||||
Error codes:
|
||||
-----------------------------------------------------------------------*/
|
||||
#define WRONGMODE -8301
|
||||
#define BADCONVERSION -8302
|
||||
#define FAILEDCOMMAND -8303
|
||||
#define BADWRITE -8304
|
||||
#define BADRESPONSE -8306
|
||||
#define UNDRIVABLE -8307
|
||||
#define BADPAR -8308
|
||||
#define ESTOP -8309
|
||||
|
||||
extern char *trim(char *str);
|
||||
#define ABS(x) (x < 0 ? -(x) : (x))
|
||||
|
||||
#define SPEEDTOL 2
|
||||
#define PHASETOL .5
|
||||
/*=============== support functions ===================================*/
|
||||
static int asciiToUnicode(char *input, char **output){
|
||||
int len, i;
|
||||
char *result = NULL;
|
||||
|
||||
len = strlen(input);
|
||||
result = (char *)malloc(2*len*sizeof(char));
|
||||
if(result == NULL){
|
||||
return 0;
|
||||
}
|
||||
memset(result,0,2*len*sizeof(char));
|
||||
for(i = 0; i < len; i++){
|
||||
result[i*2] = input[i];
|
||||
}
|
||||
*output = result;
|
||||
return 2*len;
|
||||
}
|
||||
/*-------------------------------------------------------------------*/
|
||||
static int unicodeToAscii(char *input, int len, char **output){
|
||||
int i, alen;
|
||||
char *result = NULL;
|
||||
|
||||
alen = len/2;
|
||||
|
||||
result = (char *)malloc((alen+1)*sizeof(char));
|
||||
if(result == NULL){
|
||||
return 0;
|
||||
}
|
||||
memset(result,0,(alen+1)*sizeof(char));
|
||||
for(i = 0; i < alen; i++){
|
||||
result[i] = input[i*2];
|
||||
}
|
||||
*output = result;
|
||||
return alen;
|
||||
}
|
||||
/*----------------------------------------------------------------*/
|
||||
static int tcpDoChoSend(pTcpDoCho self, char *command, int choNum,
|
||||
char *value){
|
||||
char buffer[1024];
|
||||
char *converted;
|
||||
int sendlen, status;
|
||||
|
||||
/*
|
||||
format and send command
|
||||
*/
|
||||
self->lastError = 0;
|
||||
if(choNum < 0){
|
||||
snprintf(buffer,1023,"#SOS#%s \r\n",command);
|
||||
} else if(value != NULL){
|
||||
snprintf(buffer,1023,"#SOS#%s%1.1d: %s\r\n",command, choNum,
|
||||
value);
|
||||
} else {
|
||||
snprintf(buffer,1023,"#SOS#%s%1.1d:\r\n",command, choNum);
|
||||
}
|
||||
sendlen = asciiToUnicode(buffer,&converted);
|
||||
if(sendlen == 0){
|
||||
self->lastError = BADCONVERSION;
|
||||
return 0;
|
||||
}
|
||||
status = send(self->controller->pSock->sockid,converted,sendlen,0);
|
||||
free(converted);
|
||||
if(status < 0){
|
||||
self->lastError = BADWRITE;
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
/*----------------------------------------------------------------*/
|
||||
static int statusComplete(char *statusMessage){
|
||||
char *pPtr = NULL;
|
||||
|
||||
/*
|
||||
currently the status message has no terminator. I try to find
|
||||
the last component of the message which happens to be TIME and
|
||||
the last # after that
|
||||
*/
|
||||
pPtr = strstr(statusMessage,"TIME");
|
||||
if(pPtr != NULL){
|
||||
pPtr = strstr(pPtr+6,"#");
|
||||
if(pPtr != NULL){
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------*/
|
||||
static int readChopperNum(char *entry){
|
||||
int num;
|
||||
char *pPtr = NULL;
|
||||
|
||||
pPtr = strstr(entry,"CH");
|
||||
if(pPtr == NULL){
|
||||
return -1;
|
||||
}
|
||||
sscanf(pPtr+3,"%d",&num);
|
||||
return num;
|
||||
}
|
||||
/*---------------------------------------------------------------*/
|
||||
static void addEntry(pTcpDoCho self, int choNum, char *entry){
|
||||
char name[80], value[80], *pPtr = NULL;
|
||||
char num[5];
|
||||
|
||||
memset(name,0,80);
|
||||
memset(value,0,80);
|
||||
snprintf(num,5,"_%1.1d",choNum);
|
||||
pPtr = strstr(entry,"=");
|
||||
if(pPtr != NULL){
|
||||
strncpy(name,entry,pPtr -entry);
|
||||
strncat(trim(name),num,80-strlen(trim(name)));
|
||||
strcpy(value,pPtr+1);
|
||||
if(StringDictExists(self->parameters,name)){
|
||||
StringDictUpdate(self->parameters,name,trim(value));
|
||||
} else {
|
||||
StringDictAddPair(self->parameters,name,trim(value));
|
||||
}
|
||||
}
|
||||
}
|
||||
/*----------------------------------------------------------------*/
|
||||
static int parseStatus(pTcpDoCho self, char *statusMessage){
|
||||
int choNum;
|
||||
char entry[80], *pPtr;
|
||||
|
||||
pPtr = statusMessage;
|
||||
|
||||
/* skip over SOS */
|
||||
pPtr = stptok(pPtr,entry,79,"#");
|
||||
pPtr = stptok(pPtr,entry,79,"#");
|
||||
pPtr = stptok(pPtr,entry,79,"#");
|
||||
|
||||
choNum = readChopperNum(entry);
|
||||
if(choNum < 0){
|
||||
self->lastError = BADRESPONSE;
|
||||
return 0;
|
||||
}
|
||||
while((pPtr = stptok(pPtr,entry,79,"#")) != NULL){
|
||||
addEntry(self,choNum,entry);
|
||||
memset(entry,0,80);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
/*-----------------------------------------------------------------*/
|
||||
static int tcpDoChoReceive(pTcpDoCho self){
|
||||
char buffer[1024];
|
||||
int len, bytesRead, bytesConverted, bufferStart, status;
|
||||
char *converted = NULL;
|
||||
time_t endTime;
|
||||
|
||||
endTime = time(NULL) + self->timeout;
|
||||
bufferStart = 0;
|
||||
bytesRead = 0;
|
||||
memset(buffer,0,1024*sizeof(char));
|
||||
while(time(NULL) < endTime){
|
||||
if(availableRS232(self->controller)){
|
||||
bytesRead += recv(self->controller->pSock->sockid,buffer+bufferStart,
|
||||
1024 - bytesRead,0);
|
||||
if(bytesRead < 0){
|
||||
self->lastError = BADREAD;
|
||||
return 0;
|
||||
}
|
||||
bytesConverted = unicodeToAscii(buffer,bytesRead,&converted);
|
||||
if(bytesConverted == 0){
|
||||
self->lastError = BADCONVERSION;
|
||||
return 0;
|
||||
}
|
||||
if(strstr(converted,"State") != NULL){
|
||||
if(statusComplete(converted) == 0) {
|
||||
continue;
|
||||
} else {
|
||||
status = parseStatus(self,converted);
|
||||
free(converted);
|
||||
return status;
|
||||
}
|
||||
}
|
||||
if(strstr(converted,"ACCEPT") != NULL){
|
||||
free(converted);
|
||||
return 1;
|
||||
} else if(strstr(converted,"NCCEPT") != NULL){
|
||||
free(converted);
|
||||
self->lastError = FAILEDCOMMAND;
|
||||
return 0;
|
||||
} else {
|
||||
self->lastError = BADRESPONSE;
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
SicsWait(1);
|
||||
}
|
||||
}
|
||||
self->lastError = TIMEOUT;
|
||||
return 0;
|
||||
}
|
||||
/*-----------------------------------------------------------------*/
|
||||
static int tcpDoChoCommand(pTcpDoCho self, char *command, int choNum,
|
||||
char *value){
|
||||
int status;
|
||||
|
||||
status = tcpDoChoSend(self,command,choNum,value);
|
||||
if(status == 0){
|
||||
return 0;
|
||||
}
|
||||
return tcpDoChoReceive(self);
|
||||
}
|
||||
/*---------------------------------------------------------------*/
|
||||
static int TcpDoChoConnect(pTcpDoCho self){
|
||||
int status, sendLen, readLen;
|
||||
char *converted = NULL;
|
||||
char buffer[256];
|
||||
|
||||
status = initRS232(self->controller);
|
||||
if(status != 1){
|
||||
self->lastError = status;
|
||||
return 0;
|
||||
}
|
||||
setRS232Timeout(self->controller,5);
|
||||
|
||||
readLen = 255;
|
||||
readRS232(self->controller,(void *)buffer,&readLen);
|
||||
unicodeToAscii(buffer,readLen,&converted);
|
||||
free(converted);
|
||||
|
||||
/*
|
||||
user name
|
||||
*/
|
||||
snprintf(buffer,255,"user:%s\r\n",self->user);
|
||||
sendLen = asciiToUnicode(buffer,&converted);
|
||||
if(sendLen == 0){
|
||||
self->lastError = BADCONVERSION;
|
||||
return 0;
|
||||
}
|
||||
status = send(self->controller->pSock->sockid,converted,sendLen,0);
|
||||
free(converted);
|
||||
if(status < 0){
|
||||
self->lastError = BADSEND;
|
||||
return 0;
|
||||
}
|
||||
readLen = 255;
|
||||
readRS232(self->controller,(void *)buffer,&readLen);
|
||||
unicodeToAscii(buffer,readLen,&converted);
|
||||
free(converted);
|
||||
|
||||
/*
|
||||
password
|
||||
*/
|
||||
snprintf(buffer,255,"password:%s\r\n",self->pword);
|
||||
sendLen = asciiToUnicode(buffer,&converted);
|
||||
if(sendLen == 0){
|
||||
self->lastError = BADCONVERSION;
|
||||
return 0;
|
||||
}
|
||||
status = send(self->controller->pSock->sockid,converted,sendLen,0);
|
||||
free(converted);
|
||||
if(status < 0){
|
||||
self->lastError = BADSEND;
|
||||
return 0;
|
||||
}
|
||||
readLen = 255;
|
||||
readRS232(self->controller,(void *)buffer,&readLen);
|
||||
unicodeToAscii(buffer,readLen,&converted);
|
||||
free(converted);
|
||||
|
||||
/*
|
||||
TODO: responses should be checked to test for a valid login.
|
||||
I do not know at this time how the controller reacts upon a
|
||||
bad login.
|
||||
*/
|
||||
|
||||
return 1;
|
||||
}
|
||||
/*==================== actual driver implementation code ==================*/
|
||||
static int TcpChopperTask(void *pData){
|
||||
pCodri self = NULL;
|
||||
pTcpDoCho pPriv = NULL;
|
||||
int status, code, i;
|
||||
char buffer[80];
|
||||
char error[512];
|
||||
|
||||
self = (pCodri)pData;
|
||||
assert(self);
|
||||
pPriv = (pTcpDoCho)self->pPrivate;
|
||||
assert(pPriv);
|
||||
|
||||
if(pPriv->stop == 1){
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(time(NULL) > pPriv->nextRefresh){
|
||||
if(pPriv->lastError != 0){
|
||||
self->GetError(self,&code,buffer,79);
|
||||
snprintf(error,511,"WARNING: chopper tries to fix: %s",buffer);
|
||||
WriteToCommandLog("Chopper-task:>>", error);
|
||||
status = self->TryFixIt(self,code);
|
||||
if(status == CHFAIL){
|
||||
pPriv->nextRefresh = time(NULL) + pPriv->iRefreshIntervall;
|
||||
return 1;
|
||||
}
|
||||
} else {
|
||||
pPriv->busy = 1;
|
||||
for(i = 0; i < pPriv->numChoppers; i++){
|
||||
status = tcpDoChoCommand(pPriv,"STATE ", i+1,NULL);
|
||||
if(status != 1){
|
||||
/*
|
||||
force error correction
|
||||
*/
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
pPriv->nextRefresh = time(NULL) + pPriv->iRefreshIntervall;
|
||||
pPriv->busy = 0;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
/*------------------------------------------------------------------------------*/
|
||||
static int TcpDoChoKill(pCodri self){
|
||||
pTcpDoCho pPriv = NULL;
|
||||
|
||||
pPriv = (pTcpDoCho)self->pPrivate;
|
||||
if(!pPriv)
|
||||
return 1;
|
||||
|
||||
if(pPriv->controller != NULL){
|
||||
KillRS232(pPriv->controller);
|
||||
}
|
||||
if(pPriv->parameters != NULL){
|
||||
DeleteStringDict(pPriv->parameters);
|
||||
}
|
||||
if(pPriv->config != NULL){
|
||||
free(pPriv->config);
|
||||
}
|
||||
free(pPriv);
|
||||
return 1;
|
||||
}
|
||||
/*-------------------------------------------------------------------*/
|
||||
static int TcpDoChoConfigure(pCodri pDriv){
|
||||
pTcpDoCho self = NULL;
|
||||
int status;
|
||||
char *pPtr = NULL;
|
||||
char command[80];
|
||||
|
||||
assert(pDriv != NULL);
|
||||
self = (pTcpDoCho)pDriv->pPrivate;
|
||||
assert(self != NULL);
|
||||
|
||||
if(self->config != NULL){
|
||||
pPtr = self->config;
|
||||
while( (pPtr = stptok(pPtr,command,79,"\n")) != NULL){
|
||||
status = tcpDoChoCommand(self,command,-1,NULL);
|
||||
if(status != 1){
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
/*---------------------------------------------------------------------*/
|
||||
static int TcpDoChoInit(pCodri pDriv){
|
||||
pTcpDoCho self = NULL;
|
||||
int status;
|
||||
|
||||
assert(pDriv != NULL);
|
||||
self = (pTcpDoCho)pDriv->pPrivate;
|
||||
assert(self != NULL);
|
||||
|
||||
self->lastError = 0;
|
||||
self->stop = 0;
|
||||
self->nextRefresh = 0;
|
||||
|
||||
status = TcpDoChoConnect(self);
|
||||
if(status != 1){
|
||||
return 0;
|
||||
}
|
||||
|
||||
status = TcpDoChoConfigure(pDriv);
|
||||
if(status != 1){
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* start the update task */
|
||||
if(self->lTask == 0){
|
||||
self->lTask = TaskRegister(pServ->pTasker,
|
||||
TcpChopperTask,
|
||||
NULL,
|
||||
NULL,
|
||||
pDriv,
|
||||
1);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
/*-------------------------------------------------------------------*/
|
||||
static void waitForBusy(pTcpDoCho self){
|
||||
time_t endTime;
|
||||
|
||||
endTime = time(NULL) + 10 *60; /* max 10 min */
|
||||
while(time(NULL) < endTime){
|
||||
if(self->busy == 1){
|
||||
SicsWait(3);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
WriteToCommandLog("Chopper-task>> ","WARNING: timeout on busy flag, flag forced");
|
||||
self->busy = 0;
|
||||
}
|
||||
/*----------------------------------------------------------------------*/
|
||||
static int TcpDoChoClose(pCodri pDriv){
|
||||
pTcpDoCho self = NULL;
|
||||
int status;
|
||||
|
||||
assert(pDriv != NULL);
|
||||
self = (pTcpDoCho)pDriv->pPrivate;
|
||||
assert(self != NULL);
|
||||
|
||||
self->stop = 1;
|
||||
if(self->controller != NULL){
|
||||
KillRS232(self->controller);
|
||||
self->controller = NULL;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
/*----------------------------------------------------------------------*/
|
||||
static int dissectName(char *name, char par[80], int *num){
|
||||
char *pPtr = NULL;
|
||||
|
||||
pPtr = strrchr(name,(int)'_');
|
||||
if(pPtr == NULL){
|
||||
return 0;
|
||||
}
|
||||
memset(par,0,80*sizeof(char));
|
||||
strncpy(par,name,pPtr - name);
|
||||
if(sscanf(pPtr+1,"%d",num) != 1){
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
/*----------------------------------------------------------------------*/
|
||||
static int TcpDoChoSetPar2(pCodri pDriv, char *parname, char *value){
|
||||
|
||||
pTcpDoCho self = NULL;
|
||||
int status, choNum;
|
||||
char par[80], buffer[80], state[80];
|
||||
|
||||
assert(pDriv != NULL);
|
||||
self = (pTcpDoCho)pDriv->pPrivate;
|
||||
assert(self != NULL);
|
||||
|
||||
|
||||
/*
|
||||
force status requests right after setting something in order
|
||||
to make the stored status represent the new target values
|
||||
*/
|
||||
if(dissectName(parname,par,&choNum)){
|
||||
/*
|
||||
check for emergency stop
|
||||
*/
|
||||
snprintf(buffer,79,"State_%1.1d",choNum);
|
||||
memset(state,0,80*sizeof(char));
|
||||
StringDictGet(self->parameters,buffer,state,79);
|
||||
if(strstr(state,"E-Stop") != NULL){
|
||||
self->lastError = ESTOP;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(strcmp(par,"speed") == 0){
|
||||
waitForBusy(self);
|
||||
status = tcpDoChoCommand(self,"SPEED ",choNum,trim(value));
|
||||
tcpDoChoCommand(self,"STATE ",choNum,NULL);
|
||||
if(status != 1){
|
||||
return 0;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
} else if(strcmp(par,"phase") == 0){
|
||||
waitForBusy(self);
|
||||
status = tcpDoChoCommand(self,"PHASE ",choNum,trim(value));
|
||||
tcpDoChoCommand(self,"STATE ",choNum,NULL);
|
||||
if(status != 1){
|
||||
return 0;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
self->lastError = UNDRIVABLE;
|
||||
return 0;
|
||||
}
|
||||
/*-----------------------------------------------------------------------*/
|
||||
static int TcpDoChoHalt(pCodri pDriv){
|
||||
|
||||
pTcpDoCho self = NULL;
|
||||
int status;
|
||||
|
||||
assert(pDriv != NULL);
|
||||
self = (pTcpDoCho)pDriv->pPrivate;
|
||||
assert(self != NULL);
|
||||
|
||||
waitForBusy(self);
|
||||
tcpDoChoCommand(self,"ESTOP :",-1,NULL);
|
||||
return 1;
|
||||
}
|
||||
/*-----------------------------------------------------------------------*/
|
||||
static int TcpDoChoSetPar(pCodri pDriv, char *parname, float fValue){
|
||||
|
||||
pTcpDoCho self = NULL;
|
||||
int status, choNum;
|
||||
char value[80];
|
||||
char par[80];
|
||||
|
||||
|
||||
assert(pDriv != NULL);
|
||||
self = (pTcpDoCho)pDriv->pPrivate;
|
||||
assert(self != NULL);
|
||||
|
||||
if(dissectName(parname,par,&choNum)){
|
||||
if(strcmp(par,"speed") == 0){
|
||||
snprintf(value,79,"%5.1f", fValue);
|
||||
return TcpDoChoSetPar2(pDriv,parname,value);
|
||||
} else if(strcmp(par,"phase") == 0){
|
||||
snprintf(value,79,"%6.2f",fValue);
|
||||
return TcpDoChoSetPar2(pDriv,parname,value);
|
||||
}
|
||||
}
|
||||
if(strcmp(parname,"updateintervall") == 0){
|
||||
sprintf(value,"%d",(int)fValue);
|
||||
StringDictUpdate(self->parameters,"updateintervall",value);
|
||||
self->iRefreshIntervall = (int)fValue;
|
||||
return 1;
|
||||
} else {
|
||||
snprintf(value,79,"%f",fValue);
|
||||
return TcpDoChoSetPar2(pDriv,parname,value);
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------*/
|
||||
static int TcpDoChoGetPar(pCodri pDriv, char *parname,
|
||||
char *pBuffer, int iBuflen){
|
||||
pTcpDoCho self = NULL;
|
||||
int status = 0, choNum;
|
||||
char par[80], buffer[80];
|
||||
float val;
|
||||
|
||||
assert(pDriv != NULL);
|
||||
self = (pTcpDoCho)pDriv->pPrivate;
|
||||
assert(self != NULL);
|
||||
|
||||
memset(par,0,80);
|
||||
dissectName(parname,par,&choNum);
|
||||
if(strcmp(par,"speed") == 0){
|
||||
snprintf(buffer,80,"ASPEED_%1.1d", choNum);
|
||||
status = StringDictGet(self->parameters,buffer,pBuffer,iBuflen);
|
||||
} else if(strcmp(par,"phase") == 0){
|
||||
snprintf(buffer,80,"APHASE_%1.1d", choNum);
|
||||
status = StringDictGet(self->parameters,buffer,pBuffer,iBuflen);
|
||||
} else {
|
||||
status = StringDictGet(self->parameters,parname,pBuffer,iBuflen);
|
||||
}
|
||||
return status;
|
||||
}
|
||||
/*----------------------------------------------------------------------*/
|
||||
static int TcpDoChoCheckPar(pCodri pDriv, char *parname){
|
||||
pTcpDoCho self = NULL;
|
||||
int status = 0, choNum;
|
||||
float val, soll, delta;
|
||||
char value[80], csoll[80], par[80], buffer[80], state[80];
|
||||
|
||||
assert(pDriv != NULL);
|
||||
self = (pTcpDoCho)pDriv->pPrivate;
|
||||
assert(self != NULL);
|
||||
|
||||
/*
|
||||
check for flags first
|
||||
*/
|
||||
if(self->busy){
|
||||
return HWBusy;
|
||||
}
|
||||
if(self->lastError != 0) {
|
||||
return HWFault;
|
||||
}
|
||||
|
||||
/*
|
||||
updateintervall is always Idle
|
||||
*/
|
||||
if(strcmp(parname,"updateintervall") == 0){
|
||||
return HWIdle;
|
||||
}
|
||||
|
||||
/*
|
||||
check for emergency stop
|
||||
*/
|
||||
snprintf(buffer,79,"State_%1.1d",choNum);
|
||||
memset(state,0,80*sizeof(char));
|
||||
StringDictGet(self->parameters,buffer,state,79);
|
||||
if(strstr(state,"E-Stop") != NULL){
|
||||
self->lastError = HWFault;
|
||||
return 0;
|
||||
}
|
||||
|
||||
memset(par,0,80);
|
||||
dissectName(parname,par,&choNum);
|
||||
if(strcmp(par,"speed") == 0){
|
||||
snprintf(buffer,79,"RSPEED_%1.1d", choNum);
|
||||
StringDictGet(self->parameters,buffer,csoll,79);
|
||||
sscanf(csoll,"%f",&soll);
|
||||
snprintf(buffer,79,"ASPEED_%1.1d", choNum);
|
||||
StringDictGet(self->parameters,buffer,value,79);
|
||||
sscanf(value,"%f",&val);
|
||||
delta = ABS(soll - val);
|
||||
if(delta > SPEEDTOL){
|
||||
return HWBusy;
|
||||
} else {
|
||||
return HWIdle;
|
||||
}
|
||||
} else if(strcmp(par,"phase") == 0){
|
||||
snprintf(buffer,79,"RPHASE_%1.1d", choNum);
|
||||
StringDictGet(self->parameters,buffer,csoll,79);
|
||||
sscanf(value,"%f",&soll);
|
||||
snprintf(buffer,79,"APHASE_%1.1d", choNum);
|
||||
StringDictGet(self->parameters,buffer,value,79);
|
||||
sscanf(value,"%f",&val);
|
||||
delta = ABS(soll - val);
|
||||
if(delta > PHASETOL){
|
||||
return HWBusy;
|
||||
} else {
|
||||
return HWIdle;
|
||||
}
|
||||
}
|
||||
self->lastError = BADPAR;
|
||||
return HWFault;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static int TcpDoChoError(pCodri pDriv, int *iCode, char *pError, int iLen){
|
||||
pTcpDoCho self = NULL;
|
||||
int status = 0;
|
||||
float val, soll, delta;
|
||||
char value[80];
|
||||
|
||||
assert(pDriv != NULL);
|
||||
self = (pTcpDoCho)pDriv->pPrivate;
|
||||
assert(self != NULL);
|
||||
|
||||
*iCode = self->lastError;
|
||||
switch(self->lastError){
|
||||
case WRONGMODE:
|
||||
strncpy(pError,"Chopper in wrong mode",iLen);
|
||||
break;
|
||||
case BADCONVERSION:
|
||||
strncpy(pError,"Bad ASCII to unicode conversion",iLen);
|
||||
break;
|
||||
case FAILEDCOMMAND:
|
||||
strncpy(pError,"Command not accepted",iLen);
|
||||
break;
|
||||
case BADWRITE:
|
||||
strncpy(pError,"Failed to write to chopper controller",iLen);
|
||||
break;
|
||||
case BADRESPONSE:
|
||||
strncpy(pError,"Chopper controller send invalid command",iLen);
|
||||
break;
|
||||
case UNDRIVABLE:
|
||||
strncpy(pError,"Parameter cannot be changed",iLen);
|
||||
break;
|
||||
case BADPAR:
|
||||
strncpy(pError,"No such parameter",iLen);
|
||||
break;
|
||||
case ESTOP:
|
||||
strncpy(pError,"Emergency stop is engaged",iLen);
|
||||
break;
|
||||
default:
|
||||
getRS232Error(self->lastError,pError,iLen);
|
||||
break;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
/*---------------------------------------------------------------------*/
|
||||
static int TcpDoChoFix(pCodri pDriv, int iCode){
|
||||
pTcpDoCho self = NULL;
|
||||
int status = 0;
|
||||
float val, soll, delta;
|
||||
char value[80];
|
||||
|
||||
assert(pDriv != NULL);
|
||||
self = (pTcpDoCho)pDriv->pPrivate;
|
||||
assert(self != NULL);
|
||||
|
||||
self->lastError = 0;
|
||||
switch(iCode){
|
||||
case BADCONVERSION:
|
||||
case BADRESPONSE:
|
||||
return CHREDO;
|
||||
break;
|
||||
case WRONGMODE:
|
||||
case FAILEDCOMMAND:
|
||||
case UNDRIVABLE:
|
||||
case BADPAR:
|
||||
case ESTOP:
|
||||
return CHFAIL;
|
||||
break;
|
||||
default:
|
||||
closeRS232(self->controller);
|
||||
status = TcpDoChoConnect(self);
|
||||
if(status == 1){
|
||||
return CHREDO;
|
||||
} else {
|
||||
return CHFAIL;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return CHFAIL;
|
||||
}
|
||||
/*-------------------------------------------------------------------*/
|
||||
pCodri MakeTcpDoChoDriver(char *tclArray, SConnection *pCon){
|
||||
pCodri pNew = NULL;
|
||||
pTcpDoCho self = NULL;
|
||||
const char *pPtr = NULL;
|
||||
char buffer[132];
|
||||
int port, i, count;
|
||||
Tcl_DString pars;
|
||||
char *parnames[] = {"State",
|
||||
"ASPEED",
|
||||
"RSPEED",
|
||||
"APHASE",
|
||||
"RPHASE",
|
||||
"AVETO",
|
||||
"DIR",
|
||||
"MONIT",
|
||||
"FLOWR",
|
||||
"WTEMP",
|
||||
"MTEMP",
|
||||
"MVIBR",
|
||||
"MVACU",
|
||||
"speed",
|
||||
"phase",
|
||||
NULL,
|
||||
};
|
||||
|
||||
/*
|
||||
allocate memory
|
||||
*/
|
||||
pNew = (pCodri)malloc(sizeof(Codri));
|
||||
self = (pTcpDoCho)malloc(sizeof(TcpDoCho));
|
||||
if(!pNew || !self){
|
||||
return NULL;
|
||||
}
|
||||
memset(pNew,0,sizeof(Codri));
|
||||
memset(self,0,sizeof(TcpDoCho));
|
||||
|
||||
/* port and host name */
|
||||
pPtr = Tcl_GetVar2(pServ->pSics->pTcl,tclArray,"port",TCL_GLOBAL_ONLY);
|
||||
if(!pPtr){
|
||||
SCWrite(pCon,"ERROR: port not found in configuration array for TCP Dornier Chopper",
|
||||
eError);
|
||||
free(pNew);
|
||||
free(self);
|
||||
return NULL;
|
||||
}
|
||||
sscanf(pPtr,"%d",&port);
|
||||
pPtr = Tcl_GetVar2(pServ->pSics->pTcl,tclArray,"host",TCL_GLOBAL_ONLY);
|
||||
if(!pPtr){
|
||||
SCWrite(pCon,"ERROR: host not found in configuration array for TCP Dornier Chopper",
|
||||
eError);
|
||||
free(pNew);
|
||||
free(self);
|
||||
return NULL;
|
||||
}
|
||||
memset(buffer,0,132);
|
||||
strncpy(buffer,pPtr, 131);
|
||||
self->controller = createRS232(buffer,port);
|
||||
|
||||
/* number of choppers */
|
||||
pPtr = Tcl_GetVar2(pServ->pSics->pTcl,tclArray,"nchopper",TCL_GLOBAL_ONLY);
|
||||
if(!pPtr){
|
||||
SCWrite(pCon,"ERROR: nchopper not found in configuration array for TCP Dornier Chopper",
|
||||
eError);
|
||||
free(pNew);
|
||||
free(self);
|
||||
return NULL;
|
||||
}
|
||||
sscanf(pPtr,"%d",&port);
|
||||
if(port < 0 || port > 8){
|
||||
SCWrite(pCon,"ERROR: number of choppers not in range 1 - 8",eError);
|
||||
free(pNew);
|
||||
free(self);
|
||||
}
|
||||
self->numChoppers = port;
|
||||
|
||||
/* timeout */
|
||||
pPtr = Tcl_GetVar2(pServ->pSics->pTcl,tclArray,"timeout",TCL_GLOBAL_ONLY);
|
||||
if(!pPtr){
|
||||
SCWrite(pCon,"ERROR: timeout not found in configuration array for TCP Dornier Chopper",
|
||||
eError);
|
||||
free(pNew);
|
||||
free(self);
|
||||
return NULL;
|
||||
}
|
||||
sscanf(pPtr,"%d",&port);
|
||||
self->timeout = port;
|
||||
|
||||
/* username and password */
|
||||
pPtr = Tcl_GetVar2(pServ->pSics->pTcl,tclArray,"user",TCL_GLOBAL_ONLY);
|
||||
if(!pPtr){
|
||||
SCWrite(pCon,"ERROR: user not found in configuration array for TCP Dornier Chopper",
|
||||
eError);
|
||||
free(pNew);
|
||||
free(self);
|
||||
return NULL;
|
||||
}
|
||||
strncpy(self->user,pPtr, 131);
|
||||
pPtr = Tcl_GetVar2(pServ->pSics->pTcl,tclArray,"password",TCL_GLOBAL_ONLY);
|
||||
if(!pPtr){
|
||||
SCWrite(pCon,"ERROR: password not found in configuration array for TCP Dornier Chopper",
|
||||
eError);
|
||||
free(pNew);
|
||||
free(self);
|
||||
return NULL;
|
||||
}
|
||||
strncpy(self->pword,pPtr, 131);
|
||||
|
||||
/*
|
||||
chopper configuration
|
||||
*/
|
||||
pPtr = Tcl_GetVar2(pServ->pSics->pTcl,tclArray,"config",TCL_GLOBAL_ONLY);
|
||||
if(pPtr != NULL){
|
||||
self->config = strdup(pPtr);
|
||||
}
|
||||
|
||||
|
||||
/* initialize some more */
|
||||
self->parameters = CreateStringDict();
|
||||
if(self->parameters == NULL || self->controller == NULL){
|
||||
SCWrite(pCon,"ERROR: out of memory in MakeTcpDoCho",eError);
|
||||
free(pNew);
|
||||
free(self);
|
||||
return NULL;
|
||||
}
|
||||
self->iRefreshIntervall = 60;
|
||||
pNew->Init = TcpDoChoInit;
|
||||
pNew->Close = TcpDoChoClose;
|
||||
pNew->Delete = TcpDoChoKill;
|
||||
pNew->SetPar = TcpDoChoSetPar;
|
||||
pNew->SetPar2 = TcpDoChoSetPar2;
|
||||
pNew->GetPar = TcpDoChoGetPar;
|
||||
pNew->CheckPar = TcpDoChoCheckPar;
|
||||
pNew->GetError = TcpDoChoError;
|
||||
pNew->TryFixIt = TcpDoChoFix;
|
||||
pNew->Halt = TcpDoChoHalt;
|
||||
StringDictAddPair(self->parameters,"updateintervall","60");
|
||||
pNew->pPrivate = self;
|
||||
|
||||
/*
|
||||
create parameter list
|
||||
*/
|
||||
Tcl_DStringInit(&pars);
|
||||
count = 0;
|
||||
Tcl_DStringAppend(&pars,"updateintervall",15);
|
||||
while(parnames[count] != NULL){
|
||||
for(i = 0; i < self->numChoppers; i++){
|
||||
snprintf(buffer,131,",%s_%1.1d", parnames[count], i + 1);
|
||||
Tcl_DStringAppend(&pars,buffer,strlen(buffer));
|
||||
}
|
||||
count++;
|
||||
}
|
||||
pNew->pParList = strdup(Tcl_DStringValue(&pars));
|
||||
Tcl_DStringFree(&pars);
|
||||
return pNew;
|
||||
}
|
1146
tcpdornier.c
Normal file
1146
tcpdornier.c
Normal file
File diff suppressed because it is too large
Load Diff
@ -55,7 +55,8 @@ static void KillTricsSupport(void *pData){
|
||||
}
|
||||
}
|
||||
/*=====================================================================*/
|
||||
static int FrameSupInterest(int iEvent, void *pEvent, void *pUser){
|
||||
static int FrameSupInterest(int iEvent, void *pEvent, void *pUser,
|
||||
commandContext cc){
|
||||
SConnection *pCon = NULL;
|
||||
int *iFrame;
|
||||
char pBueffel[512];
|
||||
@ -68,7 +69,9 @@ static int FrameSupInterest(int iEvent, void *pEvent, void *pUser){
|
||||
iFrame = (int *)pEvent;
|
||||
assert(pCon);
|
||||
sprintf(pBueffel,"framenumber = %d",*iFrame);
|
||||
SCPushContext2(pCon,cc);
|
||||
SCWrite(pCon,pBueffel,eWarning);
|
||||
SCPopContext(pCon);
|
||||
return 1;
|
||||
}
|
||||
/*======================================================================
|
||||
@ -182,7 +185,8 @@ int TricsSupportAction(SConnection *pCon, SicsInterp *pSics, void *pData,
|
||||
return 1;
|
||||
}
|
||||
else if(strcmp(argv[1],"interest") == 0){
|
||||
lID = RegisterCallback(self->pCall, NEWFRAME, FrameSupInterest,
|
||||
lID = RegisterCallback(self->pCall, SCGetContext(pCon),
|
||||
NEWFRAME, FrameSupInterest,
|
||||
pCon, NULL);
|
||||
SCRegister(pCon,pSics, self->pCall,lID);
|
||||
SCSendOK(pCon);
|
||||
|
@ -69,7 +69,7 @@ typedef struct __VelSelDriv *pVelSelDriv;
|
||||
#define VSACCEL -7
|
||||
#define VSFAIL -2
|
||||
|
||||
typedef enum {eStart, eRegel, eHalted} eVeloMode;
|
||||
typedef enum {vStart, eRegel, eHalted} eVeloMode;
|
||||
#define RPMALIFE 3090
|
||||
|
||||
/*----------------------------- The private data structure ---------------*/
|
||||
@ -165,7 +165,7 @@ typedef enum {eStart, eRegel, eHalted} eVeloMode;
|
||||
case eHalted:
|
||||
strcpy(pCommand,"SST");
|
||||
pDorn->fTarget = fVal;
|
||||
pDorn->eVelo = eStart;
|
||||
pDorn->eVelo = vStart;
|
||||
pDorn->t_End = time(NULL) + 1800; /* start time + 30 min */
|
||||
break;
|
||||
case eRegel:
|
||||
@ -323,7 +323,7 @@ typedef enum {eStart, eRegel, eHalted} eVeloMode;
|
||||
/* some serious logic because of multi - modes */
|
||||
switch(pDorn->eVelo)
|
||||
{
|
||||
case eStart:
|
||||
case vStart:
|
||||
*iCode = ROTSTART;
|
||||
*fCur = 0.;
|
||||
if(sStatus.cur_rpm >= RPMALIFE)
|
||||
@ -577,7 +577,7 @@ typedef enum {eStart, eRegel, eHalted} eVeloMode;
|
||||
{
|
||||
pVelSelDriv pNew = NULL;
|
||||
pDornier pDorn = NULL;
|
||||
char *pPtr = NULL;
|
||||
const char *pPtr = NULL;
|
||||
int iVal, iRet;
|
||||
|
||||
/* the most likely error is the parameters specified are wrong!
|
||||
|
Reference in New Issue
Block a user