Main Page   Class Hierarchy   Alphabetical List   Data Structures   File List   Data Fields   Globals  

bridgeporttaskintf.cc File Reference

#include <math.h>
#include <float.h>
#include <string.h>
#include "rcs.hh"
#include "nml_mod.hh"
#include "emc.hh"
#include "usrmotintf.h"
#include "emcmot.h"
#include "emcmotcfg.h"
#include "canon.hh"
#include "posemath.h"
#include "initraj.hh"
#include "iniaxis.hh"
#include "emcglb.h"
#include "emcpos.h"

Include dependency graph for bridgeporttaskintf.cc:

Include dependency graph

Go to the source code of this file.

Defines

#define __attribute__(x)

Functions

char __attribute__ ((unused)) ident[]="$Id
int emcAxisSetUnits (int axis, double units)
int emcAxisSetGains (int axis, double p, double i, double d, double ff0, double ff1, double ff2, double backlash, double bias, double maxError, double deadband)
int emcAxisSetCycleTime (int axis, double cycleTime)
int emcAxisSetInputScale (int axis, double scale, double offset)
int emcAxisSetOutputScale (int axis, double scale, double offset)
int emcAxisSetMinPositionLimit (int axis, double limit)
int emcAxisSetMaxPositionLimit (int axis, double limit)
int emcAxisSetMinOutputLimit (int axis, double limit)
int emcAxisSetMaxOutputLimit (int axis, double limit)
int emcAxisSetFerror (int axis, double ferror)
int emcAxisSetMinFerror (int axis, double ferror)
int emcAxisSetHomingVel (int axis, double homingVel)
int emcAxisSetMaxVelocity (int axis, double vel)
int emcAxisSetHomeOffset (int axis, double offset)
int emcAxisSetEnablePolarity (int axis, int level)
int emcAxisSetMinLimitSwitchPolarity (int axis, int level)
int emcAxisSetMaxLimitSwitchPolarity (int axis, int level)
int emcAxisSetHomeSwitchPolarity (int axis, int level)
int emcAxisSetHomingPolarity (int axis, int level)
int emcAxisSetFaultPolarity (int axis, int level)
int emcAxisInit (int axis)
int emcAxisHalt (int axis)
int emcAxisAbort (int axis)
int emcAxisActivate (int axis)
int emcAxisDeactivate (int axis)
int emcAxisOverrideLimits (int axis)
int emcAxisSetOutput (int axis, double output)
int emcAxisEnable (int axis)
int emcAxisDisable (int axis)
int emcAxisHome (int axis)
int emcAxisSetHome (int axis, double home)
int emcAxisJog (int axis, double vel)
int emcAxisIncrJog (int axis, double incr, double vel)
int emcAxisAbsJog (int axis, double pos, double vel)
int emcAxisLoadComp (int axis, const char *file)
int emcAxisAlter (int axis, double alter)
int emcAxisUpdate (EMC_AXIS_STAT stat[], int numAxes)
int emcTrajSetAxes (int axes)
int emcTrajSetUnits (double linearUnits, double angularUnits)
int emcTrajSetCycleTime (double cycleTime)
int emcTrajSetMode (int mode)
int emcTrajSetTeleopVector (EmcPose vel)
int emcTrajSetVelocity (double vel)
int emcTrajSetAcceleration (double acc)
int emcTrajSetMaxVelocity (double vel)
int emcTrajSetMaxAcceleration (double acc)
int emcTrajSetHome (EmcPose home)
int emcTrajSetScale (double scale)
int emcTrajSetMotionId (int id)
int emcTrajInit ()
int emcTrajHalt ()
int emcTrajEnable ()
int emcTrajDisable ()
int emcTrajAbort ()
int emcTrajPause ()
int emcTrajStep ()
int emcTrajResume ()
int emcTrajDelay (double delay)
int emcTrajSetTermCond (int cond)
int emcTrajLinearMove (EmcPose end)
int emcTrajCircularMove (EmcPose end, PM_CARTESIAN center, PM_CARTESIAN normal, int turn)
int emcTrajSetProbeIndex (int index)
int emcTrajSetProbePolarity (int polarity)
int emcTrajClearProbeTrippedFlag ()
int emcTrajProbe (EmcPose pos)
int emcTrajUpdate (EMC_TRAJ_STAT *stat)
int emcMotionInit ()
int emcMotionHalt ()
int emcMotionAbort ()
int emcMotionSetDebug (int debug)
int emcMotionSetAout (unsigned char index, double start, double end)
int emcMotionSetDout (unsigned char index, unsigned char start, unsigned char end)
int emcMotionUpdate (EMC_MOTION_STAT *stat)
int emcioNmlGet ()
int sendCommand (RCS_CMD_MSG *msg)
int forceCommand (RCS_CMD_MSG *msg)
int emcIoInit ()
int emcIoHalt ()
int emcIoAbort ()
int emcIoSetDebug (int debug)
int emcAuxEstopOn ()
int emcAuxEstopOff ()
int emcSpindleAbort ()
int emcSpindleOn (double speed)
int emcSpindleOff ()
int emcSpindleBrakeRelease ()
int emcSpindleBrakeEngage ()
int emcSpindleIncrease ()
int emcSpindleDecrease ()
int emcSpindleConstant ()
int emcCoolantMistOn ()
int emcCoolantMistOff ()
int emcCoolantFloodOn ()
int emcCoolantFloodOff ()
int emcLubeInit ()
int emcLubeHalt ()
int emcLubeAbort ()
int emcLubeOn ()
int emcLubeOff ()
int emcToolPrepare (int tool)
int emcToolLoad ()
int emcToolUnload ()
int emcToolLoadToolTable (const char *file)
int emcToolSetOffset (int tool, double length, double diameter)
int emcLogOpen (char *file, int type, int size, int skip, int which, int triggerType, int triggerVar, double triggerThreshold)
int emcLogStart ()
int emcLogStop ()
int emcLogClose ()
int emcIoUpdate (EMC_IO_STAT *stat)

Variables

double saveMinLimit [EMCMOT_MAX_AXIS]
double saveMaxLimit [EMCMOT_MAX_AXIS]
double saveMinOutput [EMCMOT_MAX_AXIS]
double saveMaxOutput [EMCMOT_MAX_AXIS]
EMCMOT_CONFIG emcmotConfig
int get_emcmot_debug_info = 0
EMCMOT_STATUS emcmotStatus
EMCMOT_DEBUG emcmotDebug
char errorString [EMCMOT_ERROR_LEN]
int new_config = 0
int localEmcTrajAxes = 0
double localEmcTrajLinearUnits = 1.0
double localEmcTrajAngularUnits = 1.0
int localEmcTrajMotionId = 0
int last_id_printed = 0
int last_status = 0
int last_id = 0
double last_id_time
RCS_CMD_CHANNEL * emcIoCommandBuffer = 0
RCS_STAT_CHANNEL * emcIoStatusBuffer = 0
EMC_IO_STATemcIoStatus = 0
int emcIoCommandSerialNumber = 0
double EMCIO_BUFFER_GET_TIMEOUT = 5.0


Define Documentation

#define __attribute__  
 

Definition at line 123 of file bridgeporttaskintf.cc.


Function Documentation

char __attribute__ (unused)    [static]
 

Definition at line 127 of file bridgeporttaskintf.cc.

00127                                                   : bridgeporttaskintf.cc,v 1.20 2001/08/17 22:05:41 proctor Exp $";
00128 
00129 /* FIXME-- defining LASER to test motion/IO synch */
00130 /* #define LASER */
00131 
00132 // MOTION INTERFACE
00133 
00134 /*
00135   Implementation notes:
00136 
00137   Initing:  the emcmot interface needs to be inited once, but nml_traj_init()
00138   and nml_servo_init() can be called in any order. Similarly, the emcmot
00139   interface needs to be exited once, but nml_traj_exit() and nml_servo_exit()
00140   can be called in any order. They can also be called multiple times. Flags
00141   are used to signify if initing has been done, or if the final exit has
00142   been called.
00143   */
00144 
00145 // define this to catch isnan errors, for rtlinux FPU register problem testing
00146 #ifdef linux
00147 #include <stdio.h>              // printf()
00148 #define ISNAN_TRAP
00149 #endif
00150 
00151 static EMCMOT_COMMAND emcmotCommand;
00152 
00153 static int emcmotTrajInited = 0; // non-zero means traj called init
00154 static int emcmotAxisInited = 0; // non-zero means axis called init
00155 static int emcmotion_initialized=0; // non-zero means both emcMotionInit called.
00156 
00157 // saved value of velocity last sent out, so we don't send redundant requests
00158 // used by emcTrajSetVelocity(), emcMotionAbort()
00159 static double lastVel = -1.0;
00160 
00161 // EMC_AXIS functions
00162 
00163 // local status data, not provided by emcmot
00164 static unsigned long localMotionHeartbeat;
00165 static int localMotionCommandType = 0;
00166 static int localMotionEchoSerialNumber = 0;
00167 static unsigned char localEmcAxisAxisType[EMCMOT_MAX_AXIS];
00168 static double localEmcAxisUnits[EMCMOT_MAX_AXIS];
00169 static double localEmcMaxAcceleration = DBL_MAX;
00170 
00171 // axes are numbered 0..NUM-1
00172 
00173 /*
00174   In emcmot, we need to set the cycle time for traj, and the interpolation
00175   rate, in any order, but both need to be done. The PID cycle time will
00176   be set by emcmot automatically.
00177  */
00178 
00179 int emcAxisSetAxis(int axis, unsigned char axisType)
00180 {
00181   if (axis < 0 || axis >= EMCMOT_MAX_AXIS)
00182   {
00183     return 0;
00184   }
00185 
00186   localEmcAxisAxisType[axis] = axisType;
00187 
00188   return 0;
00189 }

int emcAuxEstopOff  
 

Definition at line 1922 of file bridgeporttaskintf.cc.

01923 {
01924   EMC_AUX_ESTOP_OFF estopOffMsg;
01925 
01926   return sendCommand(&estopOffMsg);
01927 }

int emcAuxEstopOn  
 

Definition at line 1915 of file bridgeporttaskintf.cc.

01916 {
01917   EMC_AUX_ESTOP_ON estopOnMsg;
01918 
01919   return forceCommand(&estopOnMsg);
01920 }

int emcAxisAbort int    axis
 

Definition at line 678 of file bridgeporttaskintf.cc.

00679 {
00680   if (axis < 0 || axis >= EMCMOT_MAX_AXIS)
00681   {
00682     return 0;
00683   }
00684 
00685   emcmotCommand.command = EMCMOT_ABORT;
00686   emcmotCommand.axis = axis;
00687 
00688   return usrmotWriteEmcmotCommand(&emcmotCommand);
00689 }

int emcAxisAbsJog int    axis,
double    pos,
double    vel
 

Definition at line 846 of file bridgeporttaskintf.cc.

00847 {
00848   if (axis < 0 || axis >= EMCMOT_MAX_AXIS)
00849   {
00850     return 0;
00851   }
00852 
00853   if (vel > AXIS_MAX_VELOCITY[axis])
00854   {
00855     vel = AXIS_MAX_VELOCITY[axis];
00856   }
00857   else if (vel < -AXIS_MAX_VELOCITY[axis])
00858   {
00859     vel = -AXIS_MAX_VELOCITY[axis];
00860   }
00861 
00862   emcmotCommand.command = EMCMOT_JOG_ABS;
00863   emcmotCommand.axis = axis;
00864   emcmotCommand.vel = vel;
00865   emcmotCommand.offset = pos;
00866 
00867   return usrmotWriteEmcmotCommand(&emcmotCommand);
00868 }

int emcAxisActivate int    axis
 

Definition at line 691 of file bridgeporttaskintf.cc.

00692 {
00693   if (axis < 0 || axis >= EMCMOT_MAX_AXIS)
00694   {
00695     return 0;
00696   }
00697 
00698   emcmotCommand.command = EMCMOT_ACTIVATE_AXIS;
00699   emcmotCommand.axis = axis;
00700 
00701   return usrmotWriteEmcmotCommand(&emcmotCommand);
00702 }

int emcAxisAlter int    axis,
double    alter
 

Definition at line 875 of file bridgeporttaskintf.cc.

00876 {
00877   return usrmotAlter(axis, alter);
00878 }

int emcAxisDeactivate int    axis
 

Definition at line 704 of file bridgeporttaskintf.cc.

00705 {
00706   if (axis < 0 || axis >= EMCMOT_MAX_AXIS)
00707   {
00708     return 0;
00709   }
00710 
00711   emcmotCommand.command = EMCMOT_DEACTIVATE_AXIS;
00712   emcmotCommand.axis = axis;
00713 
00714   return usrmotWriteEmcmotCommand(&emcmotCommand);
00715 }

int emcAxisDisable int    axis
 

Definition at line 759 of file bridgeporttaskintf.cc.

00760 {
00761   if (axis < 0 || axis >= EMCMOT_MAX_AXIS)
00762   {
00763     return 0;
00764   }
00765 
00766   emcmotCommand.command = EMCMOT_DISABLE_AMPLIFIER;
00767   emcmotCommand.axis = axis;
00768 
00769   return usrmotWriteEmcmotCommand(&emcmotCommand);
00770 }

int emcAxisEnable int    axis
 

Definition at line 746 of file bridgeporttaskintf.cc.

00747 {
00748   if (axis < 0 || axis >= EMCMOT_MAX_AXIS)
00749   {
00750     return 0;
00751   }
00752 
00753   emcmotCommand.command = EMCMOT_ENABLE_AMPLIFIER;
00754   emcmotCommand.axis = axis;
00755 
00756   return usrmotWriteEmcmotCommand(&emcmotCommand);
00757 }

int emcAxisHalt int    axis
 

Definition at line 656 of file bridgeporttaskintf.cc.

00657 {
00658   if (axis < 0 || axis >= EMCMOT_MAX_AXIS)
00659   {
00660     return 0;
00661   }
00662 
00663   // FIXME-- refs global emcStatus; should make EMC_AXIS_STAT an arg here
00664   if(NULL != emcStatus && emcmotion_initialized && emcmotAxisInited)
00665   {
00666     dumpAxis(axis, EMC_INIFILE, &emcStatus->motion.axis[axis]);
00667   }
00668 
00669   if (! emcmotTrajInited)       // traj clears its inited flag on exit
00670   {
00671     usrmotExit();               // ours is final exit
00672   }
00673   emcmotAxisInited = 0;
00674 
00675   return 0;
00676 }

int emcAxisHome int    axis
 

Definition at line 772 of file bridgeporttaskintf.cc.

00773 {
00774   if (axis < 0 || axis >= EMCMOT_MAX_AXIS)
00775   {
00776     return 0;
00777   }
00778 
00779   emcmotCommand.command = EMCMOT_HOME;
00780   emcmotCommand.axis = axis;
00781 
00782   return usrmotWriteEmcmotCommand(&emcmotCommand);
00783 }

int emcAxisIncrJog int    axis,
double    incr,
double    vel
 

Definition at line 822 of file bridgeporttaskintf.cc.

00823 {
00824   if (axis < 0 || axis >= EMCMOT_MAX_AXIS)
00825   {
00826     return 0;
00827   }
00828 
00829   if (vel > AXIS_MAX_VELOCITY[axis])
00830   {
00831     vel = AXIS_MAX_VELOCITY[axis];
00832   }
00833   else if (vel < -AXIS_MAX_VELOCITY[axis])
00834   {
00835     vel = -AXIS_MAX_VELOCITY[axis];
00836   }
00837 
00838   emcmotCommand.command = EMCMOT_JOG_INCR;
00839   emcmotCommand.axis = axis;
00840   emcmotCommand.vel = vel;
00841   emcmotCommand.offset = incr;
00842 
00843   return usrmotWriteEmcmotCommand(&emcmotCommand);
00844 }

int emcAxisInit int    axis
 

Definition at line 626 of file bridgeporttaskintf.cc.

00627 {
00628   int retval = 0;
00629 
00630   if (axis < 0 || axis >= EMCMOT_MAX_AXIS)
00631   {
00632     return 0;
00633   }
00634 
00635   // init emcmot interface
00636   if (! emcmotAxisInited &&
00637       ! emcmotTrajInited)
00638   {
00639     usrmotIniLoad(EMC_INIFILE);
00640 
00641     if (0 != usrmotInit())
00642     {
00643       return -1;
00644     }
00645   }
00646   emcmotAxisInited = 1;
00647 
00648   if (0 != iniAxis(axis, EMC_INIFILE))
00649   {
00650     retval = -1;
00651   }
00652 
00653   return retval;
00654 }

int emcAxisJog int    axis,
double    vel
 

Definition at line 799 of file bridgeporttaskintf.cc.

00800 {
00801   if (axis < 0 || axis >= EMCMOT_MAX_AXIS)
00802   {
00803     return 0;
00804   }
00805 
00806   if (vel > AXIS_MAX_VELOCITY[axis])
00807   {
00808     vel = AXIS_MAX_VELOCITY[axis];
00809   }
00810   else if (vel < -AXIS_MAX_VELOCITY[axis])
00811   {
00812     vel = -AXIS_MAX_VELOCITY[axis];
00813   }
00814 
00815   emcmotCommand.command = EMCMOT_JOG_CONT;
00816   emcmotCommand.axis = axis;
00817   emcmotCommand.vel = vel;
00818 
00819   return usrmotWriteEmcmotCommand(&emcmotCommand);
00820 }

int emcAxisLoadComp int    axis,
const char *    file
 

Definition at line 870 of file bridgeporttaskintf.cc.

00871 {
00872   return usrmotLoadComp(axis, file);
00873 }

int emcAxisOverrideLimits int    axis
 

Definition at line 717 of file bridgeporttaskintf.cc.

00718 {
00719   // can have axis < 0, for resuming normal limit checking
00720   if (axis >= EMCMOT_MAX_AXIS)
00721   {
00722     return 0;
00723   }
00724 
00725   emcmotCommand.command = EMCMOT_OVERRIDE_LIMITS;
00726   emcmotCommand.axis = axis;
00727 
00728   return usrmotWriteEmcmotCommand(&emcmotCommand);
00729 
00730 }

int emcAxisSetCycleTime int    axis,
double    cycleTime
 

Definition at line 247 of file bridgeporttaskintf.cc.

00248 {
00249   if (axis < 0 || axis >= EMCMOT_MAX_AXIS)
00250   {
00251     return 0;
00252   }
00253 
00254   if (cycleTime <= 0.0)
00255   {
00256     return -1;
00257   }
00258 
00259   emcmotCommand.command = EMCMOT_SET_SERVO_CYCLE_TIME;
00260   emcmotCommand.cycleTime = cycleTime;
00261 
00262   return usrmotWriteEmcmotCommand(&emcmotCommand);
00263 }

int emcAxisSetEnablePolarity int    axis,
int    level
 

Definition at line 532 of file bridgeporttaskintf.cc.

00533 {
00534   if (axis < 0 || axis >= EMCMOT_MAX_AXIS)
00535   {
00536     return 0;
00537   }
00538 
00539   emcmotCommand.command = EMCMOT_SET_POLARITY;
00540   emcmotCommand.axis = axis;
00541   emcmotCommand.level = level;
00542   emcmotCommand.axisFlag = EMCMOT_AXIS_ENABLE_BIT;
00543 
00544   return usrmotWriteEmcmotCommand(&emcmotCommand);
00545 }

int emcAxisSetFaultPolarity int    axis,
int    level
 

Definition at line 611 of file bridgeporttaskintf.cc.

00612 {
00613   if (axis < 0 || axis >= EMCMOT_MAX_AXIS)
00614   {
00615     return 0;
00616   }
00617 
00618   emcmotCommand.command = EMCMOT_SET_POLARITY;
00619   emcmotCommand.axis = axis;
00620   emcmotCommand.level = level;
00621   emcmotCommand.axisFlag = EMCMOT_AXIS_FAULT_BIT;
00622 
00623   return usrmotWriteEmcmotCommand(&emcmotCommand);
00624 }

int emcAxisSetFerror int    axis,
double    ferror
 

Definition at line 423 of file bridgeporttaskintf.cc.

00424 {
00425   if (axis < 0 || axis >= EMCMOT_MAX_AXIS)
00426   {
00427     return 0;
00428   }
00429 
00430   emcmotCommand.command = EMCMOT_SET_MAX_FERROR;
00431   emcmotCommand.axis = axis;
00432   emcmotCommand.maxFerror = ferror;
00433 
00434 #ifdef ISNAN_TRAP
00435   if (isnan(emcmotCommand.maxFerror))
00436   {
00437     printf("isnan error in emcAxisSetFerror\n");
00438     return -1;
00439   }
00440 #endif
00441 
00442   return usrmotWriteEmcmotCommand(&emcmotCommand);
00443 }

int emcAxisSetGains int    axis,
double    p,
double    i,
double    d,
double    ff0,
double    ff1,
double    ff2,
double    backlash,
double    bias,
double    maxError,
double    deadband
 

Definition at line 203 of file bridgeporttaskintf.cc.

00207 {
00208   if (axis < 0 || axis >= EMCMOT_MAX_AXIS)
00209   {
00210     return 0;
00211   }
00212 
00213   emcmotCommand.command = EMCMOT_SET_PID;
00214   emcmotCommand.axis = axis;
00215 
00216   emcmotCommand.pid.p = p;
00217   emcmotCommand.pid.i = i;
00218   emcmotCommand.pid.d = d;
00219   emcmotCommand.pid.ff0 = ff0;
00220   emcmotCommand.pid.ff1 = ff1;
00221   emcmotCommand.pid.ff2 = ff2;
00222   emcmotCommand.pid.backlash = backlash;
00223   emcmotCommand.pid.bias = bias;
00224   emcmotCommand.pid.maxError = maxError;
00225   emcmotCommand.pid.deadband = deadband;
00226 
00227 #ifdef ISNAN_TRAP
00228   if (isnan(emcmotCommand.pid.p) ||
00229       isnan(emcmotCommand.pid.i) ||
00230       isnan(emcmotCommand.pid.d) ||
00231       isnan(emcmotCommand.pid.ff0) ||
00232       isnan(emcmotCommand.pid.ff1) ||
00233       isnan(emcmotCommand.pid.ff2) ||
00234       isnan(emcmotCommand.pid.backlash) ||
00235       isnan(emcmotCommand.pid.bias) ||
00236       isnan(emcmotCommand.pid.maxError) ||
00237       isnan(emcmotCommand.pid.deadband))
00238   {
00239     printf("isnan error in emcAxisSetGains\n");
00240     return -1;
00241   }
00242 #endif
00243 
00244   return usrmotWriteEmcmotCommand(&emcmotCommand);
00245 }

int emcAxisSetHome int    axis,
double    home
 

Definition at line 785 of file bridgeporttaskintf.cc.

00786 {
00787   if (axis < 0 || axis >= EMCMOT_MAX_AXIS)
00788   {
00789     return 0;
00790   }
00791 
00792   emcmotCommand.command = EMCMOT_SET_JOINT_HOME;
00793   emcmotCommand.axis = axis;
00794   emcmotCommand.offset = home;
00795 
00796   return usrmotWriteEmcmotCommand(&emcmotCommand);
00797 }

int emcAxisSetHomeOffset int    axis,
double    offset
 

Definition at line 510 of file bridgeporttaskintf.cc.

00511 {
00512   if (axis < 0 || axis >= EMCMOT_MAX_AXIS)
00513   {
00514     return 0;
00515   }
00516 
00517   emcmotCommand.command = EMCMOT_SET_HOME_OFFSET;
00518   emcmotCommand.axis = axis;
00519   emcmotCommand.offset = offset;
00520 
00521 #ifdef ISNAN_TRAP
00522   if (isnan(emcmotCommand.offset))
00523   {
00524     printf("isnan error in emcAxisSetHomeOffset\n");
00525     return -1;
00526   }
00527 #endif
00528 
00529   return usrmotWriteEmcmotCommand(&emcmotCommand);
00530 }

int emcAxisSetHomeSwitchPolarity int    axis,
int    level
 

Definition at line 581 of file bridgeporttaskintf.cc.

00582 {
00583   if (axis < 0 || axis >= EMCMOT_MAX_AXIS)
00584   {
00585     return 0;
00586   }
00587 
00588   emcmotCommand.command = EMCMOT_SET_POLARITY;
00589   emcmotCommand.axis = axis;
00590   emcmotCommand.level = level;
00591   emcmotCommand.axisFlag = EMCMOT_AXIS_HOME_SWITCH_BIT;
00592 
00593   return usrmotWriteEmcmotCommand(&emcmotCommand);
00594 }

int emcAxisSetHomingPolarity int    axis,
int    level
 

Definition at line 596 of file bridgeporttaskintf.cc.

00597 {
00598   if (axis < 0 || axis >= EMCMOT_MAX_AXIS)
00599   {
00600     return 0;
00601   }
00602 
00603   emcmotCommand.command = EMCMOT_SET_POLARITY;
00604   emcmotCommand.axis = axis;
00605   emcmotCommand.level = level;
00606   emcmotCommand.axisFlag = EMCMOT_AXIS_HOMING_BIT;
00607 
00608   return usrmotWriteEmcmotCommand(&emcmotCommand);
00609 }

int emcAxisSetHomingVel int    axis,
double    homingVel
 

Definition at line 467 of file bridgeporttaskintf.cc.

00468 {
00469   if (axis < 0 || axis >= EMCMOT_MAX_AXIS)
00470   {
00471     return 0;
00472   }
00473 
00474   emcmotCommand.command = EMCMOT_SET_HOMING_VEL;
00475   emcmotCommand.axis = axis;
00476   emcmotCommand.vel = homingVel;
00477 
00478 #ifdef ISNAN_TRAP
00479   if (isnan(emcmotCommand.vel))
00480   {
00481     printf("isnan error in emcAxisSetHomingVel\n");
00482     return -1;
00483   }
00484 #endif
00485 
00486   return usrmotWriteEmcmotCommand(&emcmotCommand);
00487 }

int emcAxisSetInputScale int    axis,
double    scale,
double    offset
 

Definition at line 265 of file bridgeporttaskintf.cc.

00266 {
00267   if (axis < 0 || axis >= EMCMOT_MAX_AXIS)
00268   {
00269     return 0;
00270   }
00271 
00272   emcmotCommand.command = EMCMOT_SET_INPUT_SCALE;
00273   emcmotCommand.axis = axis;
00274   emcmotCommand.scale = scale;
00275   emcmotCommand.offset = offset;
00276 
00277 #ifdef ISNAN_TRAP
00278   if (isnan(emcmotCommand.scale) ||
00279       isnan(emcmotCommand.offset))
00280   {
00281     printf("isnan eror in emcAxisSetInputScale\n");
00282     return -1;
00283   }
00284 #endif
00285 
00286   return usrmotWriteEmcmotCommand(&emcmotCommand);
00287 }

int emcAxisSetMaxLimitSwitchPolarity int    axis,
int    level
 

Definition at line 562 of file bridgeporttaskintf.cc.

00563 {
00564   if (axis < 0)
00565   {
00566     axis = 0;
00567   }
00568   else if (axis >= EMCMOT_MAX_AXIS)
00569   {
00570     axis = EMCMOT_MAX_AXIS - 1;
00571   }
00572 
00573   emcmotCommand.command = EMCMOT_SET_POLARITY;
00574   emcmotCommand.axis = axis;
00575   emcmotCommand.level = level;
00576   emcmotCommand.axisFlag = EMCMOT_AXIS_MAX_HARD_LIMIT_BIT;
00577 
00578   return usrmotWriteEmcmotCommand(&emcmotCommand);
00579 }

int emcAxisSetMaxOutputLimit int    axis,
double    limit
 

Definition at line 398 of file bridgeporttaskintf.cc.

00399 {
00400   if (axis < 0 || axis >= EMCMOT_MAX_AXIS)
00401   {
00402     return 0;
00403   }
00404 
00405   emcmotCommand.command = EMCMOT_SET_OUTPUT_LIMITS;
00406   emcmotCommand.axis = axis;
00407   emcmotCommand.minLimit = saveMinOutput[axis];
00408   emcmotCommand.maxLimit = limit;
00409   saveMaxOutput[axis] = limit;
00410 
00411 #ifdef ISNAN_TRAP
00412   if (isnan(emcmotCommand.maxLimit) ||
00413       isnan(emcmotCommand.minLimit))
00414   {
00415     printf("isnan error in emcAxisSetMaxOutputLimit\n");
00416     return -1;
00417   }
00418 #endif
00419 
00420   return usrmotWriteEmcmotCommand(&emcmotCommand);
00421 }

int emcAxisSetMaxPositionLimit int    axis,
double    limit
 

Definition at line 343 of file bridgeporttaskintf.cc.

00344 {
00345   if (axis < 0 || axis >= EMCMOT_MAX_AXIS)
00346   {
00347     return 0;
00348   }
00349 
00350   emcmotCommand.command = EMCMOT_SET_POSITION_LIMITS;
00351   emcmotCommand.axis = axis;
00352   emcmotCommand.minLimit = saveMinLimit[axis];
00353   emcmotCommand.maxLimit = limit;
00354   saveMaxLimit[axis] = limit;
00355 
00356 #ifdef ISNAN_TRAP
00357   if (isnan(emcmotCommand.maxLimit) ||
00358       isnan(emcmotCommand.minLimit))
00359   {
00360     printf("isnan error in emcAxisSetMaxPosition\n");
00361     return -1;
00362   }
00363 #endif
00364 
00365   return usrmotWriteEmcmotCommand(&emcmotCommand);
00366 }

int emcAxisSetMaxVelocity int    axis,
double    vel
 

Definition at line 489 of file bridgeporttaskintf.cc.

00490 {
00491   if (axis < 0 || axis >= EMC_AXIS_MAX)
00492   {
00493     return 0;
00494   }
00495 
00496   if (vel < 0.0)
00497   {
00498     vel = 0.0;
00499   }
00500 
00501   AXIS_MAX_VELOCITY[axis] = vel;
00502 
00503   emcmotCommand.command = EMCMOT_SET_AXIS_VEL_LIMIT;
00504   emcmotCommand.axis = axis;
00505   emcmotCommand.vel = vel;
00506 
00507   return usrmotWriteEmcmotCommand(&emcmotCommand);
00508 }

int emcAxisSetMinFerror int    axis,
double    ferror
 

Definition at line 445 of file bridgeporttaskintf.cc.

00446 {
00447   if (axis < 0 || axis >= EMCMOT_MAX_AXIS)
00448   {
00449     return 0;
00450   }
00451 
00452   emcmotCommand.command = EMCMOT_SET_MIN_FERROR;
00453   emcmotCommand.axis = axis;
00454   emcmotCommand.minFerror = ferror;
00455 
00456 #ifdef ISNAN_TRAP
00457   if (isnan(emcmotCommand.minFerror))
00458   {
00459     printf("isnan error in emcAxisSetMinFerror\n");
00460     return -1;
00461   }
00462 #endif
00463 
00464   return usrmotWriteEmcmotCommand(&emcmotCommand);
00465 }

int emcAxisSetMinLimitSwitchPolarity int    axis,
int    level
 

Definition at line 547 of file bridgeporttaskintf.cc.

00548 {
00549   if (axis < 0 || axis >= EMCMOT_MAX_AXIS)
00550   {
00551     return 0;
00552   }
00553 
00554   emcmotCommand.command = EMCMOT_SET_POLARITY;
00555   emcmotCommand.axis = axis;
00556   emcmotCommand.level = level;
00557   emcmotCommand.axisFlag = EMCMOT_AXIS_MIN_HARD_LIMIT_BIT;
00558 
00559   return usrmotWriteEmcmotCommand(&emcmotCommand);
00560 }

int emcAxisSetMinOutputLimit int    axis,
double    limit
 

Definition at line 373 of file bridgeporttaskintf.cc.

00374 {
00375   if (axis < 0 || axis >= EMCMOT_MAX_AXIS)
00376   {
00377     return 0;
00378   }
00379 
00380   emcmotCommand.command = EMCMOT_SET_OUTPUT_LIMITS;
00381   emcmotCommand.axis = axis;
00382   emcmotCommand.maxLimit = saveMaxOutput[axis];
00383   emcmotCommand.minLimit = limit;
00384   saveMinOutput[axis] = limit;
00385 
00386 #ifdef ISNAN_TRAP
00387   if (isnan(emcmotCommand.maxLimit) ||
00388       isnan(emcmotCommand.minLimit))
00389   {
00390     printf("isnan error in emcAxisSetMinOutputLimit\n");
00391     return -1;
00392   }
00393 #endif
00394 
00395   return usrmotWriteEmcmotCommand(&emcmotCommand);
00396 }

int emcAxisSetMinPositionLimit int    axis,
double    limit
 

Definition at line 318 of file bridgeporttaskintf.cc.

00319 {
00320   if (axis < 0 || axis >= EMCMOT_MAX_AXIS)
00321   {
00322     return 0;
00323   }
00324 
00325   emcmotCommand.command = EMCMOT_SET_POSITION_LIMITS;
00326   emcmotCommand.axis = axis;
00327   emcmotCommand.maxLimit = saveMaxLimit[axis];
00328   emcmotCommand.minLimit = limit;
00329   saveMinLimit[axis] = limit;
00330 
00331 #ifdef ISNAN_TRAP
00332   if (isnan(emcmotCommand.maxLimit) ||
00333       isnan(emcmotCommand.minLimit))
00334   {
00335     printf("isnan error in emcAxisSetMinPosition\n");
00336     return -1;
00337   }
00338 #endif
00339 
00340   return usrmotWriteEmcmotCommand(&emcmotCommand);
00341 }

int emcAxisSetOutput int    axis,
double    output
 

Definition at line 732 of file bridgeporttaskintf.cc.

00733 {
00734   if (axis < 0 || axis >= EMCMOT_MAX_AXIS)
00735   {
00736     return 0;
00737   }
00738 
00739   emcmotCommand.command = EMCMOT_DAC_OUT;
00740   emcmotCommand.axis = axis;
00741   emcmotCommand.dacOut = output;
00742 
00743   return usrmotWriteEmcmotCommand(&emcmotCommand);
00744 }

int emcAxisSetOutputScale int    axis,
double    scale,
double    offset
 

Definition at line 289 of file bridgeporttaskintf.cc.

00290 {
00291   if (axis < 0 || axis >= EMCMOT_MAX_AXIS)
00292   {
00293     return 0;
00294   }
00295 
00296   emcmotCommand.command = EMCMOT_SET_OUTPUT_SCALE;
00297   emcmotCommand.axis = axis;
00298   emcmotCommand.scale = scale;
00299   emcmotCommand.offset = offset;
00300 
00301 #ifdef ISNAN_TRAP
00302   if (isnan(emcmotCommand.scale) ||
00303       isnan(emcmotCommand.offset))
00304   {
00305     printf("isnan eror in emcAxisSetOutputScale\n");
00306     return -1;
00307   }
00308 #endif
00309 
00310   return usrmotWriteEmcmotCommand(&emcmotCommand);
00311 }

int emcAxisSetUnits int    axis,
double    units
 

Definition at line 191 of file bridgeporttaskintf.cc.

00192 {
00193   if (axis < 0 || axis >= EMCMOT_MAX_AXIS)
00194   {
00195     return 0;
00196   }
00197 
00198   localEmcAxisUnits[axis] = units;
00199 
00200   return 0;
00201 }

int emcAxisUpdate EMC_AXIS_STAT    stat[],
int    numAxes
 

Definition at line 892 of file bridgeporttaskintf.cc.

00893 {
00894   int axis;
00895 
00896   // check for valid range
00897   if (numAxes <= 0 || numAxes > EMCMOT_MAX_AXIS) {
00898     return -1;
00899   }
00900 
00901   for (axis = 0; axis < numAxes; axis++) {
00902     stat[axis].axisType = localEmcAxisAxisType[axis];
00903     stat[axis].units = localEmcAxisUnits[axis];
00904 
00905     stat[axis].inputScale = emcmotStatus.inputScale[axis];
00906     stat[axis].inputOffset = emcmotStatus.inputOffset[axis];
00907     stat[axis].outputScale = emcmotStatus.outputScale[axis];
00908     stat[axis].outputOffset = emcmotStatus.outputOffset[axis];
00909 
00910     if (new_config) {
00911       stat[axis].p = emcmotConfig.pid[axis].p;
00912       stat[axis].i = emcmotConfig.pid[axis].i;
00913       stat[axis].d = emcmotConfig.pid[axis].d;
00914       stat[axis].ff0 = emcmotConfig.pid[axis].ff0;
00915       stat[axis].ff1 = emcmotConfig.pid[axis].ff1;
00916       stat[axis].ff2 = emcmotConfig.pid[axis].ff2;
00917       stat[axis].backlash = emcmotConfig.pid[axis].backlash;
00918       stat[axis].bias = emcmotConfig.pid[axis].bias;
00919       stat[axis].maxError = emcmotConfig.pid[axis].maxError;
00920       stat[axis].deadband = emcmotConfig.pid[axis].deadband;
00921       stat[axis].cycleTime = emcmotConfig.servoCycleTime;
00922       stat[axis].minPositionLimit = emcmotConfig.minLimit[axis];
00923       stat[axis].maxPositionLimit = emcmotConfig.maxLimit[axis];
00924       stat[axis].minOutputLimit = emcmotConfig.minOutput[axis];
00925       stat[axis].maxOutputLimit = emcmotConfig.maxOutput[axis];
00926       stat[axis].minFerror = emcmotConfig.minFerror[axis];
00927       stat[axis].maxFerror = emcmotConfig.maxFerror[axis];
00928       stat[axis].homeOffset = emcmotConfig.homeOffset[axis];
00929       stat[axis].enablePolarity = (emcmotConfig.axisPolarity[axis] &
00930                                    EMCMOT_AXIS_ENABLE_BIT) ? 1 : 0;
00931       stat[axis].minLimitSwitchPolarity = (emcmotConfig.axisPolarity[axis] &
00932                                            EMCMOT_AXIS_MIN_HARD_LIMIT_BIT) ? 1 : 0;
00933       stat[axis].maxLimitSwitchPolarity = (emcmotConfig.axisPolarity[axis] &
00934                                            EMCMOT_AXIS_MAX_HARD_LIMIT_BIT) ? 1 : 0;
00935       stat[axis].homeSwitchPolarity = (emcmotConfig.axisPolarity[axis] &
00936                                        EMCMOT_AXIS_HOME_SWITCH_BIT) ? 1 : 0;
00937       stat[axis].homingPolarity = (emcmotConfig.axisPolarity[axis] &
00938                                    EMCMOT_AXIS_HOMING_BIT) ? 1 : 0;
00939       stat[axis].faultPolarity = (emcmotConfig.axisPolarity[axis] &
00940                                   EMCMOT_AXIS_FAULT_BIT) ? 1 : 0;
00941     }
00942 
00943     stat[axis].setpoint = emcmotStatus.axisPos[axis];
00944      
00945     if (get_emcmot_debug_info) {
00946       stat[axis].ferrorCurrent = emcmotDebug.ferrorCurrent[axis];
00947       stat[axis].ferrorHighMark = emcmotDebug.ferrorHighMark[axis];
00948     }
00949       
00950     stat[axis].output = emcmotStatus.output[axis];
00951     stat[axis].input = emcmotStatus.input[axis];
00952     stat[axis].homing = (emcmotStatus.axisFlag[axis] & EMCMOT_AXIS_HOMING_BIT ? 1 : 0);
00953     stat[axis].homed = (emcmotStatus.axisFlag[axis] & EMCMOT_AXIS_HOMED_BIT ? 1 : 0);
00954     stat[axis].fault = (emcmotStatus.axisFlag[axis] & EMCMOT_AXIS_FAULT_BIT ? 1 : 0);
00955     stat[axis].enabled = (emcmotStatus.axisFlag[axis] & EMCMOT_AXIS_ENABLE_BIT ? 1 : 0);
00956 
00957     stat[axis].minSoftLimit = (emcmotStatus.axisFlag[axis] & EMCMOT_AXIS_MIN_SOFT_LIMIT_BIT ? 1 : 0);
00958     stat[axis].maxSoftLimit = (emcmotStatus.axisFlag[axis] & EMCMOT_AXIS_MAX_SOFT_LIMIT_BIT ? 1 : 0);
00959     stat[axis].minHardLimit = (emcmotStatus.axisFlag[axis] & EMCMOT_AXIS_MIN_HARD_LIMIT_BIT ? 1 : 0);
00960     stat[axis].maxHardLimit = (emcmotStatus.axisFlag[axis] & EMCMOT_AXIS_MAX_HARD_LIMIT_BIT ? 1 : 0);
00961     stat[axis].overrideLimits = (emcmotStatus.overrideLimits); // one for all
00962 
00963     stat[axis].scale = emcmotStatus.axVscale[axis];
00964     usrmotQueryAlter(axis, &stat[axis].alter);
00965 
00966     if (emcmotStatus.axisFlag[axis] & EMCMOT_AXIS_ERROR_BIT) {
00967       if (stat[axis].status != RCS_ERROR) {
00968         rcs_print_error("Error on axis %d.\n",axis);
00969         stat[axis].status = RCS_ERROR;
00970       }
00971     }
00972     else if (emcmotStatus.axisFlag[axis] & EMCMOT_AXIS_INPOS_BIT) {
00973       stat[axis].status = RCS_DONE;
00974     }
00975     else {
00976       stat[axis].status = RCS_EXEC;
00977     }
00978   }
00979 
00980   return 0;
00981 }

int emcCoolantFloodOff  
 

Definition at line 2049 of file bridgeporttaskintf.cc.

02050 {
02051   EMC_COOLANT_FLOOD_OFF floodOffMsg;
02052 
02053   sendCommand(&floodOffMsg);
02054 
02055   return 0;
02056 }

int emcCoolantFloodOn  
 

Definition at line 2040 of file bridgeporttaskintf.cc.

02041 {
02042   EMC_COOLANT_FLOOD_ON floodOnMsg;
02043 
02044   sendCommand(&floodOnMsg);
02045 
02046   return 0;
02047 }

int emcCoolantMistOff  
 

Definition at line 2031 of file bridgeporttaskintf.cc.

02032 {
02033   EMC_COOLANT_MIST_OFF mistOffMsg;
02034 
02035   sendCommand(&mistOffMsg);
02036 
02037   return 0;
02038 }

int emcCoolantMistOn  
 

Definition at line 2022 of file bridgeporttaskintf.cc.

02023 {
02024   EMC_COOLANT_MIST_ON mistOnMsg;
02025 
02026   sendCommand(&mistOnMsg);
02027 
02028   return 0;
02029 }

int emcIoAbort  
 

Definition at line 1896 of file bridgeporttaskintf.cc.

01897 {
01898   EMC_TOOL_ABORT ioAbortMsg;
01899 
01900   // send abort command to emcio
01901   forceCommand(&ioAbortMsg);
01902 
01903   return 0;
01904 }

int emcIoHalt  
 

Definition at line 1868 of file bridgeporttaskintf.cc.

01869 {
01870   EMC_TOOL_HALT ioHaltMsg;
01871 
01872   // send halt command to emcio
01873   if (emcIoCommandBuffer != 0)
01874   {
01875     forceCommand(&ioHaltMsg);
01876   }
01877 
01878   // clear out the buffers
01879 
01880   if (emcIoStatusBuffer != 0)
01881   {
01882     delete emcIoStatusBuffer;
01883     emcIoStatusBuffer = 0;
01884     emcIoStatus = 0;
01885   }
01886 
01887   if (emcIoCommandBuffer != 0)
01888   {
01889     delete emcIoCommandBuffer;
01890     emcIoCommandBuffer = 0;
01891   }
01892 
01893   return 0;
01894 }

int emcIoInit  
 

Definition at line 1853 of file bridgeporttaskintf.cc.

01854 {
01855   EMC_TOOL_INIT ioInitMsg;
01856   int retval;
01857 
01858   // get NML buffer to emcio
01859   if (0 != (retval = emcioNmlGet()))
01860   {
01861     return -1;
01862   }
01863 
01864   // send init command to emcio
01865   return forceCommand(&ioInitMsg);
01866 }

int emcIoSetDebug int    debug
 

Definition at line 1906 of file bridgeporttaskintf.cc.

01907 {
01908   EMC_SET_DEBUG ioDebugMsg;
01909 
01910   ioDebugMsg.debug = debug;
01911 
01912   return sendCommand(&ioDebugMsg);
01913 }

int emcIoUpdate EMC_IO_STAT   stat
 

Definition at line 2267 of file bridgeporttaskintf.cc.

02268 {
02269   if (0 == emcIoStatusBuffer ||
02270       ! emcIoStatusBuffer->valid())
02271   {
02272     return -1;
02273   }
02274 
02275   switch (emcIoStatusBuffer->peek())
02276   {
02277     case -1:
02278       // error on CMS channel
02279       return -1;
02280       break;
02281 
02282     case 0:                     // nothing new
02283     case EMC_IO_STAT_TYPE:      // something new
02284       // drop out to copy
02285       break;
02286 
02287     default:
02288       // something else is in there
02289       return -1;
02290       break;
02291   }
02292 
02293   // copy status
02294   *stat = *emcIoStatus;
02295 
02296   /*
02297     We need to check that the RCS_DONE isn't left over from the previous
02298     command, by comparing the command number we sent with the command
02299     number that emcio echoes. If they're different, then the command hasn't
02300     been acknowledged yet and the state should be forced to be RCS_EXEC.
02301   */
02302   if (stat->echo_serial_number != emcIoCommandSerialNumber)
02303   {
02304     stat->status = RCS_EXEC;
02305   }
02306 
02307   return 0;
02308 }

int emcLogClose  
 

Definition at line 2238 of file bridgeporttaskintf.cc.

02239 {
02240   int r1;
02241   int r2;
02242 
02243   // first check for active log, return nicely if not
02244   if (emcStatus->logFile[0] == 0 ||
02245       emcStatus->logSize == 0)
02246   {
02247     return 0;
02248   }
02249 
02250   emcmotCommand.command = EMCMOT_CLOSE_LOG;
02251 
02252   r1 = usrmotWriteEmcmotCommand(&emcmotCommand);
02253   r2 = usrmotDumpLog(emcStatus->logFile, EMCLOG_INCLUDE_HEADER);
02254 
02255   emcStatus->logFile[0] = 0;
02256   emcStatus->logType = 0;
02257   emcStatus->logSize = 0;
02258   emcStatus->logSkip = 0;
02259   emcStatus->logOpen = 0;
02260   emcStatus->logStarted = 0;
02261 
02262   return (r1 || r2 ? -1 : 0);
02263 }

int emcLogOpen char *    file,
int    type,
int    size,
int    skip,
int    which,
int    triggerType,
int    triggerVar,
double    triggerThreshold
 

Definition at line 2157 of file bridgeporttaskintf.cc.

02158 {
02159   int r1;
02160 
02161   emcmotCommand.command = EMCMOT_OPEN_LOG;
02162   emcmotCommand.logSize = size;
02163   emcmotCommand.logSkip = skip;
02164   emcmotCommand.axis = which;
02165 
02166   // Note that EMC NML and emcmot will be different, in general--
02167   // need to map types
02168   switch (type)
02169   {
02170     case EMC_LOG_TYPE_AXIS_POS:
02171       emcmotCommand.logType = EMCMOT_LOG_TYPE_AXIS_POS;
02172       break;
02173 
02174     case EMC_LOG_TYPE_AXES_INPOS:
02175       emcmotCommand.logType = EMCMOT_LOG_TYPE_ALL_INPOS;
02176       break;
02177 
02178     case EMC_LOG_TYPE_AXES_OUTPOS:
02179       emcmotCommand.logType = EMCMOT_LOG_TYPE_ALL_OUTPOS;
02180       break;
02181 
02182     case EMC_LOG_TYPE_AXIS_VEL:
02183       emcmotCommand.logType = EMCMOT_LOG_TYPE_AXIS_VEL;
02184       break;
02185 
02186     case EMC_LOG_TYPE_AXES_FERROR:
02187       emcmotCommand.logType = EMCMOT_LOG_TYPE_ALL_FERROR;
02188       break;
02189 
02190     case EMC_LOG_TYPE_TRAJ_POS:
02191       emcmotCommand.logType = EMCMOT_LOG_TYPE_TRAJ_POS;
02192       break;
02193 
02194     case EMC_LOG_TYPE_TRAJ_VEL:
02195       emcmotCommand.logType = EMCMOT_LOG_TYPE_TRAJ_VEL;
02196       break;
02197 
02198     case EMC_LOG_TYPE_TRAJ_ACC:
02199       emcmotCommand.logType = EMCMOT_LOG_TYPE_TRAJ_ACC;
02200       break;
02201 
02202     case EMC_LOG_TYPE_POS_VOLTAGE:
02203       emcmotCommand.logType = EMCMOT_LOG_TYPE_POS_VOLTAGE;
02204       break;
02205 
02206     default:
02207       return -1;
02208   }
02209   emcmotCommand.logTriggerType = triggerType;
02210   emcmotCommand.logTriggerVariable = triggerVar;
02211   emcmotCommand.logTriggerThreshold = triggerThreshold;
02212 
02213   r1 = usrmotWriteEmcmotCommand(&emcmotCommand);
02214 
02215   if (r1 == 0)
02216   {
02217     strncpy(emcStatus->logFile, file, EMC_LOG_FILENAME_LEN - 1);
02218     emcStatus->logFile[EMC_LOG_FILENAME_LEN - 1] = 0;
02219   }
02220   // type, size, skip, open, and started will be gotten out of
02221   // subsystem status, e.g., emcTrajUpdate()
02222 
02223   return r1;
02224 }

int emcLogStart  
 

Definition at line 2226 of file bridgeporttaskintf.cc.

02227 {
02228   emcmotCommand.command = EMCMOT_START_LOG;
02229   return(usrmotWriteEmcmotCommand(&emcmotCommand));
02230 }

int emcLogStop  
 

Definition at line 2232 of file bridgeporttaskintf.cc.

02233 {
02234   emcmotCommand.command = EMCMOT_STOP_LOG;
02235   return(usrmotWriteEmcmotCommand(&emcmotCommand));
02236 }

int emcLubeAbort  
 

Definition at line 2078 of file bridgeporttaskintf.cc.

02079 {
02080   EMC_LUBE_ABORT lubeAbortMsg;
02081 
02082   sendCommand(&lubeAbortMsg);
02083 
02084   return 0;
02085 }

int emcLubeHalt  
 

Definition at line 2069 of file bridgeporttaskintf.cc.

02070 {
02071   EMC_LUBE_HALT lubeHaltMsg;
02072 
02073   sendCommand(&lubeHaltMsg);
02074 
02075   return 0;
02076 }

int emcLubeInit  
 

Definition at line 2060 of file bridgeporttaskintf.cc.

02061 {
02062   EMC_LUBE_INIT lubeInitMsg;
02063 
02064   sendCommand(&lubeInitMsg);
02065 
02066   return 0;
02067 }

int emcLubeOff  
 

Definition at line 2096 of file bridgeporttaskintf.cc.

02097 {
02098   EMC_LUBE_OFF lubeOffMsg;
02099 
02100   sendCommand(&lubeOffMsg);
02101 
02102   return 0;
02103 }

int emcLubeOn  
 

Definition at line 2087 of file bridgeporttaskintf.cc.

02088 {
02089   EMC_LUBE_ON lubeOnMsg;
02090 
02091   sendCommand(&lubeOnMsg);
02092 
02093   return 0;
02094 }

int emcMotionAbort  
 

Definition at line 1535 of file bridgeporttaskintf.cc.

01536 {
01537   int r1;
01538   int r2;
01539   int t;
01540 
01541   r1 = -1;
01542   for (t = 0; t < EMCMOT_MAX_AXIS; t++)
01543   {
01544     if (0 == emcAxisAbort(t))
01545     {
01546       r1 = 0;               // at least one is okay
01547     }
01548   }
01549 
01550   r2 = emcTrajAbort();
01551 
01552   // reset optimization flag which suppresses duplicate speed requests
01553   lastVel = -1.0;
01554 
01555   return (r1 == 0 &&
01556           r2 == 0) ? 0 : -1;
01557 }

int emcMotionHalt  
 

Definition at line 1513 of file bridgeporttaskintf.cc.

01514 {
01515   int r1;
01516   int r2;
01517   int t;
01518 
01519   r1 = -1;
01520   for (t = 0; t < EMCMOT_MAX_AXIS; t++)
01521   {
01522     if (0 == emcAxisHalt(t))
01523     {
01524       r1 = 0;               // at least one is okay
01525     }
01526   }
01527 
01528   r2 = emcTrajHalt();
01529 
01530   emcmotion_initialized=0;
01531   return (r1 == 0 &&
01532           r2 == 0) ? 0 : -1;
01533 }

int emcMotionInit  
 

Definition at line 1487 of file bridgeporttaskintf.cc.

01488 {
01489   int r1;
01490   int r2;
01491   int axis;
01492 
01493   r1 = -1;
01494   for (axis = 0; axis < EMCMOT_MAX_AXIS; axis++)
01495   {
01496     if (0 == emcAxisInit(axis))
01497     {
01498       r1 = 0;               // at least one is okay
01499     }
01500   }
01501 
01502   r2 = emcTrajInit();
01503 
01504   if(r1 == 0 && r2 == 0)
01505   {
01506     emcmotion_initialized=1;
01507   }
01508 
01509   return (r1 == 0 &&
01510           r2 == 0) ? 0 : -1;
01511 }

int emcMotionSetAout unsigned char    index,
double    start,
double    end
 

Definition at line 1566 of file bridgeporttaskintf.cc.

01567 {
01568   emcmotCommand.command = EMCMOT_SET_AOUT;
01569   /* FIXME-- if this works, set up some dedicated cmd fields instead of
01570      borrowing these */
01571   emcmotCommand.out = index;
01572   emcmotCommand.minLimit = start;
01573   emcmotCommand.maxLimit = end;
01574 
01575   return usrmotWriteEmcmotCommand(&emcmotCommand);
01576 }

int emcMotionSetDebug int    debug
 

Definition at line 1559 of file bridgeporttaskintf.cc.

01560 {
01561   emcmotCommand.command = EMCMOT_ABORT;
01562 
01563   return usrmotWriteEmcmotCommand(&emcmotCommand);
01564 }

int emcMotionSetDout unsigned char    index,
unsigned char    start,
unsigned char    end
 

Definition at line 1578 of file bridgeporttaskintf.cc.

01579 {
01580   emcmotCommand.command = EMCMOT_SET_DOUT;
01581   emcmotCommand.out = index;
01582   emcmotCommand.start = start;
01583   emcmotCommand.end = end;
01584 
01585   return usrmotWriteEmcmotCommand(&emcmotCommand);
01586 }

int emcMotionUpdate EMC_MOTION_STAT   stat
 

Definition at line 1588 of file bridgeporttaskintf.cc.

01589 {
01590   int r1;
01591   int r2;
01592   int axis;
01593   int error;
01594   int exec;
01595 
01596   // read the emcmot status
01597   if (0 != usrmotReadEmcmotStatus(&emcmotStatus)) {
01598     return -1;
01599   }
01600 
01601   new_config = 0;
01602   if (emcmotStatus.config_num != emcmotConfig.config_num) {
01603     if (0 != usrmotReadEmcmotConfig(&emcmotConfig)) {
01604       return -1;
01605     }
01606     new_config = 1;
01607   }
01608 
01609   if (get_emcmot_debug_info) {
01610     if (0 != usrmotReadEmcmotDebug(&emcmotDebug)) {
01611       return -1;
01612     }
01613   }
01614 
01615   // read the emcmot error
01616   if (0 != usrmotReadEmcmotError(errorString)) {
01617     // no error, so ignore
01618   }
01619   else {
01620     // an error to report
01621     emcOperatorError(0, errorString);
01622   }
01623 
01624   // save the heartbeat and command number locally,
01625   // for use with emcMotionUpdate
01626   localMotionHeartbeat = emcmotStatus.heartbeat;
01627   localMotionCommandType = emcmotStatus.commandEcho; // FIXME-- not NML one!
01628   localMotionEchoSerialNumber = emcmotStatus.commandNumEcho;
01629 
01630   r1 = emcAxisUpdate(&stat->axis[0], EMCMOT_MAX_AXIS);
01631   r2 = emcTrajUpdate(&stat->traj);
01632   stat->heartbeat = localMotionHeartbeat;
01633   stat->command_type = localMotionCommandType;
01634   stat->echo_serial_number = localMotionEchoSerialNumber;
01635   stat->debug = emcmotConfig.debug;
01636 
01637   // set the status flag
01638   error = 0;
01639   exec = 0;
01640 
01641   for (axis = 0; axis < stat->traj.axes; axis++) {
01642     if (stat->axis[axis].status == RCS_ERROR) {
01643       error = 1;
01644       break;
01645     }
01646     if (stat->axis[axis].status == RCS_EXEC) {
01647       exec = 1;
01648       break;
01649     }
01650   }
01651 
01652   if (stat->traj.status == RCS_ERROR) {
01653     error = 1;
01654   }
01655   else if (stat->traj.status == RCS_EXEC) {
01656     exec = 1;
01657   }
01658 
01659   if (error) {
01660     stat->status = RCS_ERROR;
01661   }
01662   else if (exec) {
01663     stat->status = RCS_EXEC;
01664   }
01665   else {
01666     stat->status = RCS_DONE;
01667   }
01668 
01669   return (r1 == 0 &&
01670           r2 == 0) ? 0 : -1;
01671 }

int emcSpindleAbort  
 

Definition at line 1929 of file bridgeporttaskintf.cc.

01930 {
01931   return emcSpindleOff();
01932 }

int emcSpindleBrakeEngage  
 

Definition at line 1962 of file bridgeporttaskintf.cc.

01963 {
01964   EMC_SPINDLE_BRAKE_ENGAGE spindleBrakeEngageMsg;
01965 
01966   sendCommand(&spindleBrakeEngageMsg);
01967 
01968   return 0;
01969 }

int emcSpindleBrakeRelease  
 

Definition at line 1953 of file bridgeporttaskintf.cc.

01954 {
01955   EMC_SPINDLE_BRAKE_RELEASE spindleBrakeReleaseMsg;
01956 
01957   sendCommand(&spindleBrakeReleaseMsg);
01958 
01959   return 0;
01960 }

int emcSpindleConstant  
 

Definition at line 1989 of file bridgeporttaskintf.cc.

01990 {
01991   EMC_SPINDLE_CONSTANT spindleConstantMsg;
01992 
01993   sendCommand(&spindleConstantMsg);
01994 
01995   return 0;
01996 }

int emcSpindleDecrease  
 

Definition at line 1980 of file bridgeporttaskintf.cc.

01981 {
01982   EMC_SPINDLE_DECREASE spindleDecreaseMsg;
01983 
01984   sendCommand(&spindleDecreaseMsg);
01985 
01986   return 0;
01987 }

int emcSpindleIncrease  
 

Definition at line 1971 of file bridgeporttaskintf.cc.

01972 {
01973   EMC_SPINDLE_INCREASE spindleIncreaseMsg;
01974 
01975   sendCommand(&spindleIncreaseMsg);
01976 
01977   return 0;
01978 }

int emcSpindleOff  
 

Definition at line 1944 of file bridgeporttaskintf.cc.

01945 {
01946   EMC_SPINDLE_OFF spindleOffMsg;
01947 
01948   sendCommand(&spindleOffMsg);
01949 
01950   return 0;
01951 }

int emcSpindleOn double    speed
 

Definition at line 1934 of file bridgeporttaskintf.cc.

01935 {
01936   EMC_SPINDLE_ON spindleOnMsg;
01937 
01938   spindleOnMsg.speed = speed;
01939   sendCommand(&spindleOnMsg);
01940 
01941   return 0;
01942 }

int emcToolLoad  
 

Definition at line 2115 of file bridgeporttaskintf.cc.

02116 {
02117   EMC_TOOL_LOAD toolLoadMsg;
02118 
02119   sendCommand(&toolLoadMsg);
02120 
02121   return 0;
02122 }

int emcToolLoadToolTable const char *    file
 

Definition at line 2133 of file bridgeporttaskintf.cc.

02134 {
02135   EMC_TOOL_LOAD_TOOL_TABLE toolLoadToolTableMsg;
02136 
02137   strcpy(toolLoadToolTableMsg.file, file);
02138 
02139   sendCommand(&toolLoadToolTableMsg);
02140 
02141   return 0;
02142 }

int emcToolPrepare int    tool
 

Definition at line 2105 of file bridgeporttaskintf.cc.

02106 {
02107   EMC_TOOL_PREPARE toolPrepareMsg;
02108 
02109   toolPrepareMsg.tool = tool;
02110   sendCommand(&toolPrepareMsg);
02111 
02112   return 0;
02113 }

int emcToolSetOffset int    tool,
double    length,
double    diameter
 

Definition at line 2144 of file bridgeporttaskintf.cc.

02145 {
02146   EMC_TOOL_SET_OFFSET toolSetOffsetMsg;
02147 
02148   toolSetOffsetMsg.tool = tool;
02149   toolSetOffsetMsg.length = length;
02150   toolSetOffsetMsg.diameter = diameter;
02151 
02152   sendCommand(&toolSetOffsetMsg);
02153 
02154   return 0;
02155 }

int emcToolUnload  
 

Definition at line 2124 of file bridgeporttaskintf.cc.

02125 {
02126   EMC_TOOL_UNLOAD toolUnloadMsg;
02127 
02128   sendCommand(&toolUnloadMsg);
02129 
02130   return 0;
02131 }

int emcTrajAbort  
 

Definition at line 1242 of file bridgeporttaskintf.cc.

01243 {
01244   emcmotCommand.command = EMCMOT_ABORT;
01245 
01246   return usrmotWriteEmcmotCommand(&emcmotCommand);
01247 }

int emcTrajCircularMove EmcPose    end,
PM_CARTESIAN    center,
PM_CARTESIAN    normal,
int    turn
 

Definition at line 1306 of file bridgeporttaskintf.cc.

01308 {
01309   emcmotCommand.command = EMCMOT_SET_CIRCLE;
01310 
01311   emcmotCommand.pos  = end;
01312 
01313   emcmotCommand.center.x = center.x;
01314   emcmotCommand.center.y = center.y;
01315   emcmotCommand.center.z = center.z;
01316 
01317   emcmotCommand.normal.x = normal.x;
01318   emcmotCommand.normal.y = normal.y;
01319   emcmotCommand.normal.z = normal.z;
01320 
01321   emcmotCommand.turn = turn;
01322   emcmotCommand.id = localEmcTrajMotionId;
01323 
01324 #ifdef ISNAN_TRAP
01325   if (isnan(emcmotCommand.pos.tran.x) ||
01326       isnan(emcmotCommand.pos.tran.y) ||
01327       isnan(emcmotCommand.pos.tran.z) ||
01328       isnan(emcmotCommand.pos.a) ||
01329       isnan(emcmotCommand.pos.b) ||
01330       isnan(emcmotCommand.pos.c) ||
01331       isnan(emcmotCommand.center.x) ||
01332       isnan(emcmotCommand.center.y) ||
01333       isnan(emcmotCommand.center.z) ||
01334       isnan(emcmotCommand.normal.x) ||
01335       isnan(emcmotCommand.normal.y) ||
01336       isnan(emcmotCommand.normal.z))
01337   {
01338     printf("isnan error in emcTrajCircularMove\n");
01339     return 0;                 // ignore it for now, just don't send it
01340   }
01341 #endif
01342 
01343   return usrmotWriteEmcmotCommand(&emcmotCommand);
01344 }

int emcTrajClearProbeTrippedFlag  
 

Definition at line 1362 of file bridgeporttaskintf.cc.

01363 {
01364   emcmotCommand.command = EMCMOT_CLEAR_PROBE_FLAGS;
01365 
01366   return usrmotWriteEmcmotCommand(&emcmotCommand);
01367 }

int emcTrajDelay double    delay
 

Definition at line 1270 of file bridgeporttaskintf.cc.

01271 {
01272   // nothing need be done here-- it's done in task controller
01273 
01274   return 0;
01275 }

int emcTrajDisable  
 

Definition at line 1235 of file bridgeporttaskintf.cc.

01236 {
01237   emcmotCommand.command = EMCMOT_DISABLE;
01238 
01239   return usrmotWriteEmcmotCommand(&emcmotCommand);
01240 }

int emcTrajEnable  
 

Definition at line 1228 of file bridgeporttaskintf.cc.

01229 {
01230   emcmotCommand.command = EMCMOT_ENABLE;
01231 
01232   return usrmotWriteEmcmotCommand(&emcmotCommand);
01233 }

int emcTrajHalt  
 

Definition at line 1217 of file bridgeporttaskintf.cc.

01218 {
01219   if (! emcmotAxisInited)       // axis clears its inited flag on exit
01220   {
01221     usrmotExit();             // ours is final exit
01222   }
01223   emcmotTrajInited = 0;
01224 
01225   return 0;
01226 }

int emcTrajInit  
 

Definition at line 1191 of file bridgeporttaskintf.cc.

01192 {
01193   int retval = 0;
01194 
01195   // init emcmot interface
01196   if (! emcmotAxisInited &&
01197       ! emcmotTrajInited)
01198   {
01199     usrmotIniLoad(EMC_INIFILE);
01200 
01201     if (0 != usrmotInit())
01202     {
01203       return -1;
01204     }
01205   }
01206   emcmotTrajInited = 1;
01207 
01208   // initialize parameters from ini file
01209   if (0 != iniTraj(EMC_INIFILE))
01210   {
01211     retval = -1;
01212   }
01213 
01214   return retval;
01215 }

int emcTrajLinearMove EmcPose    end
 

Definition at line 1285 of file bridgeporttaskintf.cc.

01286 {
01287   emcmotCommand.command = EMCMOT_SET_LINE;
01288 
01289   emcmotCommand.pos = end;
01290 
01291   emcmotCommand.id = localEmcTrajMotionId;
01292 
01293 #ifdef ISNAN_TRAP
01294   if (isnan(emcmotCommand.pos.tran.x) ||
01295       isnan(emcmotCommand.pos.tran.y) ||
01296       isnan(emcmotCommand.pos.tran.z))
01297   {
01298     printf("isnan error in emcTrajLinearMove\n");
01299     return 0;                 // ignore it for now, just don't send it
01300   }
01301 #endif
01302 
01303   return usrmotWriteEmcmotCommand(&emcmotCommand);
01304 }

int emcTrajPause  
 

Definition at line 1249 of file bridgeporttaskintf.cc.

01250 {
01251   emcmotCommand.command = EMCMOT_PAUSE;
01252 
01253   return usrmotWriteEmcmotCommand(&emcmotCommand);
01254 }

int emcTrajProbe EmcPose    pos
 

Definition at line 1369 of file bridgeporttaskintf.cc.

01370 {
01371   emcmotCommand.command = EMCMOT_PROBE;
01372   emcmotCommand.pos.tran.x = pos.tran.x;
01373   emcmotCommand.pos.tran.y = pos.tran.y;
01374   emcmotCommand.pos.tran.z = pos.tran.z;
01375   emcmotCommand.id = localEmcTrajMotionId;
01376   return usrmotWriteEmcmotCommand(&emcmotCommand);
01377 }

int emcTrajResume  
 

Definition at line 1263 of file bridgeporttaskintf.cc.

01264 {
01265   emcmotCommand.command = EMCMOT_RESUME;
01266 
01267   return usrmotWriteEmcmotCommand(&emcmotCommand);
01268 }

int emcTrajSetAcceleration double    acc
 

Definition at line 1095 of file bridgeporttaskintf.cc.

01096 {
01097   if (acc < 0.0)
01098   {
01099     acc = 0.0;
01100   }
01101   else if (acc > localEmcMaxAcceleration)
01102   {
01103     acc = localEmcMaxAcceleration;
01104   }
01105 
01106   emcmotCommand.command = EMCMOT_SET_ACC;
01107   emcmotCommand.acc = acc;
01108 
01109   return usrmotWriteEmcmotCommand(&emcmotCommand);
01110 }

int emcTrajSetAxes int    axes
 

Definition at line 991 of file bridgeporttaskintf.cc.

00992 {
00993   if (axes <= 0 || axes > EMCMOT_MAX_AXIS)
00994   {
00995     return -1;
00996   }
00997 
00998   localEmcTrajAxes = axes;
00999 
01000   return 0;
01001 }

int emcTrajSetCycleTime double    cycleTime
 

Definition at line 1017 of file bridgeporttaskintf.cc.

01018 {
01019   if (cycleTime <= 0.0)
01020   {
01021     return -1;
01022   }
01023 
01024   emcmotCommand.command = EMCMOT_SET_TRAJ_CYCLE_TIME;
01025   emcmotCommand.cycleTime = cycleTime;
01026 
01027   return usrmotWriteEmcmotCommand(&emcmotCommand);
01028 }

int emcTrajSetHome EmcPose    home
 

Definition at line 1143 of file bridgeporttaskintf.cc.

01144 {
01145   emcmotCommand.command = EMCMOT_SET_WORLD_HOME;
01146 
01147   emcmotCommand.pos = home;
01148 
01149 
01150 #ifdef ISNAN_TRAP
01151   if (isnan(emcmotCommand.pos.tran.x) ||
01152       isnan(emcmotCommand.pos.tran.y) ||
01153       isnan(emcmotCommand.pos.tran.z))
01154   {
01155     printf("isnan error in emcTrajSetHome\n");
01156     return 0;                 // ignore it for now, just don't send it
01157   }
01158 #endif
01159 
01160   return usrmotWriteEmcmotCommand(&emcmotCommand);
01161 }

int emcTrajSetMaxAcceleration double    acc
 

Definition at line 1131 of file bridgeporttaskintf.cc.

01132 {
01133   if (acc < 0.0)
01134   {
01135     acc = 0.0;
01136   }
01137 
01138   localEmcMaxAcceleration = acc;
01139 
01140   return 0;
01141 }

int emcTrajSetMaxVelocity double    vel
 

Definition at line 1116 of file bridgeporttaskintf.cc.

01117 {
01118   if (vel < 0.0)
01119   {
01120     vel = 0.0;
01121   }
01122 
01123   TRAJ_MAX_VELOCITY = vel;
01124 
01125   emcmotCommand.command = EMCMOT_SET_VEL_LIMIT;
01126   emcmotCommand.vel = vel;
01127 
01128   return usrmotWriteEmcmotCommand(&emcmotCommand);
01129 }

int emcTrajSetMode int    mode
 

Definition at line 1030 of file bridgeporttaskintf.cc.

01031 {
01032   switch (mode)
01033   {
01034     case EMC_TRAJ_MODE_FREE:
01035       emcmotCommand.command = EMCMOT_FREE;
01036       return usrmotWriteEmcmotCommand(&emcmotCommand);
01037 
01038     case EMC_TRAJ_MODE_COORD:
01039       emcmotCommand.command = EMCMOT_COORD;
01040       return usrmotWriteEmcmotCommand(&emcmotCommand);
01041 
01042     case EMC_TRAJ_MODE_TELEOP:
01043       emcmotCommand.command = EMCMOT_TELEOP;
01044       return usrmotWriteEmcmotCommand(&emcmotCommand);
01045 
01046     default:
01047       return -1;
01048   }
01049 }

int emcTrajSetMotionId int    id
 

Definition at line 1176 of file bridgeporttaskintf.cc.

01177 {
01178 
01179   if(EMC_DEBUG_MOTION_TIME & EMC_DEBUG)
01180     {
01181       if(id != localEmcTrajMotionId)
01182         {
01183           rcs_print("Outgoing motion id is %d.\n",id);
01184         }
01185     }
01186   localEmcTrajMotionId = id;
01187 
01188   return 0;
01189 }

int emcTrajSetProbeIndex int    index
 

Definition at line 1346 of file bridgeporttaskintf.cc.

01347 {
01348   emcmotCommand.command = EMCMOT_SET_PROBE_INDEX;
01349   emcmotCommand.probeIndex = index;
01350 
01351   return usrmotWriteEmcmotCommand(&emcmotCommand);
01352 }

int emcTrajSetProbePolarity int    polarity
 

Definition at line 1354 of file bridgeporttaskintf.cc.

01355 {
01356   emcmotCommand.command = EMCMOT_SET_PROBE_POLARITY;
01357   emcmotCommand.level = polarity;
01358 
01359   return usrmotWriteEmcmotCommand(&emcmotCommand);
01360 }

int emcTrajSetScale double    scale
 

Definition at line 1163 of file bridgeporttaskintf.cc.

01164 {
01165   if (scale < 0.0)
01166   {
01167     scale = 0.0;
01168   }
01169 
01170   emcmotCommand.command = EMCMOT_SCALE;
01171   emcmotCommand.scale = scale;
01172 
01173   return usrmotWriteEmcmotCommand(&emcmotCommand);
01174 }

int emcTrajSetTeleopVector EmcPose    vel
 

Definition at line 1053 of file bridgeporttaskintf.cc.

01054 {
01055   emcmotCommand.command = EMCMOT_SET_TELEOP_VECTOR;
01056   emcmotCommand.pos = vel;
01057   return usrmotWriteEmcmotCommand(&emcmotCommand);
01058 }

int emcTrajSetTermCond int    cond
 

Definition at line 1277 of file bridgeporttaskintf.cc.

01278 {
01279   emcmotCommand.command = EMCMOT_SET_TERM_COND;
01280   emcmotCommand.termCond = (cond == EMC_TRAJ_TERM_COND_STOP ? EMCMOT_TERM_COND_STOP : EMCMOT_TERM_COND_BLEND);
01281 
01282   return usrmotWriteEmcmotCommand(&emcmotCommand);
01283 }

int emcTrajSetUnits double    linearUnits,
double    angularUnits
 

Definition at line 1003 of file bridgeporttaskintf.cc.

01004 {
01005   if (linearUnits <= 0.0 ||
01006       angularUnits <= 0.0)
01007   {
01008     return -1;
01009   }
01010 
01011   localEmcTrajLinearUnits = linearUnits;
01012   localEmcTrajAngularUnits = angularUnits;
01013 
01014   return 0;
01015 }

int emcTrajSetVelocity double    vel
 

Definition at line 1060 of file bridgeporttaskintf.cc.

01061 {
01062   int retval;
01063 
01064   if (vel < 0.0)
01065   {
01066     vel = 0.0;
01067   }
01068   else if (vel > TRAJ_MAX_VELOCITY)
01069   {
01070     vel = TRAJ_MAX_VELOCITY;
01071   }
01072 
01073 #if 0
01074   // FIXME-- this fixes rapid rate reset problem
01075   if (vel == lastVel)
01076   {
01077     // suppress it
01078     return 0;
01079   }
01080 #endif
01081 
01082   emcmotCommand.command = EMCMOT_SET_VEL;
01083   emcmotCommand.vel = vel;
01084 
01085   retval = usrmotWriteEmcmotCommand(&emcmotCommand);
01086 
01087   if (0 == retval)
01088   {
01089     lastVel = vel;
01090   }
01091 
01092   return retval;
01093 }

int emcTrajStep  
 

Definition at line 1256 of file bridgeporttaskintf.cc.

01257 {
01258   emcmotCommand.command = EMCMOT_STEP;
01259 
01260   return usrmotWriteEmcmotCommand(&emcmotCommand);
01261 }

int emcTrajUpdate EMC_TRAJ_STAT   stat
 

Definition at line 1384 of file bridgeporttaskintf.cc.

01385 {
01386   int axis;
01387 
01388   stat->axes = localEmcTrajAxes;
01389   stat->linearUnits = localEmcTrajLinearUnits;
01390   stat->angularUnits = localEmcTrajAngularUnits;
01391 
01392   stat->mode = 
01393     emcmotStatus.motionFlag & EMCMOT_MOTION_TELEOP_BIT ? EMC_TRAJ_MODE_TELEOP :
01394     ( emcmotStatus.motionFlag & EMCMOT_MOTION_COORD_BIT ? EMC_TRAJ_MODE_COORD : 
01395       EMC_TRAJ_MODE_FREE ) ;
01396 
01397   // enabled iff motion enabled and all axes enabled
01398   stat->enabled = 0;            // start at disabled
01399   if (emcmotStatus.motionFlag & EMCMOT_MOTION_ENABLE_BIT) {
01400     for (axis = 0; axis < localEmcTrajAxes; axis++) {
01401       if (! emcmotStatus.axisFlag[axis] & EMCMOT_AXIS_ENABLE_BIT) {
01402         break;
01403       }
01404 
01405       // got here, then all are enabled
01406       stat->enabled = 1;
01407     }
01408   }
01409 
01410   stat->inpos = emcmotStatus.motionFlag & EMCMOT_MOTION_INPOS_BIT ? 1 : 0;
01411   stat->queue = emcmotStatus.depth;
01412   stat->activeQueue = emcmotStatus.activeDepth;
01413   stat->queueFull = emcmotStatus.queueFull;
01414   stat->id = emcmotStatus.id;
01415   if (EMC_DEBUG_MOTION_TIME & EMC_DEBUG) {
01416     if (stat->id != last_id) {
01417       if (last_id != last_id_printed) {
01418         rcs_print("Motion id %d took %f seconds.\n",last_id, etime()-last_id_time);
01419         last_id_printed = last_id;
01420       }
01421       last_id = stat->id;
01422       last_id_time = etime();
01423     }
01424   }
01425 
01426   stat->paused = emcmotStatus.paused;
01427   stat->scale = emcmotStatus.qVscale;
01428 
01429   stat->position = emcmotStatus.pos;
01430 
01431   stat->actualPosition = emcmotStatus.actualPos;
01432 
01433   stat->velocity = emcmotStatus.vel;
01434   stat->acceleration = emcmotStatus.acc;
01435   stat->maxAcceleration = localEmcMaxAcceleration;
01436 
01437   if (emcmotStatus.motionFlag & EMCMOT_MOTION_ERROR_BIT) {
01438     stat->status = RCS_ERROR;
01439   }
01440   else if (stat->inpos &&
01441            (stat->queue == 0)) {
01442     stat->status = RCS_DONE;
01443   }
01444   else {
01445     stat->status = RCS_EXEC;
01446   }
01447 
01448   if (EMC_DEBUG_MOTION_TIME & EMC_DEBUG) {
01449     if(stat->status == RCS_DONE && last_status != RCS_DONE && stat->id != last_id_printed) {
01450       rcs_print("Motion id %d took %f seconds.\n",last_id, etime()-last_id_time);
01451       last_id_printed = last_id = stat->id;
01452       last_id_time = etime();
01453     }
01454   }
01455 
01456   // update logging
01457   if (emcmotStatus.logOpen) {
01458     // we're logging motion
01459     emcStatus->logType = emcmotStatus.logType;
01460     emcStatus->logSize = emcmotStatus.logSize;
01461     emcStatus->logSkip = emcmotStatus.logSkip;
01462     emcStatus->logOpen = emcmotStatus.logOpen;
01463     emcStatus->logStarted = emcmotStatus.logStarted;
01464     emcStatus->logPoints = emcmotStatus.logPoints;
01465   }
01466   // else if it's not open, don't update emcStatus-- someone else may
01467   // be logging
01468 
01469   stat->probedPosition.tran.x = emcmotStatus.probedPos.tran.x;
01470   stat->probedPosition.tran.y = emcmotStatus.probedPos.tran.y;
01471   stat->probedPosition.tran.z = emcmotStatus.probedPos.tran.z;
01472   stat->probeval = emcmotStatus.probeval;
01473   stat->probe_tripped = emcmotStatus.probeTripped;
01474 
01475   if (new_config) {
01476     stat->cycleTime = emcmotConfig.trajCycleTime;
01477     stat->probe_index = emcmotConfig.probeIndex;
01478     stat->probe_polarity = emcmotConfig.probePolarity;
01479     stat->kinematics_type = emcmotConfig.kinematics_type;
01480     stat->maxVelocity = emcmotConfig.limitVel;
01481   }
01482 
01483   return 0;
01484 }

int emcioNmlGet   [static]
 

Definition at line 1686 of file bridgeporttaskintf.cc.

Referenced by emcIoInit().

01687 {
01688   int retval = 0;
01689   double start_time;
01690   RCS_PRINT_DESTINATION_TYPE orig_dest;
01691   if (emcIoCommandBuffer == 0)
01692     {
01693       orig_dest = get_rcs_print_destination();
01694       set_rcs_print_destination(RCS_PRINT_TO_NULL);
01695       start_time = etime();
01696       while(start_time-etime() < EMCIO_BUFFER_GET_TIMEOUT)
01697         {
01698           emcIoCommandBuffer = new RCS_CMD_CHANNEL(emcFormat, "toolCmd", "emc", EMC_NMLFILE);
01699           if (! emcIoCommandBuffer->valid())
01700             {
01701               delete emcIoCommandBuffer;
01702               emcIoCommandBuffer = 0;
01703             }
01704           else
01705             {
01706               break;
01707             }
01708           esleep(0.1);
01709         }
01710       set_rcs_print_destination(orig_dest);
01711     }
01712 
01713   if (emcIoCommandBuffer == 0)
01714     {
01715       emcIoCommandBuffer = new RCS_CMD_CHANNEL(emcFormat, "toolCmd", "emc", EMC_NMLFILE);
01716       if (! emcIoCommandBuffer->valid())
01717         {
01718           delete emcIoCommandBuffer;
01719           emcIoCommandBuffer = 0;
01720           retval=-1;
01721         }
01722     }
01723   
01724   if (emcIoStatusBuffer == 0)
01725     {
01726       orig_dest = get_rcs_print_destination();
01727       set_rcs_print_destination(RCS_PRINT_TO_NULL);
01728       start_time = etime();
01729       while(start_time-etime() < EMCIO_BUFFER_GET_TIMEOUT)
01730         {
01731           emcIoStatusBuffer = new RCS_STAT_CHANNEL(emcFormat, "toolSts", "emc", EMC_NMLFILE);
01732           if (! emcIoStatusBuffer->valid())
01733             {
01734               delete emcIoStatusBuffer;
01735               emcIoStatusBuffer = 0;
01736             }
01737           else
01738             {
01739               emcIoStatus = (EMC_IO_STAT *) emcIoStatusBuffer->get_address();
01740               // capture serial number for next send
01741               emcIoCommandSerialNumber = emcIoStatus->echo_serial_number;
01742               break;
01743             }
01744           esleep(0.1);
01745         }
01746       set_rcs_print_destination(orig_dest);
01747     }
01748 
01749   if (emcIoStatusBuffer == 0)
01750     {
01751       emcIoStatusBuffer = new RCS_STAT_CHANNEL(emcFormat, "toolSts", "emc", EMC_NMLFILE);
01752       if (! emcIoStatusBuffer->valid() ||
01753           EMC_IO_STAT_TYPE != emcIoStatusBuffer->peek())
01754         {
01755           delete emcIoStatusBuffer;
01756           emcIoStatusBuffer = 0;
01757           emcIoStatus = 0;
01758           retval = -1;
01759         }
01760       else
01761         {
01762           emcIoStatus = (EMC_IO_STAT *) emcIoStatusBuffer->get_address();
01763           // capture serial number for next send
01764           emcIoCommandSerialNumber = emcIoStatus->echo_serial_number;
01765         }
01766     }
01767 
01768   return retval;
01769 }

int forceCommand RCS_CMD_MSG   msg [static]
 

Definition at line 1826 of file bridgeporttaskintf.cc.

01827 {
01828   // need command buffer to be there
01829   if (0 == emcIoCommandBuffer)
01830   {
01831     return -1;
01832   }
01833 
01834   // need status buffer also, to check for command received
01835   if (0 == emcIoStatusBuffer ||
01836       ! emcIoStatusBuffer->valid())
01837   {
01838     return -1;
01839   }
01840 
01841   // send it immediately
01842   msg->serial_number = ++emcIoCommandSerialNumber;
01843   if (0 != emcIoCommandBuffer->write(msg))
01844   {
01845     return -1;
01846   }
01847 
01848   return 0;
01849 }

int sendCommand RCS_CMD_MSG   msg [static]
 

Definition at line 1775 of file bridgeporttaskintf.cc.

01776 {
01777   // need command buffer to be there
01778   if (0 == emcIoCommandBuffer)
01779   {
01780     return -1;
01781   }
01782 
01783   // need status buffer also, to check for command received
01784   if (0 == emcIoStatusBuffer ||
01785       ! emcIoStatusBuffer->valid())
01786   {
01787     return -1;
01788   }
01789 
01790   double send_command_timeout = etime() + 30.0;
01791 
01792   // check if we're executing, and wait until we're done
01793   while(etime() < send_command_timeout) {
01794     emcIoStatusBuffer->peek();
01795     if (emcIoStatus->echo_serial_number != emcIoCommandSerialNumber ||
01796         emcIoStatus->status == RCS_EXEC) {
01797       esleep(0.001);
01798       continue;
01799     }
01800     else {
01801       break;
01802     }
01803   }
01804 
01805   if (emcIoStatus->echo_serial_number != emcIoCommandSerialNumber ||
01806       emcIoStatus->status == RCS_EXEC) {
01807     // Still not done, must have timed out.
01808     return -1;
01809   }
01810 
01811 
01812   // now we can send
01813   msg->serial_number = ++emcIoCommandSerialNumber;
01814   if (0 != emcIoCommandBuffer->write(msg))
01815   {
01816     return -1;
01817   }
01818 
01819   return 0;
01820 }


Variable Documentation

double EMCIO_BUFFER_GET_TIMEOUT = 5.0 [static]
 

Definition at line 1684 of file bridgeporttaskintf.cc.

RCS_CMD_CHANNEL* emcIoCommandBuffer = 0 [static]
 

Definition at line 1676 of file bridgeporttaskintf.cc.

int emcIoCommandSerialNumber = 0 [static]
 

Definition at line 1683 of file bridgeporttaskintf.cc.

EMC_IO_STAT* emcIoStatus = 0
 

Definition at line 1680 of file bridgeporttaskintf.cc.

RCS_STAT_CHANNEL* emcIoStatusBuffer = 0 [static]
 

Definition at line 1677 of file bridgeporttaskintf.cc.

EMCMOT_CONFIG emcmotConfig [static]
 

Definition at line 880 of file bridgeporttaskintf.cc.

EMCMOT_DEBUG emcmotDebug [static]
 

Definition at line 888 of file bridgeporttaskintf.cc.

EMCMOT_STATUS emcmotStatus [static]
 

Definition at line 887 of file bridgeporttaskintf.cc.

char errorString[EMCMOT_ERROR_LEN] [static]
 

Definition at line 889 of file bridgeporttaskintf.cc.

int get_emcmot_debug_info = 0
 

Definition at line 881 of file bridgeporttaskintf.cc.

int last_id = 0 [static]
 

Definition at line 1381 of file bridgeporttaskintf.cc.

int last_id_printed = 0 [static]
 

Definition at line 1379 of file bridgeporttaskintf.cc.

double last_id_time [static]
 

Definition at line 1382 of file bridgeporttaskintf.cc.

int last_status = 0 [static]
 

Definition at line 1380 of file bridgeporttaskintf.cc.

double localEmcTrajAngularUnits = 1.0 [static]
 

Definition at line 988 of file bridgeporttaskintf.cc.

int localEmcTrajAxes = 0 [static]
 

Definition at line 986 of file bridgeporttaskintf.cc.

double localEmcTrajLinearUnits = 1.0 [static]
 

Definition at line 987 of file bridgeporttaskintf.cc.

int localEmcTrajMotionId = 0 [static]
 

Definition at line 989 of file bridgeporttaskintf.cc.

int new_config = 0 [static]
 

Definition at line 890 of file bridgeporttaskintf.cc.

double saveMaxLimit[EMCMOT_MAX_AXIS] [static]
 

Definition at line 316 of file bridgeporttaskintf.cc.

double saveMaxOutput[EMCMOT_MAX_AXIS] [static]
 

Definition at line 371 of file bridgeporttaskintf.cc.

double saveMinLimit[EMCMOT_MAX_AXIS] [static]
 

Definition at line 315 of file bridgeporttaskintf.cc.

double saveMinOutput[EMCMOT_MAX_AXIS] [static]
 

Definition at line 370 of file bridgeporttaskintf.cc.


Generated on Sun Dec 2 15:27:47 2001 for EMC by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001