- 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 SKIPPED: psi/amor2t.c psi/amorstat.c psi/dornier2.c psi/ecb.c psi/el734hp.c psi/fowrite.c psi/libpsi.a psi/make_gen psi/nextrics.c psi/pardef.c psi/pimotor.c psi/pipiezo.c psi/polterwrite.c psi/psi.c psi/scontroller.c psi/serial.c psi/tasinit.c psi/tasscan.c psi/tcpdocho.c psi/tcpdornier.c psi/tricssupport.c psi/velodornier.c
This commit is contained in:
207
velo.c
207
velo.c
@@ -1,4 +1,4 @@
|
||||
/*---------------------------------------------------------------------------
|
||||
/*---------------------------------------------------------------------------
|
||||
V E L O C I T Y S E L E C T O R
|
||||
|
||||
The velocity selector module for SICS. For documentation see velo.w
|
||||
@@ -116,6 +116,37 @@
|
||||
/* Success ! */
|
||||
return 1;
|
||||
}
|
||||
/*-----------------------------------------------------------------------*/
|
||||
static void VSListForbidden(pVelSel self, SConnection *pCon){
|
||||
Tcl_DString message;
|
||||
int status;
|
||||
Verbot Alcatraz;
|
||||
char pBueffel[256];
|
||||
|
||||
Tcl_DStringInit(&message);
|
||||
/*
|
||||
The first entry in the forbidden region thing is meant to
|
||||
contain the overall range: skip it!
|
||||
*/
|
||||
status = LLDnodePtr2First(self->iForbidden);
|
||||
LLDnodeDataTo(self->iForbidden,&Alcatraz);
|
||||
if(status == 1){
|
||||
snprintf(pBueffel,255,"%s.forbidden = {%f -inf", self->pName, Alcatraz.fMax);
|
||||
Tcl_DStringAppend(&message,pBueffel,strlen(pBueffel));
|
||||
}
|
||||
|
||||
/* now search the forbidden regions */
|
||||
status = LLDnodePtr2Next(self->iForbidden);
|
||||
while(status != 0){
|
||||
LLDnodeDataTo(self->iForbidden,&Alcatraz);
|
||||
snprintf(pBueffel,255,", %f - %f", Alcatraz.fMin, Alcatraz.fMax);
|
||||
Tcl_DStringAppend(&message,pBueffel,strlen(pBueffel));
|
||||
status = LLDnodePtr2Next(self->iForbidden);
|
||||
}
|
||||
Tcl_DStringAppend(&message,"}",1);
|
||||
SCWrite(pCon,Tcl_DStringValue(&message),eValue);
|
||||
Tcl_DStringFree(&message);
|
||||
}
|
||||
/*-------------------------------------------------------------------------*/
|
||||
static long VSSetValue(void *pData,SConnection *pCon, float fVal)
|
||||
{
|
||||
@@ -701,7 +732,7 @@
|
||||
return 1;
|
||||
}
|
||||
/*-------------------------------------------------------------------------*/
|
||||
static pEVDriver MakeDummyVel(pVelSel pVel)
|
||||
pEVDriver MakeDummyVel(pVelSel pVel)
|
||||
{
|
||||
pEVDriver pNew = NULL;
|
||||
pVelPrivate ich = NULL;
|
||||
@@ -869,51 +900,6 @@
|
||||
EVRegisterController(FindEMON(pSics),pBueffel,pNew->pMonitor,pCon);
|
||||
return iRet;
|
||||
}
|
||||
/*------------------------------------------------------------------------*/
|
||||
static int TTFindNumber(Tcl_Interp *pTcl,char *pPtr, float *fVal)
|
||||
{
|
||||
int iRet;
|
||||
char *pEnd;
|
||||
char *pMark;
|
||||
double dVal;
|
||||
|
||||
pEnd = pPtr + strlen(pPtr);
|
||||
|
||||
/* advance to first non blank or non = character */
|
||||
while( (isspace(*pPtr)) || (*pPtr == '=') )
|
||||
{
|
||||
pPtr++;
|
||||
if(pPtr >= pEnd)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* find end of string */
|
||||
pMark = pPtr;
|
||||
while( (!isspace(*pMark)))
|
||||
{
|
||||
pMark++;
|
||||
if(pMark >= pEnd)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
/* replace pMark temporarily by \0 */
|
||||
*pMark = '\0';
|
||||
|
||||
/* now read number from pPtr */
|
||||
iRet = Tcl_GetDouble(pTcl,pPtr,&dVal);
|
||||
if(iRet != TCL_OK)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* fix back and return */
|
||||
*pMark = ' ';
|
||||
*fVal = (float)dVal;
|
||||
return 1;
|
||||
}
|
||||
/*------------------------------------------------------------------------*/
|
||||
typedef struct {
|
||||
SConnection *pCon;
|
||||
@@ -935,7 +921,8 @@
|
||||
}
|
||||
}
|
||||
/*------------------------------------------------------------------------*/
|
||||
static int RotationInterest(int iEvent, void *pData, void *pUser)
|
||||
static int RotationInterest(int iEvent, void *pData, void *pUser,
|
||||
commandContext cc)
|
||||
{
|
||||
CBData *pDat = NULL;
|
||||
float *fVal = NULL;
|
||||
@@ -949,12 +936,12 @@
|
||||
if(iEvent == ROTSTART)
|
||||
{
|
||||
sprintf(pBueffel,"%s Starting",pDat->pName);
|
||||
SCWrite(pDat->pCon,pBueffel,eWarning);
|
||||
SCWriteInContext(pDat->pCon,pBueffel,eWarning,cc);
|
||||
}
|
||||
else if(iEvent == ROTMOVE)
|
||||
{
|
||||
sprintf(pBueffel,"%s.rpm = %f",pDat->pName, *fVal);
|
||||
SCWrite(pDat->pCon,pBueffel,eWarning);
|
||||
SCWriteInContext(pDat->pCon,pBueffel,eWarning,cc);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
@@ -980,10 +967,6 @@
|
||||
assert(pCon);
|
||||
assert(pSics);
|
||||
|
||||
/* convert to text for parsing */
|
||||
Arg2Text(argc,argv,pCommand, 511);
|
||||
strtolower(pCommand);
|
||||
|
||||
if(argc < 2)
|
||||
{
|
||||
sprintf(pBueffel,"ERROR: %s expects at least one parameter",argv[0]);
|
||||
@@ -1026,10 +1009,10 @@
|
||||
}
|
||||
pCB->pCon = pCon;
|
||||
pCB->pName = strdup(argv[0]);
|
||||
lID = RegisterCallback(self->pCall, ROTSTART, RotationInterest,
|
||||
lID = RegisterCallback(self->pCall, SCGetContext(pCon), ROTSTART, RotationInterest,
|
||||
pCB, KillCB);
|
||||
SCRegister(pCon,pSics, self->pCall,lID);
|
||||
lID = RegisterCallback(self->pCall, ROTMOVE, RotationInterest,
|
||||
lID = RegisterCallback(self->pCall, SCGetContext(pCon), ROTMOVE, RotationInterest,
|
||||
pCB, NULL);
|
||||
SCRegister(pCon,pSics, self->pCall,lID);
|
||||
SCSendOK(pCon);
|
||||
@@ -1081,6 +1064,13 @@
|
||||
SCSendOK(pCon);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* list forbidden regions */
|
||||
if(strcmp(argv[1],"forbidden") == 0)
|
||||
{
|
||||
VSListForbidden(self,pCon);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* status, prints a status message */
|
||||
if(strcmp(argv[1],"status") == 0)
|
||||
@@ -1132,6 +1122,30 @@
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
if(strcmp(argv[1],"rottolerance") == 0){
|
||||
if(argc > 2){
|
||||
/* set case */
|
||||
iRet = Tcl_GetDouble(pSics->pTcl,argv[2],&dVal);
|
||||
if(iRet != TCL_OK){
|
||||
sprintf(pBueffel,"ERROR: %s not recognized as numeric value for fMax",
|
||||
argv[2]);
|
||||
SCWrite(pCon,pBueffel,eError);
|
||||
return 0;
|
||||
}
|
||||
if(!SCMatchRights(pCon,usUser)){
|
||||
return 0;
|
||||
}
|
||||
self->pDriv->fTolerance = dVal;
|
||||
SCSendOK(pCon);
|
||||
return 1;
|
||||
} else {
|
||||
sprintf(pBueffel,"%s.rottolerance = %f",
|
||||
argv[0],self->pDriv->fTolerance);
|
||||
SCWrite(pCon,pBueffel,eError);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* initialise the tilt and rot to current values */
|
||||
iRet = VSGetRotation(self,&fRot);
|
||||
@@ -1143,61 +1157,50 @@
|
||||
iRet = MotorGetSoftPosition(self->pTilt,pCon,&fTilt);
|
||||
if(!iRet)
|
||||
{
|
||||
SCWrite(pCon,"ERROR: velocity selector operation aborted",eError);
|
||||
SCWrite(pCon,"ERROR: failed to read tilt angle",eError);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* search for Tilt */
|
||||
pPtr = strstr(pCommand,"tilt");
|
||||
if(pPtr) /* analyse tilt */
|
||||
{
|
||||
iDrive = 1;
|
||||
iRet = TTFindNumber(pSics->pTcl,pPtr+strlen("tilt"),&fTilt);
|
||||
if(!iRet)
|
||||
{
|
||||
/* no new value, just print the current one */
|
||||
MotorGetSoftPosition(self->pTilt,pCon,&fTilt);
|
||||
sprintf(pBueffel,"%s tilt = %f",argv[0],fTilt);
|
||||
SCWrite(pCon,pBueffel,eError);
|
||||
return 0;
|
||||
}
|
||||
if(strcmp(argv[1],"tilt") == 0){
|
||||
if(argc > 2){
|
||||
/* set case */
|
||||
iRet = Tcl_GetDouble(pSics->pTcl,argv[2],&dVal);
|
||||
if(iRet != TCL_OK){
|
||||
sprintf(pBueffel,"ERROR: %s not recognized as numeric value for fMax",
|
||||
argv[2]);
|
||||
SCWrite(pCon,pBueffel,eError);
|
||||
return 0;
|
||||
}
|
||||
fTilt = dVal;
|
||||
iDrive = 1;
|
||||
} else {
|
||||
sprintf(pBueffel,"%s tilt = %f",argv[0],fTilt);
|
||||
SCWrite(pCon,pBueffel,eError);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* serch for rottolerance */
|
||||
pPtr = strstr(pCommand,"rottolerance");
|
||||
if(pPtr) /* analyse rottolerance */
|
||||
{
|
||||
iDrive = 1;
|
||||
iRet = TTFindNumber(pSics->pTcl,pPtr+strlen("rottolerance"),&fTol);
|
||||
if(!iRet)
|
||||
{
|
||||
sprintf(pBueffel,"%s.rottolerance = %f",
|
||||
argv[0],self->pDriv->fTolerance);
|
||||
SCWrite(pCon,pBueffel,eError);
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
self->pDriv->fTolerance = fTol;
|
||||
SCSendOK(pCon);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* same for rot */
|
||||
pPtr = strstr(pCommand,"rot");
|
||||
if(pPtr) /* analyse tilt */
|
||||
{
|
||||
iDrive = 1;
|
||||
iRet = TTFindNumber(pSics->pTcl,pPtr+strlen("rot"),&fVal);
|
||||
if(!iRet)
|
||||
{
|
||||
sprintf(pBueffel,"%s rot = %f",argv[0],fRot);
|
||||
SCWrite(pCon,pBueffel,eError);
|
||||
return 0;
|
||||
}
|
||||
fRot = fVal;
|
||||
if(strcmp(argv[1],"rot") == 0){
|
||||
if(argc > 2){
|
||||
/* set case */
|
||||
iRet = Tcl_GetDouble(pSics->pTcl,argv[2],&dVal);
|
||||
if(iRet != TCL_OK){
|
||||
sprintf(pBueffel,"ERROR: %s not recognized as numeric value for fMax",
|
||||
argv[2]);
|
||||
SCWrite(pCon,pBueffel,eError);
|
||||
return 0;
|
||||
}
|
||||
fRot = dVal;
|
||||
iDrive = 1;
|
||||
} else {
|
||||
sprintf(pBueffel,"%s rot = %f",argv[0],fRot);
|
||||
SCWrite(pCon,pBueffel,eError);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* do drive if we really need to */
|
||||
|
||||
Reference in New Issue
Block a user