Device.cpp
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 #include "Device.h"
00019 #include "RS232Device.h"
00020 #ifdef USE_ESD
00021 #include "ESDDevice.h"
00022 #endif
00023 #ifdef USE_PCAN
00024 #include "PCanDevice.h"
00025 #endif
00026 #ifdef USE_SOCKET_CAN
00027 #include "SocketCANDevice.h"
00028 #endif
00029 #if defined (_WIN32)
00030         #include "CP5X11Device.h"
00031 #endif
00032 
00033 // ========================================================================== ;
00034 //                                                                            ;
00035 // ---- private auxiliary functions ----------------------------------------- ;
00036 //                                                                            ;
00037 // ========================================================================== ;
00038 
00039 // ========================================================================== ;
00040 //                                                                            ;
00041 // ---- protected auxiliary functions --------------------------------------- ;
00042 //                                                                            ;
00043 // ========================================================================== ;
00044 
00045 void CDevice::charStateToLongState(unsigned char ucShort, unsigned long* puiState)
00046 {
00047         *puiState = 0;
00048         if(ucShort & 1)
00049                 *puiState |= STATEID_MOD_ERROR;
00050         if(ucShort & 2)
00051                 *puiState |= STATEID_MOD_SWR;
00052         if(ucShort & 4)
00053                 *puiState |= STATEID_MOD_SW1;
00054         if(ucShort & 8)
00055                 *puiState |= STATEID_MOD_SW2;
00056         if(ucShort & 16)
00057                 *puiState |= STATEID_MOD_MOTION;
00058         if(ucShort & 32)
00059                 *puiState |= STATEID_MOD_RAMP_END;
00060         if(ucShort & 64)
00061                 *puiState |= STATEID_MOD_INPROGRESS;
00062         if(ucShort & 128)
00063                 *puiState |= STATEID_MOD_FULLBUFFER;
00064 }
00065 
00066 // ========================================================================== ;
00067 //                                                                            ;
00068 // ---- constructors / destructor ------------------------------------------- ;
00069 //                                                                            ;
00070 // ========================================================================== ;
00071 
00072 CDevice::CDevice() : m_bInitFlag(false), 
00073                                         m_iBaudRate(250), 
00074                                         m_iModuleCount(0), 
00075                                         m_iModuleCountMax(31), 
00076                                         m_clTimer(util_REAL_TIME),
00077                                         m_iErrorState(0)                
00078 { 
00079         m_acName[0] = '\0';
00080         m_acInitString[0] = '\0';
00081         strncpy(m_acRevision,"$Revision: 1.45 $",20);
00082 }
00083 
00084 CDevice::CDevice(const CDevice& rclDevice)
00085 {
00086         error(-1, "Sorry constructor is not implemented");
00087 }
00088 
00089 CDevice::~CDevice()
00090 {
00091 }
00092 
00093 // ========================================================================== ;
00094 //                                                                            ;
00095 // ---- operators ----------------------------------------------------------- ;
00096 //                                                                            ;
00097 // ========================================================================== ;
00098 
00099 CDevice& CDevice::operator=(const CDevice& rclDevice)
00100 {
00101         error(-1, "Sorry operator= is not implemented");
00102         return *this;
00103 }
00104 
00105 // ========================================================================== ;
00106 //                                                                            ;
00107 // ---- query functions ----------------------------------------------------- ;
00108 //                                                                            ;
00109 // ========================================================================== ;
00110 
00111 bool CDevice::getInitFlag()
00112 {
00113         return m_bInitFlag;
00114 }
00115 
00116 const char* CDevice::getRevision()
00117 {
00118         return m_acRevision;
00119 }
00120 
00121 const char* CDevice::getName()
00122 {
00123         return m_acName;
00124 }
00125 
00126 const char* CDevice::getInitString()
00127 {
00128         return m_acInitString;
00129 }
00130 
00131 int CDevice::getBaudRate()
00132 {
00133         return m_iBaudRate;
00134 }
00135 
00136 int CDevice::getModuleCount()
00137 {
00138         m_iErrorState = 0;
00139         if(m_bInitFlag == false)
00140         {
00141                 warning("device not initialized");
00142                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
00143                 return m_iErrorState;
00144         }
00145         return m_iModuleCount;
00146 }
00147 
00148 int CDevice::getModuleIdMap(std::vector<int>& raiModuleId)
00149 {
00150         m_iErrorState = 0;
00151         if(m_bInitFlag == false)
00152         {
00153                 warning("device not initialized");
00154                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
00155                 return m_iErrorState;
00156         }
00157         raiModuleId.resize(m_iModuleCount);
00158         for(int i=0; i < m_iModuleCount; i++)
00159                 raiModuleId[i] = m_aiModuleId[i];
00160 
00161         return m_iModuleCount;
00162 }
00163 
00164 int CDevice::getModuleState(int iModuleId, unsigned long* puiState)
00165 {
00166         m_iErrorState = 0;
00167         if(m_bInitFlag == false)
00168         {
00169                 warning("device not initialized");
00170                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
00171                 return m_iErrorState;
00172         }
00173         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
00174         {
00175                 warning("wrong module id");
00176                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
00177                 return m_iErrorState;
00178         }
00179         m_iErrorState = readUnsignedLong(iModuleId, CMDID_GETPARAM, PARID_ACT_STATE, puiState);
00180 
00181         return m_iErrorState;
00182 }
00183 
00184 int CDevice::getModuleType(int iModuleId, unsigned char* pucValue)
00185 {
00186         m_iErrorState = 0;
00187         if(m_bInitFlag == false)
00188         {
00189                 warning("device not initialized");
00190                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
00191                 return m_iErrorState;
00192         }
00193         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
00194         {
00195                 warning("wrong module id");
00196                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
00197                 return m_iErrorState;
00198         }
00199         unsigned long uiConfig = 0;
00200         m_iErrorState = readUnsignedLong(iModuleId, CMDID_GETPARAM, PARID_DEF_CONFIG, &uiConfig);
00201         if(m_iErrorState == 0)
00202         {
00203                 if (uiConfig & CONFIGID_MOD_LINEAR)
00204                         *pucValue = TYPEID_MOD_LINEAR;
00205                 else
00206                         *pucValue = TYPEID_MOD_ROTARY;
00207         }
00208         return m_iErrorState;
00209 }
00210 
00211 int CDevice::getModuleVersion(int iModuleId, unsigned short* puiValue)
00212 {
00213         m_iErrorState = 0;
00214         if(m_bInitFlag == false)
00215         {
00216                 warning("device not initialized");
00217                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
00218                 return m_iErrorState;
00219         }
00220         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
00221         {
00222                 warning("wrong module id");
00223                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
00224                 return m_iErrorState;
00225         }
00226         m_iErrorState = readUnsignedShort(iModuleId, CMDID_GETPARAM, PARID_DEF_VERSION, puiValue);
00227 
00228         return m_iErrorState;
00229 }
00230 
00231 int CDevice::getModuleSerialNo(int iModuleId, unsigned long* puiValue)
00232 {
00233         m_iErrorState = 0;
00234         if(m_bInitFlag == false)
00235         {
00236                 warning("device not initialized");
00237                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
00238                 return m_iErrorState;
00239         }
00240         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
00241         {
00242                 warning("wrong module id");
00243                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
00244                 return m_iErrorState;
00245         }
00246         m_iErrorState = readUnsignedLong(iModuleId, CMDID_GETPARAM, PARID_DEF_SERIALNO, puiValue);
00247         debug(0,"error state: 0x%04x",m_iErrorState);
00248 
00249         return m_iErrorState;
00250 }
00251 
00252 int CDevice::getDefConfig(int iModuleId, unsigned long* puiValue)
00253 {
00254         m_iErrorState = 0;
00255         if(m_bInitFlag == false)
00256         {
00257                 warning("device not initialized");
00258                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
00259                 return m_iErrorState;
00260         }
00261         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
00262         {
00263                 warning("wrong module id");
00264                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
00265                 return m_iErrorState;
00266         }
00267         m_iErrorState = readUnsignedLong(iModuleId, CMDID_GETPARAM, PARID_DEF_CONFIG, puiValue);
00268 
00269         return m_iErrorState;
00270 }
00271 
00272 int CDevice::getDefSetup(int iModuleId, unsigned long* puiValue)
00273 {
00274         m_iErrorState = 0;
00275         if(m_bInitFlag == false)
00276         {
00277                 warning("device not initialized");
00278                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
00279                 return m_iErrorState;
00280         }
00281         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
00282         {
00283                 warning("wrong module id");
00284                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
00285                 return m_iErrorState;
00286         }
00287         for(int i = 0; i < m_iModuleCount; i++)
00288         {
00289                 if(m_aiModuleId[i] == iModuleId)
00290                 {
00291                         if(m_auiModuleVersion[i] < 0x3500)
00292                         {
00293                                 warning("module version does not support function");
00294                                 m_iErrorState = ERRID_DEV_FUNCTIONNOTAVAILABLE;
00295                                 return m_iErrorState;
00296                         }
00297                 }
00298         }
00299         m_iErrorState = readUnsignedLong(iModuleId, CMDID_GETPARAM, PARID_DEF_SETUP, puiValue);
00300 
00301         return m_iErrorState;
00302 }
00303 
00304 int CDevice::getDefBaudRate(int iModuleId, unsigned char* pucValue)
00305 {
00306         m_iErrorState = 0;
00307         if(m_bInitFlag == false)
00308         {
00309                 warning("device not initialized");
00310                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
00311                 return m_iErrorState;
00312         }
00313         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
00314         {
00315                 warning("wrong module id");
00316                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
00317                 return m_iErrorState;
00318         }
00319         m_iErrorState = readUnsignedChar(iModuleId, CMDID_GETPARAM, PARID_DEF_CANBAUDRATE, pucValue);
00320 
00321         return m_iErrorState;
00322 }
00323 
00324 int CDevice::getDefCANBaudRate(int iModuleId, unsigned char* pucValue)
00325 {
00326         m_iErrorState = 0;
00327         if(m_bInitFlag == false)
00328         {
00329                 warning("device not initialized");
00330                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
00331                 return m_iErrorState;
00332         }
00333         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
00334         {
00335                 warning("wrong module id");
00336                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
00337                 return m_iErrorState;
00338         }
00339         m_iErrorState = readUnsignedChar(iModuleId, CMDID_GETPARAM, PARID_DEF_CANBAUDRATE, pucValue);
00340 
00341         return m_iErrorState;
00342 }
00343 
00344 int CDevice::getDefRSBaudRate(int iModuleId, unsigned char* pucValue)
00345 {
00346         m_iErrorState = 0;
00347         if(m_bInitFlag == false)
00348         {
00349                 warning("device not initialized");
00350                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
00351                 return m_iErrorState;
00352         }
00353         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
00354         {
00355                 warning("wrong module id");
00356                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
00357                 return m_iErrorState;
00358         }
00359         m_iErrorState = readUnsignedChar(iModuleId, CMDID_GETPARAM, PARID_DEF_RSBAUDRATE, pucValue);
00360 
00361         return m_iErrorState;
00362 }
00363 
00364 int CDevice::getDefBurnCount(int iModuleId, unsigned char* pucValue)
00365 {
00366         m_iErrorState = 0;
00367         if(m_bInitFlag == false)
00368         {
00369                 warning("device not initialized");
00370                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
00371                 return m_iErrorState;
00372         }
00373         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
00374         {
00375                 warning("wrong module id");
00376                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
00377                 return m_iErrorState;
00378         }
00379         m_iErrorState = readUnsignedChar(iModuleId, CMDID_GETPARAM, PARID_DEF_BURNCOUNT, pucValue);
00380 
00381         return m_iErrorState;
00382 }
00383 
00384 int CDevice::getDefGearRatio(int iModuleId, float* pfValue)
00385 {
00386         m_iErrorState = 0;
00387         if(m_bInitFlag == false)
00388         {
00389                 warning("device not initialized");
00390                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
00391                 return m_iErrorState;
00392         }
00393         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
00394         {
00395                 warning("wrong module id");
00396                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
00397                 return m_iErrorState;
00398         }
00399         m_iErrorState = readFloat(iModuleId, CMDID_GETPARAM, PARID_DEF_FGEARRATIO, pfValue);
00400 
00401         return m_iErrorState;
00402 }
00403 
00404 int CDevice::getDefLinearRatio(int iModuleId, float* pfValue)
00405 {
00406         m_iErrorState = 0;
00407         if(m_bInitFlag == false)
00408         {
00409                 warning("device not initialized");
00410                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
00411                 return m_iErrorState;
00412         }
00413         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
00414         {
00415                 warning("wrong module id");
00416                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
00417                 return m_iErrorState;
00418         }
00419         m_iErrorState = readFloat(iModuleId, CMDID_GETPARAM, PARID_DEF_FLINEARRATIO, pfValue);
00420 
00421         return m_iErrorState;
00422 }
00423 
00424 int CDevice::getDefCurOffset(int iModuleId, float* pfValue)
00425 {
00426         m_iErrorState = 0;
00427         if(m_bInitFlag == false)
00428         {
00429                 warning("device not initialized");
00430                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
00431                 return m_iErrorState;
00432         }
00433         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
00434         {
00435                 warning("wrong module id");
00436                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
00437                 return m_iErrorState;
00438         }
00439         m_iErrorState = readFloat(iModuleId, CMDID_GETPARAM, PARID_DEF_FCUROFFSET, pfValue);
00440 
00441         return m_iErrorState;
00442 }
00443 
00444 int CDevice::getDefCurRatio(int iModuleId, float* pfValue)
00445 {
00446         m_iErrorState = 0;
00447         if(m_bInitFlag == false)
00448         {
00449                 warning("device not initialized");
00450                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
00451                 return m_iErrorState;
00452         }
00453         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
00454         {
00455                 warning("wrong module id");
00456                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
00457                 return m_iErrorState;
00458         }
00459         m_iErrorState = readFloat(iModuleId, CMDID_GETPARAM, PARID_DEF_FCURRATIO, pfValue);
00460 
00461         return m_iErrorState;
00462 }
00463 
00464 int CDevice::getDefBrakeTimeOut(int iModuleId, unsigned short* puiValue)
00465 {
00466         m_iErrorState = 0;
00467         if(m_bInitFlag == false)
00468         {
00469                 warning("device not initialized");
00470                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
00471                 return m_iErrorState;
00472         }
00473         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
00474         {
00475                 warning("wrong module id");
00476                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
00477                 return m_iErrorState;
00478         }
00479         m_iErrorState = readUnsignedShort(iModuleId, CMDID_GETPARAM, PARID_DEF_BRAKETIMEOUT, puiValue);
00480 
00481         return m_iErrorState;
00482 }
00483 
00484 int CDevice::getDefIncPerTurn(int iModuleId, unsigned long* puiValue)
00485 {
00486         m_iErrorState = 0;
00487         if(m_bInitFlag == false)
00488         {
00489                 warning("device not initialized");
00490                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
00491                 return m_iErrorState;
00492         }
00493         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
00494         {
00495                 warning("wrong module id");
00496                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
00497                 return m_iErrorState;
00498         }
00499         m_iErrorState = readUnsignedLong(iModuleId, CMDID_GETPARAM, PARID_DEF_INCPERTURN, puiValue);
00500 
00501         return m_iErrorState;
00502 }
00503 
00504 int CDevice::getDefDioData(int iModuleId, unsigned long* puiValue)
00505 {
00506         m_iErrorState = 0;
00507         if(m_bInitFlag == false)
00508         {
00509                 warning("device not initialized");
00510                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
00511                 return m_iErrorState;
00512         }
00513         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
00514         {
00515                 warning("wrong module id");
00516                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
00517                 return m_iErrorState;
00518         }
00519 //      m_iErrorState = readUnsignedLong(iModuleId, CMDID_GETPARAM, PARID_DEF_DIODATA, puiValue);
00520 
00521         *puiValue = 0;
00522         return m_iErrorState;
00523 }
00524 
00525 int CDevice::getDefA0(int iModuleId, short* piValue)
00526 {
00527         m_iErrorState = 0;
00528         if(m_bInitFlag == false)
00529         {
00530                 warning("device not initialized");
00531                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
00532                 return m_iErrorState;
00533         }
00534         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
00535         {
00536                 warning("wrong module id");
00537                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
00538                 return m_iErrorState;
00539         }
00540         m_iErrorState = readShort(iModuleId, CMDID_GETPARAM, PARID_DEF_A0, piValue);
00541 
00542         return m_iErrorState;
00543 }
00544 
00545 int CDevice::getDefC0(int iModuleId, short* piValue)
00546 {
00547         m_iErrorState = 0;
00548         if(m_bInitFlag == false)
00549         {
00550                 warning("device not initialized");
00551                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
00552                 return m_iErrorState;
00553         }
00554         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
00555         {
00556                 warning("wrong module id");
00557                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
00558                 return m_iErrorState;
00559         }
00560         m_iErrorState = readShort(iModuleId, CMDID_GETPARAM, PARID_DEF_C0, piValue);
00561 
00562         return m_iErrorState;
00563 }
00564 
00565 int CDevice::getDefDamp(int iModuleId, short* piValue)
00566 {
00567         m_iErrorState = 0;
00568         if(m_bInitFlag == false)
00569         {
00570                 warning("device not initialized");
00571                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
00572                 return m_iErrorState;
00573         }
00574         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
00575         {
00576                 warning("wrong module id");
00577                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
00578                 return m_iErrorState;
00579         }
00580         m_iErrorState = readShort(iModuleId, CMDID_GETPARAM, PARID_DEF_DAMP, piValue);
00581 
00582         return m_iErrorState;
00583 }
00584 
00585 int CDevice::getDefHomeOffset(int iModuleId, float* pfValue)
00586 {
00587         m_iErrorState = 0;
00588         if(m_bInitFlag == false)
00589         {
00590                 warning("device not initialized");
00591                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
00592                 return m_iErrorState;
00593         }
00594         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
00595         {
00596                 warning("wrong module id");
00597                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
00598                 return m_iErrorState;
00599         }
00600         m_iErrorState = readFloat(iModuleId, CMDID_GETPARAM, PARID_DEF_FHOMEOFFSET, pfValue);
00601 
00602         return m_iErrorState;
00603 }
00604 
00605 int CDevice::getDefHomeVel(int iModuleId, float* pfValue)
00606 {
00607         m_iErrorState = 0;
00608         if(m_bInitFlag == false)
00609         {
00610                 warning("device not initialized");
00611                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
00612                 return m_iErrorState;
00613         }
00614         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
00615         {
00616                 warning("wrong module id");
00617                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
00618                 return m_iErrorState;
00619         }
00620         m_iErrorState = readFloat(iModuleId, CMDID_GETPARAM, PARID_DEF_FHOMEVEL, pfValue);
00621 
00622         return m_iErrorState;
00623 }
00624 
00625 int CDevice::getDefMinPos(int iModuleId, float* pfValue)
00626 {
00627         m_iErrorState = 0;
00628         if(m_bInitFlag == false)
00629         {
00630                 warning("device not initialized");
00631                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
00632                 return m_iErrorState;
00633         }
00634         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
00635         {
00636                 warning("wrong module id");
00637                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
00638                 return m_iErrorState;
00639         }
00640         m_iErrorState = readFloat(iModuleId, CMDID_GETPARAM, PARID_DEF_FMINPOS, pfValue);
00641 
00642         return m_iErrorState;
00643 }
00644 
00645 int CDevice::getDefMaxPos(int iModuleId, float* pfValue)
00646 {
00647         m_iErrorState = 0;
00648         if(m_bInitFlag == false)
00649         {
00650                 warning("device not initialized");
00651                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
00652                 return m_iErrorState;
00653         }
00654         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
00655         {
00656                 warning("wrong module id");
00657                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
00658                 return m_iErrorState;
00659         }
00660         m_iErrorState = readFloat(iModuleId, CMDID_GETPARAM, PARID_DEF_FMAXPOS, pfValue);
00661 
00662         return m_iErrorState;
00663 }
00664 
00665 int CDevice::getDefMaxVel(int iModuleId, float* pfValue)
00666 {
00667         m_iErrorState = 0;
00668         if(m_bInitFlag == false)
00669         {
00670                 warning("device not initialized");
00671                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
00672                 return m_iErrorState;
00673         }
00674         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
00675         {
00676                 warning("wrong module id");
00677                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
00678                 return m_iErrorState;
00679         }
00680         m_iErrorState = readFloat(iModuleId, CMDID_GETPARAM, PARID_DEF_FMAXVEL, pfValue);
00681 
00682         return m_iErrorState;
00683 }
00684 
00685 int CDevice::getDefMaxAcc(int iModuleId, float* pfValue)
00686 {
00687         m_iErrorState = 0;
00688         if(m_bInitFlag == false)
00689         {
00690                 warning("device not initialized");
00691                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
00692                 return m_iErrorState;
00693         }
00694         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
00695         {
00696                 warning("wrong module id");
00697                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
00698                 return m_iErrorState;
00699         }
00700         m_iErrorState = readFloat(iModuleId, CMDID_GETPARAM, PARID_DEF_FMAXACC, pfValue);
00701 
00702         return m_iErrorState;
00703 }
00704 
00705 int CDevice::getDefMaxCur(int iModuleId, float* pfValue)
00706 {
00707         m_iErrorState = 0;
00708         if(m_bInitFlag == false)
00709         {
00710                 warning("device not initialized");
00711                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
00712                 return m_iErrorState;
00713         }
00714         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
00715         {
00716                 warning("wrong module id");
00717                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
00718                 return m_iErrorState;
00719         }
00720         m_iErrorState = readFloat(iModuleId, CMDID_GETPARAM, PARID_DEF_FMAXCUR, pfValue);
00721 
00722         return m_iErrorState;
00723 }
00724 
00725 int CDevice::getDefMaxDeltaPos(int iModuleId, float* pfValue)
00726 {
00727         m_iErrorState = 0;
00728         if(m_bInitFlag == false)
00729         {
00730                 warning("device not initialized");
00731                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
00732                 return m_iErrorState;
00733         }
00734         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
00735         {
00736                 warning("wrong module id");
00737                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
00738                 return m_iErrorState;
00739         }
00740         m_iErrorState = readFloat(iModuleId, CMDID_GETPARAM, PARID_DEF_FMAXDELTAPOS, pfValue);
00741 
00742         return m_iErrorState;
00743 }
00744 
00745 int CDevice::getConfig(int iModuleId, unsigned long* puiValue)
00746 {
00747         m_iErrorState = 0;
00748         if(m_bInitFlag == false)
00749         {
00750                 warning("device not initialized");
00751                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
00752                 return m_iErrorState;
00753         }
00754         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
00755         {
00756                 warning("wrong module id");
00757                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
00758                 return m_iErrorState;
00759         }
00760         m_iErrorState = readUnsignedLong(iModuleId, CMDID_GETPARAM, PARID_ACT_CONFIG, puiValue);
00761 
00762         return m_iErrorState;
00763 }
00764 
00765 int CDevice::getHomeOffset(int iModuleId, float* pfValue)
00766 {
00767         m_iErrorState = 0;
00768         if(m_bInitFlag == false)
00769         {
00770                 warning("device not initialized");
00771                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
00772                 return m_iErrorState;
00773         }
00774         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
00775         {
00776                 warning("wrong module id");
00777                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
00778                 return m_iErrorState;
00779         }
00780         m_iErrorState = readFloat(iModuleId, CMDID_GETPARAM, PARID_ACT_FHOMEOFFSET, pfValue);
00781 
00782         return m_iErrorState;
00783 }
00784 
00785 int CDevice::getHomeOffsetInc(int iModuleId, long* piValue)
00786 {
00787         m_iErrorState = 0;
00788         if(m_bInitFlag == false)
00789         {
00790                 warning("device not initialized");
00791                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
00792                 return m_iErrorState;
00793         }
00794         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
00795         {
00796                 warning("wrong module id");
00797                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
00798                 return m_iErrorState;
00799         }
00800         m_iErrorState = readLong(iModuleId, CMDID_GETPARAM, PARID_ACT_IHOMEOFFSET, piValue);
00801 
00802         return m_iErrorState;
00803 }
00804 
00805 int CDevice::getIncRatio(int iModuleId, float* pfValue)
00806 {
00807         m_iErrorState = 0;
00808         if(m_bInitFlag == false)
00809         {
00810                 warning("device not initialized");
00811                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
00812                 return m_iErrorState;
00813         }
00814         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
00815         {
00816                 warning("wrong module id");
00817                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
00818                 return m_iErrorState;
00819         }
00820         m_iErrorState = readFloat(iModuleId, CMDID_GETPARAM, PARID_ACT_FINCRATIO, pfValue);
00821 
00822         return m_iErrorState;
00823 }
00824 
00825 int CDevice::getDioData(int iModuleId, unsigned long* puiValue)
00826 {
00827         m_iErrorState = 0;
00828         if(m_bInitFlag == false)
00829         {
00830                 warning("device not initialized");
00831                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
00832                 return m_iErrorState;
00833         }
00834         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
00835         {
00836                 warning("wrong module id");
00837                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
00838                 return m_iErrorState;
00839         }
00840         m_iErrorState = readUnsignedLong(iModuleId, CMDID_GETPARAM, PARID_ACT_DIODATA, puiValue);
00841 
00842         return m_iErrorState;
00843 }
00844 
00845 int CDevice::getA0(int iModuleId, short* piValue)
00846 {
00847         m_iErrorState = 0;
00848         if(m_bInitFlag == false)
00849         {
00850                 warning("device not initialized");
00851                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
00852                 return m_iErrorState;
00853         }
00854         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
00855         {
00856                 warning("wrong module id");
00857                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
00858                 return m_iErrorState;
00859         }
00860         m_iErrorState = readShort(iModuleId, CMDID_GETPARAM, PARID_ACT_A0, piValue);
00861 
00862         return m_iErrorState;
00863 }
00864 
00865 int CDevice::getC0(int iModuleId, short* piValue)
00866 {
00867         m_iErrorState = 0;
00868         if(m_bInitFlag == false)
00869         {
00870                 warning("device not initialized");
00871                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
00872                 return m_iErrorState;
00873         }
00874         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
00875         {
00876                 warning("wrong module id");
00877                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
00878                 return m_iErrorState;
00879         }
00880         m_iErrorState = readShort(iModuleId, CMDID_GETPARAM, PARID_ACT_C0, piValue);
00881 
00882         return m_iErrorState;
00883 }
00884 
00885 int CDevice::getDamp(int iModuleId, short* piValue)
00886 {
00887         m_iErrorState = 0;
00888         if(m_bInitFlag == false)
00889         {
00890                 warning("device not initialized");
00891                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
00892                 return m_iErrorState;
00893         }
00894         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
00895         {
00896                 warning("wrong module id");
00897                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
00898                 return m_iErrorState;
00899         }
00900         m_iErrorState = readShort(iModuleId, CMDID_GETPARAM, PARID_ACT_DAMP, piValue);
00901 
00902         return m_iErrorState;
00903 }
00904 
00905 int CDevice::getPos(int iModuleId, float* pfPos)
00906 {
00907         m_iErrorState = 0;
00908         if(m_bInitFlag == false)
00909         {
00910                 warning("device not initialized");
00911                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
00912                 return m_iErrorState;
00913         }
00914         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
00915         {
00916                 warning("wrong module id");
00917                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
00918                 return m_iErrorState;
00919         }
00920         m_iErrorState = readFloat(iModuleId, CMDID_GETPARAM, PARID_ACT_FPOS, pfPos);
00921 
00922         return m_iErrorState;
00923 }
00924 
00925 int CDevice::getVel(int iModuleId, float* pfVel)
00926 {
00927         m_iErrorState = 0;
00928         if(m_bInitFlag == false)
00929         {
00930                 warning("device not initialized");
00931                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
00932                 return m_iErrorState;
00933         }
00934         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
00935         {
00936                 warning("wrong module id");
00937                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
00938                 return m_iErrorState;
00939         }
00940         m_iErrorState = readFloat(iModuleId, CMDID_GETPARAM, PARID_ACT_FVEL, pfVel);
00941 
00942         return m_iErrorState;
00943 }
00944 
00945 int CDevice::getCur(int iModuleId, float* pfCur)
00946 {
00947         m_iErrorState = 0;
00948         if(m_bInitFlag == false)
00949         {
00950                 warning("device not initialized");
00951                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
00952                 return m_iErrorState;
00953         }
00954         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
00955         {
00956                 warning("wrong module id");
00957                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
00958                 return m_iErrorState;
00959         }
00960         m_iErrorState = readFloat(iModuleId, CMDID_GETPARAM, PARID_ACT_FCUR, pfCur);
00961 
00962         return m_iErrorState;
00963 }
00964 
00965 int CDevice::getMinPos(int iModuleId, float* pfValue)
00966 {
00967         m_iErrorState = 0;
00968         if(m_bInitFlag == false)
00969         {
00970                 warning("device not initialized");
00971                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
00972                 return m_iErrorState;
00973         }
00974         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
00975         {
00976                 warning("wrong module id");
00977                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
00978                 return m_iErrorState;
00979         }
00980         m_iErrorState = readFloat(iModuleId, CMDID_GETPARAM, PARID_ACT_FMINPOS, pfValue);
00981 
00982         return m_iErrorState;
00983 }
00984 
00985 int CDevice::getMaxPos(int iModuleId, float* pfValue)
00986 {
00987         m_iErrorState = 0;
00988         if(m_bInitFlag == false)
00989         {
00990                 warning("device not initialized");
00991                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
00992                 return m_iErrorState;
00993         }
00994         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
00995         {
00996                 warning("wrong module id");
00997                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
00998                 return m_iErrorState;
00999         }
01000         m_iErrorState = readFloat(iModuleId, CMDID_GETPARAM, PARID_ACT_FMAXPOS, pfValue);
01001 
01002         return m_iErrorState;
01003 }
01004 
01005 
01006 int CDevice::getMaxVel(int iModuleId, float* pfValue)
01007 {
01008         m_iErrorState = 0;
01009         if(m_bInitFlag == false)
01010         {
01011                 warning("device not initialized");
01012                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
01013                 return m_iErrorState;
01014         }
01015         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
01016         {
01017                 warning("wrong module id");
01018                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
01019                 return m_iErrorState;
01020         }
01021         m_iErrorState = readFloat(iModuleId, CMDID_GETPARAM, PARID_ACT_FMAXVEL, pfValue);
01022 
01023         return m_iErrorState;
01024 }
01025 
01026 int CDevice::getMaxAcc(int iModuleId, float* pfValue)
01027 {
01028         m_iErrorState = 0;
01029         if(m_bInitFlag == false)
01030         {
01031                 warning("device not initialized");
01032                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
01033                 return m_iErrorState;
01034         }
01035         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
01036         {
01037                 warning("wrong module id");
01038                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
01039                 return m_iErrorState;
01040         }
01041         m_iErrorState = readFloat(iModuleId, CMDID_GETPARAM, PARID_ACT_FMAXACC, pfValue);
01042 
01043         return m_iErrorState;
01044 }
01045 
01046 int CDevice::getMaxCur(int iModuleId, float* pfValue)
01047 {
01048         m_iErrorState = 0;
01049         if(m_bInitFlag == false)
01050         {
01051                 warning("device not initialized");
01052                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
01053                 return m_iErrorState;
01054         }
01055         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
01056         {
01057                 warning("wrong module id");
01058                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
01059                 return m_iErrorState;
01060         }
01061         m_iErrorState = readFloat(iModuleId, CMDID_GETPARAM, PARID_ACT_FMAXCUR, pfValue);
01062 
01063         return m_iErrorState;
01064 }
01065 
01066 int CDevice::getDeltaPos(int iModuleId, float* pfValue)
01067 {
01068         m_iErrorState = 0;
01069         if(m_bInitFlag == false)
01070         {
01071                 warning("device not initialized");
01072                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
01073                 return m_iErrorState;
01074         }
01075         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
01076         {
01077                 warning("wrong module id");
01078                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
01079                 return m_iErrorState;
01080         }
01081         m_iErrorState = readFloat(iModuleId, CMDID_GETPARAM, PARID_ACT_FDELTAPOS, pfValue);
01082 
01083         return m_iErrorState;
01084 }
01085 
01086 int CDevice::getMaxDeltaPos(int iModuleId, float* pfValue)
01087 {
01088         m_iErrorState = 0;
01089         if(m_bInitFlag == false)
01090         {
01091                 warning("device not initialized");
01092                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
01093                 return m_iErrorState;
01094         }
01095         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
01096         {
01097                 warning("wrong module id");
01098                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
01099                 return m_iErrorState;
01100         }
01101         m_iErrorState = readFloat(iModuleId, CMDID_GETPARAM, PARID_ACT_FMAXDELTAPOS, pfValue);
01102 
01103         return m_iErrorState;
01104 }
01105 
01106 int CDevice::getSavePos(int iModuleId, float* pfValue)
01107 {
01108         m_iErrorState = 0;
01109         if(m_bInitFlag == false)
01110         {
01111                 warning("device not initialized");
01112                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
01113                 return m_iErrorState;
01114         }
01115         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
01116         {
01117                 warning("wrong module id");
01118                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
01119                 return m_iErrorState;
01120         }
01121         for(int i = 0; i < m_iModuleCount; i++)
01122         {
01123                 if(m_aiModuleId[i] == iModuleId)
01124                 {
01125                         if(m_auiModuleVersion[i] < 0x2518 || (m_auiModuleVersion[i] >= 0x3500 && m_auiModuleVersion[i] < 0x3518))
01126                         {
01127                                 warning("module version does not support function");
01128                                 m_iErrorState = ERRID_DEV_FUNCTIONNOTAVAILABLE;
01129                                 return m_iErrorState;
01130                         }
01131                 }
01132         }
01133         m_iErrorState = readFloat(iModuleId, CMDID_GETPARAM, PARID_ACT_FSAVEPOS, pfValue);
01134 
01135         return m_iErrorState;
01136 }
01137 
01138 int CDevice::getIPolVel(int iModuleId, float* pfVel)
01139 {
01140         m_iErrorState = 0;
01141         if(m_bInitFlag == false)
01142         {
01143                 warning("device not initialized");
01144                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
01145                 return m_iErrorState;
01146         }
01147         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
01148         {
01149                 warning("wrong module id");
01150                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
01151                 return m_iErrorState;
01152         }
01153         m_iErrorState = readFloat(iModuleId, CMDID_GETPARAM, PARID_ACT_FIPOLVEL, pfVel);
01154 
01155         return m_iErrorState;
01156 }
01157 
01158 int CDevice::getPosCountInc(int iModuleId, long* piValue)
01159 {
01160         m_iErrorState = 0;
01161         if(m_bInitFlag == false)
01162         {
01163                 warning("device not initialized");
01164                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
01165                 return m_iErrorState;
01166         }
01167         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
01168         {
01169                 warning("wrong module id");
01170                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
01171                 return m_iErrorState;
01172         }
01173         m_iErrorState = readLong(iModuleId, CMDID_GETPARAM, PARID_ACT_IPOSCOUNT, piValue);
01174 
01175         return m_iErrorState;
01176 }
01177 
01178 int CDevice::getPosInc(int iModuleId, long* piValue)
01179 {
01180         m_iErrorState = 0;
01181         if(m_bInitFlag == false)
01182         {
01183                 warning("device not initialized");
01184                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
01185                 return m_iErrorState;
01186         }
01187         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
01188         {
01189                 warning("wrong module id");
01190                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
01191                 return m_iErrorState;
01192         }
01193         m_iErrorState = readLong(iModuleId, CMDID_GETPARAM, PARID_ACT_IPOS, piValue);
01194 
01195         return m_iErrorState;
01196 }
01197 
01198 int CDevice::getVelInc(int iModuleId, long* piValue)
01199 {
01200         m_iErrorState = 0;
01201         if(m_bInitFlag == false)
01202         {
01203                 warning("device not initialized");
01204                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
01205                 return m_iErrorState;
01206         }
01207         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
01208         {
01209                 warning("wrong module id");
01210                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
01211                 return m_iErrorState;
01212         }
01213         m_iErrorState = readLong(iModuleId, CMDID_GETPARAM, PARID_ACT_IVEL, piValue);
01214 
01215         return m_iErrorState;
01216 }
01217 
01218 int CDevice::getCurInc(int iModuleId, short* piValue)
01219 {
01220         m_iErrorState = 0;
01221         if(m_bInitFlag == false)
01222         {
01223                 warning("device not initialized");
01224                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
01225                 return m_iErrorState;
01226         }
01227         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
01228         {
01229                 warning("wrong module id");
01230                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
01231                 return m_iErrorState;
01232         }
01233         m_iErrorState = readShort(iModuleId, CMDID_GETPARAM, PARID_ACT_ICUR, piValue);
01234 
01235         return m_iErrorState;
01236 }
01237 
01238 int CDevice::getMinPosInc(int iModuleId, long* piValue)
01239 {
01240         m_iErrorState = 0;
01241         if(m_bInitFlag == false)
01242         {
01243                 warning("device not initialized");
01244                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
01245                 return m_iErrorState;
01246         }
01247         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
01248         {
01249                 warning("wrong module id");
01250                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
01251                 return m_iErrorState;
01252         }
01253         m_iErrorState = readLong(iModuleId, CMDID_GETPARAM, PARID_ACT_IMINPOS, piValue);
01254 
01255         return m_iErrorState;
01256 }
01257 
01258 int CDevice::getMaxPosInc(int iModuleId, long* piValue)
01259 {
01260         m_iErrorState = 0;
01261         if(m_bInitFlag == false)
01262         {
01263                 warning("device not initialized");
01264                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
01265                 return m_iErrorState;
01266         }
01267         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
01268         {
01269                 warning("wrong module id");
01270                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
01271                 return m_iErrorState;
01272         }
01273         m_iErrorState = readLong(iModuleId, CMDID_GETPARAM, PARID_ACT_IMAXPOS, piValue);
01274 
01275         return m_iErrorState;
01276 }
01277 
01278 int CDevice::getMaxVelInc(int iModuleId, long* piValue)
01279 {
01280         m_iErrorState = 0;
01281         if(m_bInitFlag == false)
01282         {
01283                 warning("device not initialized");
01284                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
01285                 return m_iErrorState;
01286         }
01287         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
01288         {
01289                 warning("wrong module id");
01290                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
01291                 return m_iErrorState;
01292         }
01293         m_iErrorState = readLong(iModuleId, CMDID_GETPARAM, PARID_ACT_IMAXVEL, piValue);
01294 
01295         return m_iErrorState;
01296 }
01297 
01298 int CDevice::getMaxAccInc(int iModuleId, long* piValue)
01299 {
01300         m_iErrorState = 0;
01301         if(m_bInitFlag == false)
01302         {
01303                 warning("device not initialized");
01304                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
01305                 return m_iErrorState;
01306         }
01307         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
01308         {
01309                 warning("wrong module id");
01310                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
01311                 return m_iErrorState;
01312         }
01313         m_iErrorState = readLong(iModuleId, CMDID_GETPARAM, PARID_ACT_IMAXACC, piValue);
01314 
01315         return m_iErrorState;
01316 }
01317 
01318 int CDevice::getDeltaPosInc(int iModuleId, long* piValue)
01319 {
01320         m_iErrorState = 0;
01321         if(m_bInitFlag == false)
01322         {
01323                 warning("device not initialized");
01324                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
01325                 return m_iErrorState;
01326         }
01327         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
01328         {
01329                 warning("wrong module id");
01330                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
01331                 return m_iErrorState;
01332         }
01333         m_iErrorState = readLong(iModuleId, CMDID_GETPARAM, PARID_ACT_IDELTAPOS, piValue);
01334 
01335         return m_iErrorState;
01336 }
01337 
01338 int CDevice::getMaxDeltaPosInc(int iModuleId, long* piValue)
01339 {
01340         m_iErrorState = 0;
01341         if(m_bInitFlag == false)
01342         {
01343                 warning("device not initialized");
01344                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
01345                 return m_iErrorState;
01346         }
01347         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
01348         {
01349                 warning("wrong module id");
01350                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
01351                 return m_iErrorState;
01352         }
01353         m_iErrorState = readLong(iModuleId, CMDID_GETPARAM, PARID_ACT_IMAXDELTAPOS, piValue);
01354 
01355         return m_iErrorState;
01356 }
01357 
01358 int CDevice::getStateDioPos(int iModuleId, unsigned long* puiState, unsigned char* pucDio, float* pfPos)
01359 {
01360         unsigned char ucState;
01361         m_iErrorState = 0;
01362         if(m_bInitFlag == false)
01363         {
01364                 warning("device not initialized");
01365                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
01366                 return m_iErrorState;
01367         }
01368         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
01369         {
01370                 warning("wrong module id");
01371                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
01372                 return m_iErrorState;
01373         }
01374         for(int i = 0; i < m_iModuleCount; i++)
01375         {
01376                 if(m_aiModuleId[i] == iModuleId)
01377                 {
01378                         if(m_auiModuleVersion[i] < 0x2518 || (m_auiModuleVersion[i] >= 0x3500 && m_auiModuleVersion[i] < 0x3518))
01379                         {
01380                                 warning("module version does not support function");
01381                                 m_iErrorState = ERRID_DEV_FUNCTIONNOTAVAILABLE;
01382                                 return m_iErrorState;
01383                         }
01384                 }
01385         }
01386         m_iErrorState = readFloatUnsignedChars(iModuleId, CMDID_GETPARAM, PARID_ACT_FPOSSTATEDIO, pfPos, &ucState, pucDio);
01387         if(m_iErrorState == 0)
01388                 charStateToLongState(ucState, puiState);
01389         return m_iErrorState;
01390 }
01391 
01392 int CDevice::getHomeVel(int iModuleId, float* pfVel)
01393 {
01394         m_iErrorState = 0;
01395         if(m_bInitFlag == false)
01396         {
01397                 warning("device not initialized");
01398                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
01399                 return m_iErrorState;
01400         }
01401         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
01402         {
01403                 warning("wrong module id");
01404                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
01405                 return m_iErrorState;
01406         }
01407         for(int i = 0; i < m_iModuleCount; i++)
01408         {
01409                 if(m_aiModuleId[i] == iModuleId)
01410                 {
01411                         if(m_auiModuleVersion[i] < 0x2518 || (m_auiModuleVersion[i] >= 0x3500 && m_auiModuleVersion[i] < 0x3518))
01412                         {
01413                                 warning("module version does not support function");
01414                                 m_iErrorState = ERRID_DEV_FUNCTIONNOTAVAILABLE;
01415                                 return m_iErrorState;
01416                         }
01417                 }
01418         }
01419         m_iErrorState = readFloat(iModuleId, CMDID_GETPARAM, PARID_ACT_FHOMEVEL, pfVel);
01420 
01421         return m_iErrorState;
01422 }
01423 
01424 int CDevice::getHomeVelInc(int iModuleId, long* piValue)
01425 {
01426         m_iErrorState = 0;
01427         if(m_bInitFlag == false)
01428         {
01429                 warning("device not initialized");
01430                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
01431                 return m_iErrorState;
01432         }
01433         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
01434         {
01435                 warning("wrong module id");
01436                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
01437                 return m_iErrorState;
01438         }
01439         for(int i = 0; i < m_iModuleCount; i++)
01440         {
01441                 if(m_aiModuleId[i] == iModuleId)
01442                 {
01443                         if(m_auiModuleVersion[i] < 0x2518 || (m_auiModuleVersion[i] >= 0x3500 && m_auiModuleVersion[i] < 0x3518))
01444                         {
01445                                 warning("module version does not support function");
01446                                 m_iErrorState = ERRID_DEV_FUNCTIONNOTAVAILABLE;
01447                                 return m_iErrorState;
01448                         }
01449                 }
01450         }
01451         m_iErrorState = readLong(iModuleId, CMDID_GETPARAM, PARID_ACT_IHOMEVEL, piValue);
01452 
01453         return m_iErrorState;
01454 }
01455 
01456 int CDevice::getSyncTime(int iModuleId, short* piValue)
01457 {
01458         m_iErrorState = 0;
01459         if(m_bInitFlag == false)
01460         {
01461                 warning("device not initialized");
01462                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
01463                 return m_iErrorState;
01464         }
01465         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
01466         {
01467                 warning("wrong module id");
01468                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
01469                 return m_iErrorState;
01470         }
01471         for(int i = 0; i < m_iModuleCount; i++)
01472         {
01473                 if(m_aiModuleId[i] == iModuleId)
01474                 {
01475                         if(m_auiModuleVersion[i] < 0x3602)
01476                         {
01477                                 warning("module version does not support function");
01478                                 m_iErrorState = ERRID_DEV_FUNCTIONNOTAVAILABLE;
01479                                 return m_iErrorState;
01480                         }
01481                 }
01482         }
01483         m_iErrorState = readShort(iModuleId, CMDID_GETPARAM, PARID_ACT_SYNCTIME, piValue);
01484 
01485         return m_iErrorState;
01486 }
01487 
01488 int CDevice::getRawMotorCurrent(int iModuleId, short* piValue)
01489 {
01490         m_iErrorState = 0;
01491         if(m_bInitFlag == false)
01492         {
01493                 warning("device not initialized");
01494                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
01495                 return m_iErrorState;
01496         }
01497         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
01498         {
01499                 warning("wrong module id");
01500                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
01501                 return m_iErrorState;
01502         }
01503         for(int i = 0; i < m_iModuleCount; i++)
01504         {
01505                 if(m_aiModuleId[i] == iModuleId)
01506                 {
01507                         if(m_auiModuleVersion[i] < 0x3602)
01508                         {
01509                                 warning("module version does not support function");
01510                                 m_iErrorState = ERRID_DEV_FUNCTIONNOTAVAILABLE;
01511                                 return m_iErrorState;
01512                         }
01513                 }
01514         }
01515         m_iErrorState = readShort(iModuleId, CMDID_GETPARAM, PARID_ACT_RAWMOTCUR, piValue);
01516 
01517         return m_iErrorState;
01518 }
01519 
01520 int CDevice::getRawMotorSupply(int iModuleId, short* piValue)
01521 {
01522         m_iErrorState = 0;
01523         if(m_bInitFlag == false)
01524         {
01525                 warning("device not initialized");
01526                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
01527                 return m_iErrorState;
01528         }
01529         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
01530         {
01531                 warning("wrong module id");
01532                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
01533                 return m_iErrorState;
01534         }
01535         for(int i = 0; i < m_iModuleCount; i++)
01536         {
01537                 if(m_aiModuleId[i] == iModuleId)
01538                 {
01539                         if(m_auiModuleVersion[i] < 0x3602)
01540                         {
01541                                 warning("module version does not support function");
01542                                 m_iErrorState = ERRID_DEV_FUNCTIONNOTAVAILABLE;
01543                                 return m_iErrorState;
01544                         }
01545                 }
01546         }
01547         m_iErrorState = readShort(iModuleId, CMDID_GETPARAM, PARID_ACT_RAWMOTSUPPLY, piValue);
01548 
01549         return m_iErrorState;
01550 }
01551 
01552 int CDevice::getRawTemperature(int iModuleId, short* piValue)
01553 {
01554         m_iErrorState = 0;
01555         if(m_bInitFlag == false)
01556         {
01557                 warning("device not initialized");
01558                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
01559                 return m_iErrorState;
01560         }
01561         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
01562         {
01563                 warning("wrong module id");
01564                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
01565                 return m_iErrorState;
01566         }
01567         for(int i = 0; i < m_iModuleCount; i++)
01568         {
01569                 if(m_aiModuleId[i] == iModuleId)
01570                 {
01571                         if(m_auiModuleVersion[i] < 0x3602)
01572                         {
01573                                 warning("module version does not support function");
01574                                 m_iErrorState = ERRID_DEV_FUNCTIONNOTAVAILABLE;
01575                                 return m_iErrorState;
01576                         }
01577                 }
01578         }
01579         m_iErrorState = readShort(iModuleId, CMDID_GETPARAM, PARID_ACT_RAWTEMP, piValue);
01580 
01581         return m_iErrorState;
01582 }
01583 
01584 int CDevice::getRawLogicSupply(int iModuleId, short* piValue)
01585 {
01586         m_iErrorState = 0;
01587         if(m_bInitFlag == false)
01588         {
01589                 warning("device not initialized");
01590                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
01591                 return m_iErrorState;
01592         }
01593         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
01594         {
01595                 warning("wrong module id");
01596                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
01597                 return m_iErrorState;
01598         }
01599         for(int i = 0; i < m_iModuleCount; i++)
01600         {
01601                 if(m_aiModuleId[i] == iModuleId)
01602                 {
01603                         if(m_auiModuleVersion[i] < 0x3602)
01604                         {
01605                                 warning("module version does not support function");
01606                                 m_iErrorState = ERRID_DEV_FUNCTIONNOTAVAILABLE;
01607                                 return m_iErrorState;
01608                         }
01609                 }
01610         }
01611         m_iErrorState = readShort(iModuleId, CMDID_GETPARAM, PARID_ACT_RAWLOGICSUPPLY, piValue);
01612 
01613         return m_iErrorState;
01614 }
01615 
01616 int CDevice::getLoadLimit(int iModuleId, long* piValue)
01617 {
01618         m_iErrorState = 0;
01619         if(m_bInitFlag == false)
01620         {
01621                 warning("device not initialized");
01622                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
01623                 return m_iErrorState;
01624         }
01625         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
01626         {
01627                 warning("wrong module id");
01628                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
01629                 return m_iErrorState;
01630         }
01631         for(int i = 0; i < m_iModuleCount; i++)
01632         {
01633                 if(m_aiModuleId[i] == iModuleId)
01634                 {
01635                         if(m_auiModuleVersion[i] < 0x351A )
01636                         {
01637                                 warning("module version does not support function");
01638                                 m_iErrorState = ERRID_DEV_FUNCTIONNOTAVAILABLE;
01639                                 return m_iErrorState;
01640                         }
01641                 }
01642         }
01643         m_iErrorState = readLong(iModuleId, CMDID_GETPARAM, PARID_ACT_LOADLIMIT, piValue);
01644 
01645         return m_iErrorState;
01646 }
01647 
01648 int CDevice::getMaxLoadGradient(int iModuleId, long* piValue)
01649 {
01650         m_iErrorState = 0;
01651         if(m_bInitFlag == false)
01652         {
01653                 warning("device not initialized");
01654                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
01655                 return m_iErrorState;
01656         }
01657         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
01658         {
01659                 warning("wrong module id");
01660                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
01661                 return m_iErrorState;
01662         }
01663         for(int i = 0; i < m_iModuleCount; i++)
01664         {
01665                 if(m_aiModuleId[i] == iModuleId)
01666                 {
01667                         if(m_auiModuleVersion[i] < 0x351A )
01668                         {
01669                                 warning("module version does not support function");
01670                                 m_iErrorState = ERRID_DEV_FUNCTIONNOTAVAILABLE;
01671                                 return m_iErrorState;
01672                         }
01673                 }
01674         }
01675         m_iErrorState = readLong(iModuleId, CMDID_GETPARAM, PARID_ACT_MAXLOADGRADIENT, piValue);
01676 
01677         return m_iErrorState;
01678 }
01679 
01680 int CDevice::getLoadDeltaTime(int iModuleId, unsigned short* piValue)
01681 {
01682         m_iErrorState = 0;
01683         if(m_bInitFlag == false)
01684         {
01685                 warning("device not initialized");
01686                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
01687                 return m_iErrorState;
01688         }
01689         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
01690         {
01691                 warning("wrong module id");
01692                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
01693                 return m_iErrorState;
01694         }
01695         for(int i = 0; i < m_iModuleCount; i++)
01696         {
01697                 if(m_aiModuleId[i] == iModuleId)
01698                 {
01699                         if(m_auiModuleVersion[i] < 0x351A)
01700                         {
01701                                 warning("module version does not support function");
01702                                 m_iErrorState = ERRID_DEV_FUNCTIONNOTAVAILABLE;
01703                                 return m_iErrorState;
01704                         }
01705                 }
01706         }
01707         m_iErrorState = readShort(iModuleId, CMDID_GETPARAM, PARID_ACT_LOADDELTATIME, (short*)piValue);
01708 
01709         return m_iErrorState;
01710 }
01711 
01712 int CDevice::getMotorCurrent(int iModuleId, float* pfValue)
01713 {
01714         m_iErrorState = 0;
01715         if(m_bInitFlag == false)
01716         {
01717                 warning("device not initialized");
01718                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
01719                 return m_iErrorState;
01720         }
01721         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
01722         {
01723                 warning("wrong module id");
01724                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
01725                 return m_iErrorState;
01726         }
01727         for(int i = 0; i < m_iModuleCount; i++)
01728         {
01729                 if(m_aiModuleId[i] == iModuleId)
01730                 {
01731                         if(m_auiModuleVersion[i] < 0x4601)
01732                         {
01733                                 warning("module version does not support function");
01734                                 m_iErrorState = ERRID_DEV_FUNCTIONNOTAVAILABLE;
01735                                 return m_iErrorState;
01736                         }
01737                 }
01738         }
01739         m_iErrorState = readFloat(iModuleId, CMDID_GETPARAM, PARID_ACT_FMOTCUR, pfValue);
01740 
01741         return m_iErrorState;
01742 }
01743 
01744 int CDevice::getMotorSupply(int iModuleId, float* pfValue)
01745 {
01746         m_iErrorState = 0;
01747         if(m_bInitFlag == false)
01748         {
01749                 warning("device not initialized");
01750                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
01751                 return m_iErrorState;
01752         }
01753         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
01754         {
01755                 warning("wrong module id");
01756                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
01757                 return m_iErrorState;
01758         }
01759         for(int i = 0; i < m_iModuleCount; i++)
01760         {
01761                 if(m_aiModuleId[i] == iModuleId)
01762                 {
01763                         if(m_auiModuleVersion[i] < 0x4601)
01764                         {
01765                                 warning("module version does not support function");
01766                                 m_iErrorState = ERRID_DEV_FUNCTIONNOTAVAILABLE;
01767                                 return m_iErrorState;
01768                         }
01769                 }
01770         }
01771         m_iErrorState = readFloat(iModuleId, CMDID_GETPARAM, PARID_ACT_FMOTSUPPLY, pfValue);
01772 
01773         return m_iErrorState;
01774 }
01775 
01776 int CDevice::getTemperature(int iModuleId, float* pfValue)
01777 {
01778         m_iErrorState = 0;
01779         if(m_bInitFlag == false)
01780         {
01781                 warning("device not initialized");
01782                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
01783                 return m_iErrorState;
01784         }
01785         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
01786         {
01787                 warning("wrong module id");
01788                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
01789                 return m_iErrorState;
01790         }
01791         for(int i = 0; i < m_iModuleCount; i++)
01792         {
01793                 if(m_aiModuleId[i] == iModuleId)
01794                 {
01795                         if(m_auiModuleVersion[i] < 0x4601)
01796                         {
01797                                 warning("module version does not support function");
01798                                 m_iErrorState = ERRID_DEV_FUNCTIONNOTAVAILABLE;
01799                                 return m_iErrorState;
01800                         }
01801                 }
01802         }
01803         m_iErrorState = readFloat(iModuleId, CMDID_GETPARAM, PARID_ACT_FTEMP, pfValue);
01804 
01805         return m_iErrorState;
01806 }
01807 
01808 int CDevice::getLogicSupply(int iModuleId, float* pfValue)
01809 {
01810         m_iErrorState = 0;
01811         if(m_bInitFlag == false)
01812         {
01813                 warning("device not initialized");
01814                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
01815                 return m_iErrorState;
01816         }
01817         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
01818         {
01819                 warning("wrong module id");
01820                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
01821                 return m_iErrorState;
01822         }
01823         for(int i = 0; i < m_iModuleCount; i++)
01824         {
01825                 if(m_aiModuleId[i] == iModuleId)
01826                 {
01827                         if(m_auiModuleVersion[i] < 0x4601)
01828                         {
01829                                 warning("module version does not support function");
01830                                 m_iErrorState = ERRID_DEV_FUNCTIONNOTAVAILABLE;
01831                                 return m_iErrorState;
01832                         }
01833                 }
01834         }
01835         m_iErrorState = readFloat(iModuleId, CMDID_GETPARAM, PARID_ACT_FLOGICSUPPLY, pfValue);
01836 
01837         return m_iErrorState;
01838 }
01839 
01840 int CDevice::getMinLogicVoltage(int iModuleId, float* pfValue)
01841 {
01842         m_iErrorState = 0;
01843         if(m_bInitFlag == false)
01844         {
01845                 warning("device not initialized");
01846                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
01847                 return m_iErrorState;
01848         }
01849         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
01850         {
01851                 warning("wrong module id");
01852                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
01853                 return m_iErrorState;
01854         }
01855         for(int i = 0; i < m_iModuleCount; i++)
01856         {
01857                 if(m_aiModuleId[i] == iModuleId)
01858                 {
01859                         if(m_auiModuleVersion[i] < 0x4601)
01860                         {
01861                                 warning("module version does not support function");
01862                                 m_iErrorState = ERRID_DEV_FUNCTIONNOTAVAILABLE;
01863                                 return m_iErrorState;
01864                         }
01865                 }
01866         }
01867         m_iErrorState = readFloat(iModuleId, CMDID_GETPARAM, PARID_ACT_MINLOGIC, pfValue);
01868 
01869         return m_iErrorState;
01870 }
01871 
01872 int CDevice::getMaxLogicVoltage(int iModuleId, float* pfValue)
01873 {
01874         m_iErrorState = 0;
01875         if(m_bInitFlag == false)
01876         {
01877                 warning("device not initialized");
01878                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
01879                 return m_iErrorState;
01880         }
01881         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
01882         {
01883                 warning("wrong module id");
01884                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
01885                 return m_iErrorState;
01886         }
01887         for(int i = 0; i < m_iModuleCount; i++)
01888         {
01889                 if(m_aiModuleId[i] == iModuleId)
01890                 {
01891                         if(m_auiModuleVersion[i] < 0x4601)
01892                         {
01893                                 warning("module version does not support function");
01894                                 m_iErrorState = ERRID_DEV_FUNCTIONNOTAVAILABLE;
01895                                 return m_iErrorState;
01896                         }
01897                 }
01898         }
01899         m_iErrorState = readFloat(iModuleId, CMDID_GETPARAM, PARID_ACT_MAXLOGIC, pfValue);
01900 
01901         return m_iErrorState;
01902 }
01903 
01904 int CDevice::getMinMotorVoltage(int iModuleId, float* pfValue)
01905 {
01906         m_iErrorState = 0;
01907         if(m_bInitFlag == false)
01908         {
01909                 warning("device not initialized");
01910                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
01911                 return m_iErrorState;
01912         }
01913         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
01914         {
01915                 warning("wrong module id");
01916                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
01917                 return m_iErrorState;
01918         }
01919         for(int i = 0; i < m_iModuleCount; i++)
01920         {
01921                 if(m_aiModuleId[i] == iModuleId)
01922                 {
01923                         if(m_auiModuleVersion[i] < 0x4601)
01924                         {
01925                                 warning("module version does not support function");
01926                                 m_iErrorState = ERRID_DEV_FUNCTIONNOTAVAILABLE;
01927                                 return m_iErrorState;
01928                         }
01929                 }
01930         }
01931         m_iErrorState = readFloat(iModuleId, CMDID_GETPARAM, PARID_ACT_MINMOTOR, pfValue);
01932 
01933         return m_iErrorState;
01934 }
01935 
01936 int CDevice::getMaxMotorVoltage(int iModuleId, float* pfValue)
01937 {
01938         m_iErrorState = 0;
01939         if(m_bInitFlag == false)
01940         {
01941                 warning("device not initialized");
01942                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
01943                 return m_iErrorState;
01944         }
01945         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
01946         {
01947                 warning("wrong module id");
01948                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
01949                 return m_iErrorState;
01950         }
01951         for(int i = 0; i < m_iModuleCount; i++)
01952         {
01953                 if(m_aiModuleId[i] == iModuleId)
01954                 {
01955                         if(m_auiModuleVersion[i] < 0x4601)
01956                         {
01957                                 warning("module version does not support function");
01958                                 m_iErrorState = ERRID_DEV_FUNCTIONNOTAVAILABLE;
01959                                 return m_iErrorState;
01960                         }
01961                 }
01962         }
01963         m_iErrorState = readFloat(iModuleId, CMDID_GETPARAM, PARID_ACT_MAXMOTOR, pfValue);
01964 
01965         return m_iErrorState;
01966 }
01967 
01968 int CDevice::getNominalMotorCurrent(int iModuleId, float* pfValue)
01969 {
01970         m_iErrorState = 0;
01971         if(m_bInitFlag == false)
01972         {
01973                 warning("device not initialized");
01974                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
01975                 return m_iErrorState;
01976         }
01977         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
01978         {
01979                 warning("wrong module id");
01980                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
01981                 return m_iErrorState;
01982         }
01983         for(int i = 0; i < m_iModuleCount; i++)
01984         {
01985                 if(m_aiModuleId[i] == iModuleId)
01986                 {
01987                         if(m_auiModuleVersion[i] < 0x4601)
01988                         {
01989                                 warning("module version does not support function");
01990                                 m_iErrorState = ERRID_DEV_FUNCTIONNOTAVAILABLE;
01991                                 return m_iErrorState;
01992                         }
01993                 }
01994         }
01995         m_iErrorState = readFloat(iModuleId, CMDID_GETPARAM, PARID_ACT_NOMCUR, pfValue);
01996 
01997         return m_iErrorState;
01998 }
01999 
02000 int CDevice::getMaximumMotorCurrent(int iModuleId, float* pfValue)
02001 {
02002         m_iErrorState = 0;
02003         if(m_bInitFlag == false)
02004         {
02005                 warning("device not initialized");
02006                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
02007                 return m_iErrorState;
02008         }
02009         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
02010         {
02011                 warning("wrong module id");
02012                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
02013                 return m_iErrorState;
02014         }
02015         for(int i = 0; i < m_iModuleCount; i++)
02016         {
02017                 if(m_aiModuleId[i] == iModuleId)
02018                 {
02019                         if(m_auiModuleVersion[i] < 0x4601)
02020                         {
02021                                 warning("module version does not support function");
02022                                 m_iErrorState = ERRID_DEV_FUNCTIONNOTAVAILABLE;
02023                                 return m_iErrorState;
02024                         }
02025                 }
02026         }
02027         m_iErrorState = readFloat(iModuleId, CMDID_GETPARAM, PARID_ACT_HMAXCUR, pfValue);
02028 
02029         return m_iErrorState;
02030 }
02031 
02032 int CDevice::getLogicUndershootTime(int iModuleId, long* piValue)
02033 {
02034         m_iErrorState = 0;
02035         if(m_bInitFlag == false)
02036         {
02037                 warning("device not initialized");
02038                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
02039                 return m_iErrorState;
02040         }
02041         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
02042         {
02043                 warning("wrong module id");
02044                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
02045                 return m_iErrorState;
02046         }
02047         for(int i = 0; i < m_iModuleCount; i++)
02048         {
02049                 if(m_aiModuleId[i] == iModuleId)
02050                 {
02051                         if(m_auiModuleVersion[i] < 0x4601 )
02052                         {
02053                                 warning("module version does not support function");
02054                                 m_iErrorState = ERRID_DEV_FUNCTIONNOTAVAILABLE;
02055                                 return m_iErrorState;
02056                         }
02057                 }
02058         }
02059         m_iErrorState = readLong(iModuleId, CMDID_GETPARAM, PARID_ACT_LOGICUNDERSHOOT, piValue);
02060 
02061         return m_iErrorState;
02062 }
02063 
02064 int CDevice::getLogicOvershootTime(int iModuleId, long* piValue)
02065 {
02066         m_iErrorState = 0;
02067         if(m_bInitFlag == false)
02068         {
02069                 warning("device not initialized");
02070                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
02071                 return m_iErrorState;
02072         }
02073         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
02074         {
02075                 warning("wrong module id");
02076                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
02077                 return m_iErrorState;
02078         }
02079         for(int i = 0; i < m_iModuleCount; i++)
02080         {
02081                 if(m_aiModuleId[i] == iModuleId)
02082                 {
02083                         if(m_auiModuleVersion[i] < 0x4601 )
02084                         {
02085                                 warning("module version does not support function");
02086                                 m_iErrorState = ERRID_DEV_FUNCTIONNOTAVAILABLE;
02087                                 return m_iErrorState;
02088                         }
02089                 }
02090         }
02091         m_iErrorState = readLong(iModuleId, CMDID_GETPARAM, PARID_ACT_LOGICOVERSHOOT, piValue);
02092 
02093         return m_iErrorState;
02094 }
02095 
02096 int CDevice::getMotorUndershootTime(int iModuleId, long* piValue)
02097 {
02098         m_iErrorState = 0;
02099         if(m_bInitFlag == false)
02100         {
02101                 warning("device not initialized");
02102                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
02103                 return m_iErrorState;
02104         }
02105         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
02106         {
02107                 warning("wrong module id");
02108                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
02109                 return m_iErrorState;
02110         }
02111         for(int i = 0; i < m_iModuleCount; i++)
02112         {
02113                 if(m_aiModuleId[i] == iModuleId)
02114                 {
02115                         if(m_auiModuleVersion[i] < 0x4601 )
02116                         {
02117                                 warning("module version does not support function");
02118                                 m_iErrorState = ERRID_DEV_FUNCTIONNOTAVAILABLE;
02119                                 return m_iErrorState;
02120                         }
02121                 }
02122         }
02123         m_iErrorState = readLong(iModuleId, CMDID_GETPARAM, PARID_ACT_MOTORUNDERSHOOT, piValue);
02124 
02125         return m_iErrorState;
02126 }
02127 
02128 int CDevice::getMotorOvershootTime(int iModuleId, long* piValue)
02129 {
02130         m_iErrorState = 0;
02131         if(m_bInitFlag == false)
02132         {
02133                 warning("device not initialized");
02134                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
02135                 return m_iErrorState;
02136         }
02137         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
02138         {
02139                 warning("wrong module id");
02140                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
02141                 return m_iErrorState;
02142         }
02143         for(int i = 0; i < m_iModuleCount; i++)
02144         {
02145                 if(m_aiModuleId[i] == iModuleId)
02146                 {
02147                         if(m_auiModuleVersion[i] < 0x4601 )
02148                         {
02149                                 warning("module version does not support function");
02150                                 m_iErrorState = ERRID_DEV_FUNCTIONNOTAVAILABLE;
02151                                 return m_iErrorState;
02152                         }
02153                 }
02154         }
02155         m_iErrorState = readLong(iModuleId, CMDID_GETPARAM, PARID_ACT_MOTOROVERSHOOT, piValue);
02156 
02157         return m_iErrorState;
02158 }
02159 
02160 int CDevice::getNomCurOvershootTime(int iModuleId, long* piValue)
02161 {
02162         m_iErrorState = 0;
02163         if(m_bInitFlag == false)
02164         {
02165                 warning("device not initialized");
02166                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
02167                 return m_iErrorState;
02168         }
02169         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
02170         {
02171                 warning("wrong module id");
02172                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
02173                 return m_iErrorState;
02174         }
02175         for(int i = 0; i < m_iModuleCount; i++)
02176         {
02177                 if(m_aiModuleId[i] == iModuleId)
02178                 {
02179                         if(m_auiModuleVersion[i] < 0x4601 )
02180                         {
02181                                 warning("module version does not support function");
02182                                 m_iErrorState = ERRID_DEV_FUNCTIONNOTAVAILABLE;
02183                                 return m_iErrorState;
02184                         }
02185                 }
02186         }
02187         m_iErrorState = readLong(iModuleId, CMDID_GETPARAM, PARID_ACT_NOMCUROVERSHOOT, piValue);
02188 
02189         return m_iErrorState;
02190 }
02191 
02192 int CDevice::getHMaxCurOvershootTime(int iModuleId, long* piValue)
02193 {
02194         m_iErrorState = 0;
02195         if(m_bInitFlag == false)
02196         {
02197                 warning("device not initialized");
02198                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
02199                 return m_iErrorState;
02200         }
02201         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
02202         {
02203                 warning("wrong module id");
02204                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
02205                 return m_iErrorState;
02206         }
02207         for(int i = 0; i < m_iModuleCount; i++)
02208         {
02209                 if(m_aiModuleId[i] == iModuleId)
02210                 {
02211                         if(m_auiModuleVersion[i] < 0x4601 )
02212                         {
02213                                 warning("module version does not support function");
02214                                 m_iErrorState = ERRID_DEV_FUNCTIONNOTAVAILABLE;
02215                                 return m_iErrorState;
02216                         }
02217                 }
02218         }
02219         m_iErrorState = readLong(iModuleId, CMDID_GETPARAM, PARID_ACT_HMAXCUROVERSHOOT, piValue);
02220 
02221         return m_iErrorState;
02222 }
02223 
02224 int CDevice::getKpPWMLimit(int iModuleId, long* piValue)
02225 {
02226         m_iErrorState = 0;
02227         if(m_bInitFlag == false)
02228         {
02229                 warning("device not initialized");
02230                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
02231                 return m_iErrorState;
02232         }
02233         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
02234         {
02235                 warning("wrong module id");
02236                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
02237                 return m_iErrorState;
02238         }
02239         for(int i = 0; i < m_iModuleCount; i++)
02240         {
02241                 if(m_aiModuleId[i] == iModuleId)
02242                 {
02243                         if(m_auiModuleVersion[i] < 0x4601 )
02244                         {
02245                                 warning("module version does not support function");
02246                                 m_iErrorState = ERRID_DEV_FUNCTIONNOTAVAILABLE;
02247                                 return m_iErrorState;
02248                         }
02249                 }
02250         }
02251         m_iErrorState = readLong(iModuleId, CMDID_GETPARAM, PARID_ACT_KP_PWMLIM, piValue);
02252 
02253         return m_iErrorState;
02254 }
02255 
02256 int CDevice::getCurrentLimit(int iModuleId, float* pfValue)
02257 {
02258         m_iErrorState = 0;
02259         if(m_bInitFlag == false)
02260         {
02261                 warning("device not initialized");
02262                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
02263                 return m_iErrorState;
02264         }
02265         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
02266         {
02267                 warning("wrong module id");
02268                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
02269                 return m_iErrorState;
02270         }
02271         for(int i = 0; i < m_iModuleCount; i++)
02272         {
02273                 if(m_aiModuleId[i] == iModuleId)
02274                 {
02275                         if(m_auiModuleVersion[i] < 0x4601)
02276                         {
02277                                 warning("module version does not support function");
02278                                 m_iErrorState = ERRID_DEV_FUNCTIONNOTAVAILABLE;
02279                                 return m_iErrorState;
02280                         }
02281                 }
02282         }
02283         m_iErrorState = readFloat(iModuleId, CMDID_GETPARAM, PARID_ACT_CURRENTLIMIT, pfValue);
02284 
02285         return m_iErrorState;
02286 }
02287 
02288 int CDevice::getMaxPWMOutput(int iModuleId, long* piValue)
02289 {
02290         m_iErrorState = 0;
02291         if(m_bInitFlag == false)
02292         {
02293                 warning("device not initialized");
02294                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
02295                 return m_iErrorState;
02296         }
02297         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
02298         {
02299                 warning("wrong module id");
02300                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
02301                 return m_iErrorState;
02302         }
02303         for(int i = 0; i < m_iModuleCount; i++)
02304         {
02305                 if(m_aiModuleId[i] == iModuleId)
02306                 {
02307                         if(m_auiModuleVersion[i] < 0x4601 )
02308                         {
02309                                 warning("module version does not support function");
02310                                 m_iErrorState = ERRID_DEV_FUNCTIONNOTAVAILABLE;
02311                                 return m_iErrorState;
02312                         }
02313                 }
02314         }
02315         m_iErrorState = readLong(iModuleId, CMDID_GETPARAM, PARID_ACT_MAXPWMOUTPUT, piValue);
02316 
02317         return m_iErrorState;
02318 }
02319 
02320 // ========================================================================== ;
02321 //                                                                            ;
02322 // ---- modify functions ---------------------------------------------------- ;
02323 //                                                                            ;
02324 // ========================================================================== ;
02325 
02326 void CDevice::setName(const char* acName)
02327 {
02328         strncpy(m_acName, acName, 128);
02329 }
02330 
02331 void CDevice::setInitString(const char* acInitString)
02332 {
02333         strncpy(m_acInitString, acInitString, 128);
02334 }
02335 
02336 int CDevice::setConfig(int iModuleId, unsigned long uiValue)
02337 {
02338         m_iErrorState = 0;
02339         if(m_bInitFlag == false)
02340         {
02341                 warning("device not initialized");
02342                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
02343                 return m_iErrorState;
02344         }
02345         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
02346         {
02347                 warning("wrong module id");
02348                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
02349                 return m_iErrorState;
02350         }
02351         m_iErrorState = writeUnsignedLong(iModuleId, CMDID_SETPARAM, PARID_ACT_CONFIG, uiValue);
02352 
02353         return m_iErrorState;
02354 }
02355 
02356 int CDevice::setHomeOffset(int iModuleId, float fValue)
02357 {
02358         m_iErrorState = 0;
02359         if(m_bInitFlag == false)
02360         {
02361                 warning("device not initialized");
02362                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
02363                 return m_iErrorState;
02364         }
02365         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
02366         {
02367                 warning("wrong module id");
02368                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
02369                 return m_iErrorState;
02370         }
02371         m_iErrorState = writeFloat(iModuleId, CMDID_SETPARAM, PARID_ACT_FHOMEOFFSET, fValue);
02372 
02373         return m_iErrorState;
02374 }
02375 
02376 int CDevice::setHomeOffsetInc(int iModuleId, long iValue)
02377 {
02378         m_iErrorState = 0;
02379         if(m_bInitFlag == false)
02380         {
02381                 warning("device not initialized");
02382                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
02383                 return m_iErrorState;
02384         }
02385         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
02386         {
02387                 warning("wrong module id");
02388                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
02389                 return m_iErrorState;
02390         }
02391         m_iErrorState = writeLong(iModuleId, CMDID_SETPARAM, PARID_ACT_IHOMEOFFSET, iValue);
02392 
02393         return m_iErrorState;
02394 }
02395 
02396 int CDevice::setDioData(int iModuleId, unsigned long uiValue)
02397 {
02398         m_iErrorState = 0;
02399         if(m_bInitFlag == false)
02400         {
02401                 warning("device not initialized");
02402                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
02403                 return m_iErrorState;
02404         }
02405         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
02406         {
02407                 warning("wrong module id");
02408                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
02409                 return m_iErrorState;
02410         }
02411         m_iErrorState = writeUnsignedLong(iModuleId, CMDID_SETPARAM, PARID_ACT_DIODATA, uiValue);
02412 
02413         return m_iErrorState;
02414 }
02415 
02416 int CDevice::setA0(int iModuleId, short iValue)
02417 {
02418         m_iErrorState = 0;
02419         if(m_bInitFlag == false)
02420         {
02421                 warning("device not initialized");
02422                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
02423                 return m_iErrorState;
02424         }
02425         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
02426         {
02427                 warning("wrong module id");
02428                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
02429                 return m_iErrorState;
02430         }
02431         m_iErrorState = writeShort(iModuleId, CMDID_SETPARAM, PARID_ACT_A0, iValue);
02432 
02433         return m_iErrorState;
02434 }
02435 
02436 int CDevice::setC0(int iModuleId, short iValue)
02437 {
02438         m_iErrorState = 0;
02439         if(m_bInitFlag == false)
02440         {
02441                 warning("device not initialized");
02442                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
02443                 return m_iErrorState;
02444         }
02445         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
02446         {
02447                 warning("wrong module id");
02448                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
02449                 return m_iErrorState;
02450         }
02451         m_iErrorState = writeShort(iModuleId, CMDID_SETPARAM, PARID_ACT_C0, iValue);
02452 
02453         return m_iErrorState;
02454 }
02455 
02456 int CDevice::setDamp(int iModuleId, short iValue)
02457 {
02458         m_iErrorState = 0;
02459         if(m_bInitFlag == false)
02460         {
02461                 warning("device not initialized");
02462                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
02463                 return m_iErrorState;
02464         }
02465         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
02466         {
02467                 warning("wrong module id");
02468                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
02469                 return m_iErrorState;
02470         }
02471         m_iErrorState = writeShort(iModuleId, CMDID_SETPARAM, PARID_ACT_DAMP, iValue);
02472 
02473         return m_iErrorState;
02474 }
02475 
02476 int CDevice::setMinPos(int iModuleId, float fValue)
02477 {
02478         m_iErrorState = 0;
02479         if(m_bInitFlag == false)
02480         {
02481                 warning("device not initialized");
02482                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
02483                 return m_iErrorState;
02484         }
02485         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
02486         {
02487                 warning("wrong module id");
02488                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
02489                 return m_iErrorState;
02490         }
02491         m_iErrorState = writeFloat(iModuleId, CMDID_SETPARAM, PARID_ACT_FMINPOS, fValue);
02492 
02493         return m_iErrorState;
02494 }
02495 
02496 int CDevice::setMaxPos(int iModuleId, float fValue)
02497 {
02498         m_iErrorState = 0;
02499         if(m_bInitFlag == false)
02500         {
02501                 warning("device not initialized");
02502                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
02503                 return m_iErrorState;
02504         }
02505         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
02506         {
02507                 warning("wrong module id");
02508                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
02509                 return m_iErrorState;
02510         }
02511         m_iErrorState = writeFloat(iModuleId, CMDID_SETPARAM, PARID_ACT_FMAXPOS, fValue);
02512 
02513         return m_iErrorState;
02514 }
02515 
02516 int CDevice::setMaxVel(int iModuleId, float fValue)
02517 {
02518         m_iErrorState = 0;
02519         if(m_bInitFlag == false)
02520         {
02521                 warning("device not initialized");
02522                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
02523                 return m_iErrorState;
02524         }
02525         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
02526         {
02527                 warning("wrong module id");
02528                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
02529                 return m_iErrorState;
02530         }
02531         m_iErrorState = writeFloat(iModuleId, CMDID_SETPARAM, PARID_ACT_FMAXVEL, fValue);
02532 
02533         return m_iErrorState;
02534 }
02535 
02536 int CDevice::setMaxAcc(int iModuleId, float fValue)
02537 {
02538         m_iErrorState = 0;
02539         if(m_bInitFlag == false)
02540         {
02541                 warning("device not initialized");
02542                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
02543                 return m_iErrorState;
02544         }
02545         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
02546         {
02547                 warning("wrong module id");
02548                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
02549                 return m_iErrorState;
02550         }
02551         m_iErrorState = writeFloat(iModuleId, CMDID_SETPARAM, PARID_ACT_FMAXACC, fValue);
02552 
02553         return m_iErrorState;
02554 }
02555 
02556 int CDevice::setMaxCur(int iModuleId, float fValue)
02557 {
02558         m_iErrorState = 0;
02559         if(m_bInitFlag == false)
02560         {
02561                 warning("device not initialized");
02562                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
02563                 return m_iErrorState;
02564         }
02565         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
02566         {
02567                 warning("wrong module id");
02568                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
02569                 return m_iErrorState;
02570         }
02571         m_iErrorState = writeFloat(iModuleId, CMDID_SETPARAM, PARID_ACT_FMAXCUR, fValue);
02572 
02573         return m_iErrorState;
02574 }
02575 
02576 int CDevice::setMaxDeltaPos(int iModuleId, float fValue)
02577 {
02578         m_iErrorState = 0;
02579         if(m_bInitFlag == false)
02580         {
02581                 warning("device not initialized");
02582                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
02583                 return m_iErrorState;
02584         }
02585         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
02586         {
02587                 warning("wrong module id");
02588                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
02589                 return m_iErrorState;
02590         }
02591         m_iErrorState = writeFloat(iModuleId, CMDID_SETPARAM, PARID_ACT_FMAXDELTAPOS, fValue);
02592 
02593         return m_iErrorState;
02594 }
02595 
02596 int CDevice::setMinPosInc(int iModuleId, long iValue)
02597 {
02598         m_iErrorState = 0;
02599         if(m_bInitFlag == false)
02600         {
02601                 warning("device not initialized");
02602                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
02603                 return m_iErrorState;
02604         }
02605         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
02606         {
02607                 warning("wrong module id");
02608                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
02609                 return m_iErrorState;
02610         }
02611         m_iErrorState = writeLong(iModuleId, CMDID_SETPARAM, PARID_ACT_IMINPOS, iValue);
02612 
02613         return m_iErrorState;
02614 }
02615 
02616 int CDevice::setMaxPosInc(int iModuleId, long iValue)
02617 {
02618         m_iErrorState = 0;
02619         if(m_bInitFlag == false)
02620         {
02621                 warning("device not initialized");
02622                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
02623                 return m_iErrorState;
02624         }
02625         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
02626         {
02627                 warning("wrong module id");
02628                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
02629                 return m_iErrorState;
02630         }
02631         m_iErrorState = writeLong(iModuleId, CMDID_SETPARAM, PARID_ACT_IMAXPOS, iValue);
02632 
02633         return m_iErrorState;
02634 }
02635 
02636 int CDevice::setMaxVelInc(int iModuleId, long iValue)
02637 {
02638         m_iErrorState = 0;
02639         if(m_bInitFlag == false)
02640         {
02641                 warning("device not initialized");
02642                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
02643                 return m_iErrorState;
02644         }
02645         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
02646         {
02647                 warning("wrong module id");
02648                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
02649                 return m_iErrorState;
02650         }
02651         m_iErrorState = writeLong(iModuleId, CMDID_SETPARAM, PARID_ACT_IMAXVEL, iValue);
02652 
02653         return m_iErrorState;
02654 }
02655 
02656 int CDevice::setMaxAccInc(int iModuleId, long iValue)
02657 {
02658         m_iErrorState = 0;
02659         if(m_bInitFlag == false)
02660         {
02661                 warning("device not initialized");
02662                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
02663                 return m_iErrorState;
02664         }
02665         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
02666         {
02667                 warning("wrong module id");
02668                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
02669                 return m_iErrorState;
02670         }
02671         m_iErrorState = writeLong(iModuleId, CMDID_SETPARAM, PARID_ACT_IMAXACC, iValue);
02672 
02673         return m_iErrorState;
02674 }
02675 
02676 int CDevice::setMaxDeltaPosInc(int iModuleId, long iValue)
02677 {
02678         m_iErrorState = 0;
02679         if(m_bInitFlag == false)
02680         {
02681                 warning("device not initialized");
02682                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
02683                 return m_iErrorState;
02684         }
02685         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
02686         {
02687                 warning("wrong module id");
02688                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
02689                 return m_iErrorState;
02690         }
02691         m_iErrorState = writeLong(iModuleId, CMDID_SETPARAM, PARID_ACT_IMAXDELTAPOS, iValue);
02692 
02693         return m_iErrorState;
02694 }
02695 
02696 int CDevice::setHomeVel(int iModuleId, float fValue)
02697 {
02698         m_iErrorState = 0;
02699         if(m_bInitFlag == false)
02700         {
02701                 warning("device not initialized");
02702                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
02703                 return m_iErrorState;
02704         }
02705         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
02706         {
02707                 warning("wrong module id");
02708                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
02709                 return m_iErrorState;
02710         }
02711         for(int i = 0; i < m_iModuleCount; i++)
02712         {
02713                 if(m_aiModuleId[i] == iModuleId)
02714                 {
02715                         if(m_auiModuleVersion[i] < 0x2518 || (m_auiModuleVersion[i] >= 0x3500 && m_auiModuleVersion[i] < 0x3518))
02716                         {
02717                                 warning("module version does not support function");
02718                                 m_iErrorState = ERRID_DEV_FUNCTIONNOTAVAILABLE;
02719                                 return m_iErrorState;
02720                         }
02721                 }
02722         }
02723         m_iErrorState = writeFloat(iModuleId, CMDID_SETPARAM, PARID_ACT_FHOMEVEL, fValue);
02724 
02725         return m_iErrorState;
02726 }
02727 
02728 int CDevice::setHomeVelInc(int iModuleId, long iValue)
02729 {
02730         m_iErrorState = 0;
02731         if(m_bInitFlag == false)
02732         {
02733                 warning("device not initialized");
02734                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
02735                 return m_iErrorState;
02736         }
02737         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
02738         {
02739                 warning("wrong module id");
02740                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
02741                 return m_iErrorState;
02742         }
02743         for(int i = 0; i < m_iModuleCount; i++)
02744         {
02745                 if(m_aiModuleId[i] == iModuleId)
02746                 {
02747                         if(m_auiModuleVersion[i] < 0x2518 || (m_auiModuleVersion[i] >= 0x3500 && m_auiModuleVersion[i] < 0x3518))
02748                         {
02749                                 warning("module version does not support function");
02750                                 m_iErrorState = ERRID_DEV_FUNCTIONNOTAVAILABLE;
02751                                 return m_iErrorState;
02752                         }
02753                 }
02754         }
02755         m_iErrorState = writeLong(iModuleId, CMDID_SETPARAM, PARID_ACT_IHOMEVEL, iValue);
02756 
02757         return m_iErrorState;
02758 }
02759 
02760 int CDevice::setRampVel(int iModuleId, float fValue)
02761 {
02762         m_iErrorState = 0;
02763         if(m_bInitFlag == false)
02764         {
02765                 warning("device not initialized");
02766                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
02767                 return m_iErrorState;
02768         }
02769         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
02770         {
02771                 warning("wrong module id");
02772                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
02773                 return m_iErrorState;
02774         }
02775         m_iErrorState = writeFloat(iModuleId, CMDID_SETPARAM, PARID_ACT_FRAMPVEL, fValue);
02776 
02777         return m_iErrorState;
02778 }
02779 
02780 int CDevice::setRampVelInc(int iModuleId, long iValue)
02781 {
02782         m_iErrorState = 0;
02783         if(m_bInitFlag == false)
02784         {
02785                 warning("device not initialized");
02786                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
02787                 return m_iErrorState;
02788         }
02789         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
02790         {
02791                 warning("wrong module id");
02792                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
02793                 return m_iErrorState;
02794         }
02795         m_iErrorState = writeLong(iModuleId, CMDID_SETPARAM, PARID_ACT_IRAMPVEL, iValue);
02796 
02797         return m_iErrorState;
02798 }
02799 
02800 int CDevice::setRampAcc(int iModuleId, float fValue)
02801 {
02802         m_iErrorState = 0;
02803         if(m_bInitFlag == false)
02804         {
02805                 warning("device not initialized");
02806                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
02807                 return m_iErrorState;
02808         }
02809         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
02810         {
02811                 warning("wrong module id");
02812                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
02813                 return m_iErrorState;
02814         }
02815         m_iErrorState = writeFloat(iModuleId, CMDID_SETPARAM, PARID_ACT_FRAMPACC, fValue);
02816 
02817         return m_iErrorState;
02818 }
02819 
02820 int CDevice::setRampAccInc(int iModuleId, long iValue)
02821 {
02822         m_iErrorState = 0;
02823         if(m_bInitFlag == false)
02824         {
02825                 warning("device not initialized");
02826                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
02827                 return m_iErrorState;
02828         }
02829         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
02830         {
02831                 warning("wrong module id");
02832                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
02833                 return m_iErrorState;
02834         }
02835         m_iErrorState = writeLong(iModuleId, CMDID_SETPARAM, PARID_ACT_IRAMPACC, iValue);
02836 
02837         return m_iErrorState;
02838 }
02839 
02840 int CDevice::setSyncTime(int iModuleId, short iValue)
02841 {
02842         m_iErrorState = 0;
02843         if(m_bInitFlag == false)
02844         {
02845                 warning("device not initialized");
02846                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
02847                 return m_iErrorState;
02848         }
02849         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
02850         {
02851                 warning("wrong module id");
02852                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
02853                 return m_iErrorState;
02854         }
02855         for(int i = 0; i < m_iModuleCount; i++)
02856         {
02857                 if(m_aiModuleId[i] == iModuleId)
02858                 {
02859                         if(m_auiModuleVersion[i] < 0x3602)
02860                         {
02861                                 warning("module version does not support function");
02862                                 m_iErrorState = ERRID_DEV_FUNCTIONNOTAVAILABLE;
02863                                 return m_iErrorState;
02864                         }
02865                 }
02866         }
02867         m_iErrorState = writeShort(iModuleId, CMDID_SETPARAM, PARID_ACT_SYNCTIME, iValue);
02868 
02869         return m_iErrorState;
02870 }
02871 
02872 int CDevice::setLoadLimit(int iModuleId, long iValue)
02873 {
02874         m_iErrorState = 0;
02875         if(m_bInitFlag == false)
02876         {
02877                 warning("device not initialized");
02878                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
02879                 return m_iErrorState;
02880         }
02881         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
02882         {
02883                 warning("wrong module id");
02884                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
02885                 return m_iErrorState;
02886         }
02887         for(int i = 0; i < m_iModuleCount; i++)
02888         {
02889                 if(m_aiModuleId[i] == iModuleId)
02890                 {
02891                         if(m_auiModuleVersion[i] < 0x351A)
02892                         {
02893                                 warning("module version does not support function");
02894                                 m_iErrorState = ERRID_DEV_FUNCTIONNOTAVAILABLE;
02895                                 return m_iErrorState;
02896                         }
02897                 }
02898         }
02899         m_iErrorState = writeLong(iModuleId, CMDID_SETPARAM, PARID_ACT_LOADLIMIT, iValue);
02900 
02901         return m_iErrorState;
02902 }
02903 
02904 int CDevice::setMaxLoadGradient(int iModuleId, long iValue)
02905 {
02906         m_iErrorState = 0;
02907         if(m_bInitFlag == false)
02908         {
02909                 warning("device not initialized");
02910                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
02911                 return m_iErrorState;
02912         }
02913         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
02914         {
02915                 warning("wrong module id");
02916                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
02917                 return m_iErrorState;
02918         }
02919         for(int i = 0; i < m_iModuleCount; i++)
02920         {
02921                 if(m_aiModuleId[i] == iModuleId)
02922                 {
02923                         if(m_auiModuleVersion[i] < 0x351A)
02924                         {
02925                                 warning("module version does not support function");
02926                                 m_iErrorState = ERRID_DEV_FUNCTIONNOTAVAILABLE;
02927                                 return m_iErrorState;
02928                         }
02929                 }
02930         }
02931         m_iErrorState = writeLong(iModuleId, CMDID_SETPARAM, PARID_ACT_MAXLOADGRADIENT, iValue);
02932 
02933         return m_iErrorState;
02934 }
02935 
02936 int CDevice::setLoadDeltaTime(int iModuleId, unsigned short iValue)
02937 {
02938         m_iErrorState = 0;
02939         if(m_bInitFlag == false)
02940         {
02941                 warning("device not initialized");
02942                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
02943                 return m_iErrorState;
02944         }
02945         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
02946         {
02947                 warning("wrong module id");
02948                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
02949                 return m_iErrorState;
02950         }
02951         for(int i = 0; i < m_iModuleCount; i++)
02952         {
02953                 if(m_aiModuleId[i] == iModuleId)
02954                 {
02955                         if(m_auiModuleVersion[i] < 0x351A)
02956                         {
02957                                 warning("module version does not support function");
02958                                 m_iErrorState = ERRID_DEV_FUNCTIONNOTAVAILABLE;
02959                                 return m_iErrorState;
02960                         }
02961                 }
02962         }
02963         m_iErrorState = writeShort(iModuleId, CMDID_SETPARAM, PARID_ACT_LOADDELTATIME, iValue);
02964 
02965         return m_iErrorState;
02966 }
02967 
02968 int CDevice::setDefGearRatio(int iModuleId, float fValue)
02969 {
02970         m_iErrorState = 0;
02971         if(m_bInitFlag == false)
02972         {
02973                 warning("device not initialized");
02974                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
02975                 return m_iErrorState;
02976         }
02977         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
02978         {
02979                 warning("wrong module id");
02980                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
02981                 return m_iErrorState;
02982         }
02983         for(int i = 0; i < m_iModuleCount; i++)
02984         {
02985                 if(m_aiModuleId[i] == iModuleId)
02986                 {
02987                         if(m_auiModuleVersion[i] < 0x4601)
02988                         {
02989                                 warning("module version does not support function");
02990                                 m_iErrorState = ERRID_DEV_FUNCTIONNOTAVAILABLE;
02991                                 return m_iErrorState;
02992                         }
02993                 }
02994         }
02995         m_iErrorState = writeFloat(iModuleId, CMDID_SETPARAM, PARID_DEF_FGEARRATIO, fValue);
02996 
02997         return m_iErrorState;
02998 }
02999 
03000 int CDevice::setDefLinRatio(int iModuleId, float fValue)
03001 {
03002         m_iErrorState = 0;
03003         if(m_bInitFlag == false)
03004         {
03005                 warning("device not initialized");
03006                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
03007                 return m_iErrorState;
03008         }
03009         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
03010         {
03011                 warning("wrong module id");
03012                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
03013                 return m_iErrorState;
03014         }
03015         for(int i = 0; i < m_iModuleCount; i++)
03016         {
03017                 if(m_aiModuleId[i] == iModuleId)
03018                 {
03019                         if(m_auiModuleVersion[i] < 0x4601)
03020                         {
03021                                 warning("module version does not support function");
03022                                 m_iErrorState = ERRID_DEV_FUNCTIONNOTAVAILABLE;
03023                                 return m_iErrorState;
03024                         }
03025                 }
03026         }
03027         m_iErrorState = writeFloat(iModuleId, CMDID_SETPARAM, PARID_DEF_FLINEARRATIO, fValue);
03028 
03029         return m_iErrorState;
03030 }
03031 
03032 int CDevice::setDefCurRatio(int iModuleId, float fValue)
03033 {
03034         m_iErrorState = 0;
03035         if(m_bInitFlag == false)
03036         {
03037                 warning("device not initialized");
03038                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
03039                 return m_iErrorState;
03040         }
03041         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
03042         {
03043                 warning("wrong module id");
03044                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
03045                 return m_iErrorState;
03046         }
03047         for(int i = 0; i < m_iModuleCount; i++)
03048         {
03049                 if(m_aiModuleId[i] == iModuleId)
03050                 {
03051                         if(m_auiModuleVersion[i] < 0x4601)
03052                         {
03053                                 warning("module version does not support function");
03054                                 m_iErrorState = ERRID_DEV_FUNCTIONNOTAVAILABLE;
03055                                 return m_iErrorState;
03056                         }
03057                 }
03058         }
03059         m_iErrorState = writeFloat(iModuleId, CMDID_SETPARAM, PARID_DEF_FCURRATIO, fValue);
03060 
03061         return m_iErrorState;
03062 }
03063 
03064 int CDevice::setDefHomeAcc(int iModuleId, float fValue)
03065 {
03066         m_iErrorState = 0;
03067         if(m_bInitFlag == false)
03068         {
03069                 warning("device not initialized");
03070                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
03071                 return m_iErrorState;
03072         }
03073         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
03074         {
03075                 warning("wrong module id");
03076                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
03077                 return m_iErrorState;
03078         }
03079         for(int i = 0; i < m_iModuleCount; i++)
03080         {
03081                 if(m_aiModuleId[i] == iModuleId)
03082                 {
03083                         if(m_auiModuleVersion[i] < 0x4601)
03084                         {
03085                                 warning("module version does not support function");
03086                                 m_iErrorState = ERRID_DEV_FUNCTIONNOTAVAILABLE;
03087                                 return m_iErrorState;
03088                         }
03089                 }
03090         }
03091         m_iErrorState = writeFloat(iModuleId, CMDID_SETPARAM, PARID_DEF_FHOMEACC, fValue);
03092 
03093         return m_iErrorState;
03094 }
03095 
03096 int CDevice::setModuleSerialNo(int iModuleId, unsigned long uiValue)
03097 {
03098         m_iErrorState = 0;
03099         if(m_bInitFlag == false)
03100         {
03101                 warning("device not initialized");
03102                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
03103                 return m_iErrorState;
03104         }
03105         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
03106         {
03107                 warning("wrong module id");
03108                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
03109                 return m_iErrorState;
03110         }
03111         for(int i = 0; i < m_iModuleCount; i++)
03112         {
03113                 if(m_aiModuleId[i] == iModuleId)
03114                 {
03115                         if(m_auiModuleVersion[i] < 0x4601)
03116                         {
03117                                 warning("module version does not support function");
03118                                 m_iErrorState = ERRID_DEV_FUNCTIONNOTAVAILABLE;
03119                                 return m_iErrorState;
03120                         }
03121                 }
03122         }
03123         m_iErrorState = writeLong(iModuleId, CMDID_SETPARAM, PARID_DEF_SERIALNO, uiValue);
03124 
03125         return m_iErrorState;
03126 }
03127 
03128 int CDevice::setDefIncPerTurn(int iModuleId, unsigned long uiValue)
03129 {
03130         m_iErrorState = 0;
03131         if(m_bInitFlag == false)
03132         {
03133                 warning("device not initialized");
03134                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
03135                 return m_iErrorState;
03136         }
03137         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
03138         {
03139                 warning("wrong module id");
03140                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
03141                 return m_iErrorState;
03142         }
03143         for(int i = 0; i < m_iModuleCount; i++)
03144         {
03145                 if(m_aiModuleId[i] == iModuleId)
03146                 {
03147                         if(m_auiModuleVersion[i] < 0x4601)
03148                         {
03149                                 warning("module version does not support function");
03150                                 m_iErrorState = ERRID_DEV_FUNCTIONNOTAVAILABLE;
03151                                 return m_iErrorState;
03152                         }
03153                 }
03154         }
03155         m_iErrorState = writeLong(iModuleId, CMDID_SETPARAM, PARID_DEF_INCPERTURN, uiValue);
03156 
03157         return m_iErrorState;
03158 }
03159 
03160 int CDevice::setDefBrakeTimeOut(int iModuleId, unsigned short uiValue)
03161 {
03162         m_iErrorState = 0;
03163         if(m_bInitFlag == false)
03164         {
03165                 warning("device not initialized");
03166                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
03167                 return m_iErrorState;
03168         }
03169         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
03170         {
03171                 warning("wrong module id");
03172                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
03173                 return m_iErrorState;
03174         }
03175         for(int i = 0; i < m_iModuleCount; i++)
03176         {
03177                 if(m_aiModuleId[i] == iModuleId)
03178                 {
03179                         if(m_auiModuleVersion[i] < 0x4601)
03180                         {
03181                                 warning("module version does not support function");
03182                                 m_iErrorState = ERRID_DEV_FUNCTIONNOTAVAILABLE;
03183                                 return m_iErrorState;
03184                         }
03185                 }
03186         }
03187         m_iErrorState = writeShort(iModuleId, CMDID_SETPARAM, PARID_DEF_BRAKETIMEOUT, uiValue);
03188 
03189         return m_iErrorState;
03190 }
03191 
03192 int CDevice::setDefAddress(int iModuleId, unsigned char uiValue)
03193 {
03194         m_iErrorState = 0;
03195         if(m_bInitFlag == false)
03196         {
03197                 warning("device not initialized");
03198                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
03199                 return m_iErrorState;
03200         }
03201         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
03202         {
03203                 warning("wrong module id");
03204                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
03205                 return m_iErrorState;
03206         }
03207         for(int i = 0; i < m_iModuleCount; i++)
03208         {
03209                 if(m_aiModuleId[i] == iModuleId)
03210                 {
03211                         if(m_auiModuleVersion[i] < 0x4601)
03212                         {
03213                                 warning("module version does not support function");
03214                                 m_iErrorState = ERRID_DEV_FUNCTIONNOTAVAILABLE;
03215                                 return m_iErrorState;
03216                         }
03217                 }
03218         }
03219         m_iErrorState = writeChar(iModuleId, CMDID_SETPARAM, PARID_DEF_ADDRESS, uiValue);
03220 
03221         return m_iErrorState;
03222 }
03223 
03224 int CDevice::setDefCANBaudRate(int iModuleId, unsigned char uiValue)
03225 {
03226         m_iErrorState = 0;
03227         if(m_bInitFlag == false)
03228         {
03229                 warning("device not initialized");
03230                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
03231                 return m_iErrorState;
03232         }
03233         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
03234         {
03235                 warning("wrong module id");
03236                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
03237                 return m_iErrorState;
03238         }
03239         for(int i = 0; i < m_iModuleCount; i++)
03240         {
03241                 if(m_aiModuleId[i] == iModuleId)
03242                 {
03243                         if(m_auiModuleVersion[i] < 0x4601)
03244                         {
03245                                 warning("module version does not support function");
03246                                 m_iErrorState = ERRID_DEV_FUNCTIONNOTAVAILABLE;
03247                                 return m_iErrorState;
03248                         }
03249                 }
03250         }
03251         m_iErrorState = writeChar(iModuleId, CMDID_SETPARAM, PARID_DEF_CANBAUDRATE, uiValue);
03252 
03253         return m_iErrorState;
03254 }
03255 
03256 int CDevice::setDefRSBaudRate(int iModuleId, unsigned char uiValue)
03257 {
03258         m_iErrorState = 0;
03259         if(m_bInitFlag == false)
03260         {
03261                 warning("device not initialized");
03262                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
03263                 return m_iErrorState;
03264         }
03265         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
03266         {
03267                 warning("wrong module id");
03268                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
03269                 return m_iErrorState;
03270         }
03271         for(int i = 0; i < m_iModuleCount; i++)
03272         {
03273                 if(m_aiModuleId[i] == iModuleId)
03274                 {
03275                         if(m_auiModuleVersion[i] < 0x4601)
03276                         {
03277                                 warning("module version does not support function");
03278                                 m_iErrorState = ERRID_DEV_FUNCTIONNOTAVAILABLE;
03279                                 return m_iErrorState;
03280                         }
03281                 }
03282         }
03283         m_iErrorState = writeChar(iModuleId, CMDID_SETPARAM, PARID_DEF_RSBAUDRATE, uiValue);
03284 
03285         return m_iErrorState;
03286 }
03287 
03288 int CDevice::setDefSetup(int iModuleId, unsigned long uiValue)
03289 {
03290         m_iErrorState = 0;
03291         if(m_bInitFlag == false)
03292         {
03293                 warning("device not initialized");
03294                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
03295                 return m_iErrorState;
03296         }
03297         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
03298         {
03299                 warning("wrong module id");
03300                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
03301                 return m_iErrorState;
03302         }
03303         for(int i = 0; i < m_iModuleCount; i++)
03304         {
03305                 if(m_aiModuleId[i] == iModuleId)
03306                 {
03307                         if(m_auiModuleVersion[i] < 0x4601)
03308                         {
03309                                 warning("module version does not support function");
03310                                 m_iErrorState = ERRID_DEV_FUNCTIONNOTAVAILABLE;
03311                                 return m_iErrorState;
03312                         }
03313                 }
03314         }
03315         m_iErrorState = writeLong(iModuleId, CMDID_SETPARAM, PARID_DEF_SETUP, uiValue);
03316 
03317         return m_iErrorState;
03318 }
03319 
03320 int CDevice::setMinLogicVoltage(int iModuleId, float fValue)
03321 {
03322         m_iErrorState = 0;
03323         if(m_bInitFlag == false)
03324         {
03325                 warning("device not initialized");
03326                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
03327                 return m_iErrorState;
03328         }
03329         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
03330         {
03331                 warning("wrong module id");
03332                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
03333                 return m_iErrorState;
03334         }
03335         for(int i = 0; i < m_iModuleCount; i++)
03336         {
03337                 if(m_aiModuleId[i] == iModuleId)
03338                 {
03339                         if(m_auiModuleVersion[i] < 0x4601)
03340                         {
03341                                 warning("module version does not support function");
03342                                 m_iErrorState = ERRID_DEV_FUNCTIONNOTAVAILABLE;
03343                                 return m_iErrorState;
03344                         }
03345                 }
03346         }
03347         m_iErrorState = writeFloat(iModuleId, CMDID_SETPARAM, PARID_ACT_MINLOGIC, fValue);
03348 
03349         return m_iErrorState;
03350 }
03351 
03352 int CDevice::setMaxLogicVoltage(int iModuleId, float fValue)
03353 {
03354         m_iErrorState = 0;
03355         if(m_bInitFlag == false)
03356         {
03357                 warning("device not initialized");
03358                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
03359                 return m_iErrorState;
03360         }
03361         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
03362         {
03363                 warning("wrong module id");
03364                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
03365                 return m_iErrorState;
03366         }
03367         for(int i = 0; i < m_iModuleCount; i++)
03368         {
03369                 if(m_aiModuleId[i] == iModuleId)
03370                 {
03371                         if(m_auiModuleVersion[i] < 0x4601)
03372                         {
03373                                 warning("module version does not support function");
03374                                 m_iErrorState = ERRID_DEV_FUNCTIONNOTAVAILABLE;
03375                                 return m_iErrorState;
03376                         }
03377                 }
03378         }
03379         m_iErrorState = writeFloat(iModuleId, CMDID_SETPARAM, PARID_ACT_MAXLOGIC, fValue);
03380 
03381         return m_iErrorState;
03382 }
03383 
03384 int CDevice::setMinMotorVoltage(int iModuleId, float fValue)
03385 {
03386         m_iErrorState = 0;
03387         if(m_bInitFlag == false)
03388         {
03389                 warning("device not initialized");
03390                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
03391                 return m_iErrorState;
03392         }
03393         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
03394         {
03395                 warning("wrong module id");
03396                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
03397                 return m_iErrorState;
03398         }
03399         for(int i = 0; i < m_iModuleCount; i++)
03400         {
03401                 if(m_aiModuleId[i] == iModuleId)
03402                 {
03403                         if(m_auiModuleVersion[i] < 0x4601)
03404                         {
03405                                 warning("module version does not support function");
03406                                 m_iErrorState = ERRID_DEV_FUNCTIONNOTAVAILABLE;
03407                                 return m_iErrorState;
03408                         }
03409                 }
03410         }
03411         m_iErrorState = writeFloat(iModuleId, CMDID_SETPARAM, PARID_ACT_MINMOTOR, fValue);
03412 
03413         return m_iErrorState;
03414 }
03415 
03416 int CDevice::setMaxMotorVoltage(int iModuleId, float fValue)
03417 {
03418         m_iErrorState = 0;
03419         if(m_bInitFlag == false)
03420         {
03421                 warning("device not initialized");
03422                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
03423                 return m_iErrorState;
03424         }
03425         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
03426         {
03427                 warning("wrong module id");
03428                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
03429                 return m_iErrorState;
03430         }
03431         for(int i = 0; i < m_iModuleCount; i++)
03432         {
03433                 if(m_aiModuleId[i] == iModuleId)
03434                 {
03435                         if(m_auiModuleVersion[i] < 0x4601)
03436                         {
03437                                 warning("module version does not support function");
03438                                 m_iErrorState = ERRID_DEV_FUNCTIONNOTAVAILABLE;
03439                                 return m_iErrorState;
03440                         }
03441                 }
03442         }
03443         m_iErrorState = writeFloat(iModuleId, CMDID_SETPARAM, PARID_ACT_MAXMOTOR, fValue);
03444 
03445         return m_iErrorState;
03446 }
03447 
03448 int CDevice::setNominalMotorCurrent(int iModuleId, float fValue)
03449 {
03450         m_iErrorState = 0;
03451         if(m_bInitFlag == false)
03452         {
03453                 warning("device not initialized");
03454                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
03455                 return m_iErrorState;
03456         }
03457         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
03458         {
03459                 warning("wrong module id");
03460                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
03461                 return m_iErrorState;
03462         }
03463         for(int i = 0; i < m_iModuleCount; i++)
03464         {
03465                 if(m_aiModuleId[i] == iModuleId)
03466                 {
03467                         if(m_auiModuleVersion[i] < 0x4601)
03468                         {
03469                                 warning("module version does not support function");
03470                                 m_iErrorState = ERRID_DEV_FUNCTIONNOTAVAILABLE;
03471                                 return m_iErrorState;
03472                         }
03473                 }
03474         }
03475         m_iErrorState = writeFloat(iModuleId, CMDID_SETPARAM, PARID_ACT_NOMCUR, fValue);
03476 
03477         return m_iErrorState;
03478 }
03479 
03480 int CDevice::setMaximumMotorCurrent(int iModuleId, float fValue)
03481 {
03482         m_iErrorState = 0;
03483         if(m_bInitFlag == false)
03484         {
03485                 warning("device not initialized");
03486                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
03487                 return m_iErrorState;
03488         }
03489         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
03490         {
03491                 warning("wrong module id");
03492                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
03493                 return m_iErrorState;
03494         }
03495         for(int i = 0; i < m_iModuleCount; i++)
03496         {
03497                 if(m_aiModuleId[i] == iModuleId)
03498                 {
03499                         if(m_auiModuleVersion[i] < 0x4601)
03500                         {
03501                                 warning("module version does not support function");
03502                                 m_iErrorState = ERRID_DEV_FUNCTIONNOTAVAILABLE;
03503                                 return m_iErrorState;
03504                         }
03505                 }
03506         }
03507         m_iErrorState = writeFloat(iModuleId, CMDID_SETPARAM, PARID_ACT_HMAXCUR, fValue);
03508 
03509         return m_iErrorState;
03510 }
03511 
03512 int CDevice::setLogicUndershootTime(int iModuleId, long iValue)
03513 {
03514         m_iErrorState = 0;
03515         if(m_bInitFlag == false)
03516         {
03517                 warning("device not initialized");
03518                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
03519                 return m_iErrorState;
03520         }
03521         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
03522         {
03523                 warning("wrong module id");
03524                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
03525                 return m_iErrorState;
03526         }
03527         for(int i = 0; i < m_iModuleCount; i++)
03528         {
03529                 if(m_aiModuleId[i] == iModuleId)
03530                 {
03531                         if(m_auiModuleVersion[i] < 0x4601)
03532                         {
03533                                 warning("module version does not support function");
03534                                 m_iErrorState = ERRID_DEV_FUNCTIONNOTAVAILABLE;
03535                                 return m_iErrorState;
03536                         }
03537                 }
03538         }
03539         m_iErrorState = writeLong(iModuleId, CMDID_SETPARAM, PARID_ACT_LOGICUNDERSHOOT, iValue);
03540 
03541         return m_iErrorState;
03542 }
03543 
03544 int CDevice::setLogicOvershootTime(int iModuleId, long iValue)
03545 {
03546         m_iErrorState = 0;
03547         if(m_bInitFlag == false)
03548         {
03549                 warning("device not initialized");
03550                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
03551                 return m_iErrorState;
03552         }
03553         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
03554         {
03555                 warning("wrong module id");
03556                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
03557                 return m_iErrorState;
03558         }
03559         for(int i = 0; i < m_iModuleCount; i++)
03560         {
03561                 if(m_aiModuleId[i] == iModuleId)
03562                 {
03563                         if(m_auiModuleVersion[i] < 0x4601)
03564                         {
03565                                 warning("module version does not support function");
03566                                 m_iErrorState = ERRID_DEV_FUNCTIONNOTAVAILABLE;
03567                                 return m_iErrorState;
03568                         }
03569                 }
03570         }
03571         m_iErrorState = writeLong(iModuleId, CMDID_SETPARAM, PARID_ACT_LOGICOVERSHOOT, iValue);
03572 
03573         return m_iErrorState;
03574 }
03575 
03576 int CDevice::setMotorUndershootTime(int iModuleId, long iValue)
03577 {
03578         m_iErrorState = 0;
03579         if(m_bInitFlag == false)
03580         {
03581                 warning("device not initialized");
03582                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
03583                 return m_iErrorState;
03584         }
03585         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
03586         {
03587                 warning("wrong module id");
03588                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
03589                 return m_iErrorState;
03590         }
03591         for(int i = 0; i < m_iModuleCount; i++)
03592         {
03593                 if(m_aiModuleId[i] == iModuleId)
03594                 {
03595                         if(m_auiModuleVersion[i] < 0x4601)
03596                         {
03597                                 warning("module version does not support function");
03598                                 m_iErrorState = ERRID_DEV_FUNCTIONNOTAVAILABLE;
03599                                 return m_iErrorState;
03600                         }
03601                 }
03602         }
03603         m_iErrorState = writeLong(iModuleId, CMDID_SETPARAM, PARID_ACT_MOTORUNDERSHOOT, iValue);
03604 
03605         return m_iErrorState;
03606 }
03607 
03608 int CDevice::setMotorOvershootTime(int iModuleId, long iValue)
03609 {
03610         m_iErrorState = 0;
03611         if(m_bInitFlag == false)
03612         {
03613                 warning("device not initialized");
03614                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
03615                 return m_iErrorState;
03616         }
03617         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
03618         {
03619                 warning("wrong module id");
03620                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
03621                 return m_iErrorState;
03622         }
03623         for(int i = 0; i < m_iModuleCount; i++)
03624         {
03625                 if(m_aiModuleId[i] == iModuleId)
03626                 {
03627                         if(m_auiModuleVersion[i] < 0x4601)
03628                         {
03629                                 warning("module version does not support function");
03630                                 m_iErrorState = ERRID_DEV_FUNCTIONNOTAVAILABLE;
03631                                 return m_iErrorState;
03632                         }
03633                 }
03634         }
03635         m_iErrorState = writeLong(iModuleId, CMDID_SETPARAM, PARID_ACT_MOTOROVERSHOOT, iValue);
03636 
03637         return m_iErrorState;
03638 }
03639 
03640 int CDevice::setNomCurOvershootTime(int iModuleId, long iValue)
03641 {
03642         m_iErrorState = 0;
03643         if(m_bInitFlag == false)
03644         {
03645                 warning("device not initialized");
03646                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
03647                 return m_iErrorState;
03648         }
03649         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
03650         {
03651                 warning("wrong module id");
03652                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
03653                 return m_iErrorState;
03654         }
03655         for(int i = 0; i < m_iModuleCount; i++)
03656         {
03657                 if(m_aiModuleId[i] == iModuleId)
03658                 {
03659                         if(m_auiModuleVersion[i] < 0x4601)
03660                         {
03661                                 warning("module version does not support function");
03662                                 m_iErrorState = ERRID_DEV_FUNCTIONNOTAVAILABLE;
03663                                 return m_iErrorState;
03664                         }
03665                 }
03666         }
03667         m_iErrorState = writeLong(iModuleId, CMDID_SETPARAM, PARID_ACT_NOMCUROVERSHOOT, iValue);
03668 
03669         return m_iErrorState;
03670 }
03671 
03672 int CDevice::setHMaxCurOvershootTime(int iModuleId, long iValue)
03673 {
03674         m_iErrorState = 0;
03675         if(m_bInitFlag == false)
03676         {
03677                 warning("device not initialized");
03678                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
03679                 return m_iErrorState;
03680         }
03681         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
03682         {
03683                 warning("wrong module id");
03684                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
03685                 return m_iErrorState;
03686         }
03687         for(int i = 0; i < m_iModuleCount; i++)
03688         {
03689                 if(m_aiModuleId[i] == iModuleId)
03690                 {
03691                         if(m_auiModuleVersion[i] < 0x4601)
03692                         {
03693                                 warning("module version does not support function");
03694                                 m_iErrorState = ERRID_DEV_FUNCTIONNOTAVAILABLE;
03695                                 return m_iErrorState;
03696                         }
03697                 }
03698         }
03699         m_iErrorState = writeLong(iModuleId, CMDID_SETPARAM, PARID_ACT_HMAXCUROVERSHOOT, iValue);
03700 
03701         return m_iErrorState;
03702 }
03703 
03704 int CDevice::setKpPWMLimit(int iModuleId, long iValue)
03705 {
03706         m_iErrorState = 0;
03707         if(m_bInitFlag == false)
03708         {
03709                 warning("device not initialized");
03710                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
03711                 return m_iErrorState;
03712         }
03713         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
03714         {
03715                 warning("wrong module id");
03716                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
03717                 return m_iErrorState;
03718         }
03719         for(int i = 0; i < m_iModuleCount; i++)
03720         {
03721                 if(m_aiModuleId[i] == iModuleId)
03722                 {
03723                         if(m_auiModuleVersion[i] < 0x4601)
03724                         {
03725                                 warning("module version does not support function");
03726                                 m_iErrorState = ERRID_DEV_FUNCTIONNOTAVAILABLE;
03727                                 return m_iErrorState;
03728                         }
03729                 }
03730         }
03731         m_iErrorState = writeLong(iModuleId, CMDID_SETPARAM, PARID_ACT_KP_PWMLIM, iValue);
03732 
03733         return m_iErrorState;
03734 }
03735 
03736 int CDevice::setCurrentLimit(int iModuleId, float fValue)
03737 {
03738         m_iErrorState = 0;
03739         if(m_bInitFlag == false)
03740         {
03741                 warning("device not initialized");
03742                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
03743                 return m_iErrorState;
03744         }
03745         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
03746         {
03747                 warning("wrong module id");
03748                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
03749                 return m_iErrorState;
03750         }
03751         for(int i = 0; i < m_iModuleCount; i++)
03752         {
03753                 if(m_aiModuleId[i] == iModuleId)
03754                 {
03755                         if(m_auiModuleVersion[i] < 0x4601)
03756                         {
03757                                 warning("module version does not support function");
03758                                 m_iErrorState = ERRID_DEV_FUNCTIONNOTAVAILABLE;
03759                                 return m_iErrorState;
03760                         }
03761                 }
03762         }
03763         m_iErrorState = writeFloat(iModuleId, CMDID_SETPARAM, PARID_ACT_CURRENTLIMIT, fValue);
03764 
03765         return m_iErrorState;
03766 }
03767 // ========================================================================== ;
03768 //                                                                            ;
03769 // ---- I/O functions ------------------------------------------------------- ;
03770 //                                                                            ;
03771 // ========================================================================== ;
03772 
03773 // ========================================================================== ;
03774 //                                                                            ;
03775 // ---- exec functions ------------------------------------------------------ ;
03776 //                                                                            ;
03777 // ========================================================================== ;
03778 
03779 int CDevice::updateModuleIdMap()
03780 {
03781         unsigned short uiVersion;
03782         std::vector<float> afData;
03783         if(m_bInitFlag == false)
03784         {
03785                 warning("device not initialized");
03786                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
03787                 return m_iErrorState;
03788         }
03789         m_aiModuleId.clear();
03790         m_auiModuleVersion.clear();
03791 
03792         m_iModuleCount = m_iModuleCountMax;     // timout = m_uiTimeOut + 10 * m_iModuleCount for RS232
03793         for(int i = 1; i <= m_iModuleCountMax; i++)
03794         {
03795                 debug(0,"searching for module %i", i);
03796                 m_iErrorState = getModuleVersion(i, &uiVersion);
03797                 if(m_iErrorState == 0)
03798                 {
03799                         m_aiModuleId.push_back(i);
03800                         m_auiModuleVersion.push_back(uiVersion);
03801                         debug(0,"found module with ID %i and Version %x", i, uiVersion);
03802                 }
03803                 else
03804                         m_iErrorState = 0;
03805         }
03806         m_iModuleCount = m_aiModuleId.size();
03807         m_iErrorState = 0;
03808         return m_iModuleCount;
03809 }
03810 
03811 int CDevice::homeModule(int iModuleId)
03812 {
03813         m_iErrorState = 0;
03814         if(m_bInitFlag == false)
03815         {
03816                 warning("device not initialized");
03817                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
03818                 return m_iErrorState;
03819         }
03820         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
03821         {
03822                 warning("wrong module id");
03823                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
03824                 return m_iErrorState;
03825         }
03826         m_iErrorState = writeCommand(iModuleId, CMDID_HOME);
03827 
03828         return m_iErrorState;
03829 }
03830 
03831 int CDevice::haltModule(int iModuleId)
03832 {
03833         m_iErrorState = 0;
03834         if(m_bInitFlag == false)
03835         {
03836                 warning("device not initialized");
03837                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
03838                 return m_iErrorState;
03839         }
03840         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
03841         {
03842                 warning("wrong module id");
03843                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
03844                 return m_iErrorState;
03845         }
03846         m_iErrorState = writeCommand(iModuleId, CMDID_HALT);
03847 
03848         return m_iErrorState;
03849 }
03850 
03851 int CDevice::resetModule(int iModuleId)
03852 {
03853         m_iErrorState = 0;
03854         if(m_bInitFlag == false)
03855         {
03856                 warning("device not initialized");
03857                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
03858                 return m_iErrorState;
03859         }
03860         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
03861         {
03862                 warning("wrong module id");
03863                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
03864                 return m_iErrorState;
03865         }
03866         m_iErrorState = writeCommand(iModuleId, CMDID_RESET);
03867 
03868         return m_iErrorState;
03869 }
03870 
03871 int CDevice::recalcPIDParams(int iModuleId)
03872 {
03873         m_iErrorState = 0;
03874         if(m_bInitFlag == false)
03875         {
03876                 warning("device not initialized");
03877                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
03878                 return m_iErrorState;
03879         }
03880         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
03881         {
03882                 warning("wrong module id");
03883                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
03884                 return m_iErrorState;
03885         }
03886         m_iErrorState = writeCommand(iModuleId, CMDID_RECALCPID);
03887 
03888         return m_iErrorState;
03889 }
03890 
03891 int CDevice::saveParameters(int iModuleId)
03892 {
03893         m_iErrorState = 0;
03894         if(m_bInitFlag == false)
03895         {
03896                 warning("device not initialized");
03897                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
03898                 return m_iErrorState;
03899         }
03900         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
03901         {
03902                 warning("wrong module id");
03903                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
03904                 return m_iErrorState;
03905         }
03906         m_iErrorState = writeCommand(iModuleId, CMDID_SAVEPARAMS);
03907 
03908         return m_iErrorState;
03909 }
03910 
03911 int CDevice::movePos(int iModuleId, float fPos)
03912 {
03913         m_iErrorState = 0;
03914         if(m_bInitFlag == false)
03915         {
03916                 warning("device not initialized");
03917                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
03918                 return m_iErrorState;
03919         }
03920         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
03921         {
03922                 warning("wrong module id");
03923                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
03924                 return m_iErrorState;
03925         }
03926         m_iErrorState = writeFloat(iModuleId, CMDID_SETMOVE, PARID_MOVE_FRAMP, fPos);
03927 
03928         return m_iErrorState;
03929 }
03930 
03931 int CDevice::moveRamp(int iModuleId, float fPos, float fVel, float fAcc)
03932 {
03933         m_iErrorState = 0;
03934         if(m_bInitFlag == false)
03935         {
03936                 warning("device not initialized");
03937                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
03938                 return m_iErrorState;
03939         }
03940         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
03941         {
03942                 warning("wrong module id");
03943                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
03944                 return m_iErrorState;
03945         }
03946         m_iErrorState = writeFloat(iModuleId, CMDID_SETPARAM, PARID_ACT_FRAMPVEL, fVel);
03947         m_iErrorState = writeFloat(iModuleId, CMDID_SETPARAM, PARID_ACT_FRAMPACC, fAcc);
03948         m_iErrorState = writeFloat(iModuleId, CMDID_SETMOVE, PARID_MOVE_FRAMP, fPos);
03949 
03950         return m_iErrorState;
03951 }
03952 
03953 int CDevice::moveVel(int iModuleId, float fVel)
03954 {
03955         m_iErrorState = 0;
03956         if(m_bInitFlag == false)
03957         {
03958                 warning("device not initialized");
03959                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
03960                 return m_iErrorState;
03961         }
03962         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
03963         {
03964                 warning("wrong module id");
03965                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
03966                 return m_iErrorState;
03967         }
03968         m_iErrorState = writeFloat(iModuleId, CMDID_SETMOVE, PARID_MOVE_FVEL, fVel);
03969 
03970         return m_iErrorState;
03971 }
03972 
03973 int CDevice::moveCur(int iModuleId, float fCur)
03974 {
03975         m_iErrorState = 0;
03976         if(m_bInitFlag == false)
03977         {
03978                 warning("device not initialized");
03979                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
03980                 return m_iErrorState;
03981         }
03982         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
03983         {
03984                 warning("wrong module id");
03985                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
03986                 return m_iErrorState;
03987         }
03988         m_iErrorState = writeFloat(iModuleId, CMDID_SETMOVE, PARID_MOVE_FCUR, fCur);
03989 
03990         return m_iErrorState;
03991 }
03992 
03993 int CDevice::moveStep(int iModuleId, float fPos, unsigned short uiTime)
03994 {
03995         m_iErrorState = 0;
03996         if(m_bInitFlag == false)
03997         {
03998                 warning("device not initialized");
03999                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
04000                 return m_iErrorState;
04001         }
04002         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
04003         {
04004                 warning("wrong module id");
04005                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
04006                 return m_iErrorState;
04007         }
04008         m_iErrorState = writeFloatShort(iModuleId, CMDID_SETMOVE, PARID_MOVE_FSTEP, fPos, uiTime);
04009 
04010         return m_iErrorState;
04011 }
04012 
04013 int CDevice::movePosInc(int iModuleId, long iPos)
04014 {
04015         m_iErrorState = 0;
04016         if(m_bInitFlag == false)
04017         {
04018                 warning("device not initialized");
04019                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
04020                 return m_iErrorState;
04021         }
04022         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
04023         {
04024                 warning("wrong module id");
04025                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
04026                 return m_iErrorState;
04027         }
04028         m_iErrorState = writeLong(iModuleId, CMDID_SETMOVE, PARID_MOVE_IRAMP, iPos);
04029 
04030         return m_iErrorState;
04031 }
04032 
04033 int CDevice::moveRampInc(int iModuleId, long iPos, long iVel, long iAcc)
04034 {
04035         m_iErrorState = 0;
04036         if(m_bInitFlag == false)
04037         {
04038                 warning("device not initialized");
04039                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
04040                 return m_iErrorState;
04041         }
04042         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
04043         {
04044                 warning("wrong module id");
04045                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
04046                 return m_iErrorState;
04047         }
04048         m_iErrorState = writeLong(iModuleId, CMDID_SETPARAM, PARID_ACT_IRAMPVEL, iVel);
04049         m_iErrorState = writeLong(iModuleId, CMDID_SETPARAM, PARID_ACT_IRAMPACC, iAcc);
04050         m_iErrorState = writeLong(iModuleId, CMDID_SETMOVE, PARID_MOVE_IRAMP, iPos);
04051 
04052         return m_iErrorState;
04053 }
04054 
04055 int CDevice::moveVelInc(int iModuleId, long iVel)
04056 {
04057         m_iErrorState = 0;
04058         if(m_bInitFlag == false)
04059         {
04060                 warning("device not initialized");
04061                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
04062                 return m_iErrorState;
04063         }
04064         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
04065         {
04066                 warning("wrong module id");
04067                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
04068                 return m_iErrorState;
04069         }
04070         m_iErrorState = writeLong(iModuleId, CMDID_SETMOVE, PARID_MOVE_IVEL, iVel);
04071 
04072         return m_iErrorState;
04073 }
04074 
04075 int CDevice::moveCurInc(int iModuleId, long iCur)
04076 {
04077         m_iErrorState = 0;
04078         if(m_bInitFlag == false)
04079         {
04080                 warning("device not initialized");
04081                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
04082                 return m_iErrorState;
04083         }
04084         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
04085         {
04086                 warning("wrong module id");
04087                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
04088                 return m_iErrorState;
04089         }
04090         m_iErrorState = writeLong(iModuleId, CMDID_SETMOVE, PARID_MOVE_ICUR, iCur);
04091 
04092         return m_iErrorState;
04093 }
04094 
04095 int CDevice::moveStepInc(int iModuleId, long iPos, unsigned short uiTime)
04096 {
04097         m_iErrorState = 0;
04098         if(m_bInitFlag == false)
04099         {
04100                 warning("device not initialized");
04101                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
04102                 return m_iErrorState;
04103         }
04104         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
04105         {
04106                 warning("wrong module id");
04107                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
04108                 return m_iErrorState;
04109         }
04110         m_iErrorState = writeLongShort(iModuleId, CMDID_SETMOVE, PARID_MOVE_ISTEP, iPos, uiTime);
04111 
04112         return m_iErrorState;
04113 }
04114 
04115 int CDevice::movePosExtended(int iModuleId, float fPos, 
04116         unsigned long* puiState, unsigned char* pucDio, float* pfPos)
04117 {
04118         m_iErrorState = 0;
04119         if(m_bInitFlag == false)
04120         {
04121                 warning("device not initialized");
04122                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
04123                 return m_iErrorState;
04124         }
04125         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
04126         {
04127                 warning("wrong module id");
04128                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
04129                 return m_iErrorState;
04130         }
04131         unsigned char ucState = 0;
04132         m_iErrorState = writeFloatReadFloatUnsignedChars(iModuleId, CMDID_SETMOVE, PARID_MOVE_FRAMP_EXT, fPos, pfPos, &ucState, pucDio);
04133         if(m_iErrorState == 0)
04134                 charStateToLongState(ucState, puiState);
04135 
04136         return m_iErrorState;
04137 }
04138 
04139 int CDevice::moveRampExtended(int iModuleId, float fPos, float fVel, float fAcc, 
04140         unsigned long* puiState, unsigned char* pucDio, float* pfPos)
04141 {
04142         m_iErrorState = 0;
04143         if(m_bInitFlag == false)
04144         {
04145                 warning("device not initialized");
04146                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
04147                 return m_iErrorState;
04148         }
04149         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
04150         {
04151                 warning("wrong module id");
04152                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
04153                 return m_iErrorState;
04154         }
04155         unsigned char ucState = 0;
04156         m_iErrorState = writeFloat(iModuleId, CMDID_SETPARAM, PARID_ACT_FRAMPVEL, fVel);
04157         m_iErrorState = writeFloat(iModuleId, CMDID_SETPARAM, PARID_ACT_FRAMPACC, fAcc);
04158         m_iErrorState = writeFloatReadFloatUnsignedChars(iModuleId, CMDID_SETMOVE, PARID_MOVE_FRAMP_EXT, fPos, pfPos, &ucState, pucDio);
04159         if(m_iErrorState == 0)
04160                 charStateToLongState(ucState, puiState);
04161 
04162         return m_iErrorState;
04163 }
04164 
04165 int CDevice::moveVelExtended(int iModuleId, float fVel, 
04166         unsigned long* puiState, unsigned char* pucDio, float* pfPos)
04167 {
04168         m_iErrorState = 0;
04169         if(m_bInitFlag == false)
04170         {
04171                 warning("device not initialized");
04172                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
04173                 return m_iErrorState;
04174         }
04175         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
04176         {
04177                 warning("wrong module id");
04178                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
04179                 return m_iErrorState;
04180         }
04181         unsigned char ucState = 0;
04182         m_iErrorState = writeFloatReadFloatUnsignedChars(iModuleId, CMDID_SETMOVE, PARID_MOVE_FVEL_EXT, fVel, pfPos, &ucState, pucDio);
04183         if(m_iErrorState == 0)
04184                 charStateToLongState(ucState, puiState);
04185 
04186         return m_iErrorState;
04187 }
04188 
04189 int CDevice::moveCurExtended(int iModuleId, float fCur, 
04190         unsigned long* puiState, unsigned char* pucDio, float* pfPos)
04191 {
04192         m_iErrorState = 0;
04193         if(m_bInitFlag == false)
04194         {
04195                 warning("device not initialized");
04196                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
04197                 return m_iErrorState;
04198         }
04199         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
04200         {
04201                 warning("wrong module id");
04202                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
04203                 return m_iErrorState;
04204         }
04205         unsigned char ucState = 0;
04206         m_iErrorState = writeFloatReadFloatUnsignedChars(iModuleId, CMDID_SETMOVE, PARID_MOVE_FCUR_EXT, fCur, pfPos, &ucState, pucDio);
04207         if(m_iErrorState == 0)
04208                 charStateToLongState(ucState, puiState);
04209 
04210         return m_iErrorState;
04211 }
04212 
04213 int CDevice::moveStepExtended(int iModuleId, float fPos, unsigned short uiTime, 
04214         unsigned long* puiState, unsigned char* pucDio, float* pfPos)
04215 {
04216         m_iErrorState = 0;
04217         if(m_bInitFlag == false)
04218         {
04219                 warning("device not initialized");
04220                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
04221                 return m_iErrorState;
04222         }
04223         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
04224         {
04225                 warning("wrong module id");
04226                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
04227                 return m_iErrorState;
04228         }
04229         unsigned char ucState = 0;
04230         m_iErrorState = writeFloatShortReadFloatUnsignedChars(iModuleId, CMDID_SETMOVE, PARID_MOVE_FSTEP_EXT, fPos, uiTime, pfPos, &ucState, pucDio);
04231         if(m_iErrorState == 0)
04232                 charStateToLongState(ucState, puiState);
04233         return m_iErrorState;
04234 }
04235 
04236 // ========================================================================== ;
04237 //                                                                            ;
04238 // ---- wait functions ------------------------------------------------------ ;
04239 //                                                                            ;
04240 // ========================================================================== ;
04241 
04242 int CDevice::waitForHomeEnd(int iModuleId, unsigned long uiTimeOut)
04243 {
04244         int iRetVal;
04245         unsigned long uiTime, uiState;
04246         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
04247         {
04248                 warning("wrong module id");
04249                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
04250                 return m_iErrorState;
04251         }
04252         m_clTimer.start();
04253         while(1)
04254         {
04255                 Sleep(1);
04256                 iRetVal = getModuleState(iModuleId, &uiState);
04257                 if (iRetVal < 0)
04258                 {
04259                         debug(1,"com error in waitForHomeEnd()");
04260                         break;
04261                 }
04262                 if (uiState & STATEID_MOD_ERROR)
04263                 {
04264                         debug(1, "module error in waitForHomeEnd()");
04265                         iRetVal=ERRID_DEV_MODULEERROR;
04266                         break;
04267                 }
04268                 if ((uiState & STATEID_MOD_HOME) && (uiState & STATEID_MOD_RAMP_END))
04269                 {
04270                         debug(2, "reached home position in waitForHomeEnd()");
04271                         iRetVal=0;
04272                         break;
04273                 }
04274                 m_clTimer.stop();
04275                 uiTime = (unsigned long)(1000 * m_clTimer.executionTime());
04276                 if (uiTime > uiTimeOut)
04277                 {
04278                         debug(1, "timeout in waitForHomeEnd()");
04279                         iRetVal=ERRID_DEV_WAITTIMEOUT;
04280                         break;
04281                 }
04282         }
04283         return iRetVal;
04284 }
04285 
04286 int CDevice::waitForMotionEnd(int iModuleId, unsigned long uiTimeOut)
04287 {
04288         int iRetVal;
04289         unsigned long uiTime, uiState;
04290         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
04291         {
04292                 warning("wrong module id");
04293                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
04294                 return m_iErrorState;
04295         }
04296         m_clTimer.start();
04297         while(1)
04298         {
04299                 Sleep(1);
04300                 iRetVal = getModuleState(iModuleId, &uiState);
04301                 if (iRetVal < 0)
04302                 {
04303                         debug(1,"com error in waitForMotionEnd()");
04304                         break;
04305                 }
04306                 if (uiState & STATEID_MOD_ERROR)
04307                 {
04308                         debug(1, "module error in waitForMotionEnd()");
04309                         iRetVal=ERRID_DEV_MODULEERROR;
04310                         break;
04311                 }
04312                 if (!(uiState & STATEID_MOD_MOTION))
04313                 {
04314                         debug(2, "finished motion in waitForMotionEnd()");
04315                         iRetVal=0;
04316                         break;
04317                 }
04318                 m_clTimer.stop();
04319                 uiTime = (unsigned long)(1000 * m_clTimer.executionTime());
04320                 if (uiTime > uiTimeOut)
04321                 {
04322                         debug(1, "timeout in waitForMotionEnd()");
04323                         iRetVal=ERRID_DEV_WAITTIMEOUT;
04324                         break;
04325                 }
04326         }
04327         return iRetVal;
04328 }
04329 
04330 int CDevice::waitForRampEnd(int iModuleId, unsigned long uiTimeOut)
04331 {
04332         int iRetVal;
04333         unsigned long uiTime, uiState;
04334         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
04335         {
04336                 warning("wrong module id");
04337                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
04338                 return m_iErrorState;
04339         }
04340         m_clTimer.start();
04341         while(1)
04342         {
04343                 Sleep(1);
04344                 iRetVal = getModuleState(iModuleId, &uiState);
04345                 if (iRetVal < 0)
04346                 {
04347                         debug(1,"com error in waitForRampEnd()");
04348                         break;
04349                 }
04350                 if (uiState & STATEID_MOD_ERROR)
04351                 {
04352                         debug(1, "module error in waitForRampEnd()");
04353                         iRetVal=ERRID_DEV_MODULEERROR;
04354                         break;
04355                 }
04356                 if (uiState & STATEID_MOD_RAMP_END)
04357                 {
04358                         debug(2, "reached ramp end position in waitForRampEnd()");
04359                         iRetVal=0;
04360                         break;
04361                 }
04362                 m_clTimer.stop();
04363                 uiTime = (unsigned long)(1000 * m_clTimer.executionTime());
04364                 if (uiTime > uiTimeOut)
04365                 {
04366                         debug(1, "timeout in waitForRampEnd()");
04367                         iRetVal=ERRID_DEV_WAITTIMEOUT;
04368                         break;
04369                 }
04370         }
04371         return iRetVal;
04372 }
04373 
04374 int CDevice::waitForRampDec(int iModuleId, unsigned long uiTimeOut)
04375 {
04376         int iRetVal;
04377         unsigned long uiTime, uiState;
04378         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
04379         {
04380                 warning("wrong module id");
04381                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
04382                 return m_iErrorState;
04383         }
04384         m_clTimer.start();
04385         while(1)
04386         {
04387                 Sleep(1);
04388                 iRetVal = getModuleState(iModuleId, &uiState);
04389                 if (iRetVal < 0)
04390                 {
04391                         debug(1,"com error in waitForRampDec()");
04392                         break;
04393                 }
04394                 if (uiState & STATEID_MOD_ERROR)
04395                 {
04396                         debug(1, "module error in waitForRampDec()");
04397                         iRetVal=ERRID_DEV_MODULEERROR;
04398                         break;
04399                 }
04400                 if (uiState & STATEID_MOD_RAMP_DEC)
04401                 {
04402                         debug(2, "reached ramp end position in waitForRampDec()");
04403                         iRetVal=0;
04404                         break;
04405                 }
04406                 m_clTimer.stop();
04407                 uiTime = (unsigned long)(1000 * m_clTimer.executionTime());
04408                 if (uiTime > uiTimeOut)
04409                 {
04410                         debug(1, "timeout in waitForRampDec()");
04411                         iRetVal=ERRID_DEV_WAITTIMEOUT;
04412                         break;
04413                 }
04414         }
04415         return iRetVal;
04416 }
04417 
04418 int CDevice::waitForRampSteady(int iModuleId, unsigned long uiTimeOut)
04419 {
04420         int iRetVal;
04421         unsigned long uiTime, uiState;
04422         if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
04423         {
04424                 warning("wrong module id");
04425                 m_iErrorState = ERRID_DEV_WRONGMODULEID;
04426                 return m_iErrorState;
04427         }
04428         m_clTimer.start();
04429         while(1)
04430         {
04431                 Sleep(1);
04432                 iRetVal = getModuleState(iModuleId, &uiState);
04433                 if (iRetVal < 0)
04434                 {
04435                         debug(1,"com error in waitForRampSteady()");
04436                         break;
04437                 }
04438                 if (uiState & STATEID_MOD_ERROR)
04439                 {
04440                         debug(1, "module error in waitForRampSteady()");
04441                         iRetVal=ERRID_DEV_MODULEERROR;
04442                         break;
04443                 }
04444                 if (uiState & STATEID_MOD_RAMP_STEADY)
04445                 {
04446                         debug(2, "reached ramp end position in waitForRampSteady()");
04447                         iRetVal=0;
04448                         break;
04449                 }
04450                 m_clTimer.stop();
04451                 uiTime = (unsigned long)(1000 * m_clTimer.executionTime());
04452                 if (uiTime > uiTimeOut)
04453                 {
04454                         debug(1, "timeout in waitForRampSteady()");
04455                         iRetVal=ERRID_DEV_WAITTIMEOUT;
04456                         break;
04457                 }
04458         }
04459         return iRetVal;
04460 }
04461 
04462 int CDevice::waitForHomeEndAll(unsigned long uiTimeOut)
04463 {
04464         int i, iRetVal = ERRID_DEV_NOMODULES;
04465         bool bExitFlag = false;
04466         unsigned long uiTime, uiState;
04467         m_clTimer.start();
04468         do
04469         {
04470                 Sleep(1);
04471                 bExitFlag = true;
04472                 for(i = 0; i < m_iModuleCount;i++)
04473                 {
04474                         iRetVal = getModuleState(m_aiModuleId[i], &uiState);
04475                         if (iRetVal < 0)
04476                         {
04477                                 debug(1,"com error in waitForHomeEndAll()");
04478                                 return iRetVal;
04479                         }
04480                         if (uiState & STATEID_MOD_ERROR)
04481                         {
04482                                 debug(1, "module error in waitForHomeEndAll()");
04483                                 iRetVal=ERRID_DEV_MODULEERROR;
04484                                 return iRetVal;
04485                         }
04486                         if (!(uiState & STATEID_MOD_HOME) || !(uiState & STATEID_MOD_RAMP_END))
04487                         {
04488                                 debug(2, "module %i not home end in waitForHomeEndAll()", m_aiModuleId[i]);
04489                                 bExitFlag = false;
04490                                 break;
04491                         }
04492                 }
04493                 m_clTimer.stop();
04494                 uiTime = (unsigned long)(1000 * m_clTimer.executionTime());
04495                 if (uiTime > uiTimeOut)
04496                 {
04497                         debug(1, "timeout in waitForHomeEndAll()");
04498                         iRetVal=ERRID_DEV_WAITTIMEOUT;
04499                         return iRetVal;
04500                 }
04501         }while(!bExitFlag);
04502         return iRetVal;
04503 }
04504 
04505 int CDevice::waitForMotionEndAll(unsigned long uiTimeOut)
04506 {
04507         int i, iRetVal = ERRID_DEV_NOMODULES;
04508         bool bExitFlag = false;
04509         unsigned long uiTime, uiState;
04510         m_clTimer.start();
04511         do
04512         {
04513                 Sleep(1);
04514                 bExitFlag = true;
04515                 for(i = 0; i < m_iModuleCount;i++)
04516                 {
04517                         iRetVal = getModuleState(m_aiModuleId[i], &uiState);
04518                         if (iRetVal < 0)
04519                         {
04520                                 debug(1,"com error in waitForMotionEndAll()");
04521                                 return iRetVal;
04522                         }
04523                         if (uiState & STATEID_MOD_ERROR)
04524                         {
04525                                 debug(1, "module error in waitForMotionEndAll()");
04526                                 iRetVal=ERRID_DEV_MODULEERROR;
04527                                 return iRetVal;
04528                         }
04529                         if (uiState & STATEID_MOD_MOTION)
04530                         {
04531                                 debug(2, "module %i not motion end in waitForMotionEndAll()", m_aiModuleId[i]);
04532                                 bExitFlag = false;
04533                                 break;
04534                         }
04535                 }
04536                 m_clTimer.stop();
04537                 uiTime = (unsigned long)(1000 * m_clTimer.executionTime());
04538                 if (uiTime > uiTimeOut)
04539                 {
04540                         debug(1, "timeout in waitForMotionEndAll()");
04541                         iRetVal=ERRID_DEV_WAITTIMEOUT;
04542                         return iRetVal;
04543                 }
04544         }while(!bExitFlag);
04545         return iRetVal;
04546 }
04547 
04548 int CDevice::waitForRampEndAll(unsigned long uiTimeOut)
04549 {
04550         int i, iRetVal = ERRID_DEV_NOMODULES;
04551         bool bExitFlag = false;
04552         unsigned long uiTime, uiState;
04553         m_clTimer.start();
04554         do
04555         {
04556                 Sleep(1);
04557                 bExitFlag = true;
04558                 for(i = 0; i < m_iModuleCount;i++)
04559                 {
04560                         iRetVal = getModuleState(m_aiModuleId[i], &uiState);
04561                         if (iRetVal < 0)
04562                         {
04563                                 debug(1,"com error in waitForRampEndAll()");
04564                                 return iRetVal;
04565                         }
04566                         if (uiState & STATEID_MOD_ERROR)
04567                         {
04568                                 debug(1, "module error in waitForRampEndAll()");
04569                                 iRetVal=ERRID_DEV_MODULEERROR;
04570                                 return iRetVal;
04571                         }
04572                         if (!(uiState & STATEID_MOD_RAMP_END))
04573                         {
04574                                 debug(2, "module %i not ramp end in waitForRampEndAll()", m_aiModuleId[i]);
04575                                 bExitFlag = false;
04576                                 break;
04577                         }
04578                 }
04579                 m_clTimer.stop();
04580                 uiTime = (unsigned long)(1000 * m_clTimer.executionTime());
04581                 if (uiTime > uiTimeOut)
04582                 {
04583                         debug(1, "timeout in waitForRampEndAll()");
04584                         iRetVal=ERRID_DEV_WAITTIMEOUT;
04585                         return iRetVal;
04586                 }
04587         }while(!bExitFlag);
04588         return iRetVal;
04589 }
04590 
04591 int CDevice::waitForStartMotionAll()
04592 { 
04593         m_iErrorState = 0;
04594         if(m_bInitFlag == false)
04595         {
04596                 warning("device not initialized");
04597                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
04598                 return m_iErrorState;
04599         }
04600         m_iErrorState = ERRID_DEV_FUNCTIONNOTAVAILABLE;
04601         return m_iErrorState;
04602 }
04603 
04604 
04605 // ========================================================================== ;
04606 //                                                                            ;
04607 // ---- broadcast functions -------------------------------------------------- ;
04608 //                                                                            ;
04609 // ========================================================================== ;
04610 
04611 int CDevice::homeAll(void)
04612 { 
04613         m_iErrorState = 0;
04614         if(m_bInitFlag == false)
04615         {
04616                 warning("device not initialized");
04617                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
04618                 return m_iErrorState;
04619         }
04620         m_iErrorState = writeAll( CMDID_HOME, 0 );
04621         return m_iErrorState;
04622 }
04623 
04624 int CDevice::resetAll(void)
04625 {
04626         m_iErrorState = 0;
04627         if(m_bInitFlag == false)
04628         {
04629                 warning("device not initialized");
04630                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
04631                 return m_iErrorState;
04632         }
04633         m_iErrorState = writeAll( CMDID_RESET, 0 );
04634         return m_iErrorState;
04635 }
04636 
04637 int CDevice::haltAll(void)
04638 {
04639         m_iErrorState = 0;
04640         if(m_bInitFlag == false)
04641         {
04642                 warning("device not initialized");
04643                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
04644                 return m_iErrorState;
04645         }
04646         m_iErrorState = writeAll( CMDID_HALT, 0 );
04647         return m_iErrorState;
04648 }
04649 
04650 int CDevice::serveWatchdogAll(void)
04651 {
04652         m_iErrorState = 0;
04653         if(m_bInitFlag == false)
04654         {
04655                 warning("device not initialized");
04656                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
04657                 return m_iErrorState;
04658         }
04659         m_iErrorState = writeAll( CMDID_WATCHDOG, 0 );
04660         return m_iErrorState;
04661 }
04662 
04663 int CDevice::setBaudRateAll(unsigned char ucBaudRateId)
04664 {
04665         m_iErrorState = 0;
04666         if(m_bInitFlag == false)
04667         {
04668                 warning("device not initialized");
04669                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
04670                 return m_iErrorState;
04671         }
04672         m_iErrorState = writeAll( CMDID_BAUDRATE, ucBaudRateId );
04673         reinit(ucBaudRateId);
04674         return m_iErrorState;
04675 }
04676 
04677 int CDevice::startMotionAll(void)
04678 {
04679         m_iErrorState = 0;
04680         if(m_bInitFlag == false)
04681         {
04682                 warning("device not initialized");
04683                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
04684                 return m_iErrorState;
04685         }
04686         m_iErrorState = writeAll( CMDID_STARTMOVE, 0 );
04687         return m_iErrorState;
04688 }
04689 
04690 int CDevice::savePosAll(void)
04691 {
04692         m_iErrorState = 0;
04693         if(m_bInitFlag == false)
04694         {
04695                 warning("device not initialized");
04696                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
04697                 return m_iErrorState;
04698         }
04699         m_iErrorState = writeAll( CMDID_SAVEPOS, 0 );
04700         return m_iErrorState;
04701 }
04702 
04703 // ========================================================================== ;
04704 //                                                                            ;
04705 // ---- Special functions for internal use ---------------------------------- ;
04706 //                                                                            ;
04707 // ========================================================================== ;
04708 int CDevice::xmit8Bytes(int iModuleId, void* pBytes )
04709 {
04710         m_iErrorState = 0;
04711         if(m_bInitFlag == false)
04712         {
04713                 warning("device not initialized");
04714                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
04715                 return m_iErrorState;
04716         }
04717         m_iErrorState = write8Bytes(iModuleId, false, pBytes );
04718         return m_iErrorState;
04719 }
04720 
04721 int CDevice::xack8Bytes(int iModuleId, void* pBytes )
04722 {
04723         m_iErrorState = 0;
04724         if(m_bInitFlag == false)
04725         {
04726                 warning("device not initialized");
04727                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
04728                 return m_iErrorState;
04729         }
04730         m_iErrorState = write8Bytes( iModuleId, true, pBytes );
04731         return m_iErrorState;
04732 }
04733 
04734 int CDevice::doInternal(int iModuleId, void* pBytes )
04735 {       unsigned char toSend[8];
04736         m_iErrorState = 0;
04737         if(m_bInitFlag == false)
04738         {
04739                 warning("device not initialized");
04740                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
04741                 return m_iErrorState;
04742         }
04743         toSend[0] = 0x04;
04744         memcpy( &toSend[1], pBytes, 7 );
04745         m_iErrorState = write8Bytes( iModuleId, true, toSend );
04746         memcpy( pBytes, &toSend[1], 7 );
04747         return m_iErrorState;
04748 }
04749 
04750 int CDevice::getStateInternal(int iModuleId, unsigned long* pStat )
04751 {       m_iErrorState = 0;
04752         if(m_bInitFlag == false)
04753         {
04754                 warning("device not initialized");
04755                 m_iErrorState = ERRID_DEV_NOTINITIALIZED;
04756                 return m_iErrorState;
04757         }
04758         m_iErrorState = getUnsignedLong( iModuleId, pStat );
04759         return m_iErrorState;
04760 }
04761 
04762 // ========================================================================== ;
04763 //                                                                            ;
04764 // ---- Init functions ------------------------------------------------------ ;
04765 //                                                                            ;
04766 // ========================================================================== ;
04767 
04768 CDevice* newDevice(const char* acInitString)
04769 {
04770         char* pcToken;
04771         char acString[128];
04772         strncpy(acString,acInitString,128);
04773         pcToken = strtok( acString, ":" );
04774         if( !pcToken )
04775         {
04776                 printf("CDevice* newDevice(const char* acInitString): wrong format, no ':' found!\n");
04777                 return NULL;
04778         }
04779         if( strcmp( pcToken, "RS232" ) == 0 )
04780         {
04781                 return new CRS232Device();
04782         }
04783 #ifdef USE_ESD
04784         if( strcmp( pcToken, "ESD" ) == 0 )
04785         {
04786                 return new CESDDevice();
04787         }
04788 #endif
04789 #ifdef USE_PCAN
04790         if( strcmp( pcToken, "PCAN" ) == 0 )
04791         {
04792                 return new CPCanDevice();
04793         }
04794 #endif
04795 #ifdef USE_SOCKET_CAN
04796         if( strcmp( pcToken, "SOCKETCAN" ) == 0 )
04797         {
04798                 return new SocketCANDevice();
04799         }
04800 #endif
04801 #if defined(_WIN32)     
04802         if( strcmp( pcToken, "CP5X11" ) == 0 )
04803         {
04804                 return new CCP5X11Device();
04805         }
04806 #endif
04807         printf("CDevice* newDevice(const char* acInitString): wrong format, no device found!\n");
04808         return NULL;
04809 }


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