Add ActionRoutine hook to motor object
r1728 | dcl | 2007-03-27 13:16:08 +1000 (Tue, 27 Mar 2007) | 2 lines
This commit is contained in:
6
motor.c
6
motor.c
@@ -407,7 +407,8 @@ static void handleMoveCallback(pMotor self, SConnection *pCon)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
memset(pM, 0, sizeof(Motor)); /* DFC init all to zero */
|
||||
pM->pActionRoutine = NULL; /* DFC belt and braces */
|
||||
|
||||
/* create and initialize parameters */
|
||||
pM->ParArray = ObParCreate(MOTOBPARLENGTH);
|
||||
@@ -1056,6 +1057,9 @@ extern MotorDriver *MakePiPiezo(Tcl_Interp *pTcl, char *pArray);
|
||||
}
|
||||
|
||||
/* create the interpreter command */
|
||||
if (pNew->pActionRoutine)
|
||||
iRet = AddCommand(pSics,argv[1],pNew->pActionRoutine,MotorKill,pNew);
|
||||
else
|
||||
iRet = AddCommand(pSics,argv[1],MotorAction,MotorKill,pNew);
|
||||
if(!iRet)
|
||||
{
|
||||
|
||||
1
motor.h
1
motor.h
@@ -20,6 +20,7 @@
|
||||
ObPar *ParArray;
|
||||
pIDrivable pDrivInt;
|
||||
pICallBack pCall;
|
||||
ObjectFunc pActionRoutine;
|
||||
char *drivername;
|
||||
char *name;
|
||||
MotorDriver *pDriver;
|
||||
|
||||
@@ -72,6 +72,7 @@ typedef struct __MoDriv {
|
||||
int errorCode;
|
||||
char *errorMsg; /**< Points to memory for error messages */
|
||||
char units[256]; /**< physical units for axis */
|
||||
char long_name[256]; /**< long name of motor */
|
||||
float speed; /**< physical units per second */
|
||||
float maxSpeed; /**< physical units per second */
|
||||
float accel; /**< physical units per second^2 */
|
||||
@@ -159,6 +160,7 @@ int DMC2280MotionControl = 1; /* defaults to enabled */
|
||||
#define MOTOFFDELAY "motoffdelay"
|
||||
#define AIRPADS "airpads"
|
||||
#define SETTLE "settle"
|
||||
#define LONG_NAME "long_name"
|
||||
#define BLOCKAGE_CHECK_INTERVAL "blockage_check_interval"
|
||||
|
||||
static int DMC2280Halt(void *pData);
|
||||
@@ -1701,6 +1703,8 @@ static int DMC2280SetPar(void *pData, SConnection *pCon,
|
||||
static void DMC2280List(void *self, char *name, SConnection *pCon){
|
||||
char buffer[BUFFLEN];
|
||||
|
||||
snprintf(buffer, BUFFLEN, "%s.long_name = %s\n", name, ((pDMC2280Driv)self)->long_name);
|
||||
SCWrite(pCon, buffer, eStatus);
|
||||
snprintf(buffer, BUFFLEN, "%s.axis = %c\n", name, ((pDMC2280Driv)self)->axisLabel);
|
||||
SCWrite(pCon, buffer, eStatus);
|
||||
snprintf(buffer, BUFFLEN, "%s.home = %f\n", name, ((pDMC2280Driv)self)->home);
|
||||
@@ -1882,6 +1886,10 @@ MotorDriver *CreateDMC2280(SConnection *pCon, char *motor, char *params) {
|
||||
pNew->blockage_fail = 0;
|
||||
|
||||
/* PARAMETERS: Fetch parameter values */
|
||||
if ((pPtr=getParam(pCon, interp, params, LONG_NAME, _OPTIONAL)) != NULL) {
|
||||
strncpy(pNew->long_name, pPtr, sizeof(pNew->long_name));
|
||||
pNew->long_name[sizeof(pNew->long_name) - 1] = '\0';
|
||||
}
|
||||
if ((pPtr=getParam(pCon, interp, params,HARDLOWERLIM,_REQUIRED)) == NULL) {
|
||||
KillDMC2280(pNew);
|
||||
return NULL;
|
||||
@@ -1989,3 +1997,39 @@ MotorDriver *CreateDMC2280(SConnection *pCon, char *motor, char *params) {
|
||||
/* TODO Initialise current position and target to get a sensible initial list output */
|
||||
return (MotorDriver *)pNew;
|
||||
}
|
||||
int DMC2280Action(SConnection *pCon, SicsInterp *pSics, void *pData,
|
||||
int argc, char *argv[])
|
||||
{
|
||||
pMotor pm = (pMotor) pData;
|
||||
pDMC2280Driv self = (pDMC2280Driv) pm->pDriver;
|
||||
|
||||
if (argc > 1) {
|
||||
if (strcasecmp("units", argv[1]) == 0) {
|
||||
if (argc > 2) {
|
||||
strncpy(self->units, argv[2], sizeof(self->units));
|
||||
self->units[sizeof(self->units) - 1] = '\0';
|
||||
}
|
||||
else {
|
||||
char line[132];
|
||||
snprintf(line, 132, "%s.units = %s", self->name, self->units);
|
||||
SCWrite(pCon, line, eValue);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
if (strcasecmp("long_name", argv[1]) == 0) {
|
||||
if (argc > 2) {
|
||||
strncpy(self->long_name, argv[2], sizeof(self->long_name));
|
||||
self->long_name[sizeof(self->long_name) - 1] = '\0';
|
||||
}
|
||||
else {
|
||||
char line[132];
|
||||
snprintf(line, 132, "%s.long_name = %s", self->name, self->long_name);
|
||||
SCWrite(pCon, line, eValue);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
if (strcasecmp("list", argv[1]) == 0) {
|
||||
}
|
||||
}
|
||||
return MotorAction(pCon, pSics, pData, argc, argv);
|
||||
}
|
||||
|
||||
@@ -11,7 +11,9 @@
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
MotorDriver *CreateDMC2280(SConnection *pCon, int argc, char *argv[]);
|
||||
MotorDriver *CreateDMC2280(SConnection *pCon, char* motor, char *params);
|
||||
int DMC2280Action(SConnection *pCon, SicsInterp *pSics, void *pData,
|
||||
int argc, char *argv[]);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include <SCinter.h>
|
||||
|
||||
/* site-specific driver header files */
|
||||
#include "motor_dmc2280.h"
|
||||
#include "motor_asim.h"
|
||||
#include "itc4.h"
|
||||
/* Added code for new LH45 and Lakeshore 340 drivers */
|
||||
@@ -90,6 +91,7 @@ static void RemoveCommands(SicsInterp *pSics){
|
||||
SCWrite(pCon,pBueffel,eError);
|
||||
return NULL;
|
||||
}
|
||||
pNew->pActionRoutine = DMC2280Action;
|
||||
}
|
||||
if(strcmp(argv[1],"asim") == 0) {
|
||||
pDriver = (MotorDriver *)CreateASIM(pCon,argc-2,&argv[2]);
|
||||
|
||||
Reference in New Issue
Block a user