Remove superfluous trailing white space from C files
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
/*-----------------------------------------------------------------------------
|
||||
|
||||
Based on SINQ code 1996-2003 by Mark Koennecke
|
||||
|
||||
|
||||
Modifications: Paul Hathaway April 2004
|
||||
SimRun failure rate independent of polling rate
|
||||
Fault condition determined at initial drive command and reported
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
Instrument definition file usage:
|
||||
Motor motname ASIM lowerlimit upperlimit failpercent [speed]
|
||||
|
||||
|
||||
----------------------------------------------------------------------------*/
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
@@ -41,11 +41,11 @@
|
||||
|
||||
/* ----------------------- Simulation -----------------------------------*/
|
||||
/* #ifndef SICS_ANSTO_MOTOR_ASIM */
|
||||
#define SICS_ANSTO_MOTOR_ASIM
|
||||
#define SICS_ANSTO_MOTOR_ASIM
|
||||
#define MAX_LONG 2147483647
|
||||
|
||||
/* device internal status and error codes */
|
||||
/* BUSY - motor in motion toward target
|
||||
/* BUSY - motor in motion toward target
|
||||
* IDLE - movement complete, normal condition
|
||||
* FAULT - no motion, motor awaiting reset
|
||||
* CRASH - no motion, unable to recover
|
||||
@@ -61,9 +61,9 @@
|
||||
#define SETPOS "setpos"
|
||||
#define BUFFLEN 512
|
||||
|
||||
/* the first fields of ASIMDriv structure HAVE to be IDENTICAL to the
|
||||
/* the first fields of ASIMDriv structure HAVE to be IDENTICAL to the
|
||||
* abstract motor driver structure in modriv.h (motor_driver.h)
|
||||
*/
|
||||
*/
|
||||
|
||||
typedef struct ___MoDriv {
|
||||
/* general motor driver interface fields. REQUIRED! */
|
||||
@@ -77,11 +77,11 @@ typedef struct ___MoDriv {
|
||||
int (*TryAndFixIt)(void *self,int iError, float fNew);
|
||||
int (*Halt)(void *self);
|
||||
int (*GetDriverPar)(void *self, char *name, float *value);
|
||||
int (*SetDriverPar)(void *self,SConnection *pCon, char *name,
|
||||
int (*SetDriverPar)(void *self,SConnection *pCon, char *name,
|
||||
float newValue);
|
||||
void (*ListDriverPar)(void *self, char *motorName, SConnection *pCon);
|
||||
void (*KillPrivate)(void *self);
|
||||
|
||||
|
||||
/* ASIM-specific fields */
|
||||
pMotor pMot; /**< Points to logical motor object */
|
||||
float fFailure; /* percent random failures */
|
||||
@@ -150,7 +150,7 @@ static int SimStat(void *self);
|
||||
pDriv->iRunningTime += ((long)tD - pDriv->iLastPollTime);
|
||||
}
|
||||
pDriv->iLastPollTime = (long)tD;
|
||||
}
|
||||
}
|
||||
/*----------------------------------------------------------------------------*/
|
||||
static void UpdatePosition(ASIMDriv *pDriv)
|
||||
{
|
||||
@@ -186,9 +186,9 @@ static int SimStat(void *self);
|
||||
case ASIM_FAULT:
|
||||
motCode = HWFault;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return motCode;
|
||||
}
|
||||
}
|
||||
/*----------------------------------------------------------------------------*/
|
||||
static int SimRun(void *self, float fVal)
|
||||
{
|
||||
@@ -200,25 +200,25 @@ static int SimStat(void *self);
|
||||
float fDelta;
|
||||
float fDuration;
|
||||
time_t tD;
|
||||
|
||||
|
||||
assert(self);
|
||||
pDriv = (ASIMDriv *)self;
|
||||
|
||||
switch (pDriv->iStatus)
|
||||
{
|
||||
case ASIM_IDLE: pDriv->iStatus = ASIM_BUSY;
|
||||
case ASIM_BUSY: break;
|
||||
default: pDriv->iStatus = ASIM_CRASH;
|
||||
case ASIM_BUSY: break;
|
||||
default: pDriv->iStatus = ASIM_CRASH;
|
||||
case ASIM_CRASH:
|
||||
case ASIM_FAULT: return HWFault;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
/* New run command */
|
||||
/* Determine desired distance and direction (fDiff >= 0.0)*/
|
||||
pDriv->fDestination = fVal;
|
||||
fDiff = fVal - pDriv->fPos;
|
||||
if(0.0 > fDiff)
|
||||
if(0.0 > fDiff)
|
||||
{
|
||||
fDiff = -fDiff;
|
||||
fDirection = -1.0;
|
||||
@@ -231,7 +231,7 @@ static int SimStat(void *self);
|
||||
iSucceed = 1;
|
||||
else
|
||||
iSucceed = 0;
|
||||
|
||||
|
||||
/* Determine delta from actual target by fault mode */
|
||||
if (0 == iSucceed)
|
||||
{
|
||||
@@ -242,14 +242,14 @@ static int SimStat(void *self);
|
||||
pDriv->iFaultType = ASIM_HW_FAULT;
|
||||
fDelta = -fDiff;
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
if (TH_STALL_FAULT > fFault)
|
||||
if (TH_STALL_FAULT > fFault)
|
||||
{ /* stall before 80% complete */
|
||||
pDriv->iFaultType = ASIM_STALL_FAULT;
|
||||
fDelta = (-1.0) * fDiff * (0.2 + SimRandom()/125.0);
|
||||
}
|
||||
else
|
||||
else
|
||||
{ /* position fault to +/- 10% */
|
||||
pDriv->iFaultType = ASIM_POS_FAULT;
|
||||
fDelta = fDiff * SimRandom()/1000.0;
|
||||
@@ -266,9 +266,9 @@ static int SimStat(void *self);
|
||||
/* Calculate target and time using speed */
|
||||
if (pDriv->fSpeed >= MIN_SPEED)
|
||||
{
|
||||
fDiff = fDiff + fDelta;
|
||||
fDiff = fDiff + fDelta;
|
||||
fDuration = fDiff/(pDriv->fSpeed);
|
||||
if (fDuration > MAX_LONG)
|
||||
if (fDuration > MAX_LONG)
|
||||
pDriv->iDuration = 2000000000;
|
||||
else
|
||||
pDriv->iDuration = (long)fDuration;
|
||||
@@ -282,14 +282,14 @@ static int SimStat(void *self);
|
||||
pDriv->iRunningTime = 0;
|
||||
pDriv->iLastPollTime = time(&tD);
|
||||
pDriv->iTime = tD + pDriv->iDuration;
|
||||
|
||||
|
||||
if(ASIM_BUSY==pDriv->iStatus)
|
||||
return OKOK;
|
||||
else
|
||||
return HWFault;
|
||||
|
||||
} /* SimRun */
|
||||
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
/* iErrLen fixed to 131 in fn [reportAndFixError] of <motor.c>
|
||||
* iCode reported to SimFix via [reportAndFixError]
|
||||
@@ -298,27 +298,27 @@ static int SimStat(void *self);
|
||||
{
|
||||
int motCode = HWFault;
|
||||
ASIMDriv *pDriv;
|
||||
|
||||
|
||||
assert(self);
|
||||
pDriv = (ASIMDriv *)self;
|
||||
|
||||
switch (pDriv->iStatus)
|
||||
{
|
||||
case ASIM_IDLE: motCode = HWIdle; break;
|
||||
case ASIM_BUSY: motCode = HWBusy; break;
|
||||
case ASIM_BUSY: motCode = HWBusy; break;
|
||||
case ASIM_CRASH:
|
||||
case ASIM_FAULT:
|
||||
case ASIM_FAULT:
|
||||
default: motCode = HWFault; break;
|
||||
}
|
||||
|
||||
|
||||
*iCode = pDriv->iFaultType;
|
||||
|
||||
|
||||
switch (pDriv->iFaultType)
|
||||
{
|
||||
case ASIM_POS_FAULT:
|
||||
strncpy(error,"ERROR: ASIM Position Fault",iErrLen);
|
||||
break;
|
||||
case ASIM_NO_FAULT:
|
||||
case ASIM_NO_FAULT:
|
||||
strncpy(error,"STATUS: ASIM No Fault",iErrLen);
|
||||
break;
|
||||
case ASIM_HW_FAULT:
|
||||
@@ -333,18 +333,18 @@ static int SimStat(void *self);
|
||||
}
|
||||
assert(strlen(error)<131);
|
||||
} /* SimError */
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static int SimFix(void *self, int iError, float fNew)
|
||||
{
|
||||
ASIMDriv *pDriv;
|
||||
|
||||
assert(self);
|
||||
pDriv = (ASIMDriv *)self;
|
||||
|
||||
pDriv = (ASIMDriv *)self;
|
||||
|
||||
switch (pDriv->iStatus)
|
||||
{
|
||||
case ASIM_IDLE:
|
||||
case ASIM_IDLE:
|
||||
switch (pDriv->iFaultType)
|
||||
{
|
||||
case ASIM_POS_FAULT: return MOTOK;
|
||||
@@ -354,11 +354,11 @@ static int SimStat(void *self);
|
||||
default: return MOTFAIL; /* error: unknown fault type */
|
||||
}
|
||||
break;
|
||||
case ASIM_BUSY: return MOTOK; break;
|
||||
case ASIM_BUSY: return MOTOK; break;
|
||||
case ASIM_CRASH: return MOTFAIL; break;
|
||||
case ASIM_FAULT:
|
||||
case ASIM_FAULT:
|
||||
SimHalt(self);
|
||||
if(TH_HW_FAULT >= SimRandom())
|
||||
if(TH_HW_FAULT >= SimRandom())
|
||||
{
|
||||
pDriv->iStatus = ASIM_CRASH;
|
||||
return MOTFAIL;
|
||||
@@ -367,11 +367,11 @@ static int SimStat(void *self);
|
||||
pDriv->iFaultType = ASIM_NO_FAULT;
|
||||
return MOTOK;
|
||||
break;
|
||||
default:
|
||||
pDriv->iStatus = ASIM_CRASH;
|
||||
default:
|
||||
pDriv->iStatus = ASIM_CRASH;
|
||||
pDriv->iFaultType = ASIM_HW_FAULT;
|
||||
return MOTFAIL;
|
||||
}
|
||||
}
|
||||
/* SICSLogWrite("Attempt fix for simulated motor",eHWError); */
|
||||
} /* SimFix */
|
||||
|
||||
@@ -381,7 +381,7 @@ static int SimStat(void *self);
|
||||
int motCode = OKOK;
|
||||
ASIMDriv *pDriv;
|
||||
assert(self);
|
||||
|
||||
|
||||
pDriv = (ASIMDriv *)self;
|
||||
UpdatePosition(pDriv);
|
||||
pDriv->iTime = 0;
|
||||
@@ -406,7 +406,7 @@ static int SimStat(void *self);
|
||||
assert(self);
|
||||
pDriv = (ASIMDriv *)self;
|
||||
|
||||
UpdatePosition(pDriv);
|
||||
UpdatePosition(pDriv);
|
||||
switch (pDriv->iStatus)
|
||||
{
|
||||
case ASIM_BUSY: motCode = HWBusy; break;
|
||||
@@ -438,7 +438,7 @@ static int SimSetPar(void *self, SConnection *pCon, char *name, float newValue)
|
||||
{
|
||||
pDriv->fSpeed = newValue;
|
||||
iSuccess = 1;
|
||||
}
|
||||
}
|
||||
return iSuccess;
|
||||
}
|
||||
|
||||
@@ -473,7 +473,7 @@ static void SimListPar(void *self, char *motorName, SConnection *pCon)
|
||||
/* ASIMDriv *pDriv = (ASIMDriv *) self;
|
||||
char pBuffer[256];
|
||||
*/
|
||||
|
||||
|
||||
assert(self);
|
||||
assert(pCon);
|
||||
/* The logical motor does this for us
|
||||
@@ -495,7 +495,7 @@ static void SimListPar(void *self, char *motorName, SConnection *pCon)
|
||||
*/
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
MotorDriver *CreateASIM(SConnection *pCon, char *motor, char *params)
|
||||
{
|
||||
@@ -503,10 +503,10 @@ MotorDriver *CreateASIM(SConnection *pCon, char *motor, char *params)
|
||||
time_t tD;
|
||||
char *pPtr = NULL;
|
||||
Tcl_Interp *interp;
|
||||
|
||||
|
||||
assert(pCon);
|
||||
interp = InterpGetTcl(pServ->pSics);
|
||||
|
||||
|
||||
/* allocate memory */
|
||||
pDriv = (ASIMDriv *)malloc(sizeof(ASIMDriv));
|
||||
if(!pDriv)
|
||||
@@ -531,13 +531,13 @@ MotorDriver *CreateASIM(SConnection *pCon, char *motor, char *params)
|
||||
}
|
||||
sscanf(pPtr,"%s",pDriv->units);
|
||||
pDriv->fFailure = 0;
|
||||
|
||||
|
||||
/* calculate current position, initialise func pters */
|
||||
pDriv->fPos = (pDriv->fUpper + pDriv->fLower)/2.0;
|
||||
/* pDriv->name = strdup("SICS_ANSTO_MOTOR_ASIM"); */
|
||||
/* pDriv->name = strdup("SICS_ANSTO_MOTOR_ASIM"); */
|
||||
pDriv->name = malloc((1+strlen("SICS_ANSTO_MOTOR_ASIM"))*sizeof(char));
|
||||
strcpy(pDriv->name,"SICS_ANSTO_MOTOR_ASIM");
|
||||
|
||||
|
||||
pDriv->GetPosition = SimGetPos;
|
||||
pDriv->RunTo = SimRun;
|
||||
pDriv->GetStatus = SimStat;
|
||||
@@ -548,7 +548,7 @@ MotorDriver *CreateASIM(SConnection *pCon, char *motor, char *params)
|
||||
pDriv->GetDriverPar = SimGetPar;
|
||||
pDriv->ListDriverPar = SimListPar;
|
||||
pDriv->KillPrivate = SimKill;
|
||||
|
||||
|
||||
/* set default parameters */
|
||||
pDriv->fSpeed = 1.0;
|
||||
pDriv->iTime = time(&tD);
|
||||
@@ -559,7 +559,7 @@ MotorDriver *CreateASIM(SConnection *pCon, char *motor, char *params)
|
||||
pDriv->fTarget = pDriv->fPos;
|
||||
pDriv->fDestination = pDriv->fPos;
|
||||
pDriv->iStatus = OKOK;
|
||||
|
||||
|
||||
srand( (unsigned)time( NULL ) );
|
||||
|
||||
return (MotorDriver *)pDriv;
|
||||
|
||||
Reference in New Issue
Block a user