SerRelayBoard.h
Go to the documentation of this file.
00001 /*
00002  * Copyright 2017 Fraunhofer Institute for Manufacturing Engineering and Automation (IPA)
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  *   http://www.apache.org/licenses/LICENSE-2.0
00009 
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016  
00017 
00018 #ifndef SerRelayBoard_INCLUDEDEF_H
00019 #define SerRelayBoard_INCLUDEDEF_H
00020 
00021 //-----------------------------------------------
00022 #include <cob_relayboard/SerialIO.h>
00023 #include <cob_relayboard/Mutex.h>
00024 #include <cob_relayboard/CmdRelaisBoard.h>
00025 
00026 //-----------------------------------------------
00027 
00032 class SerRelayBoard
00033 {
00034 public:
00035 
00036         SerRelayBoard(std::string ComPort, int ProtocolVersion = 1);
00037 
00038         ~SerRelayBoard();
00039 
00040         // Main control functions
00041         bool init();
00042         bool reset();
00043         bool shutdown();
00044 
00045         int evalRxBuffer(); //needs to be calles to read new data from relayboard
00046         int sendRequest(); //sends collected data and requests response
00047 
00048         //Services by relayboard
00049         int setDigOut(int iChannel, bool bOn);
00050         int getAnalogIn(int* piAnalogIn);
00051         int getDigIn();
00052         bool isEMStop();
00053         bool isScannerStop();
00054         int getBatteryVoltage()
00055         {
00056                 return m_iRelBoardBattVoltage;
00057         }
00058         int getChargeCurrent()
00059         {
00060                 return m_iChargeCurrent;
00061         }
00062 
00063 
00064         enum RelBoardReturns
00065         {
00066                 NO_ERROR = 0,
00067                 NOT_INITIALIZED = 1,
00068                 GENERAL_SENDING_ERROR = 2,
00069                 TOO_LESS_BYTES_IN_QUEUE = 3,
00070                 NO_MESSAGES = 4, //for a long time, no message have been received, check com port!
00071                 CHECKSUM_ERROR = 5,
00072         };
00073 
00074         enum RelBoardCmd
00075         {
00076                 CMD_SET_CHARGE_RELAY = 1,
00077                 CMD_RESET_POS_CNT = 2,
00078                 CMD_QUICK_STOP = 4,
00079                 CMD_SET_RELAY1 = 8,
00080                 CMD_SET_RELAY2 = 16,
00081                 CMD_SET_RELAY3 = 32,
00082                 CMD_SET_RELAY4 = 64,
00083                 CMD_SET_RELAY5 = 128,
00084                 CMD_SET_RELAY6 = 256,
00085                 CMD_ZERO_GYRO = 512
00086         };
00087 
00088         enum RelBoardConfig
00089         {
00090                 CONFIG_HAS_IOBOARD = 1,
00091                 CONFIG_HAS_USBOARD = 2,
00092                 CONFIG_HAS_GYROBOARD = 4,
00093                 CONFIG_HAS_RADARBOARD1 = 8,
00094                 CONFIG_HAS_RADARBOARD2 = 16,
00095                 CONFIG_HAS_DRIVES = 32,
00096         };
00097 
00098         enum TypeLCD
00099         {
00100                 LCD_20CHAR_TEXT,
00101                 LCD_60CHAR_TEXT,
00102                 RELAY_BOARD_1_4
00103         };
00104 
00105 protected:
00106 
00107 
00108         std::string m_sNumComPort;
00109 
00110         void txCharArray();
00111         void rxCharArray();
00112 
00113         void convDataToSendMsg(unsigned char cMsg[]);
00114         bool convRecMsgToData(unsigned char cMsg[]);
00115 
00116         Mutex m_Mutex;
00117 
00118         int m_iNumBytesSend;
00119         int m_iTypeLCD;
00120 
00121         unsigned char m_cTextDisplay[60];
00122 
00123         //relayboard 1.4:
00124         int m_iVelCmdMotRearRightEncS;
00125         int m_iVelCmdMotRearLeftEncS;
00126         char m_cSoftEMStop;
00127         char m_cDebugRearRight[4];
00128         int m_iPosMeasMotRearRightEnc;
00129         int m_iVelMeasMotRearRightEncS;
00130         int m_iPosMeasMotRearLeftEnc;
00131         char m_cDebugRearLeft[4];
00132         int m_iVelMeasMotRearLeftEncS;
00133         int m_iMotRearRightStatus;
00134         int m_iMotRearLeftStatus;
00135         double m_dLastPosRearRight;
00136         double m_dLastPosRearLeft;
00137 
00138         //-----------------------
00139         // send data
00140 
00141         // RelayBoard
00142         int m_iConfigRelayBoard;
00143         int m_iCmdRelayBoard;
00144 
00145         // IOBoard
00146         int m_iIOBoardDigOut;
00147 
00148         // MotCtrlBoards
00149         int m_iVelCmdMotRightEncS;
00150         int m_iVelCmdMotLeftEncS;
00151 
00152         // USBoard
00153         int m_iUSBoardSensorActive;
00154 
00155         //-----------------------
00156         // rec data
00157         int m_iRelBoardStatus;
00158         int m_iChargeCurrent;
00159         int m_iRelBoardBattVoltage;
00160         int m_iRelBoardKeyPad;
00161         int m_iRelBoardAnalogIn[4];
00162         int m_iRelBoardTempSensor;
00163 
00164         int m_iDigIn;
00165         int m_iProtocolVersion;
00166         int m_NUM_BYTE_SEND;
00167 
00168         SerialIO m_SerIO;
00169 
00170         bool m_bComInit;
00171 };
00172 
00173 
00174 //-----------------------------------------------
00175 #endif


cob_relayboard
Author(s): Christian Connette
autogenerated on Sat Jun 8 2019 21:02:18