More functions.

This commit is contained in:
Ron Sluiter
2003-03-04 15:27:29 +00:00
parent d36ecc4af1
commit 1167a6bb77
2 changed files with 93 additions and 18 deletions
+35 -8
View File
@@ -2,9 +2,9 @@
FILENAME... devMXmotor.cc
USAGE... Motor record device level support for MX device driver.
Version: $Revision: 1.1 $
Version: $Revision: 1.2 $
Modified By: $Author: sluiter $
Last Modified: $Date: 2003-02-14 15:15:28 $
Last Modified: $Date: 2003-03-04 15:26:47 $
*/
/*
@@ -90,7 +90,6 @@ static const char errmsg[] = {"\n\n!!!ERROR!!! - MX driver uninitialized.\n"};
static long MXmotor_init(void *after)
{
int before_after = (int) after;
long rtnval = 0;
if (*(MXmotor_access.init_indicator) == NO)
{
@@ -143,15 +142,13 @@ static RTN_STATUS MXmotor_build(motor_cmnd command, double *parms, struct motorR
{
struct motor_trans *trans = (struct motor_trans *) mr->dpvt;
struct mess_node *motor_call;
int size;
unsigned int size;
char buff[110];
RTN_STATUS rtnval = OK;
bool send = true; /* Default to send motor command. */
struct controller *brdptr;
struct MXcontroller *cntrl;
float fparm;
mx_status_type mx_status;
brdptr = (*trans->tabptr->card_array)[mr->card];
if (brdptr == NULL)
@@ -171,14 +168,44 @@ static RTN_STATUS MXmotor_build(motor_cmnd command, double *parms, struct motorR
{
case MOVE_ABS:
sprintf(buff, "%d %f", command, *parms);
fparm = *parms;
mx_status = mx_motor_raw_move_absolute(cntrl->MXmotor_record, fparm);
break;
case MOVE_REL:
sprintf(buff, "%d %f", command, *parms);
break;
case HOME_FOR:
sprintf(buff, "%d %d", command, 1);
break;
case HOME_REV:
sprintf(buff, "%d %d", command, -1);
break;
case LOAD_POS:
sprintf(buff, "%d %f", command, *parms);
break;
case SET_VEL_BASE:
case SET_VELOCITY:
case SET_ACCEL:
sprintf(buff, "%d %f", command, *parms);
break;
case GO:
send = false;
break;
case GET_INFO:
/* This command is not actually done by sending a message, but
rather they will indirectly cause the driver to read the status
of all motors */
break;
case STOP_AXIS:
sprintf(buff, "%d", command);
break;
default:
send = false;
rtnval = ERROR;
+58 -10
View File
@@ -2,9 +2,9 @@
FILENAME... drvMXmotor.cc
USAGE... Motor record driver level support for MX device driver.
Version: $Revision: 1.1 $
Version: $Revision: 1.2 $
Modified By: $Author: sluiter $
Last Modified: $Date: 2003-02-14 15:15:29 $
Last Modified: $Date: 2003-03-04 15:27:29 $
*/
/*
@@ -166,9 +166,7 @@ RTN_STATUS MXmotorSetup(int max_motors, /* Maximum number of motors. */
static int motor_init()
{
struct controller *pmotorState;
long status;
int card_index, motor_index;
char axis_pos[50], encoder_pos[50];
int total_encoders = 0, total_axis = 0;
/* Check for setup */
@@ -295,23 +293,73 @@ static RTN_STATUS send_mess(int card, char const *com, char inchar)
struct MXcontroller *cntrl;
motor_cmnd command;
mx_status_type mx_status;
char *cmndptr, *posptr;
float position;
char *cmndptr, *argptr;
double darg;
int iarg, flags = MXF_MTR_IGNORE_BACKLASH;
brdptr = motor_state[card];
cntrl = (struct MXcontroller *) brdptr->DevicePrivate;
posptr = NULL;
cmndptr = strtok_r((char *) com, " ", &posptr);
argptr = NULL;
cmndptr = strtok_r((char *) com, " ", &argptr);
if (cmndptr == NULL)
return(OK);
command = (motor_cmnd) atoi(cmndptr);
position = atof(posptr);
switch (command)
{
case MOVE_ABS:
mx_status = mx_motor_raw_move_absolute(cntrl->MXmotor_record, position);
case MOVE_REL:
case LOAD_POS:
case SET_VEL_BASE:
case SET_VELOCITY:
darg = atof(argptr);
break;
case HOME_FOR:
case HOME_REV:
iarg = atoi(argptr);
break;
default:
break;
}
switch (command)
{
case MOVE_ABS:
mx_status = mx_motor_move_absolute(cntrl->MXmotor_record, darg, flags);
break;
case MOVE_REL:
mx_status = mx_motor_move_relative(cntrl->MXmotor_record, darg, flags);
break;
case HOME_FOR:
case HOME_REV:
mx_status = mx_motor_find_home_position(cntrl->MXmotor_record, iarg);
break;
case SET_VEL_BASE:
mx_status = mx_motor_set_base_speed(cntrl->MXmotor_record, darg);
break;
case SET_VELOCITY:
mx_status = mx_motor_set_speed(cntrl->MXmotor_record, darg);
break;
case SET_ACCEL:
break;
case LOAD_POS:
mx_status = mx_motor_set_position(cntrl->MXmotor_record, darg);
break;
case STOP_AXIS:
mx_status = mx_motor_soft_abort(cntrl->MXmotor_record);
break;
default:
break;
}