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


schunk_libm5api
Author(s): Florian Weisshardt
autogenerated on Mon Oct 6 2014 07:30:34