Device.h
Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2012 SCHUNK GmbH & Co. KG
00003  * Copyright (c) 2017 Fraunhofer Institute for Manufacturing Engineering and Automation (IPA)
00004  *
00005  * Licensed under the Apache License, Version 2.0 (the "License");
00006  * you may not use this file except in compliance with the License.
00007  * You may obtain a copy of the License at
00008  *
00009  *   http://www.apache.org/licenses/LICENSE-2.0
00010 
00011  * Unless required by applicable law or agreed to in writing, software
00012  * distributed under the License is distributed on an "AS IS" BASIS,
00013  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  * See the License for the specific language governing permissions and
00015  * limitations under the License.
00016  */
00017 
00018 #ifndef CDEVICE_H
00019 #define CDEVICE_H
00020 
00021 #include "../Util/Message.h"
00022 #include "../Util/StopWatch.h"
00023 #include "../ComDef/DeviceErrors.h"
00024 #include "../ComDef/ModuleErrors.h"
00025 #include "../ComDef/IOErrors.h"
00026 #include "../Device/ProtocolCommands.h"
00027 
00028 class CDevice : public CMessage
00029 {
00030         private:
00031 
00032                 // ---- private data ---------------------------------------------------- ;
00033         
00034                 // ---- private auxiliary functions ------------------------------------- ;
00035 
00036         protected:
00037 
00038                 // ---- protected data -------------------------------------------------- ;
00039 
00040                         bool m_bInitFlag;
00041                         char m_acName[128];
00042                         char m_acInitString[128];
00043                         char m_acRevision[20];
00044                         int m_iBaudRate;
00045                         int m_iModuleCount;
00046                         int m_iModuleCountMax;
00047                         std::vector<int> m_aiModuleId;
00048                         std::vector<unsigned short> m_auiModuleVersion;
00049                         CStopWatch m_clTimer;
00050                         int m_iErrorState;
00051 
00052                 // ---- protected auxiliary functions ----------------------------------- ;
00053 
00054                         virtual int reinit(unsigned char ucBaudRateId) = 0;
00055                         virtual int write8Bytes(int iModuleId, bool ack, void* pBytes ) = 0; 
00056                         virtual int getUnsignedLong(int iModuleId, unsigned long* puiData) = 0;
00057 
00058                         virtual int readChar(int iModuleId, int iCommandId, int iParameterId, char* pcData) = 0;
00059                         virtual int readUnsignedChar(int iModuleId, int iCommandId, int iParameterId, unsigned char* pucData) = 0;
00060                         virtual int readShort(int iModuleId, int iCommandId, int iParameterId, short* piData) = 0;
00061                         virtual int readUnsignedShort(int iModuleId, int iCommandId, int iParameterId, unsigned short* puiData) = 0;
00062                         virtual int readLong(int iModuleId, int iCommandId, int iParameterId, long* piData) = 0;
00063                         virtual int readUnsignedLong(int iModuleId, int iCommandId, int iParameterId, unsigned long* puiData) = 0;
00064                         virtual int readFloat(int iModuleId, int iCommandId, int iParameterId, float* pfData) = 0;
00065 
00066                         virtual int readLongUnsignedChars(int iModuleId, int iCommandId, int iParameterId, long* piData, unsigned char* pucData1, unsigned char* pucData2) = 0;
00067                         virtual int readFloatUnsignedChars(int iModuleId, int iCommandId, int iParameterId, float* pfData, unsigned char* pucData1, unsigned char* pucData2) = 0;
00068 
00069                         virtual int writeChar(int iModuleId, int iCommandId, int iParameterId, char cData) = 0;
00070                         virtual int writeUnsignedChar(int iModuleId, int iCommandId, int iParameterId, unsigned char ucData) = 0;
00071                         virtual int writeShort(int iModuleId, int iCommandId, int iParameterId, short iData) = 0;
00072                         virtual int writeUnsignedShort(int iModuleId, int iCommandId, int iParameterId, unsigned short uiData) = 0;
00073                         virtual int writeLong(int iModuleId, int iCommandId, int iParameterId, long iData) = 0;
00074                         virtual int writeUnsignedLong(int iModuleId, int iCommandId, int iParameterId, unsigned long uiData) = 0;
00075                         virtual int writeFloat(int iModuleId, int iCommandId, int iParameterId, float fData) = 0;
00076 
00077                         virtual int writeAll(int iCommandId, int iParameterId) = 0;
00078                         virtual int writeCommand(int iModuleId, int iCommandId) = 0;
00079                         virtual int writeLongShort(int iModuleId, int iCommandId, int iParameterId, long iData, short iTime) = 0;
00080                         virtual int writeFloatShort(int iModuleId, int iCommandId, int iParameterId, float fData, short iTime) = 0;
00081 
00082                         virtual int writeShortReadLongUnsignedChars(int iModuleId, int iCommandId, int iParameterId, short iData, long* piData, unsigned char* pucData1, unsigned char* pucData2) = 0;
00083                         virtual int writeLongReadLongUnsignedChars(int iModuleId, int iCommandId, int iParameterId, long iData, long* piData, unsigned char* pucData1, unsigned char* pucData2) = 0;
00084                         virtual int writeLongShortReadLongUnsignedChars(int iModuleId, int iCommandId, int iParameterId, long iData1, short iData2, long* piData, unsigned char* pucData1, unsigned char* pucData2) = 0;
00085                         virtual int writeFloatReadFloatUnsignedChars(int iModuleId, int iCommandId, int iParameterId, float fData, float* pfData, unsigned char* pucData1, unsigned char* pucData2) = 0;
00086                         virtual int writeFloatShortReadFloatUnsignedChars(int iModuleId, int iCommandId, int iParameterId, float fData, short iData, float* pfData, unsigned char* pucData1, unsigned char* pucData2) = 0;
00087 
00088                         void charStateToLongState(unsigned char uiShort, unsigned long* puiState);
00089 
00090         public:
00091 
00092                 // ---- public data ----------------------------------------------------- ;
00093 
00094         
00095                 // ---- constructors / destructor --------------------------------------- ;
00096 
00098                         CDevice(void);
00100                         CDevice(const CDevice& rclDevice);
00102                         virtual ~CDevice();
00103 
00104                 // ---- operators ------------------------------------------------------- ;
00105                 
00106                         // assignment operator
00107                         CDevice& operator=(const CDevice& rclDevice);
00108 
00109                 // ---- query functions ------------------------------------------------- ;
00110 
00112                         bool getInitFlag();
00114                         const char* getRevision();
00116                         const char* getName();
00118                         const char* getInitString();
00120                         int getBaudRate(void);
00122                         int getModuleCount(void);
00124                         int getModuleIdMap(std::vector<int>& raiModuleId);
00125 
00126                         int getModuleState(int iModuleId, unsigned long* puiState);
00127                         int getModuleType(int iModuleId, unsigned char* pucValue);
00128                         int getModuleVersion(int iModuleId, unsigned short* puiValue);
00129                         int getModuleSerialNo(int iModuleId, unsigned long* puiValue);
00130 
00131                         int getDefConfig(int iModuleId, unsigned long* puiValue);
00132                         int getDefSetup(int iModuleId, unsigned long* puiValue);
00133                         int getDefBaudRate(int iModuleId, unsigned char* pucValue);
00134                         int getDefBurnCount(int iModuleId, unsigned char* pucValue);
00135                         int getDefGearRatio(int iModuleId, float* pfValue);
00136                         int getDefLinearRatio(int iModuleId, float* pfValue);
00137                         int getDefCurOffset(int iModuleId, float* pfValue);
00138                         int getDefCurRatio(int iModuleId, float* pfValue);
00139                         int getDefBrakeTimeOut(int iModuleId, unsigned short* puiValue);
00140                         int getDefIncPerTurn(int iModuleId, unsigned long* puiValue);
00141                         int getDefDioData(int iModuleId, unsigned long* puiValue);
00142                         int getDefA0(int iModuleId, short* piValue);
00143                         int getDefC0(int iModuleId, short* piValue);
00144                         int getDefDamp(int iModuleId, short* piValue);
00145                         int getDefHomeOffset(int iModuleId, float* pfValue);
00146                         int getDefHomeVel(int iModuleId, float* pfValue);
00147                         int getDefMinPos(int iModuleId, float* pfValue);
00148                         int getDefMaxPos(int iModuleId, float* pfValue);
00149                         int getDefMaxVel(int iModuleId, float* pfValue);
00150                         int getDefMaxAcc(int iModuleId, float* pfValue);
00151                         int getDefMaxCur(int iModuleId, float* pfValue);
00152                         int getDefMaxDeltaPos(int iModuleId, float* pfValue);
00153 
00154                         int getConfig(int iModuleId, unsigned long* puiValue);
00155                         int getIncRatio(int iModuleId, float* pValue );
00156                         int getStateDioPos(int iModuleId, unsigned long* puiState, 
00157                                 unsigned char* pucDio, float* pfPos);
00158                         int getDioData(int iModuleId, unsigned long* puiValue);
00159                         int getA0(int iModuleId, short* piValue);
00160                         int getC0(int iModuleId, short* piValue);
00161                         int getDamp(int iModuleId, short* piValue);
00162                         int getHomeOffset(int iModuleId, float* pValue );
00163                         int getHomeOffsetInc(int iModuleId, long* piValue );
00164                         int getHomeVel(int iModuleId, float* pfValue );
00165                         int getHomeVelInc(int iModuleId, long* piValue);
00166                         int getPos(int iModuleId, float* pfPos);
00167                         int getPosInc(int iModuleId, long* piValue);
00168                         int getPosCountInc(int iModuleId, long* piValue);
00169                         int getVel(int iModuleId, float* pfVel);
00170                         int getVelInc(int iModuleId, long* piValue);
00171                         int getIPolVel(int iModuleId, float* pValue );
00172                         int getCur(int iModuleId, float* pfCur);
00173                         int getCurInc(int iModuleId, short* piValue);
00174                         int getMinPos(int iModuleId, float* pfValue);
00175                         int getMinPosInc(int iModuleId, long* piValue);
00176                         int getMaxPos(int iModuleId, float* pfValue);
00177                         int getMaxPosInc(int iModuleId, long* piValue);
00178                         int getMaxVel(int iModuleId, float* pfValue);
00179                         int getMaxVelInc(int iModuleId, long* piValue);
00180                         int getMaxAcc(int iModuleId, float* pfValue);
00181                         int getMaxAccInc(int iModuleId, long* piValue);
00182                         int getMaxCur(int iModuleId, float* pfValue);
00183                         int getDeltaPos(int iModuleId, float* pfValue);
00184                         int getDeltaPosInc(int iModuleId, long* piValue);
00185                         int getMaxDeltaPos(int iModuleId, float* pfValue);
00186                         int getMaxDeltaPosInc(int iModuleId, long* piValue);
00187                         int getSavePos(int iModuleId, float* pfValue);
00188                         int getSyncTime(int iModuleId, short* piValue);
00189                         int getRawMotorCurrent(int iModuleId, short* piValue);
00190                         int getRawMotorSupply(int iModuleId, short* piValue);
00191                         int getRawTemperature(int iModuleId, short* piValue);
00192                         int getRawLogicSupply(int iModuleId, short* piValue);
00193                         int getLoadLimit(int iModuleId, long* piValue);
00194                         int getMaxLoadGradient(int iModuleId, long* piValue);
00195                         int getLoadDeltaTime(int iModuleId, unsigned short* piValue);
00196 
00197                         int getMotorCurrent(int iModuleId, float* pfValue);
00198                         int getMotorSupply(int iModuleId, float* pfValue);
00199                         int getTemperature(int iModuleId, float* pfValue);
00200                         int getLogicSupply(int iModuleId, float* pfValue);
00201 
00202                         int getMinLogicVoltage(int iModuleId, float* pfValue);
00203                         int getMaxLogicVoltage(int iModuleId, float* pfValue);
00204                         int getMinMotorVoltage(int iModuleId, float* pfValue);
00205                         int getMaxMotorVoltage(int iModuleId, float* pfValue);
00206                         int getNominalMotorCurrent(int iModuleId, float* pfValue);
00207                         int getMaximumMotorCurrent(int iModuleId, float* pfValue);
00208                         int getLogicUndershootTime(int iModuleId, long* piValue);
00209                         int getLogicOvershootTime(int iModuleId, long* piValue);
00210                         int getMotorUndershootTime(int iModuleId, long* piValue);
00211                         int getMotorOvershootTime(int iModuleId, long* piValue);
00212                         int getNomCurOvershootTime(int iModuleId, long* piValue);
00213                         int getHMaxCurOvershootTime(int iModuleId, long* piValue);
00214 
00215                         int getDefCANBaudRate(int iModuleId, unsigned char* pucValue);
00216                         int getDefRSBaudRate(int iModuleId, unsigned char* pucValue);
00217 
00218                         int getKpPWMLimit(int iModuleId, long* piValue);
00219                         int getCurrentLimit(int iModuleId, float* pfValue);
00220                         int     getMaxPWMOutput(int iModuleId, long* piValue);
00221 
00222                         virtual int getDataDLR_FTS(std::vector<float>& rafData, long* piState) = 0;
00223                         virtual int getDataSCHUNK_FTC(int iModuleId, int iChannelTypeId, std::vector<float>& rafData, short* piState) = 0;
00224                         virtual int getDataMP55_IO(int iModuleId, float* pfData) = 0;
00225                         virtual int getDataMP55_IO_fast(int iModuleId, float* pfData) = 0;
00226                         virtual int getCanOpenRawAbsEnc(int iModuleId, short* piValue) = 0;
00227 
00228 
00229                 // ---- modify functions ------------------------------------------------ ;
00230 
00232                         void setName(const char* acNameString);
00233                         void setInitString(const char* acInitString);
00234 
00235                         int setConfig(int iModuleId, unsigned long puiValue);
00236                         int setDioData(int iModuleId, unsigned long uiValue);
00237                         int setA0(int iModuleId, short iValue);
00238                         int setC0(int iModuleId, short iValue);
00239                         int setDamp(int iModuleId, short iValue);
00240                         int setHomeOffset(int iModuleId, float fValue );
00241                         int setHomeOffsetInc(int iModuleId, long iValue );
00242                         int setHomeVel(int iModuleId, float fValue);                    
00243                         int setHomeVelInc(int iModuleId, long iValue);
00244                         int setRampVel(int iModuleId, float fValue );
00245                         int setRampAcc(int iModuleId, float fValue );
00246                         int setRampVelInc(int iModuleId, long iValue );
00247                         int setRampAccInc(int iModuleId, long iValue );
00248                         int setMinPos(int iModuleId, float fValue);
00249                         int setMinPosInc(int iModuleId, long iValue);
00250                         int setMaxPos(int iModuleId, float fValue);
00251                         int setMaxPosInc(int iModuleId, long iValue);
00252                         int setMaxVel(int iModuleId, float fValue);
00253                         int setMaxVelInc(int iModuleId, long iValue);
00254                         int setMaxAcc(int iModuleId, float fValue);
00255                         int setMaxAccInc(int iModuleId, long iValue);
00256                         int setMaxCur(int iModuleId, float fValue);
00257                         int setMaxDeltaPos(int iModuleId, float fValue);
00258                         int setMaxDeltaPosInc(int iModuleId, long iValue);
00259                         int setSyncTime(int iModuleId, short iValue);
00260                         int setLoadLimit(int iModuleId, long iValue);
00261                         int setMaxLoadGradient(int iModuleId, long iValue);
00262                         int setLoadDeltaTime(int iModuleId, unsigned short iValue);
00263                         
00264                         int setDefGearRatio(int iModuleId, float fValue);
00265                         int setDefLinRatio(int iModuleId, float fValue);
00266                         int setDefCurRatio(int iModuleId, float fValue);
00267                         int setDefHomeAcc(int iModuleId, float fValue);
00268                         int setModuleSerialNo(int iModuleId, unsigned long uiValue);
00269                         int setDefIncPerTurn(int iModuleId, unsigned long uiValue);
00270                         int setDefBrakeTimeOut(int iModuleId, unsigned short uiValue);
00271                         int setDefAddress(int iModuleId, unsigned char uiValue);
00272                         int setDefCANBaudRate(int iModuleId, unsigned char uiValue);
00273                         int setDefRSBaudRate(int iModuleId, unsigned char uiValue);
00274                         int setDefSetup(int iModuleId, unsigned long uiValue);
00275 
00276                         int setMinLogicVoltage(int iModuleId, float fValue);
00277                         int setMaxLogicVoltage(int iModuleId, float fValue);
00278                         int setMinMotorVoltage(int iModuleId, float fValue);
00279                         int setMaxMotorVoltage(int iModuleId, float fValue);
00280                         int setNominalMotorCurrent(int iModuleId, float fValue);
00281                         int setMaximumMotorCurrent(int iModuleId, float fValue);
00282                         int setLogicUndershootTime(int iModuleId, long iValue);
00283                         int setLogicOvershootTime(int iModuleId, long iValue);
00284                         int setMotorUndershootTime(int iModuleId, long iValue);
00285                         int setMotorOvershootTime(int iModuleId, long iValue);
00286                         int setNomCurOvershootTime(int iModuleId, long iValue);
00287                         int setHMaxCurOvershootTime(int iModuleId, long iValue);
00288 
00289                         int setKpPWMLimit(int iModuleId, long iValue);
00290                         int setCurrentLimit(int iModuleId, float fValue);
00291 
00292                         virtual int setNullSCHUNK_FTC(int iModuleId, short* piState) = 0;
00293                         virtual int setTaraMP55_IO(int iModuleId, float fTara) = 0;
00294                         virtual int setInitMP55_IO_fast(int iModuleId) = 0;
00295 
00296                 // ---- I/O functions --------------------------------------------------- ;
00297 
00298                 // ---- exec functions -------------------------------------------------- ;
00299 
00300                         virtual int init() = 0;
00301                         virtual int init(const char* acInitString) = 0;
00302                         virtual int exit() = 0;
00303 
00304                         virtual int initDLR_FTS() = 0;
00305                         int updateModuleIdMap();
00306 
00307                         int homeModule(int iModuleId);
00308                         int resetModule(int iModuleId);
00309                         int haltModule(int iModuleId);
00310                         int recalcPIDParams(int iModuleId);
00311                         int saveParameters(int iModuleId);
00312 
00313                         int movePos(int iModuleId, float fPos);
00314                         int movePosInc(int iModuleId, long iPos);
00315                         int movePosExtended(int iModuleId, float fPos, 
00316                                 unsigned long* puiState, unsigned char* pucDio, float* pfPos);
00317                         int moveRamp(int iModuleId, float fPos, float fVel, float fAcc);
00318                         int moveRampInc(int iModuleId, long iPos, long iVel, long iAcc);
00319                         int moveRampExtended(int iModuleId, float fPos, float fVel, float fAcc, 
00320                                 unsigned long* puiState, unsigned char* pucDio, float* pfPos);
00321                         int moveVel(int iModuleId, float fVel);
00322                         int moveVelInc(int iModuleId, long iVel);
00323                         int moveVelExtended(int iModuleId, float fCur, 
00324                                 unsigned long* puiState, unsigned char* pucDio, float* pfPos);
00325                         int moveCur(int iModuleId, float fCur);
00326                         int moveCurInc(int iModuleId, long iCur);
00327                         int moveCurExtended(int iModuleId, float fCur, 
00328                                 unsigned long* puiState, unsigned char* pucDio, float* pfPos);
00329                         int moveStep(int iModuleId, float fPos, unsigned short uiTime);
00330                         int moveStepInc(int iModuleId, long iPos, unsigned short uiTime);
00331                         int moveStepExtended(int iModuleId, float fPos, unsigned short uiTime, 
00332                                 unsigned long* puiState, unsigned char* pucDio, float* pfPos);
00333 
00334                 // ---- wait functions -------------------------------------------------- ;
00335 
00336                         int waitForHomeEnd(int iModuleId, unsigned long uiTimeOut = 60000);
00337                         int waitForMotionEnd(int iModuleId, unsigned long uiTimeOut = 60000);
00338                         int waitForRampEnd(int iModuleId, unsigned long uiTimeOut = 60000);
00339                         int waitForRampDec(int iModuleId, unsigned long uiTimeOut = 60000);
00340                         int waitForRampSteady(int iModuleId, unsigned long uiTimeOut = 60000);
00341                         int waitForHomeEndAll(unsigned long uiTimeOut = 60000);
00342                         int waitForMotionEndAll(unsigned long uiTimeOut = 60000);
00343                         int waitForRampEndAll(unsigned long uiTimeOut = 60000);
00344                         virtual int waitForStartMotionAll();
00345 
00346                 // ---- broadcast functions -------------------------------------------------- ;
00347 
00348                         int homeAll(void);
00349                         int resetAll(void);
00350                         int haltAll(void);
00351                         int serveWatchdogAll(void);
00352                         int setBaudRateAll(unsigned char ucBaudRateId);
00353                         int startMotionAll(void);
00354                         int savePosAll(void);
00355 
00356                 // ---- Special functions -------------------------------------------------- ;
00357 
00358                         int xmit8Bytes(int iModuleId, void* pBytes );
00359                         int xack8Bytes(int iModuleId, void* pBytes );
00360                         int doInternal(int iModuleId, void* pBytes );
00361                         int getStateInternal(int iModuleId, unsigned long* pBytes );
00362 
00363 };
00364 
00365 CDevice* newDevice(const char* acInitString);
00366 
00367 #endif


schunk_libm5api
Author(s): Florian Weisshardt
autogenerated on Sat Jun 8 2019 20:25:13