Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 #ifndef SerRelayBoard_INCLUDEDEF_H
00037 #define SerRelayBoard_INCLUDEDEF_H
00038
00039
00040
00041
00042 #include <SerialIO.h>
00043 #include <Mutex.h>
00044 #include <StrUtil.h>
00045 #include <DriveParam.h>
00046
00047
00048 #include <vector>
00049 #include <boost/array.hpp>
00050
00051
00052
00057 class RelayBoardV2
00058 {
00059 public:
00060
00061 RelayBoardV2();
00062
00063 ~RelayBoardV2();
00064
00065
00066 int openSerial(const char* device,int baudrate);
00067 int init(const char* device_name, int iactive_motors, int ihoming_motors, int iext_hardware, long lModulo0, long lModulo1, long lModulo2, long lModulo3, long lModulo4, long lModulo5, long lModulo6, long lModulo7);
00068
00069 bool shutdownPltf();
00070
00071 int evalRxBuffer();
00072
00073 int sendDataToRelayBoard();
00074
00075 int convDataToSendMsg(unsigned char cMsg[]);
00076
00077 void convRecMsgToData(unsigned char cMsg[]);
00078
00079
00080
00081 void startCharging();
00082 void stopCharging();
00083 void setRelayBoardDigOut(int iChannel, bool bOn);
00084
00085
00086 void setMotorDesiredEncS(int motor_nr, long dVel);
00087
00088
00089 void setEMStop();
00090 void resetEMStop();
00091
00092
00093 void writeLCD(const std::string& sText);
00094
00095
00096 void startUSBoard(int iChannelActive);
00097 void stopUSBoard();
00098
00099
00100 void setIOBoardDigOut(int iChannel, bool bVal);
00101
00102
00103 bool isEMStop();
00104 bool isScannerStop();
00105
00106
00107 void getRelayBoardState(int* State);
00108 void getTemperature(int* temp);
00109 void getBattVoltage(int* battvolt);
00110 void getChargingCurrent(int* current);
00111 void getChargingState(int* state);
00112 void getRelayBoardDigOut(int* DigOut);
00113 void getKeyPad(int* keypad);
00114
00115
00116 void getMotorEnc(int imotor_nr,long* lmotorEnc);
00117 void getMotorEncS(int imotor_nr,long* lmotorEncS);
00118 void getMotorState(int imotor_nr,int* lmotorStatus);
00119
00120
00121 void getUSBoardData1To8(int* piUSDistMM);
00122 void getUSBoardData9To16(int* piUSDistMM);
00123 void getUSBoardAnalogIn(int* piAnalogIn);
00124
00125
00126 void getIOBoardDigIn(int* DigIn);
00127 void getIOBoardDigOut(int* DigOut);
00128 void getIOBoardAnalogIn(int* iAnalogIn);
00129
00130 void enable_logging();
00131 void disable_logging();
00132 void log_to_file(int direction, unsigned char cMsg[]);
00133
00134 enum RelBoardReturns
00135 {
00136 NO_ERROR = 0,
00137 NOT_INITIALIZED = 1,
00138 GENERAL_SENDING_ERROR = 2,
00139 TOO_LESS_BYTES_IN_QUEUE = 3,
00140 NO_MESSAGES = 4,
00141 CHECKSUM_ERROR = 5,
00142 MSG_CONFIG = 6,
00143 MSG_DATA = 7
00144 };
00145 private:
00146
00147 SerialIO m_SerIO;
00148
00149 Mutex m_Mutex;
00150
00151
00152 int m_iFoundMotors;
00153 int m_iHomedMotors;
00154 int m_iFoundExtHardware;
00155 int m_iConfigured;
00156 int m_iNumBytesRec;
00157 int m_iNumBytesSend;
00158
00159
00160 int m_ihasRelayData;
00161 int m_ihas_LCD_DATA;
00162 int m_iHasIOBoard;
00163 int m_iHasUSBoard;
00164 int m_iHasSpeakerData;
00165 int m_iChargeState;
00166
00167 struct Motor
00168 {
00169 int iMotorActive;
00170 long lEnc;
00171 long lEncS;
00172 int iStatus;
00173 long ldesiredEncS;
00174 };
00175 Motor m_Motor[8];
00176
00177 struct Send_MSG
00178 {
00179 int iSoftEM;
00180 int iCmdRelayBoard;
00181 char LCD_Txt[20];
00182 int IOBoard_Cmd;
00183 int USBoard_Cmd;
00184 int Speaker;
00185 int SpeakerLoud;
00186 };
00187 Send_MSG m_S_MSG;
00188
00189 struct Recived_MSG
00190 {
00191
00192 int iRelayBoard_Status;
00193 int iCharging_Current;
00194 int iCharging_State;
00195 int iBattery_Voltage;
00196 int iKey_Pad;
00197 int iTemp_Sensor;
00198
00199
00200 int iIODig_In;
00201 int iIOAnalog_In[8];
00202 int iIOBoard_State;
00203
00204
00205 int iUSSensor_Dist[16];
00206 int iUSAnalog_In[4];
00207 int iUSBoard_State;
00208 };
00209
00210 Recived_MSG m_REC_MSG;
00211
00212 bool m_blogging;
00213 };
00214
00215
00216
00217 #endif