00001
00002
00004
00005 #ifndef BHAND_CAN_DRIVER_H
00006 #define BHAND_CAN_DRIVER_H
00007
00008
00009 #include "BHandDriver.h"
00010
00011 #include "PucksInHand.h"
00012 #include "PucksInHandCommon.h"
00013
00014
00015 class BHandCANDriver : public BHandDriver
00016 {
00017 public:
00018
00020
00022
00023 BHandCANDriver(BHand *bhand, BHandSupervisoryRealtime *moduleSuperReal);
00024 virtual ~BHandCANDriver();
00025
00026
00027 void SetWaitCallbackFunc(BHCallback waitCallbackFunc);
00028
00029
00031
00033
00034
00035 int Initialize();
00036 void Close();
00037
00038
00040
00042
00043
00044 int RTStart(const char *motor, BHMotorProtection motorProtection = BHMotorTSTOPProtect);
00045 int RTUpdate(bool control = true, bool feedback = true);
00046 int RTAbort();
00047
00048
00049 int RTSetFlags(const char *motor, bool LCV, int LCVC, bool LCPG,
00050 bool LFV, int LFVC, bool LFS, bool LFAP, bool LFDP, int LFDPC);
00051 int RTSetFlags(const char *motor, bool LCV, int LCVC, bool LCPG, bool LCT,
00052 bool LFV, int LFVC, bool LFS, bool LFAP, bool LFDP, int LFDPC,
00053 bool LFBP, bool LFAIN, bool LFDPD, bool LFT);
00054
00055 int RTUpdate(const char *motor, const char *property, int *values);
00056
00057
00058 int RTSetVelocity(const char motor, int velocity);
00059 int RTSetGain(const char motor, int gain);
00060 int RTSetTorque(const char motor, int torque);
00061 int RTSetPosition(const char motor, int position);
00062
00063
00064 char RTGetVelocity(const char motor);
00065 unsigned char RTGetStrain(const char motor);
00066 int RTGetPosition(const char motor);
00067 char RTGetDeltaPos(const char motor);
00068 int RTGetBreakawayPosition(const char motor);
00069 int RTGetTemp();
00070 unsigned char RTGetAIN(const char motor);
00071 void RTGetPPS(const char motor, int *pps, int ppsElements);
00072
00073
00074 private:
00075
00076 void waitForStop(BHMotors bhMotors = 0x0f);
00077
00079
00081
00082
00083 int HandInit(BHMotors bhMotors);
00084 int HandReset(BHMotors bhMotors, bool *responseReceived);
00085
00086
00087 int HandClose(BHMotors bhMotors);
00088 int HandOpen(BHMotors bhMotors);
00089
00090 int HandGoToDefault(BHMotors bhMotors, bool valueIncluded = false, int defaultPosition = 0);
00091 int HandGoToDifferentPositionsHand(const int *encoderPositions, unsigned int numEncoderPositions);
00092 int HandGoToHome(BHMotors bhMotors);
00093 int HandGoToPosition(BHMotors bhMotors, unsigned int encoderPositionTickCount);
00094
00095 int HandStepClose(BHMotors bhMotors, bool valueIncluded = false, int stepAmount = 0);
00096 int HandStepOpen(BHMotors bhMotors, bool valueIncluded = false, int stepAmount = 0);
00097
00098 int HandTorqueClose(BHMotors bhMotors);
00099 int HandTorqueOpen(BHMotors bhMotors);
00100
00101
00102 int HandGet(BHMotors bhMotors, const char *property, int *propertyResult, int *nresults = 0);
00103 int HandSet(BHMotors bhMotors, const char *property, int value);
00104
00105 int HandPGet(const char *property, int *propertyResult);
00106 int HandPSet(const char *property, int value);
00107
00108 int HandDefault(BHMotors bhMotors);
00109 int HandLoad(BHMotors bhMotors);
00110 int HandSave(BHMotors bhMotors);
00111
00112 int HandTemperature(BHMotors bhMotors, int *temperature, unsigned int numTemperatures);
00113
00114
00115 int HandDelay(unsigned int msec);
00116
00117 int HandStopMotor(BHMotors bhMotors);
00118
00119 char * HandCommand(const char *send, int *errorCode);
00120
00121 int HandBaud(unsigned int newbaud);
00122
00123
00124
00125
00126 int ExecuteRealtimeCall();
00127 int HandleSupervisoryCall();
00128
00129
00130 void RTHandProtectMotors();
00131 int pucksInHandRTGet(BHMotors bhMotors, const char *property, int *value);
00132 int pucksInHandRTSet(BHMotors bhMotors, const char *property, int value);
00133
00134 int RTUpdatePPS(BHMotors bhMotors);
00135
00137
00139
00140 BPuck2Manager pucksInHand;
00141 BPuck2 **pucks;
00142
00143 BHAND_PUCK2 puckTwos;
00144 BHCallback waitCallbackFunc;
00145
00146 bool m_control;
00147 bool m_feedback;
00148
00149 bool m_realtimeMode;
00150 BHiResTimer updateTmr;
00151
00152 RealTimeGlobalParameters realtimeGlobalParameters;
00153 RealTimeMotorParameters *realtimeMotorParameters;
00154 };
00155
00156 #endif // BHAND_CAN_DRIVER_H