- Reworked the connection object and the IO system
- Reworked the support for TRICS - Added a second generation motor
This commit is contained in:
134
scan.c
134
scan.c
@ -395,7 +395,7 @@ int StoreScanCounts(pScanData self, char *data)
|
||||
if(data == NULL)
|
||||
{
|
||||
SCWrite(self->pCon,"WARNING: StoreScanCounts called without data",
|
||||
eWarning);
|
||||
eLog);
|
||||
return 1;
|
||||
}
|
||||
InitCountEntry(&sCount);
|
||||
@ -409,9 +409,9 @@ int StoreScanCounts(pScanData self, char *data)
|
||||
}
|
||||
else
|
||||
{
|
||||
SCWrite(self->pCon,"WARNING: No data in StoreScanCounts",eWarning);
|
||||
SCWrite(self->pCon,"WARNING: No data in StoreScanCounts",eLog);
|
||||
snprintf(pBueffel,255,"Received: %s", data);
|
||||
SCWrite(self->pCon,pBueffel,eWarning);
|
||||
SCWrite(self->pCon,pBueffel,eLog);
|
||||
return 1;
|
||||
}
|
||||
pPtr = stptok(pPtr,pNumber,29," \t");
|
||||
@ -431,7 +431,7 @@ int StoreScanCounts(pScanData self, char *data)
|
||||
{
|
||||
SCWrite(self->pCon,
|
||||
"ERROR: I have only space for 10 Monitors in count structure",
|
||||
eError);
|
||||
eLogError);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@ -484,7 +484,7 @@ CountEntry CollectCounterData(pScanData self)
|
||||
iRet = Tcl_Eval(pTcl,self->pCommand);
|
||||
if(iRet != TCL_OK)
|
||||
{
|
||||
SCWrite(self->pCon,pTcl->result,eError);
|
||||
SCWrite(self->pCon,pTcl->result,eLogError);
|
||||
return sCount;
|
||||
}
|
||||
/* interprete the Tcl result as a list of counts
|
||||
@ -495,7 +495,7 @@ CountEntry CollectCounterData(pScanData self)
|
||||
pPtr = strtok(pAns," ");
|
||||
if(!pPtr)
|
||||
{
|
||||
SCWrite(self->pCon,"ERROR: no counts found in Tcl-result",eError);
|
||||
SCWrite(self->pCon,"ERROR: no counts found in Tcl-result",eLogError);
|
||||
}
|
||||
sscanf(pPtr,"%f",&fVal);
|
||||
sCount.lCount = (long)fVal;
|
||||
@ -559,11 +559,11 @@ CountEntry CollectCounterData(pScanData self)
|
||||
SCSetInterrupt(self->pCon,eContinue);
|
||||
SCWrite(self->pCon,
|
||||
"WARNING: skipped scan point due to motor failure",
|
||||
eWarning);
|
||||
eLog);
|
||||
continue;
|
||||
break;
|
||||
case eAbortScan:
|
||||
SCWrite(self->pCon,"ERROR: Scan aborted",eError);
|
||||
SCWrite(self->pCon,"ERROR: Scan aborted",eLogError);
|
||||
/* eat the interrupt, the requested op has been
|
||||
done
|
||||
*/
|
||||
@ -571,14 +571,14 @@ CountEntry CollectCounterData(pScanData self)
|
||||
return 0;
|
||||
break;
|
||||
default: /* all others */
|
||||
SCWrite(self->pCon,"ERROR: Scan aborted",eError);
|
||||
SCWrite(self->pCon,"ERROR: Scan aborted",eLogError);
|
||||
return 0;
|
||||
break;
|
||||
}
|
||||
if(!iRet)
|
||||
{
|
||||
SCWrite(self->pCon,"WARNING: skipped scan point after drive failure",
|
||||
eWarning);
|
||||
eLog);
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -596,7 +596,7 @@ CountEntry CollectCounterData(pScanData self)
|
||||
continue;
|
||||
break;
|
||||
case eAbortScan:
|
||||
SCWrite(self->pCon,"ERROR: Scan aborted",eError);
|
||||
SCWrite(self->pCon,"ERROR: Scan aborted",eLogError);
|
||||
/* eat the interrupt, the requested op has been
|
||||
done
|
||||
*/
|
||||
@ -604,14 +604,14 @@ CountEntry CollectCounterData(pScanData self)
|
||||
return 0;
|
||||
break;
|
||||
default: /* all others */
|
||||
SCWrite(self->pCon,"ERROR: Scan aborted",eError);
|
||||
SCWrite(self->pCon,"ERROR: Scan aborted",eLogError);
|
||||
return 0;
|
||||
break;
|
||||
}
|
||||
if(!iRet)
|
||||
{
|
||||
SCWrite(self->pCon,"WARNING: skipped scan point after count failure",
|
||||
eWarning);
|
||||
eLog);
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -1264,8 +1264,7 @@ CountEntry CollectCounterData(pScanData self)
|
||||
return 1;
|
||||
}
|
||||
/*--------------------------------------------------------------------------*/
|
||||
static int ScanInterest(int iEvent, void *pEventData, void *pUser,
|
||||
commandContext cc)
|
||||
static int ScanInterest(int iEvent, void *pEventData, void *pUser)
|
||||
{
|
||||
pScanData self = NULL;
|
||||
SConnection *pCon = NULL;
|
||||
@ -1280,14 +1279,18 @@ CountEntry CollectCounterData(pScanData self)
|
||||
assert(self);
|
||||
assert(pCon);
|
||||
|
||||
if(!SCisConnected(pCon)){
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(iEvent == SCANSTART)
|
||||
{
|
||||
SCWriteInContext(pCon,"NewScan",eWarning,cc);
|
||||
SCWrite(pCon,"NewScan",eLog);
|
||||
return 1;
|
||||
}
|
||||
else if(iEvent == SCANEND)
|
||||
{
|
||||
SCWriteInContext(pCon,"ScanEnd",eWarning,cc);
|
||||
SCWrite(pCon,"ScanEnd",eLog);
|
||||
return 1;
|
||||
}
|
||||
else if(iEvent == SCANPOINT)
|
||||
@ -1319,7 +1322,7 @@ CountEntry CollectCounterData(pScanData self)
|
||||
strcat(pPtr,"}");
|
||||
oldWrite = SCGetWriteFunc(pCon);
|
||||
SCSetWriteFunc(pCon,SCOnlySockWrite);
|
||||
SCWrite(pCon,pPtr,eWarning);
|
||||
SCWrite(pCon,pPtr,eLog);
|
||||
SCSetWriteFunc(pCon,oldWrite);
|
||||
free(lData);
|
||||
free(pPtr);
|
||||
@ -1328,8 +1331,7 @@ CountEntry CollectCounterData(pScanData self)
|
||||
return 1;
|
||||
}
|
||||
/*--------------------------------------------------------------------------*/
|
||||
static int ScanDynInterest(int iEvent, void *pEventData, void *pUser,
|
||||
commandContext cc)
|
||||
static int ScanDynInterest(int iEvent, void *pEventData, void *pUser)
|
||||
{
|
||||
pScanData self = NULL;
|
||||
SConnection *pCon = NULL;
|
||||
@ -1347,14 +1349,19 @@ CountEntry CollectCounterData(pScanData self)
|
||||
assert(self);
|
||||
assert(pCon);
|
||||
|
||||
if(!SCisConnected(pCon))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(iEvent == SCANSTART)
|
||||
{
|
||||
SCWriteInContext(pCon,"NewScan",eWarning,cc);
|
||||
SCWrite(pCon,"NewScan",eLog);
|
||||
return 1;
|
||||
}
|
||||
else if(iEvent == SCANEND)
|
||||
{
|
||||
SCWriteInContext(pCon,"ScanEnd",eWarning,cc);
|
||||
SCWrite(pCon,"ScanEnd",eLog);
|
||||
return 1;
|
||||
}
|
||||
else if(iEvent == SCANPOINT)
|
||||
@ -1376,16 +1383,15 @@ CountEntry CollectCounterData(pScanData self)
|
||||
}
|
||||
snprintf(pBueffel,255,"%s.scanpoint = {%d %f %ld}",
|
||||
self->objectName,i,fVal,lVal);
|
||||
SCWriteInContext(pCon,pBueffel,eValue,cc);
|
||||
SCWrite(pCon,pBueffel,eLog);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
/*--------------------------------------------------------------------------*/
|
||||
static int ScanUUInterest(int iEvent, void *pEventData, void *pUser,
|
||||
commandContext cc)
|
||||
static int ScanUUInterest(int iEvent, void *pEventData, void *pUser)
|
||||
{
|
||||
pScanData self = NULL;
|
||||
SConnection *pCon = NULL;
|
||||
SConnection *pCon = NULL, *comCon = NULL;
|
||||
char pItem[20];
|
||||
long *lData = NULL;
|
||||
int *iData = NULL;
|
||||
@ -1396,15 +1402,21 @@ CountEntry CollectCounterData(pScanData self)
|
||||
|
||||
assert(self);
|
||||
assert(pCon);
|
||||
|
||||
/*
|
||||
printf("ScanUUInterest called for pCon = %p handle %d\n", pCon, pCon->sockHandle);
|
||||
*/
|
||||
if(!SCisConnected(pCon)){
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(iEvent == SCANSTART)
|
||||
{
|
||||
SCWriteInContext(pCon,"NewScan",eWarning,cc);
|
||||
SCWrite(pCon,"NewScan",eLog);
|
||||
return 1;
|
||||
}
|
||||
else if(iEvent == SCANEND)
|
||||
{
|
||||
SCWriteInContext(pCon,"ScanEnd",eWarning,cc);
|
||||
SCWrite(pCon,"ScanEnd",eLog);
|
||||
return 1;
|
||||
}
|
||||
else if(iEvent == SCANPOINT)
|
||||
@ -1426,9 +1438,7 @@ CountEntry CollectCounterData(pScanData self)
|
||||
{
|
||||
iData[i] = htonl((int)lData[i]);
|
||||
}
|
||||
SCPushContext2(pCon,cc);
|
||||
SCWriteUUencoded(pCon,"ScanData",iData,self->iNP*sizeof(int));
|
||||
SCPopContext(pCon);
|
||||
free(lData);
|
||||
free(iData);
|
||||
return 1;
|
||||
@ -1929,53 +1939,53 @@ static int DumpScan(pScanData self, SConnection *pCon)
|
||||
/*-------- interest */
|
||||
else if(strcmp(argv[1],"interest") == 0)
|
||||
{
|
||||
lID = RegisterCallback(self->pCall, SCGetContext(pCon),SCANSTART, ScanInterest,
|
||||
pCon, NULL);
|
||||
SCRegister(pCon,pSics, self->pCall,lID);
|
||||
lID = RegisterCallback(self->pCall, SCGetContext(pCon),SCANEND, ScanInterest,
|
||||
pCon, NULL);
|
||||
SCRegister(pCon,pSics, self->pCall,lID);
|
||||
lID = RegisterCallback(self->pCall, SCGetContext(pCon),SCANPOINT, ScanInterest,
|
||||
pCon, NULL);
|
||||
SCRegister(pCon,pSics, self->pCall,lID);
|
||||
/*
|
||||
printf("Registering scan callbacks on handle %d\n", pCon->sockHandle);
|
||||
*/
|
||||
lID = RegisterCallback(self->pCall, SCANSTART, ScanInterest,
|
||||
SCCopyConnection(pCon), SCDeleteConnection);
|
||||
lID = RegisterCallback(self->pCall, SCANEND, ScanInterest,
|
||||
SCCopyConnection(pCon),SCDeleteConnection);
|
||||
lID = RegisterCallback(self->pCall, SCANPOINT, ScanInterest,
|
||||
SCCopyConnection(pCon), SCDeleteConnection);
|
||||
SCSendOK(pCon);
|
||||
return 1;
|
||||
}
|
||||
/*-------- interest */
|
||||
else if(strcmp(argv[1],"dyninterest") == 0)
|
||||
{
|
||||
lID = RegisterCallback(self->pCall, SCGetContext(pCon),SCANSTART, ScanDynInterest,
|
||||
pCon, NULL);
|
||||
SCRegister(pCon,pSics, self->pCall,lID);
|
||||
lID = RegisterCallback(self->pCall, SCGetContext(pCon), SCANEND, ScanDynInterest,
|
||||
pCon, NULL);
|
||||
SCRegister(pCon,pSics, self->pCall,lID);
|
||||
lID = RegisterCallback(self->pCall, SCGetContext(pCon),SCANPOINT, ScanDynInterest,
|
||||
pCon, NULL);
|
||||
SCRegister(pCon,pSics, self->pCall,lID);
|
||||
/*
|
||||
printf("Registering scanDyn callbacks on handle %d\n", pCon->sockHandle);
|
||||
*/
|
||||
lID = RegisterCallback(self->pCall, SCANSTART, ScanDynInterest,
|
||||
SCCopyConnection(pCon), SCDeleteConnection);
|
||||
lID = RegisterCallback(self->pCall,SCANEND, ScanDynInterest,
|
||||
SCCopyConnection(pCon), SCDeleteConnection);
|
||||
lID = RegisterCallback(self->pCall, SCANPOINT, ScanDynInterest,
|
||||
SCCopyConnection(pCon), SCDeleteConnection);
|
||||
SCSendOK(pCon);
|
||||
return 1;
|
||||
}
|
||||
/*-------- uuinterest */
|
||||
else if(strcmp(argv[1],"uuinterest") == 0)
|
||||
{
|
||||
lID = RegisterCallback(self->pCall, SCGetContext(pCon),SCANSTART, ScanUUInterest,
|
||||
pCon, NULL);
|
||||
SCRegister(pCon,pSics, self->pCall,lID);
|
||||
lID = RegisterCallback(self->pCall, SCGetContext(pCon),SCANEND, ScanUUInterest,
|
||||
pCon, NULL);
|
||||
SCRegister(pCon,pSics, self->pCall,lID);
|
||||
lID = RegisterCallback(self->pCall, SCGetContext(pCon),SCANPOINT, ScanUUInterest,
|
||||
pCon, NULL);
|
||||
SCRegister(pCon,pSics, self->pCall,lID);
|
||||
/*
|
||||
printf("Registering scanUU callbacks on handle %d, con = %p\n",
|
||||
conSave->sockHandle, conSave);
|
||||
*/
|
||||
lID = RegisterCallback(self->pCall, SCANSTART, ScanUUInterest,
|
||||
SCCopyConnection(pCon), SCDeleteConnection);
|
||||
lID = RegisterCallback(self->pCall, SCANEND, ScanUUInterest,
|
||||
SCCopyConnection(pCon),SCDeleteConnection);
|
||||
lID = RegisterCallback(self->pCall, SCANPOINT, ScanUUInterest,
|
||||
SCCopyConnection(pCon), SCDeleteConnection);
|
||||
SCSendOK(pCon);
|
||||
return 1;
|
||||
}
|
||||
/* ------- uninterest */
|
||||
else if(strcmp(argv[1],"uninterest") == 0)
|
||||
{
|
||||
RemoveCallback2(self->pCall,pCon);
|
||||
SCUnregister(pCon,self->pCall);
|
||||
RemoveCallbackCon(self->pCall,pCon);
|
||||
SCSendOK(pCon);
|
||||
return 1;
|
||||
}
|
||||
@ -2134,7 +2144,7 @@ static int DumpScan(pScanData self, SConnection *pCon)
|
||||
iRet = Tcl_GetInt(InterpGetTcl(pSics),argv[2],&lNP);
|
||||
if(iRet != TCL_OK)
|
||||
{
|
||||
sprintf(pBueffel,"ERROR: expected number, got %s",argv[3]);
|
||||
sprintf(pBueffel,"ERROR: expected number, got %s",argv[2]);
|
||||
SCWrite(pCon,pBueffel,eError);
|
||||
return 0;
|
||||
}
|
||||
@ -2187,7 +2197,7 @@ static int DumpScan(pScanData self, SConnection *pCon)
|
||||
iRet = Tcl_GetInt(InterpGetTcl(pSics),argv[2],&lNP);
|
||||
if(iRet != TCL_OK)
|
||||
{
|
||||
sprintf(pBueffel,"ERROR: expected number, got %s",argv[3]);
|
||||
sprintf(pBueffel,"ERROR: expected number, got %s",argv[2]);
|
||||
SCWrite(pCon,pBueffel,eError);
|
||||
return 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user