Device.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2012 SCHUNK GmbH & Co. KG
3  * Copyright (c) 2017 Fraunhofer Institute for Manufacturing Engineering and Automation (IPA)
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10 
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 #include "Device.h"
19 #include "RS232Device.h"
20 #ifdef USE_ESD
21 #include "ESDDevice.h"
22 #endif
23 #ifdef USE_PCAN
24 #include "PCanDevice.h"
25 #endif
26 #ifdef USE_SOCKET_CAN
27 #include "SocketCANDevice.h"
28 #endif
29 #if defined (_WIN32)
30  #include "CP5X11Device.h"
31 #endif
32 
33 // ========================================================================== ;
34 // ;
35 // ---- private auxiliary functions ----------------------------------------- ;
36 // ;
37 // ========================================================================== ;
38 
39 // ========================================================================== ;
40 // ;
41 // ---- protected auxiliary functions --------------------------------------- ;
42 // ;
43 // ========================================================================== ;
44 
45 void CDevice::charStateToLongState(unsigned char ucShort, unsigned long* puiState)
46 {
47  *puiState = 0;
48  if(ucShort & 1)
49  *puiState |= STATEID_MOD_ERROR;
50  if(ucShort & 2)
51  *puiState |= STATEID_MOD_SWR;
52  if(ucShort & 4)
53  *puiState |= STATEID_MOD_SW1;
54  if(ucShort & 8)
55  *puiState |= STATEID_MOD_SW2;
56  if(ucShort & 16)
57  *puiState |= STATEID_MOD_MOTION;
58  if(ucShort & 32)
59  *puiState |= STATEID_MOD_RAMP_END;
60  if(ucShort & 64)
61  *puiState |= STATEID_MOD_INPROGRESS;
62  if(ucShort & 128)
63  *puiState |= STATEID_MOD_FULLBUFFER;
64 }
65 
66 // ========================================================================== ;
67 // ;
68 // ---- constructors / destructor ------------------------------------------- ;
69 // ;
70 // ========================================================================== ;
71 
73  m_iBaudRate(250),
74  m_iModuleCount(0),
75  m_iModuleCountMax(31),
77  m_iErrorState(0)
78 {
79  m_acName[0] = '\0';
80  m_acInitString[0] = '\0';
81  strncpy(m_acRevision,"$Revision: 1.45 $",20);
82 }
83 
84 CDevice::CDevice(const CDevice& rclDevice)
85 {
86  error(-1, "Sorry constructor is not implemented");
87 }
88 
90 {
91 }
92 
93 // ========================================================================== ;
94 // ;
95 // ---- operators ----------------------------------------------------------- ;
96 // ;
97 // ========================================================================== ;
98 
100 {
101  error(-1, "Sorry operator= is not implemented");
102  return *this;
103 }
104 
105 // ========================================================================== ;
106 // ;
107 // ---- query functions ----------------------------------------------------- ;
108 // ;
109 // ========================================================================== ;
110 
112 {
113  return m_bInitFlag;
114 }
115 
116 const char* CDevice::getRevision()
117 {
118  return m_acRevision;
119 }
120 
121 const char* CDevice::getName()
122 {
123  return m_acName;
124 }
125 
127 {
128  return m_acInitString;
129 }
130 
132 {
133  return m_iBaudRate;
134 }
135 
137 {
138  m_iErrorState = 0;
139  if(m_bInitFlag == false)
140  {
141  warning("device not initialized");
143  return m_iErrorState;
144  }
145  return m_iModuleCount;
146 }
147 
148 int CDevice::getModuleIdMap(std::vector<int>& raiModuleId)
149 {
150  m_iErrorState = 0;
151  if(m_bInitFlag == false)
152  {
153  warning("device not initialized");
155  return m_iErrorState;
156  }
157  raiModuleId.resize(m_iModuleCount);
158  for(int i=0; i < m_iModuleCount; i++)
159  raiModuleId[i] = m_aiModuleId[i];
160 
161  return m_iModuleCount;
162 }
163 
164 int CDevice::getModuleState(int iModuleId, unsigned long* puiState)
165 {
166  m_iErrorState = 0;
167  if(m_bInitFlag == false)
168  {
169  warning("device not initialized");
171  return m_iErrorState;
172  }
173  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
174  {
175  warning("wrong module id");
177  return m_iErrorState;
178  }
180 
181  return m_iErrorState;
182 }
183 
184 int CDevice::getModuleType(int iModuleId, unsigned char* pucValue)
185 {
186  m_iErrorState = 0;
187  if(m_bInitFlag == false)
188  {
189  warning("device not initialized");
191  return m_iErrorState;
192  }
193  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
194  {
195  warning("wrong module id");
197  return m_iErrorState;
198  }
199  unsigned long uiConfig = 0;
201  if(m_iErrorState == 0)
202  {
203  if (uiConfig & CONFIGID_MOD_LINEAR)
204  *pucValue = TYPEID_MOD_LINEAR;
205  else
206  *pucValue = TYPEID_MOD_ROTARY;
207  }
208  return m_iErrorState;
209 }
210 
211 int CDevice::getModuleVersion(int iModuleId, unsigned short* puiValue)
212 {
213  m_iErrorState = 0;
214  if(m_bInitFlag == false)
215  {
216  warning("device not initialized");
218  return m_iErrorState;
219  }
220  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
221  {
222  warning("wrong module id");
224  return m_iErrorState;
225  }
227 
228  return m_iErrorState;
229 }
230 
231 int CDevice::getModuleSerialNo(int iModuleId, unsigned long* puiValue)
232 {
233  m_iErrorState = 0;
234  if(m_bInitFlag == false)
235  {
236  warning("device not initialized");
238  return m_iErrorState;
239  }
240  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
241  {
242  warning("wrong module id");
244  return m_iErrorState;
245  }
247  debug(0,"error state: 0x%04x",m_iErrorState);
248 
249  return m_iErrorState;
250 }
251 
252 int CDevice::getDefConfig(int iModuleId, unsigned long* puiValue)
253 {
254  m_iErrorState = 0;
255  if(m_bInitFlag == false)
256  {
257  warning("device not initialized");
259  return m_iErrorState;
260  }
261  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
262  {
263  warning("wrong module id");
265  return m_iErrorState;
266  }
268 
269  return m_iErrorState;
270 }
271 
272 int CDevice::getDefSetup(int iModuleId, unsigned long* puiValue)
273 {
274  m_iErrorState = 0;
275  if(m_bInitFlag == false)
276  {
277  warning("device not initialized");
279  return m_iErrorState;
280  }
281  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
282  {
283  warning("wrong module id");
285  return m_iErrorState;
286  }
287  for(int i = 0; i < m_iModuleCount; i++)
288  {
289  if(m_aiModuleId[i] == iModuleId)
290  {
291  if(m_auiModuleVersion[i] < 0x3500)
292  {
293  warning("module version does not support function");
295  return m_iErrorState;
296  }
297  }
298  }
300 
301  return m_iErrorState;
302 }
303 
304 int CDevice::getDefBaudRate(int iModuleId, unsigned char* pucValue)
305 {
306  m_iErrorState = 0;
307  if(m_bInitFlag == false)
308  {
309  warning("device not initialized");
311  return m_iErrorState;
312  }
313  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
314  {
315  warning("wrong module id");
317  return m_iErrorState;
318  }
320 
321  return m_iErrorState;
322 }
323 
324 int CDevice::getDefCANBaudRate(int iModuleId, unsigned char* pucValue)
325 {
326  m_iErrorState = 0;
327  if(m_bInitFlag == false)
328  {
329  warning("device not initialized");
331  return m_iErrorState;
332  }
333  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
334  {
335  warning("wrong module id");
337  return m_iErrorState;
338  }
340 
341  return m_iErrorState;
342 }
343 
344 int CDevice::getDefRSBaudRate(int iModuleId, unsigned char* pucValue)
345 {
346  m_iErrorState = 0;
347  if(m_bInitFlag == false)
348  {
349  warning("device not initialized");
351  return m_iErrorState;
352  }
353  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
354  {
355  warning("wrong module id");
357  return m_iErrorState;
358  }
360 
361  return m_iErrorState;
362 }
363 
364 int CDevice::getDefBurnCount(int iModuleId, unsigned char* pucValue)
365 {
366  m_iErrorState = 0;
367  if(m_bInitFlag == false)
368  {
369  warning("device not initialized");
371  return m_iErrorState;
372  }
373  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
374  {
375  warning("wrong module id");
377  return m_iErrorState;
378  }
380 
381  return m_iErrorState;
382 }
383 
384 int CDevice::getDefGearRatio(int iModuleId, float* pfValue)
385 {
386  m_iErrorState = 0;
387  if(m_bInitFlag == false)
388  {
389  warning("device not initialized");
391  return m_iErrorState;
392  }
393  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
394  {
395  warning("wrong module id");
397  return m_iErrorState;
398  }
400 
401  return m_iErrorState;
402 }
403 
404 int CDevice::getDefLinearRatio(int iModuleId, float* pfValue)
405 {
406  m_iErrorState = 0;
407  if(m_bInitFlag == false)
408  {
409  warning("device not initialized");
411  return m_iErrorState;
412  }
413  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
414  {
415  warning("wrong module id");
417  return m_iErrorState;
418  }
420 
421  return m_iErrorState;
422 }
423 
424 int CDevice::getDefCurOffset(int iModuleId, float* pfValue)
425 {
426  m_iErrorState = 0;
427  if(m_bInitFlag == false)
428  {
429  warning("device not initialized");
431  return m_iErrorState;
432  }
433  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
434  {
435  warning("wrong module id");
437  return m_iErrorState;
438  }
440 
441  return m_iErrorState;
442 }
443 
444 int CDevice::getDefCurRatio(int iModuleId, float* pfValue)
445 {
446  m_iErrorState = 0;
447  if(m_bInitFlag == false)
448  {
449  warning("device not initialized");
451  return m_iErrorState;
452  }
453  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
454  {
455  warning("wrong module id");
457  return m_iErrorState;
458  }
460 
461  return m_iErrorState;
462 }
463 
464 int CDevice::getDefBrakeTimeOut(int iModuleId, unsigned short* puiValue)
465 {
466  m_iErrorState = 0;
467  if(m_bInitFlag == false)
468  {
469  warning("device not initialized");
471  return m_iErrorState;
472  }
473  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
474  {
475  warning("wrong module id");
477  return m_iErrorState;
478  }
480 
481  return m_iErrorState;
482 }
483 
484 int CDevice::getDefIncPerTurn(int iModuleId, unsigned long* puiValue)
485 {
486  m_iErrorState = 0;
487  if(m_bInitFlag == false)
488  {
489  warning("device not initialized");
491  return m_iErrorState;
492  }
493  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
494  {
495  warning("wrong module id");
497  return m_iErrorState;
498  }
500 
501  return m_iErrorState;
502 }
503 
504 int CDevice::getDefDioData(int iModuleId, unsigned long* puiValue)
505 {
506  m_iErrorState = 0;
507  if(m_bInitFlag == false)
508  {
509  warning("device not initialized");
511  return m_iErrorState;
512  }
513  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
514  {
515  warning("wrong module id");
517  return m_iErrorState;
518  }
519 // m_iErrorState = readUnsignedLong(iModuleId, CMDID_GETPARAM, PARID_DEF_DIODATA, puiValue);
520 
521  *puiValue = 0;
522  return m_iErrorState;
523 }
524 
525 int CDevice::getDefA0(int iModuleId, short* piValue)
526 {
527  m_iErrorState = 0;
528  if(m_bInitFlag == false)
529  {
530  warning("device not initialized");
532  return m_iErrorState;
533  }
534  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
535  {
536  warning("wrong module id");
538  return m_iErrorState;
539  }
540  m_iErrorState = readShort(iModuleId, CMDID_GETPARAM, PARID_DEF_A0, piValue);
541 
542  return m_iErrorState;
543 }
544 
545 int CDevice::getDefC0(int iModuleId, short* piValue)
546 {
547  m_iErrorState = 0;
548  if(m_bInitFlag == false)
549  {
550  warning("device not initialized");
552  return m_iErrorState;
553  }
554  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
555  {
556  warning("wrong module id");
558  return m_iErrorState;
559  }
560  m_iErrorState = readShort(iModuleId, CMDID_GETPARAM, PARID_DEF_C0, piValue);
561 
562  return m_iErrorState;
563 }
564 
565 int CDevice::getDefDamp(int iModuleId, short* piValue)
566 {
567  m_iErrorState = 0;
568  if(m_bInitFlag == false)
569  {
570  warning("device not initialized");
572  return m_iErrorState;
573  }
574  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
575  {
576  warning("wrong module id");
578  return m_iErrorState;
579  }
580  m_iErrorState = readShort(iModuleId, CMDID_GETPARAM, PARID_DEF_DAMP, piValue);
581 
582  return m_iErrorState;
583 }
584 
585 int CDevice::getDefHomeOffset(int iModuleId, float* pfValue)
586 {
587  m_iErrorState = 0;
588  if(m_bInitFlag == false)
589  {
590  warning("device not initialized");
592  return m_iErrorState;
593  }
594  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
595  {
596  warning("wrong module id");
598  return m_iErrorState;
599  }
601 
602  return m_iErrorState;
603 }
604 
605 int CDevice::getDefHomeVel(int iModuleId, float* pfValue)
606 {
607  m_iErrorState = 0;
608  if(m_bInitFlag == false)
609  {
610  warning("device not initialized");
612  return m_iErrorState;
613  }
614  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
615  {
616  warning("wrong module id");
618  return m_iErrorState;
619  }
621 
622  return m_iErrorState;
623 }
624 
625 int CDevice::getDefMinPos(int iModuleId, float* pfValue)
626 {
627  m_iErrorState = 0;
628  if(m_bInitFlag == false)
629  {
630  warning("device not initialized");
632  return m_iErrorState;
633  }
634  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
635  {
636  warning("wrong module id");
638  return m_iErrorState;
639  }
641 
642  return m_iErrorState;
643 }
644 
645 int CDevice::getDefMaxPos(int iModuleId, float* pfValue)
646 {
647  m_iErrorState = 0;
648  if(m_bInitFlag == false)
649  {
650  warning("device not initialized");
652  return m_iErrorState;
653  }
654  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
655  {
656  warning("wrong module id");
658  return m_iErrorState;
659  }
661 
662  return m_iErrorState;
663 }
664 
665 int CDevice::getDefMaxVel(int iModuleId, float* pfValue)
666 {
667  m_iErrorState = 0;
668  if(m_bInitFlag == false)
669  {
670  warning("device not initialized");
672  return m_iErrorState;
673  }
674  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
675  {
676  warning("wrong module id");
678  return m_iErrorState;
679  }
681 
682  return m_iErrorState;
683 }
684 
685 int CDevice::getDefMaxAcc(int iModuleId, float* pfValue)
686 {
687  m_iErrorState = 0;
688  if(m_bInitFlag == false)
689  {
690  warning("device not initialized");
692  return m_iErrorState;
693  }
694  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
695  {
696  warning("wrong module id");
698  return m_iErrorState;
699  }
701 
702  return m_iErrorState;
703 }
704 
705 int CDevice::getDefMaxCur(int iModuleId, float* pfValue)
706 {
707  m_iErrorState = 0;
708  if(m_bInitFlag == false)
709  {
710  warning("device not initialized");
712  return m_iErrorState;
713  }
714  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
715  {
716  warning("wrong module id");
718  return m_iErrorState;
719  }
721 
722  return m_iErrorState;
723 }
724 
725 int CDevice::getDefMaxDeltaPos(int iModuleId, float* pfValue)
726 {
727  m_iErrorState = 0;
728  if(m_bInitFlag == false)
729  {
730  warning("device not initialized");
732  return m_iErrorState;
733  }
734  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
735  {
736  warning("wrong module id");
738  return m_iErrorState;
739  }
741 
742  return m_iErrorState;
743 }
744 
745 int CDevice::getConfig(int iModuleId, unsigned long* puiValue)
746 {
747  m_iErrorState = 0;
748  if(m_bInitFlag == false)
749  {
750  warning("device not initialized");
752  return m_iErrorState;
753  }
754  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
755  {
756  warning("wrong module id");
758  return m_iErrorState;
759  }
761 
762  return m_iErrorState;
763 }
764 
765 int CDevice::getHomeOffset(int iModuleId, float* pfValue)
766 {
767  m_iErrorState = 0;
768  if(m_bInitFlag == false)
769  {
770  warning("device not initialized");
772  return m_iErrorState;
773  }
774  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
775  {
776  warning("wrong module id");
778  return m_iErrorState;
779  }
781 
782  return m_iErrorState;
783 }
784 
785 int CDevice::getHomeOffsetInc(int iModuleId, long* piValue)
786 {
787  m_iErrorState = 0;
788  if(m_bInitFlag == false)
789  {
790  warning("device not initialized");
792  return m_iErrorState;
793  }
794  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
795  {
796  warning("wrong module id");
798  return m_iErrorState;
799  }
801 
802  return m_iErrorState;
803 }
804 
805 int CDevice::getIncRatio(int iModuleId, float* pfValue)
806 {
807  m_iErrorState = 0;
808  if(m_bInitFlag == false)
809  {
810  warning("device not initialized");
812  return m_iErrorState;
813  }
814  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
815  {
816  warning("wrong module id");
818  return m_iErrorState;
819  }
821 
822  return m_iErrorState;
823 }
824 
825 int CDevice::getDioData(int iModuleId, unsigned long* puiValue)
826 {
827  m_iErrorState = 0;
828  if(m_bInitFlag == false)
829  {
830  warning("device not initialized");
832  return m_iErrorState;
833  }
834  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
835  {
836  warning("wrong module id");
838  return m_iErrorState;
839  }
841 
842  return m_iErrorState;
843 }
844 
845 int CDevice::getA0(int iModuleId, short* piValue)
846 {
847  m_iErrorState = 0;
848  if(m_bInitFlag == false)
849  {
850  warning("device not initialized");
852  return m_iErrorState;
853  }
854  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
855  {
856  warning("wrong module id");
858  return m_iErrorState;
859  }
860  m_iErrorState = readShort(iModuleId, CMDID_GETPARAM, PARID_ACT_A0, piValue);
861 
862  return m_iErrorState;
863 }
864 
865 int CDevice::getC0(int iModuleId, short* piValue)
866 {
867  m_iErrorState = 0;
868  if(m_bInitFlag == false)
869  {
870  warning("device not initialized");
872  return m_iErrorState;
873  }
874  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
875  {
876  warning("wrong module id");
878  return m_iErrorState;
879  }
880  m_iErrorState = readShort(iModuleId, CMDID_GETPARAM, PARID_ACT_C0, piValue);
881 
882  return m_iErrorState;
883 }
884 
885 int CDevice::getDamp(int iModuleId, short* piValue)
886 {
887  m_iErrorState = 0;
888  if(m_bInitFlag == false)
889  {
890  warning("device not initialized");
892  return m_iErrorState;
893  }
894  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
895  {
896  warning("wrong module id");
898  return m_iErrorState;
899  }
900  m_iErrorState = readShort(iModuleId, CMDID_GETPARAM, PARID_ACT_DAMP, piValue);
901 
902  return m_iErrorState;
903 }
904 
905 int CDevice::getPos(int iModuleId, float* pfPos)
906 {
907  m_iErrorState = 0;
908  if(m_bInitFlag == false)
909  {
910  warning("device not initialized");
912  return m_iErrorState;
913  }
914  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
915  {
916  warning("wrong module id");
918  return m_iErrorState;
919  }
921 
922  return m_iErrorState;
923 }
924 
925 int CDevice::getVel(int iModuleId, float* pfVel)
926 {
927  m_iErrorState = 0;
928  if(m_bInitFlag == false)
929  {
930  warning("device not initialized");
932  return m_iErrorState;
933  }
934  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
935  {
936  warning("wrong module id");
938  return m_iErrorState;
939  }
941 
942  return m_iErrorState;
943 }
944 
945 int CDevice::getCur(int iModuleId, float* pfCur)
946 {
947  m_iErrorState = 0;
948  if(m_bInitFlag == false)
949  {
950  warning("device not initialized");
952  return m_iErrorState;
953  }
954  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
955  {
956  warning("wrong module id");
958  return m_iErrorState;
959  }
961 
962  return m_iErrorState;
963 }
964 
965 int CDevice::getMinPos(int iModuleId, float* pfValue)
966 {
967  m_iErrorState = 0;
968  if(m_bInitFlag == false)
969  {
970  warning("device not initialized");
972  return m_iErrorState;
973  }
974  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
975  {
976  warning("wrong module id");
978  return m_iErrorState;
979  }
981 
982  return m_iErrorState;
983 }
984 
985 int CDevice::getMaxPos(int iModuleId, float* pfValue)
986 {
987  m_iErrorState = 0;
988  if(m_bInitFlag == false)
989  {
990  warning("device not initialized");
992  return m_iErrorState;
993  }
994  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
995  {
996  warning("wrong module id");
998  return m_iErrorState;
999  }
1000  m_iErrorState = readFloat(iModuleId, CMDID_GETPARAM, PARID_ACT_FMAXPOS, pfValue);
1001 
1002  return m_iErrorState;
1003 }
1004 
1005 
1006 int CDevice::getMaxVel(int iModuleId, float* pfValue)
1007 {
1008  m_iErrorState = 0;
1009  if(m_bInitFlag == false)
1010  {
1011  warning("device not initialized");
1013  return m_iErrorState;
1014  }
1015  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
1016  {
1017  warning("wrong module id");
1019  return m_iErrorState;
1020  }
1021  m_iErrorState = readFloat(iModuleId, CMDID_GETPARAM, PARID_ACT_FMAXVEL, pfValue);
1022 
1023  return m_iErrorState;
1024 }
1025 
1026 int CDevice::getMaxAcc(int iModuleId, float* pfValue)
1027 {
1028  m_iErrorState = 0;
1029  if(m_bInitFlag == false)
1030  {
1031  warning("device not initialized");
1033  return m_iErrorState;
1034  }
1035  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
1036  {
1037  warning("wrong module id");
1039  return m_iErrorState;
1040  }
1041  m_iErrorState = readFloat(iModuleId, CMDID_GETPARAM, PARID_ACT_FMAXACC, pfValue);
1042 
1043  return m_iErrorState;
1044 }
1045 
1046 int CDevice::getMaxCur(int iModuleId, float* pfValue)
1047 {
1048  m_iErrorState = 0;
1049  if(m_bInitFlag == false)
1050  {
1051  warning("device not initialized");
1053  return m_iErrorState;
1054  }
1055  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
1056  {
1057  warning("wrong module id");
1059  return m_iErrorState;
1060  }
1061  m_iErrorState = readFloat(iModuleId, CMDID_GETPARAM, PARID_ACT_FMAXCUR, pfValue);
1062 
1063  return m_iErrorState;
1064 }
1065 
1066 int CDevice::getDeltaPos(int iModuleId, float* pfValue)
1067 {
1068  m_iErrorState = 0;
1069  if(m_bInitFlag == false)
1070  {
1071  warning("device not initialized");
1073  return m_iErrorState;
1074  }
1075  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
1076  {
1077  warning("wrong module id");
1079  return m_iErrorState;
1080  }
1082 
1083  return m_iErrorState;
1084 }
1085 
1086 int CDevice::getMaxDeltaPos(int iModuleId, float* pfValue)
1087 {
1088  m_iErrorState = 0;
1089  if(m_bInitFlag == false)
1090  {
1091  warning("device not initialized");
1093  return m_iErrorState;
1094  }
1095  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
1096  {
1097  warning("wrong module id");
1099  return m_iErrorState;
1100  }
1102 
1103  return m_iErrorState;
1104 }
1105 
1106 int CDevice::getSavePos(int iModuleId, float* pfValue)
1107 {
1108  m_iErrorState = 0;
1109  if(m_bInitFlag == false)
1110  {
1111  warning("device not initialized");
1113  return m_iErrorState;
1114  }
1115  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
1116  {
1117  warning("wrong module id");
1119  return m_iErrorState;
1120  }
1121  for(int i = 0; i < m_iModuleCount; i++)
1122  {
1123  if(m_aiModuleId[i] == iModuleId)
1124  {
1125  if(m_auiModuleVersion[i] < 0x2518 || (m_auiModuleVersion[i] >= 0x3500 && m_auiModuleVersion[i] < 0x3518))
1126  {
1127  warning("module version does not support function");
1129  return m_iErrorState;
1130  }
1131  }
1132  }
1133  m_iErrorState = readFloat(iModuleId, CMDID_GETPARAM, PARID_ACT_FSAVEPOS, pfValue);
1134 
1135  return m_iErrorState;
1136 }
1137 
1138 int CDevice::getIPolVel(int iModuleId, float* pfVel)
1139 {
1140  m_iErrorState = 0;
1141  if(m_bInitFlag == false)
1142  {
1143  warning("device not initialized");
1145  return m_iErrorState;
1146  }
1147  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
1148  {
1149  warning("wrong module id");
1151  return m_iErrorState;
1152  }
1154 
1155  return m_iErrorState;
1156 }
1157 
1158 int CDevice::getPosCountInc(int iModuleId, long* piValue)
1159 {
1160  m_iErrorState = 0;
1161  if(m_bInitFlag == false)
1162  {
1163  warning("device not initialized");
1165  return m_iErrorState;
1166  }
1167  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
1168  {
1169  warning("wrong module id");
1171  return m_iErrorState;
1172  }
1173  m_iErrorState = readLong(iModuleId, CMDID_GETPARAM, PARID_ACT_IPOSCOUNT, piValue);
1174 
1175  return m_iErrorState;
1176 }
1177 
1178 int CDevice::getPosInc(int iModuleId, long* piValue)
1179 {
1180  m_iErrorState = 0;
1181  if(m_bInitFlag == false)
1182  {
1183  warning("device not initialized");
1185  return m_iErrorState;
1186  }
1187  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
1188  {
1189  warning("wrong module id");
1191  return m_iErrorState;
1192  }
1193  m_iErrorState = readLong(iModuleId, CMDID_GETPARAM, PARID_ACT_IPOS, piValue);
1194 
1195  return m_iErrorState;
1196 }
1197 
1198 int CDevice::getVelInc(int iModuleId, long* piValue)
1199 {
1200  m_iErrorState = 0;
1201  if(m_bInitFlag == false)
1202  {
1203  warning("device not initialized");
1205  return m_iErrorState;
1206  }
1207  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
1208  {
1209  warning("wrong module id");
1211  return m_iErrorState;
1212  }
1213  m_iErrorState = readLong(iModuleId, CMDID_GETPARAM, PARID_ACT_IVEL, piValue);
1214 
1215  return m_iErrorState;
1216 }
1217 
1218 int CDevice::getCurInc(int iModuleId, short* piValue)
1219 {
1220  m_iErrorState = 0;
1221  if(m_bInitFlag == false)
1222  {
1223  warning("device not initialized");
1225  return m_iErrorState;
1226  }
1227  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
1228  {
1229  warning("wrong module id");
1231  return m_iErrorState;
1232  }
1233  m_iErrorState = readShort(iModuleId, CMDID_GETPARAM, PARID_ACT_ICUR, piValue);
1234 
1235  return m_iErrorState;
1236 }
1237 
1238 int CDevice::getMinPosInc(int iModuleId, long* piValue)
1239 {
1240  m_iErrorState = 0;
1241  if(m_bInitFlag == false)
1242  {
1243  warning("device not initialized");
1245  return m_iErrorState;
1246  }
1247  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
1248  {
1249  warning("wrong module id");
1251  return m_iErrorState;
1252  }
1253  m_iErrorState = readLong(iModuleId, CMDID_GETPARAM, PARID_ACT_IMINPOS, piValue);
1254 
1255  return m_iErrorState;
1256 }
1257 
1258 int CDevice::getMaxPosInc(int iModuleId, long* piValue)
1259 {
1260  m_iErrorState = 0;
1261  if(m_bInitFlag == false)
1262  {
1263  warning("device not initialized");
1265  return m_iErrorState;
1266  }
1267  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
1268  {
1269  warning("wrong module id");
1271  return m_iErrorState;
1272  }
1273  m_iErrorState = readLong(iModuleId, CMDID_GETPARAM, PARID_ACT_IMAXPOS, piValue);
1274 
1275  return m_iErrorState;
1276 }
1277 
1278 int CDevice::getMaxVelInc(int iModuleId, long* piValue)
1279 {
1280  m_iErrorState = 0;
1281  if(m_bInitFlag == false)
1282  {
1283  warning("device not initialized");
1285  return m_iErrorState;
1286  }
1287  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
1288  {
1289  warning("wrong module id");
1291  return m_iErrorState;
1292  }
1293  m_iErrorState = readLong(iModuleId, CMDID_GETPARAM, PARID_ACT_IMAXVEL, piValue);
1294 
1295  return m_iErrorState;
1296 }
1297 
1298 int CDevice::getMaxAccInc(int iModuleId, long* piValue)
1299 {
1300  m_iErrorState = 0;
1301  if(m_bInitFlag == false)
1302  {
1303  warning("device not initialized");
1305  return m_iErrorState;
1306  }
1307  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
1308  {
1309  warning("wrong module id");
1311  return m_iErrorState;
1312  }
1313  m_iErrorState = readLong(iModuleId, CMDID_GETPARAM, PARID_ACT_IMAXACC, piValue);
1314 
1315  return m_iErrorState;
1316 }
1317 
1318 int CDevice::getDeltaPosInc(int iModuleId, long* piValue)
1319 {
1320  m_iErrorState = 0;
1321  if(m_bInitFlag == false)
1322  {
1323  warning("device not initialized");
1325  return m_iErrorState;
1326  }
1327  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
1328  {
1329  warning("wrong module id");
1331  return m_iErrorState;
1332  }
1333  m_iErrorState = readLong(iModuleId, CMDID_GETPARAM, PARID_ACT_IDELTAPOS, piValue);
1334 
1335  return m_iErrorState;
1336 }
1337 
1338 int CDevice::getMaxDeltaPosInc(int iModuleId, long* piValue)
1339 {
1340  m_iErrorState = 0;
1341  if(m_bInitFlag == false)
1342  {
1343  warning("device not initialized");
1345  return m_iErrorState;
1346  }
1347  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
1348  {
1349  warning("wrong module id");
1351  return m_iErrorState;
1352  }
1354 
1355  return m_iErrorState;
1356 }
1357 
1358 int CDevice::getStateDioPos(int iModuleId, unsigned long* puiState, unsigned char* pucDio, float* pfPos)
1359 {
1360  unsigned char ucState;
1361  m_iErrorState = 0;
1362  if(m_bInitFlag == false)
1363  {
1364  warning("device not initialized");
1366  return m_iErrorState;
1367  }
1368  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
1369  {
1370  warning("wrong module id");
1372  return m_iErrorState;
1373  }
1374  for(int i = 0; i < m_iModuleCount; i++)
1375  {
1376  if(m_aiModuleId[i] == iModuleId)
1377  {
1378  if(m_auiModuleVersion[i] < 0x2518 || (m_auiModuleVersion[i] >= 0x3500 && m_auiModuleVersion[i] < 0x3518))
1379  {
1380  warning("module version does not support function");
1382  return m_iErrorState;
1383  }
1384  }
1385  }
1386  m_iErrorState = readFloatUnsignedChars(iModuleId, CMDID_GETPARAM, PARID_ACT_FPOSSTATEDIO, pfPos, &ucState, pucDio);
1387  if(m_iErrorState == 0)
1388  charStateToLongState(ucState, puiState);
1389  return m_iErrorState;
1390 }
1391 
1392 int CDevice::getHomeVel(int iModuleId, float* pfVel)
1393 {
1394  m_iErrorState = 0;
1395  if(m_bInitFlag == false)
1396  {
1397  warning("device not initialized");
1399  return m_iErrorState;
1400  }
1401  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
1402  {
1403  warning("wrong module id");
1405  return m_iErrorState;
1406  }
1407  for(int i = 0; i < m_iModuleCount; i++)
1408  {
1409  if(m_aiModuleId[i] == iModuleId)
1410  {
1411  if(m_auiModuleVersion[i] < 0x2518 || (m_auiModuleVersion[i] >= 0x3500 && m_auiModuleVersion[i] < 0x3518))
1412  {
1413  warning("module version does not support function");
1415  return m_iErrorState;
1416  }
1417  }
1418  }
1420 
1421  return m_iErrorState;
1422 }
1423 
1424 int CDevice::getHomeVelInc(int iModuleId, long* piValue)
1425 {
1426  m_iErrorState = 0;
1427  if(m_bInitFlag == false)
1428  {
1429  warning("device not initialized");
1431  return m_iErrorState;
1432  }
1433  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
1434  {
1435  warning("wrong module id");
1437  return m_iErrorState;
1438  }
1439  for(int i = 0; i < m_iModuleCount; i++)
1440  {
1441  if(m_aiModuleId[i] == iModuleId)
1442  {
1443  if(m_auiModuleVersion[i] < 0x2518 || (m_auiModuleVersion[i] >= 0x3500 && m_auiModuleVersion[i] < 0x3518))
1444  {
1445  warning("module version does not support function");
1447  return m_iErrorState;
1448  }
1449  }
1450  }
1451  m_iErrorState = readLong(iModuleId, CMDID_GETPARAM, PARID_ACT_IHOMEVEL, piValue);
1452 
1453  return m_iErrorState;
1454 }
1455 
1456 int CDevice::getSyncTime(int iModuleId, short* piValue)
1457 {
1458  m_iErrorState = 0;
1459  if(m_bInitFlag == false)
1460  {
1461  warning("device not initialized");
1463  return m_iErrorState;
1464  }
1465  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
1466  {
1467  warning("wrong module id");
1469  return m_iErrorState;
1470  }
1471  for(int i = 0; i < m_iModuleCount; i++)
1472  {
1473  if(m_aiModuleId[i] == iModuleId)
1474  {
1475  if(m_auiModuleVersion[i] < 0x3602)
1476  {
1477  warning("module version does not support function");
1479  return m_iErrorState;
1480  }
1481  }
1482  }
1483  m_iErrorState = readShort(iModuleId, CMDID_GETPARAM, PARID_ACT_SYNCTIME, piValue);
1484 
1485  return m_iErrorState;
1486 }
1487 
1488 int CDevice::getRawMotorCurrent(int iModuleId, short* piValue)
1489 {
1490  m_iErrorState = 0;
1491  if(m_bInitFlag == false)
1492  {
1493  warning("device not initialized");
1495  return m_iErrorState;
1496  }
1497  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
1498  {
1499  warning("wrong module id");
1501  return m_iErrorState;
1502  }
1503  for(int i = 0; i < m_iModuleCount; i++)
1504  {
1505  if(m_aiModuleId[i] == iModuleId)
1506  {
1507  if(m_auiModuleVersion[i] < 0x3602)
1508  {
1509  warning("module version does not support function");
1511  return m_iErrorState;
1512  }
1513  }
1514  }
1516 
1517  return m_iErrorState;
1518 }
1519 
1520 int CDevice::getRawMotorSupply(int iModuleId, short* piValue)
1521 {
1522  m_iErrorState = 0;
1523  if(m_bInitFlag == false)
1524  {
1525  warning("device not initialized");
1527  return m_iErrorState;
1528  }
1529  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
1530  {
1531  warning("wrong module id");
1533  return m_iErrorState;
1534  }
1535  for(int i = 0; i < m_iModuleCount; i++)
1536  {
1537  if(m_aiModuleId[i] == iModuleId)
1538  {
1539  if(m_auiModuleVersion[i] < 0x3602)
1540  {
1541  warning("module version does not support function");
1543  return m_iErrorState;
1544  }
1545  }
1546  }
1548 
1549  return m_iErrorState;
1550 }
1551 
1552 int CDevice::getRawTemperature(int iModuleId, short* piValue)
1553 {
1554  m_iErrorState = 0;
1555  if(m_bInitFlag == false)
1556  {
1557  warning("device not initialized");
1559  return m_iErrorState;
1560  }
1561  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
1562  {
1563  warning("wrong module id");
1565  return m_iErrorState;
1566  }
1567  for(int i = 0; i < m_iModuleCount; i++)
1568  {
1569  if(m_aiModuleId[i] == iModuleId)
1570  {
1571  if(m_auiModuleVersion[i] < 0x3602)
1572  {
1573  warning("module version does not support function");
1575  return m_iErrorState;
1576  }
1577  }
1578  }
1579  m_iErrorState = readShort(iModuleId, CMDID_GETPARAM, PARID_ACT_RAWTEMP, piValue);
1580 
1581  return m_iErrorState;
1582 }
1583 
1584 int CDevice::getRawLogicSupply(int iModuleId, short* piValue)
1585 {
1586  m_iErrorState = 0;
1587  if(m_bInitFlag == false)
1588  {
1589  warning("device not initialized");
1591  return m_iErrorState;
1592  }
1593  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
1594  {
1595  warning("wrong module id");
1597  return m_iErrorState;
1598  }
1599  for(int i = 0; i < m_iModuleCount; i++)
1600  {
1601  if(m_aiModuleId[i] == iModuleId)
1602  {
1603  if(m_auiModuleVersion[i] < 0x3602)
1604  {
1605  warning("module version does not support function");
1607  return m_iErrorState;
1608  }
1609  }
1610  }
1612 
1613  return m_iErrorState;
1614 }
1615 
1616 int CDevice::getLoadLimit(int iModuleId, long* piValue)
1617 {
1618  m_iErrorState = 0;
1619  if(m_bInitFlag == false)
1620  {
1621  warning("device not initialized");
1623  return m_iErrorState;
1624  }
1625  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
1626  {
1627  warning("wrong module id");
1629  return m_iErrorState;
1630  }
1631  for(int i = 0; i < m_iModuleCount; i++)
1632  {
1633  if(m_aiModuleId[i] == iModuleId)
1634  {
1635  if(m_auiModuleVersion[i] < 0x351A )
1636  {
1637  warning("module version does not support function");
1639  return m_iErrorState;
1640  }
1641  }
1642  }
1643  m_iErrorState = readLong(iModuleId, CMDID_GETPARAM, PARID_ACT_LOADLIMIT, piValue);
1644 
1645  return m_iErrorState;
1646 }
1647 
1648 int CDevice::getMaxLoadGradient(int iModuleId, long* piValue)
1649 {
1650  m_iErrorState = 0;
1651  if(m_bInitFlag == false)
1652  {
1653  warning("device not initialized");
1655  return m_iErrorState;
1656  }
1657  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
1658  {
1659  warning("wrong module id");
1661  return m_iErrorState;
1662  }
1663  for(int i = 0; i < m_iModuleCount; i++)
1664  {
1665  if(m_aiModuleId[i] == iModuleId)
1666  {
1667  if(m_auiModuleVersion[i] < 0x351A )
1668  {
1669  warning("module version does not support function");
1671  return m_iErrorState;
1672  }
1673  }
1674  }
1676 
1677  return m_iErrorState;
1678 }
1679 
1680 int CDevice::getLoadDeltaTime(int iModuleId, unsigned short* piValue)
1681 {
1682  m_iErrorState = 0;
1683  if(m_bInitFlag == false)
1684  {
1685  warning("device not initialized");
1687  return m_iErrorState;
1688  }
1689  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
1690  {
1691  warning("wrong module id");
1693  return m_iErrorState;
1694  }
1695  for(int i = 0; i < m_iModuleCount; i++)
1696  {
1697  if(m_aiModuleId[i] == iModuleId)
1698  {
1699  if(m_auiModuleVersion[i] < 0x351A)
1700  {
1701  warning("module version does not support function");
1703  return m_iErrorState;
1704  }
1705  }
1706  }
1707  m_iErrorState = readShort(iModuleId, CMDID_GETPARAM, PARID_ACT_LOADDELTATIME, (short*)piValue);
1708 
1709  return m_iErrorState;
1710 }
1711 
1712 int CDevice::getMotorCurrent(int iModuleId, float* pfValue)
1713 {
1714  m_iErrorState = 0;
1715  if(m_bInitFlag == false)
1716  {
1717  warning("device not initialized");
1719  return m_iErrorState;
1720  }
1721  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
1722  {
1723  warning("wrong module id");
1725  return m_iErrorState;
1726  }
1727  for(int i = 0; i < m_iModuleCount; i++)
1728  {
1729  if(m_aiModuleId[i] == iModuleId)
1730  {
1731  if(m_auiModuleVersion[i] < 0x4601)
1732  {
1733  warning("module version does not support function");
1735  return m_iErrorState;
1736  }
1737  }
1738  }
1739  m_iErrorState = readFloat(iModuleId, CMDID_GETPARAM, PARID_ACT_FMOTCUR, pfValue);
1740 
1741  return m_iErrorState;
1742 }
1743 
1744 int CDevice::getMotorSupply(int iModuleId, float* pfValue)
1745 {
1746  m_iErrorState = 0;
1747  if(m_bInitFlag == false)
1748  {
1749  warning("device not initialized");
1751  return m_iErrorState;
1752  }
1753  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
1754  {
1755  warning("wrong module id");
1757  return m_iErrorState;
1758  }
1759  for(int i = 0; i < m_iModuleCount; i++)
1760  {
1761  if(m_aiModuleId[i] == iModuleId)
1762  {
1763  if(m_auiModuleVersion[i] < 0x4601)
1764  {
1765  warning("module version does not support function");
1767  return m_iErrorState;
1768  }
1769  }
1770  }
1772 
1773  return m_iErrorState;
1774 }
1775 
1776 int CDevice::getTemperature(int iModuleId, float* pfValue)
1777 {
1778  m_iErrorState = 0;
1779  if(m_bInitFlag == false)
1780  {
1781  warning("device not initialized");
1783  return m_iErrorState;
1784  }
1785  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
1786  {
1787  warning("wrong module id");
1789  return m_iErrorState;
1790  }
1791  for(int i = 0; i < m_iModuleCount; i++)
1792  {
1793  if(m_aiModuleId[i] == iModuleId)
1794  {
1795  if(m_auiModuleVersion[i] < 0x4601)
1796  {
1797  warning("module version does not support function");
1799  return m_iErrorState;
1800  }
1801  }
1802  }
1803  m_iErrorState = readFloat(iModuleId, CMDID_GETPARAM, PARID_ACT_FTEMP, pfValue);
1804 
1805  return m_iErrorState;
1806 }
1807 
1808 int CDevice::getLogicSupply(int iModuleId, float* pfValue)
1809 {
1810  m_iErrorState = 0;
1811  if(m_bInitFlag == false)
1812  {
1813  warning("device not initialized");
1815  return m_iErrorState;
1816  }
1817  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
1818  {
1819  warning("wrong module id");
1821  return m_iErrorState;
1822  }
1823  for(int i = 0; i < m_iModuleCount; i++)
1824  {
1825  if(m_aiModuleId[i] == iModuleId)
1826  {
1827  if(m_auiModuleVersion[i] < 0x4601)
1828  {
1829  warning("module version does not support function");
1831  return m_iErrorState;
1832  }
1833  }
1834  }
1836 
1837  return m_iErrorState;
1838 }
1839 
1840 int CDevice::getMinLogicVoltage(int iModuleId, float* pfValue)
1841 {
1842  m_iErrorState = 0;
1843  if(m_bInitFlag == false)
1844  {
1845  warning("device not initialized");
1847  return m_iErrorState;
1848  }
1849  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
1850  {
1851  warning("wrong module id");
1853  return m_iErrorState;
1854  }
1855  for(int i = 0; i < m_iModuleCount; i++)
1856  {
1857  if(m_aiModuleId[i] == iModuleId)
1858  {
1859  if(m_auiModuleVersion[i] < 0x4601)
1860  {
1861  warning("module version does not support function");
1863  return m_iErrorState;
1864  }
1865  }
1866  }
1867  m_iErrorState = readFloat(iModuleId, CMDID_GETPARAM, PARID_ACT_MINLOGIC, pfValue);
1868 
1869  return m_iErrorState;
1870 }
1871 
1872 int CDevice::getMaxLogicVoltage(int iModuleId, float* pfValue)
1873 {
1874  m_iErrorState = 0;
1875  if(m_bInitFlag == false)
1876  {
1877  warning("device not initialized");
1879  return m_iErrorState;
1880  }
1881  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
1882  {
1883  warning("wrong module id");
1885  return m_iErrorState;
1886  }
1887  for(int i = 0; i < m_iModuleCount; i++)
1888  {
1889  if(m_aiModuleId[i] == iModuleId)
1890  {
1891  if(m_auiModuleVersion[i] < 0x4601)
1892  {
1893  warning("module version does not support function");
1895  return m_iErrorState;
1896  }
1897  }
1898  }
1899  m_iErrorState = readFloat(iModuleId, CMDID_GETPARAM, PARID_ACT_MAXLOGIC, pfValue);
1900 
1901  return m_iErrorState;
1902 }
1903 
1904 int CDevice::getMinMotorVoltage(int iModuleId, float* pfValue)
1905 {
1906  m_iErrorState = 0;
1907  if(m_bInitFlag == false)
1908  {
1909  warning("device not initialized");
1911  return m_iErrorState;
1912  }
1913  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
1914  {
1915  warning("wrong module id");
1917  return m_iErrorState;
1918  }
1919  for(int i = 0; i < m_iModuleCount; i++)
1920  {
1921  if(m_aiModuleId[i] == iModuleId)
1922  {
1923  if(m_auiModuleVersion[i] < 0x4601)
1924  {
1925  warning("module version does not support function");
1927  return m_iErrorState;
1928  }
1929  }
1930  }
1931  m_iErrorState = readFloat(iModuleId, CMDID_GETPARAM, PARID_ACT_MINMOTOR, pfValue);
1932 
1933  return m_iErrorState;
1934 }
1935 
1936 int CDevice::getMaxMotorVoltage(int iModuleId, float* pfValue)
1937 {
1938  m_iErrorState = 0;
1939  if(m_bInitFlag == false)
1940  {
1941  warning("device not initialized");
1943  return m_iErrorState;
1944  }
1945  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
1946  {
1947  warning("wrong module id");
1949  return m_iErrorState;
1950  }
1951  for(int i = 0; i < m_iModuleCount; i++)
1952  {
1953  if(m_aiModuleId[i] == iModuleId)
1954  {
1955  if(m_auiModuleVersion[i] < 0x4601)
1956  {
1957  warning("module version does not support function");
1959  return m_iErrorState;
1960  }
1961  }
1962  }
1963  m_iErrorState = readFloat(iModuleId, CMDID_GETPARAM, PARID_ACT_MAXMOTOR, pfValue);
1964 
1965  return m_iErrorState;
1966 }
1967 
1968 int CDevice::getNominalMotorCurrent(int iModuleId, float* pfValue)
1969 {
1970  m_iErrorState = 0;
1971  if(m_bInitFlag == false)
1972  {
1973  warning("device not initialized");
1975  return m_iErrorState;
1976  }
1977  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
1978  {
1979  warning("wrong module id");
1981  return m_iErrorState;
1982  }
1983  for(int i = 0; i < m_iModuleCount; i++)
1984  {
1985  if(m_aiModuleId[i] == iModuleId)
1986  {
1987  if(m_auiModuleVersion[i] < 0x4601)
1988  {
1989  warning("module version does not support function");
1991  return m_iErrorState;
1992  }
1993  }
1994  }
1995  m_iErrorState = readFloat(iModuleId, CMDID_GETPARAM, PARID_ACT_NOMCUR, pfValue);
1996 
1997  return m_iErrorState;
1998 }
1999 
2000 int CDevice::getMaximumMotorCurrent(int iModuleId, float* pfValue)
2001 {
2002  m_iErrorState = 0;
2003  if(m_bInitFlag == false)
2004  {
2005  warning("device not initialized");
2007  return m_iErrorState;
2008  }
2009  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
2010  {
2011  warning("wrong module id");
2013  return m_iErrorState;
2014  }
2015  for(int i = 0; i < m_iModuleCount; i++)
2016  {
2017  if(m_aiModuleId[i] == iModuleId)
2018  {
2019  if(m_auiModuleVersion[i] < 0x4601)
2020  {
2021  warning("module version does not support function");
2023  return m_iErrorState;
2024  }
2025  }
2026  }
2027  m_iErrorState = readFloat(iModuleId, CMDID_GETPARAM, PARID_ACT_HMAXCUR, pfValue);
2028 
2029  return m_iErrorState;
2030 }
2031 
2032 int CDevice::getLogicUndershootTime(int iModuleId, long* piValue)
2033 {
2034  m_iErrorState = 0;
2035  if(m_bInitFlag == false)
2036  {
2037  warning("device not initialized");
2039  return m_iErrorState;
2040  }
2041  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
2042  {
2043  warning("wrong module id");
2045  return m_iErrorState;
2046  }
2047  for(int i = 0; i < m_iModuleCount; i++)
2048  {
2049  if(m_aiModuleId[i] == iModuleId)
2050  {
2051  if(m_auiModuleVersion[i] < 0x4601 )
2052  {
2053  warning("module version does not support function");
2055  return m_iErrorState;
2056  }
2057  }
2058  }
2060 
2061  return m_iErrorState;
2062 }
2063 
2064 int CDevice::getLogicOvershootTime(int iModuleId, long* piValue)
2065 {
2066  m_iErrorState = 0;
2067  if(m_bInitFlag == false)
2068  {
2069  warning("device not initialized");
2071  return m_iErrorState;
2072  }
2073  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
2074  {
2075  warning("wrong module id");
2077  return m_iErrorState;
2078  }
2079  for(int i = 0; i < m_iModuleCount; i++)
2080  {
2081  if(m_aiModuleId[i] == iModuleId)
2082  {
2083  if(m_auiModuleVersion[i] < 0x4601 )
2084  {
2085  warning("module version does not support function");
2087  return m_iErrorState;
2088  }
2089  }
2090  }
2092 
2093  return m_iErrorState;
2094 }
2095 
2096 int CDevice::getMotorUndershootTime(int iModuleId, long* piValue)
2097 {
2098  m_iErrorState = 0;
2099  if(m_bInitFlag == false)
2100  {
2101  warning("device not initialized");
2103  return m_iErrorState;
2104  }
2105  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
2106  {
2107  warning("wrong module id");
2109  return m_iErrorState;
2110  }
2111  for(int i = 0; i < m_iModuleCount; i++)
2112  {
2113  if(m_aiModuleId[i] == iModuleId)
2114  {
2115  if(m_auiModuleVersion[i] < 0x4601 )
2116  {
2117  warning("module version does not support function");
2119  return m_iErrorState;
2120  }
2121  }
2122  }
2124 
2125  return m_iErrorState;
2126 }
2127 
2128 int CDevice::getMotorOvershootTime(int iModuleId, long* piValue)
2129 {
2130  m_iErrorState = 0;
2131  if(m_bInitFlag == false)
2132  {
2133  warning("device not initialized");
2135  return m_iErrorState;
2136  }
2137  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
2138  {
2139  warning("wrong module id");
2141  return m_iErrorState;
2142  }
2143  for(int i = 0; i < m_iModuleCount; i++)
2144  {
2145  if(m_aiModuleId[i] == iModuleId)
2146  {
2147  if(m_auiModuleVersion[i] < 0x4601 )
2148  {
2149  warning("module version does not support function");
2151  return m_iErrorState;
2152  }
2153  }
2154  }
2156 
2157  return m_iErrorState;
2158 }
2159 
2160 int CDevice::getNomCurOvershootTime(int iModuleId, long* piValue)
2161 {
2162  m_iErrorState = 0;
2163  if(m_bInitFlag == false)
2164  {
2165  warning("device not initialized");
2167  return m_iErrorState;
2168  }
2169  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
2170  {
2171  warning("wrong module id");
2173  return m_iErrorState;
2174  }
2175  for(int i = 0; i < m_iModuleCount; i++)
2176  {
2177  if(m_aiModuleId[i] == iModuleId)
2178  {
2179  if(m_auiModuleVersion[i] < 0x4601 )
2180  {
2181  warning("module version does not support function");
2183  return m_iErrorState;
2184  }
2185  }
2186  }
2188 
2189  return m_iErrorState;
2190 }
2191 
2192 int CDevice::getHMaxCurOvershootTime(int iModuleId, long* piValue)
2193 {
2194  m_iErrorState = 0;
2195  if(m_bInitFlag == false)
2196  {
2197  warning("device not initialized");
2199  return m_iErrorState;
2200  }
2201  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
2202  {
2203  warning("wrong module id");
2205  return m_iErrorState;
2206  }
2207  for(int i = 0; i < m_iModuleCount; i++)
2208  {
2209  if(m_aiModuleId[i] == iModuleId)
2210  {
2211  if(m_auiModuleVersion[i] < 0x4601 )
2212  {
2213  warning("module version does not support function");
2215  return m_iErrorState;
2216  }
2217  }
2218  }
2220 
2221  return m_iErrorState;
2222 }
2223 
2224 int CDevice::getKpPWMLimit(int iModuleId, long* piValue)
2225 {
2226  m_iErrorState = 0;
2227  if(m_bInitFlag == false)
2228  {
2229  warning("device not initialized");
2231  return m_iErrorState;
2232  }
2233  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
2234  {
2235  warning("wrong module id");
2237  return m_iErrorState;
2238  }
2239  for(int i = 0; i < m_iModuleCount; i++)
2240  {
2241  if(m_aiModuleId[i] == iModuleId)
2242  {
2243  if(m_auiModuleVersion[i] < 0x4601 )
2244  {
2245  warning("module version does not support function");
2247  return m_iErrorState;
2248  }
2249  }
2250  }
2251  m_iErrorState = readLong(iModuleId, CMDID_GETPARAM, PARID_ACT_KP_PWMLIM, piValue);
2252 
2253  return m_iErrorState;
2254 }
2255 
2256 int CDevice::getCurrentLimit(int iModuleId, float* pfValue)
2257 {
2258  m_iErrorState = 0;
2259  if(m_bInitFlag == false)
2260  {
2261  warning("device not initialized");
2263  return m_iErrorState;
2264  }
2265  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
2266  {
2267  warning("wrong module id");
2269  return m_iErrorState;
2270  }
2271  for(int i = 0; i < m_iModuleCount; i++)
2272  {
2273  if(m_aiModuleId[i] == iModuleId)
2274  {
2275  if(m_auiModuleVersion[i] < 0x4601)
2276  {
2277  warning("module version does not support function");
2279  return m_iErrorState;
2280  }
2281  }
2282  }
2284 
2285  return m_iErrorState;
2286 }
2287 
2288 int CDevice::getMaxPWMOutput(int iModuleId, long* piValue)
2289 {
2290  m_iErrorState = 0;
2291  if(m_bInitFlag == false)
2292  {
2293  warning("device not initialized");
2295  return m_iErrorState;
2296  }
2297  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
2298  {
2299  warning("wrong module id");
2301  return m_iErrorState;
2302  }
2303  for(int i = 0; i < m_iModuleCount; i++)
2304  {
2305  if(m_aiModuleId[i] == iModuleId)
2306  {
2307  if(m_auiModuleVersion[i] < 0x4601 )
2308  {
2309  warning("module version does not support function");
2311  return m_iErrorState;
2312  }
2313  }
2314  }
2316 
2317  return m_iErrorState;
2318 }
2319 
2320 // ========================================================================== ;
2321 // ;
2322 // ---- modify functions ---------------------------------------------------- ;
2323 // ;
2324 // ========================================================================== ;
2325 
2326 void CDevice::setName(const char* acName)
2327 {
2328  strncpy(m_acName, acName, 128);
2329 }
2330 
2331 void CDevice::setInitString(const char* acInitString)
2332 {
2333  strncpy(m_acInitString, acInitString, 128);
2334 }
2335 
2336 int CDevice::setConfig(int iModuleId, unsigned long uiValue)
2337 {
2338  m_iErrorState = 0;
2339  if(m_bInitFlag == false)
2340  {
2341  warning("device not initialized");
2343  return m_iErrorState;
2344  }
2345  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
2346  {
2347  warning("wrong module id");
2349  return m_iErrorState;
2350  }
2352 
2353  return m_iErrorState;
2354 }
2355 
2356 int CDevice::setHomeOffset(int iModuleId, float fValue)
2357 {
2358  m_iErrorState = 0;
2359  if(m_bInitFlag == false)
2360  {
2361  warning("device not initialized");
2363  return m_iErrorState;
2364  }
2365  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
2366  {
2367  warning("wrong module id");
2369  return m_iErrorState;
2370  }
2372 
2373  return m_iErrorState;
2374 }
2375 
2376 int CDevice::setHomeOffsetInc(int iModuleId, long iValue)
2377 {
2378  m_iErrorState = 0;
2379  if(m_bInitFlag == false)
2380  {
2381  warning("device not initialized");
2383  return m_iErrorState;
2384  }
2385  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
2386  {
2387  warning("wrong module id");
2389  return m_iErrorState;
2390  }
2392 
2393  return m_iErrorState;
2394 }
2395 
2396 int CDevice::setDioData(int iModuleId, unsigned long uiValue)
2397 {
2398  m_iErrorState = 0;
2399  if(m_bInitFlag == false)
2400  {
2401  warning("device not initialized");
2403  return m_iErrorState;
2404  }
2405  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
2406  {
2407  warning("wrong module id");
2409  return m_iErrorState;
2410  }
2412 
2413  return m_iErrorState;
2414 }
2415 
2416 int CDevice::setA0(int iModuleId, short iValue)
2417 {
2418  m_iErrorState = 0;
2419  if(m_bInitFlag == false)
2420  {
2421  warning("device not initialized");
2423  return m_iErrorState;
2424  }
2425  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
2426  {
2427  warning("wrong module id");
2429  return m_iErrorState;
2430  }
2431  m_iErrorState = writeShort(iModuleId, CMDID_SETPARAM, PARID_ACT_A0, iValue);
2432 
2433  return m_iErrorState;
2434 }
2435 
2436 int CDevice::setC0(int iModuleId, short iValue)
2437 {
2438  m_iErrorState = 0;
2439  if(m_bInitFlag == false)
2440  {
2441  warning("device not initialized");
2443  return m_iErrorState;
2444  }
2445  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
2446  {
2447  warning("wrong module id");
2449  return m_iErrorState;
2450  }
2451  m_iErrorState = writeShort(iModuleId, CMDID_SETPARAM, PARID_ACT_C0, iValue);
2452 
2453  return m_iErrorState;
2454 }
2455 
2456 int CDevice::setDamp(int iModuleId, short iValue)
2457 {
2458  m_iErrorState = 0;
2459  if(m_bInitFlag == false)
2460  {
2461  warning("device not initialized");
2463  return m_iErrorState;
2464  }
2465  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
2466  {
2467  warning("wrong module id");
2469  return m_iErrorState;
2470  }
2471  m_iErrorState = writeShort(iModuleId, CMDID_SETPARAM, PARID_ACT_DAMP, iValue);
2472 
2473  return m_iErrorState;
2474 }
2475 
2476 int CDevice::setMinPos(int iModuleId, float fValue)
2477 {
2478  m_iErrorState = 0;
2479  if(m_bInitFlag == false)
2480  {
2481  warning("device not initialized");
2483  return m_iErrorState;
2484  }
2485  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
2486  {
2487  warning("wrong module id");
2489  return m_iErrorState;
2490  }
2492 
2493  return m_iErrorState;
2494 }
2495 
2496 int CDevice::setMaxPos(int iModuleId, float fValue)
2497 {
2498  m_iErrorState = 0;
2499  if(m_bInitFlag == false)
2500  {
2501  warning("device not initialized");
2503  return m_iErrorState;
2504  }
2505  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
2506  {
2507  warning("wrong module id");
2509  return m_iErrorState;
2510  }
2512 
2513  return m_iErrorState;
2514 }
2515 
2516 int CDevice::setMaxVel(int iModuleId, float fValue)
2517 {
2518  m_iErrorState = 0;
2519  if(m_bInitFlag == false)
2520  {
2521  warning("device not initialized");
2523  return m_iErrorState;
2524  }
2525  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
2526  {
2527  warning("wrong module id");
2529  return m_iErrorState;
2530  }
2532 
2533  return m_iErrorState;
2534 }
2535 
2536 int CDevice::setMaxAcc(int iModuleId, float fValue)
2537 {
2538  m_iErrorState = 0;
2539  if(m_bInitFlag == false)
2540  {
2541  warning("device not initialized");
2543  return m_iErrorState;
2544  }
2545  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
2546  {
2547  warning("wrong module id");
2549  return m_iErrorState;
2550  }
2552 
2553  return m_iErrorState;
2554 }
2555 
2556 int CDevice::setMaxCur(int iModuleId, float fValue)
2557 {
2558  m_iErrorState = 0;
2559  if(m_bInitFlag == false)
2560  {
2561  warning("device not initialized");
2563  return m_iErrorState;
2564  }
2565  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
2566  {
2567  warning("wrong module id");
2569  return m_iErrorState;
2570  }
2572 
2573  return m_iErrorState;
2574 }
2575 
2576 int CDevice::setMaxDeltaPos(int iModuleId, float fValue)
2577 {
2578  m_iErrorState = 0;
2579  if(m_bInitFlag == false)
2580  {
2581  warning("device not initialized");
2583  return m_iErrorState;
2584  }
2585  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
2586  {
2587  warning("wrong module id");
2589  return m_iErrorState;
2590  }
2592 
2593  return m_iErrorState;
2594 }
2595 
2596 int CDevice::setMinPosInc(int iModuleId, long iValue)
2597 {
2598  m_iErrorState = 0;
2599  if(m_bInitFlag == false)
2600  {
2601  warning("device not initialized");
2603  return m_iErrorState;
2604  }
2605  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
2606  {
2607  warning("wrong module id");
2609  return m_iErrorState;
2610  }
2612 
2613  return m_iErrorState;
2614 }
2615 
2616 int CDevice::setMaxPosInc(int iModuleId, long iValue)
2617 {
2618  m_iErrorState = 0;
2619  if(m_bInitFlag == false)
2620  {
2621  warning("device not initialized");
2623  return m_iErrorState;
2624  }
2625  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
2626  {
2627  warning("wrong module id");
2629  return m_iErrorState;
2630  }
2632 
2633  return m_iErrorState;
2634 }
2635 
2636 int CDevice::setMaxVelInc(int iModuleId, long iValue)
2637 {
2638  m_iErrorState = 0;
2639  if(m_bInitFlag == false)
2640  {
2641  warning("device not initialized");
2643  return m_iErrorState;
2644  }
2645  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
2646  {
2647  warning("wrong module id");
2649  return m_iErrorState;
2650  }
2652 
2653  return m_iErrorState;
2654 }
2655 
2656 int CDevice::setMaxAccInc(int iModuleId, long iValue)
2657 {
2658  m_iErrorState = 0;
2659  if(m_bInitFlag == false)
2660  {
2661  warning("device not initialized");
2663  return m_iErrorState;
2664  }
2665  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
2666  {
2667  warning("wrong module id");
2669  return m_iErrorState;
2670  }
2672 
2673  return m_iErrorState;
2674 }
2675 
2676 int CDevice::setMaxDeltaPosInc(int iModuleId, long iValue)
2677 {
2678  m_iErrorState = 0;
2679  if(m_bInitFlag == false)
2680  {
2681  warning("device not initialized");
2683  return m_iErrorState;
2684  }
2685  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
2686  {
2687  warning("wrong module id");
2689  return m_iErrorState;
2690  }
2692 
2693  return m_iErrorState;
2694 }
2695 
2696 int CDevice::setHomeVel(int iModuleId, float fValue)
2697 {
2698  m_iErrorState = 0;
2699  if(m_bInitFlag == false)
2700  {
2701  warning("device not initialized");
2703  return m_iErrorState;
2704  }
2705  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
2706  {
2707  warning("wrong module id");
2709  return m_iErrorState;
2710  }
2711  for(int i = 0; i < m_iModuleCount; i++)
2712  {
2713  if(m_aiModuleId[i] == iModuleId)
2714  {
2715  if(m_auiModuleVersion[i] < 0x2518 || (m_auiModuleVersion[i] >= 0x3500 && m_auiModuleVersion[i] < 0x3518))
2716  {
2717  warning("module version does not support function");
2719  return m_iErrorState;
2720  }
2721  }
2722  }
2724 
2725  return m_iErrorState;
2726 }
2727 
2728 int CDevice::setHomeVelInc(int iModuleId, long iValue)
2729 {
2730  m_iErrorState = 0;
2731  if(m_bInitFlag == false)
2732  {
2733  warning("device not initialized");
2735  return m_iErrorState;
2736  }
2737  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
2738  {
2739  warning("wrong module id");
2741  return m_iErrorState;
2742  }
2743  for(int i = 0; i < m_iModuleCount; i++)
2744  {
2745  if(m_aiModuleId[i] == iModuleId)
2746  {
2747  if(m_auiModuleVersion[i] < 0x2518 || (m_auiModuleVersion[i] >= 0x3500 && m_auiModuleVersion[i] < 0x3518))
2748  {
2749  warning("module version does not support function");
2751  return m_iErrorState;
2752  }
2753  }
2754  }
2756 
2757  return m_iErrorState;
2758 }
2759 
2760 int CDevice::setRampVel(int iModuleId, float fValue)
2761 {
2762  m_iErrorState = 0;
2763  if(m_bInitFlag == false)
2764  {
2765  warning("device not initialized");
2767  return m_iErrorState;
2768  }
2769  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
2770  {
2771  warning("wrong module id");
2773  return m_iErrorState;
2774  }
2776 
2777  return m_iErrorState;
2778 }
2779 
2780 int CDevice::setRampVelInc(int iModuleId, long iValue)
2781 {
2782  m_iErrorState = 0;
2783  if(m_bInitFlag == false)
2784  {
2785  warning("device not initialized");
2787  return m_iErrorState;
2788  }
2789  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
2790  {
2791  warning("wrong module id");
2793  return m_iErrorState;
2794  }
2796 
2797  return m_iErrorState;
2798 }
2799 
2800 int CDevice::setRampAcc(int iModuleId, float fValue)
2801 {
2802  m_iErrorState = 0;
2803  if(m_bInitFlag == false)
2804  {
2805  warning("device not initialized");
2807  return m_iErrorState;
2808  }
2809  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
2810  {
2811  warning("wrong module id");
2813  return m_iErrorState;
2814  }
2816 
2817  return m_iErrorState;
2818 }
2819 
2820 int CDevice::setRampAccInc(int iModuleId, long iValue)
2821 {
2822  m_iErrorState = 0;
2823  if(m_bInitFlag == false)
2824  {
2825  warning("device not initialized");
2827  return m_iErrorState;
2828  }
2829  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
2830  {
2831  warning("wrong module id");
2833  return m_iErrorState;
2834  }
2836 
2837  return m_iErrorState;
2838 }
2839 
2840 int CDevice::setSyncTime(int iModuleId, short iValue)
2841 {
2842  m_iErrorState = 0;
2843  if(m_bInitFlag == false)
2844  {
2845  warning("device not initialized");
2847  return m_iErrorState;
2848  }
2849  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
2850  {
2851  warning("wrong module id");
2853  return m_iErrorState;
2854  }
2855  for(int i = 0; i < m_iModuleCount; i++)
2856  {
2857  if(m_aiModuleId[i] == iModuleId)
2858  {
2859  if(m_auiModuleVersion[i] < 0x3602)
2860  {
2861  warning("module version does not support function");
2863  return m_iErrorState;
2864  }
2865  }
2866  }
2868 
2869  return m_iErrorState;
2870 }
2871 
2872 int CDevice::setLoadLimit(int iModuleId, long iValue)
2873 {
2874  m_iErrorState = 0;
2875  if(m_bInitFlag == false)
2876  {
2877  warning("device not initialized");
2879  return m_iErrorState;
2880  }
2881  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
2882  {
2883  warning("wrong module id");
2885  return m_iErrorState;
2886  }
2887  for(int i = 0; i < m_iModuleCount; i++)
2888  {
2889  if(m_aiModuleId[i] == iModuleId)
2890  {
2891  if(m_auiModuleVersion[i] < 0x351A)
2892  {
2893  warning("module version does not support function");
2895  return m_iErrorState;
2896  }
2897  }
2898  }
2900 
2901  return m_iErrorState;
2902 }
2903 
2904 int CDevice::setMaxLoadGradient(int iModuleId, long iValue)
2905 {
2906  m_iErrorState = 0;
2907  if(m_bInitFlag == false)
2908  {
2909  warning("device not initialized");
2911  return m_iErrorState;
2912  }
2913  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
2914  {
2915  warning("wrong module id");
2917  return m_iErrorState;
2918  }
2919  for(int i = 0; i < m_iModuleCount; i++)
2920  {
2921  if(m_aiModuleId[i] == iModuleId)
2922  {
2923  if(m_auiModuleVersion[i] < 0x351A)
2924  {
2925  warning("module version does not support function");
2927  return m_iErrorState;
2928  }
2929  }
2930  }
2932 
2933  return m_iErrorState;
2934 }
2935 
2936 int CDevice::setLoadDeltaTime(int iModuleId, unsigned short iValue)
2937 {
2938  m_iErrorState = 0;
2939  if(m_bInitFlag == false)
2940  {
2941  warning("device not initialized");
2943  return m_iErrorState;
2944  }
2945  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
2946  {
2947  warning("wrong module id");
2949  return m_iErrorState;
2950  }
2951  for(int i = 0; i < m_iModuleCount; i++)
2952  {
2953  if(m_aiModuleId[i] == iModuleId)
2954  {
2955  if(m_auiModuleVersion[i] < 0x351A)
2956  {
2957  warning("module version does not support function");
2959  return m_iErrorState;
2960  }
2961  }
2962  }
2964 
2965  return m_iErrorState;
2966 }
2967 
2968 int CDevice::setDefGearRatio(int iModuleId, float fValue)
2969 {
2970  m_iErrorState = 0;
2971  if(m_bInitFlag == false)
2972  {
2973  warning("device not initialized");
2975  return m_iErrorState;
2976  }
2977  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
2978  {
2979  warning("wrong module id");
2981  return m_iErrorState;
2982  }
2983  for(int i = 0; i < m_iModuleCount; i++)
2984  {
2985  if(m_aiModuleId[i] == iModuleId)
2986  {
2987  if(m_auiModuleVersion[i] < 0x4601)
2988  {
2989  warning("module version does not support function");
2991  return m_iErrorState;
2992  }
2993  }
2994  }
2996 
2997  return m_iErrorState;
2998 }
2999 
3000 int CDevice::setDefLinRatio(int iModuleId, float fValue)
3001 {
3002  m_iErrorState = 0;
3003  if(m_bInitFlag == false)
3004  {
3005  warning("device not initialized");
3007  return m_iErrorState;
3008  }
3009  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
3010  {
3011  warning("wrong module id");
3013  return m_iErrorState;
3014  }
3015  for(int i = 0; i < m_iModuleCount; i++)
3016  {
3017  if(m_aiModuleId[i] == iModuleId)
3018  {
3019  if(m_auiModuleVersion[i] < 0x4601)
3020  {
3021  warning("module version does not support function");
3023  return m_iErrorState;
3024  }
3025  }
3026  }
3028 
3029  return m_iErrorState;
3030 }
3031 
3032 int CDevice::setDefCurRatio(int iModuleId, float fValue)
3033 {
3034  m_iErrorState = 0;
3035  if(m_bInitFlag == false)
3036  {
3037  warning("device not initialized");
3039  return m_iErrorState;
3040  }
3041  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
3042  {
3043  warning("wrong module id");
3045  return m_iErrorState;
3046  }
3047  for(int i = 0; i < m_iModuleCount; i++)
3048  {
3049  if(m_aiModuleId[i] == iModuleId)
3050  {
3051  if(m_auiModuleVersion[i] < 0x4601)
3052  {
3053  warning("module version does not support function");
3055  return m_iErrorState;
3056  }
3057  }
3058  }
3060 
3061  return m_iErrorState;
3062 }
3063 
3064 int CDevice::setDefHomeAcc(int iModuleId, float fValue)
3065 {
3066  m_iErrorState = 0;
3067  if(m_bInitFlag == false)
3068  {
3069  warning("device not initialized");
3071  return m_iErrorState;
3072  }
3073  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
3074  {
3075  warning("wrong module id");
3077  return m_iErrorState;
3078  }
3079  for(int i = 0; i < m_iModuleCount; i++)
3080  {
3081  if(m_aiModuleId[i] == iModuleId)
3082  {
3083  if(m_auiModuleVersion[i] < 0x4601)
3084  {
3085  warning("module version does not support function");
3087  return m_iErrorState;
3088  }
3089  }
3090  }
3092 
3093  return m_iErrorState;
3094 }
3095 
3096 int CDevice::setModuleSerialNo(int iModuleId, unsigned long uiValue)
3097 {
3098  m_iErrorState = 0;
3099  if(m_bInitFlag == false)
3100  {
3101  warning("device not initialized");
3103  return m_iErrorState;
3104  }
3105  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
3106  {
3107  warning("wrong module id");
3109  return m_iErrorState;
3110  }
3111  for(int i = 0; i < m_iModuleCount; i++)
3112  {
3113  if(m_aiModuleId[i] == iModuleId)
3114  {
3115  if(m_auiModuleVersion[i] < 0x4601)
3116  {
3117  warning("module version does not support function");
3119  return m_iErrorState;
3120  }
3121  }
3122  }
3123  m_iErrorState = writeLong(iModuleId, CMDID_SETPARAM, PARID_DEF_SERIALNO, uiValue);
3124 
3125  return m_iErrorState;
3126 }
3127 
3128 int CDevice::setDefIncPerTurn(int iModuleId, unsigned long uiValue)
3129 {
3130  m_iErrorState = 0;
3131  if(m_bInitFlag == false)
3132  {
3133  warning("device not initialized");
3135  return m_iErrorState;
3136  }
3137  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
3138  {
3139  warning("wrong module id");
3141  return m_iErrorState;
3142  }
3143  for(int i = 0; i < m_iModuleCount; i++)
3144  {
3145  if(m_aiModuleId[i] == iModuleId)
3146  {
3147  if(m_auiModuleVersion[i] < 0x4601)
3148  {
3149  warning("module version does not support function");
3151  return m_iErrorState;
3152  }
3153  }
3154  }
3156 
3157  return m_iErrorState;
3158 }
3159 
3160 int CDevice::setDefBrakeTimeOut(int iModuleId, unsigned short uiValue)
3161 {
3162  m_iErrorState = 0;
3163  if(m_bInitFlag == false)
3164  {
3165  warning("device not initialized");
3167  return m_iErrorState;
3168  }
3169  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
3170  {
3171  warning("wrong module id");
3173  return m_iErrorState;
3174  }
3175  for(int i = 0; i < m_iModuleCount; i++)
3176  {
3177  if(m_aiModuleId[i] == iModuleId)
3178  {
3179  if(m_auiModuleVersion[i] < 0x4601)
3180  {
3181  warning("module version does not support function");
3183  return m_iErrorState;
3184  }
3185  }
3186  }
3188 
3189  return m_iErrorState;
3190 }
3191 
3192 int CDevice::setDefAddress(int iModuleId, unsigned char uiValue)
3193 {
3194  m_iErrorState = 0;
3195  if(m_bInitFlag == false)
3196  {
3197  warning("device not initialized");
3199  return m_iErrorState;
3200  }
3201  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
3202  {
3203  warning("wrong module id");
3205  return m_iErrorState;
3206  }
3207  for(int i = 0; i < m_iModuleCount; i++)
3208  {
3209  if(m_aiModuleId[i] == iModuleId)
3210  {
3211  if(m_auiModuleVersion[i] < 0x4601)
3212  {
3213  warning("module version does not support function");
3215  return m_iErrorState;
3216  }
3217  }
3218  }
3219  m_iErrorState = writeChar(iModuleId, CMDID_SETPARAM, PARID_DEF_ADDRESS, uiValue);
3220 
3221  return m_iErrorState;
3222 }
3223 
3224 int CDevice::setDefCANBaudRate(int iModuleId, unsigned char uiValue)
3225 {
3226  m_iErrorState = 0;
3227  if(m_bInitFlag == false)
3228  {
3229  warning("device not initialized");
3231  return m_iErrorState;
3232  }
3233  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
3234  {
3235  warning("wrong module id");
3237  return m_iErrorState;
3238  }
3239  for(int i = 0; i < m_iModuleCount; i++)
3240  {
3241  if(m_aiModuleId[i] == iModuleId)
3242  {
3243  if(m_auiModuleVersion[i] < 0x4601)
3244  {
3245  warning("module version does not support function");
3247  return m_iErrorState;
3248  }
3249  }
3250  }
3252 
3253  return m_iErrorState;
3254 }
3255 
3256 int CDevice::setDefRSBaudRate(int iModuleId, unsigned char uiValue)
3257 {
3258  m_iErrorState = 0;
3259  if(m_bInitFlag == false)
3260  {
3261  warning("device not initialized");
3263  return m_iErrorState;
3264  }
3265  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
3266  {
3267  warning("wrong module id");
3269  return m_iErrorState;
3270  }
3271  for(int i = 0; i < m_iModuleCount; i++)
3272  {
3273  if(m_aiModuleId[i] == iModuleId)
3274  {
3275  if(m_auiModuleVersion[i] < 0x4601)
3276  {
3277  warning("module version does not support function");
3279  return m_iErrorState;
3280  }
3281  }
3282  }
3284 
3285  return m_iErrorState;
3286 }
3287 
3288 int CDevice::setDefSetup(int iModuleId, unsigned long uiValue)
3289 {
3290  m_iErrorState = 0;
3291  if(m_bInitFlag == false)
3292  {
3293  warning("device not initialized");
3295  return m_iErrorState;
3296  }
3297  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
3298  {
3299  warning("wrong module id");
3301  return m_iErrorState;
3302  }
3303  for(int i = 0; i < m_iModuleCount; i++)
3304  {
3305  if(m_aiModuleId[i] == iModuleId)
3306  {
3307  if(m_auiModuleVersion[i] < 0x4601)
3308  {
3309  warning("module version does not support function");
3311  return m_iErrorState;
3312  }
3313  }
3314  }
3315  m_iErrorState = writeLong(iModuleId, CMDID_SETPARAM, PARID_DEF_SETUP, uiValue);
3316 
3317  return m_iErrorState;
3318 }
3319 
3320 int CDevice::setMinLogicVoltage(int iModuleId, float fValue)
3321 {
3322  m_iErrorState = 0;
3323  if(m_bInitFlag == false)
3324  {
3325  warning("device not initialized");
3327  return m_iErrorState;
3328  }
3329  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
3330  {
3331  warning("wrong module id");
3333  return m_iErrorState;
3334  }
3335  for(int i = 0; i < m_iModuleCount; i++)
3336  {
3337  if(m_aiModuleId[i] == iModuleId)
3338  {
3339  if(m_auiModuleVersion[i] < 0x4601)
3340  {
3341  warning("module version does not support function");
3343  return m_iErrorState;
3344  }
3345  }
3346  }
3348 
3349  return m_iErrorState;
3350 }
3351 
3352 int CDevice::setMaxLogicVoltage(int iModuleId, float fValue)
3353 {
3354  m_iErrorState = 0;
3355  if(m_bInitFlag == false)
3356  {
3357  warning("device not initialized");
3359  return m_iErrorState;
3360  }
3361  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
3362  {
3363  warning("wrong module id");
3365  return m_iErrorState;
3366  }
3367  for(int i = 0; i < m_iModuleCount; i++)
3368  {
3369  if(m_aiModuleId[i] == iModuleId)
3370  {
3371  if(m_auiModuleVersion[i] < 0x4601)
3372  {
3373  warning("module version does not support function");
3375  return m_iErrorState;
3376  }
3377  }
3378  }
3380 
3381  return m_iErrorState;
3382 }
3383 
3384 int CDevice::setMinMotorVoltage(int iModuleId, float fValue)
3385 {
3386  m_iErrorState = 0;
3387  if(m_bInitFlag == false)
3388  {
3389  warning("device not initialized");
3391  return m_iErrorState;
3392  }
3393  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
3394  {
3395  warning("wrong module id");
3397  return m_iErrorState;
3398  }
3399  for(int i = 0; i < m_iModuleCount; i++)
3400  {
3401  if(m_aiModuleId[i] == iModuleId)
3402  {
3403  if(m_auiModuleVersion[i] < 0x4601)
3404  {
3405  warning("module version does not support function");
3407  return m_iErrorState;
3408  }
3409  }
3410  }
3412 
3413  return m_iErrorState;
3414 }
3415 
3416 int CDevice::setMaxMotorVoltage(int iModuleId, float fValue)
3417 {
3418  m_iErrorState = 0;
3419  if(m_bInitFlag == false)
3420  {
3421  warning("device not initialized");
3423  return m_iErrorState;
3424  }
3425  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
3426  {
3427  warning("wrong module id");
3429  return m_iErrorState;
3430  }
3431  for(int i = 0; i < m_iModuleCount; i++)
3432  {
3433  if(m_aiModuleId[i] == iModuleId)
3434  {
3435  if(m_auiModuleVersion[i] < 0x4601)
3436  {
3437  warning("module version does not support function");
3439  return m_iErrorState;
3440  }
3441  }
3442  }
3444 
3445  return m_iErrorState;
3446 }
3447 
3448 int CDevice::setNominalMotorCurrent(int iModuleId, float fValue)
3449 {
3450  m_iErrorState = 0;
3451  if(m_bInitFlag == false)
3452  {
3453  warning("device not initialized");
3455  return m_iErrorState;
3456  }
3457  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
3458  {
3459  warning("wrong module id");
3461  return m_iErrorState;
3462  }
3463  for(int i = 0; i < m_iModuleCount; i++)
3464  {
3465  if(m_aiModuleId[i] == iModuleId)
3466  {
3467  if(m_auiModuleVersion[i] < 0x4601)
3468  {
3469  warning("module version does not support function");
3471  return m_iErrorState;
3472  }
3473  }
3474  }
3476 
3477  return m_iErrorState;
3478 }
3479 
3480 int CDevice::setMaximumMotorCurrent(int iModuleId, float fValue)
3481 {
3482  m_iErrorState = 0;
3483  if(m_bInitFlag == false)
3484  {
3485  warning("device not initialized");
3487  return m_iErrorState;
3488  }
3489  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
3490  {
3491  warning("wrong module id");
3493  return m_iErrorState;
3494  }
3495  for(int i = 0; i < m_iModuleCount; i++)
3496  {
3497  if(m_aiModuleId[i] == iModuleId)
3498  {
3499  if(m_auiModuleVersion[i] < 0x4601)
3500  {
3501  warning("module version does not support function");
3503  return m_iErrorState;
3504  }
3505  }
3506  }
3508 
3509  return m_iErrorState;
3510 }
3511 
3512 int CDevice::setLogicUndershootTime(int iModuleId, long iValue)
3513 {
3514  m_iErrorState = 0;
3515  if(m_bInitFlag == false)
3516  {
3517  warning("device not initialized");
3519  return m_iErrorState;
3520  }
3521  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
3522  {
3523  warning("wrong module id");
3525  return m_iErrorState;
3526  }
3527  for(int i = 0; i < m_iModuleCount; i++)
3528  {
3529  if(m_aiModuleId[i] == iModuleId)
3530  {
3531  if(m_auiModuleVersion[i] < 0x4601)
3532  {
3533  warning("module version does not support function");
3535  return m_iErrorState;
3536  }
3537  }
3538  }
3540 
3541  return m_iErrorState;
3542 }
3543 
3544 int CDevice::setLogicOvershootTime(int iModuleId, long iValue)
3545 {
3546  m_iErrorState = 0;
3547  if(m_bInitFlag == false)
3548  {
3549  warning("device not initialized");
3551  return m_iErrorState;
3552  }
3553  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
3554  {
3555  warning("wrong module id");
3557  return m_iErrorState;
3558  }
3559  for(int i = 0; i < m_iModuleCount; i++)
3560  {
3561  if(m_aiModuleId[i] == iModuleId)
3562  {
3563  if(m_auiModuleVersion[i] < 0x4601)
3564  {
3565  warning("module version does not support function");
3567  return m_iErrorState;
3568  }
3569  }
3570  }
3572 
3573  return m_iErrorState;
3574 }
3575 
3576 int CDevice::setMotorUndershootTime(int iModuleId, long iValue)
3577 {
3578  m_iErrorState = 0;
3579  if(m_bInitFlag == false)
3580  {
3581  warning("device not initialized");
3583  return m_iErrorState;
3584  }
3585  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
3586  {
3587  warning("wrong module id");
3589  return m_iErrorState;
3590  }
3591  for(int i = 0; i < m_iModuleCount; i++)
3592  {
3593  if(m_aiModuleId[i] == iModuleId)
3594  {
3595  if(m_auiModuleVersion[i] < 0x4601)
3596  {
3597  warning("module version does not support function");
3599  return m_iErrorState;
3600  }
3601  }
3602  }
3604 
3605  return m_iErrorState;
3606 }
3607 
3608 int CDevice::setMotorOvershootTime(int iModuleId, long iValue)
3609 {
3610  m_iErrorState = 0;
3611  if(m_bInitFlag == false)
3612  {
3613  warning("device not initialized");
3615  return m_iErrorState;
3616  }
3617  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
3618  {
3619  warning("wrong module id");
3621  return m_iErrorState;
3622  }
3623  for(int i = 0; i < m_iModuleCount; i++)
3624  {
3625  if(m_aiModuleId[i] == iModuleId)
3626  {
3627  if(m_auiModuleVersion[i] < 0x4601)
3628  {
3629  warning("module version does not support function");
3631  return m_iErrorState;
3632  }
3633  }
3634  }
3636 
3637  return m_iErrorState;
3638 }
3639 
3640 int CDevice::setNomCurOvershootTime(int iModuleId, long iValue)
3641 {
3642  m_iErrorState = 0;
3643  if(m_bInitFlag == false)
3644  {
3645  warning("device not initialized");
3647  return m_iErrorState;
3648  }
3649  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
3650  {
3651  warning("wrong module id");
3653  return m_iErrorState;
3654  }
3655  for(int i = 0; i < m_iModuleCount; i++)
3656  {
3657  if(m_aiModuleId[i] == iModuleId)
3658  {
3659  if(m_auiModuleVersion[i] < 0x4601)
3660  {
3661  warning("module version does not support function");
3663  return m_iErrorState;
3664  }
3665  }
3666  }
3668 
3669  return m_iErrorState;
3670 }
3671 
3672 int CDevice::setHMaxCurOvershootTime(int iModuleId, long iValue)
3673 {
3674  m_iErrorState = 0;
3675  if(m_bInitFlag == false)
3676  {
3677  warning("device not initialized");
3679  return m_iErrorState;
3680  }
3681  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
3682  {
3683  warning("wrong module id");
3685  return m_iErrorState;
3686  }
3687  for(int i = 0; i < m_iModuleCount; i++)
3688  {
3689  if(m_aiModuleId[i] == iModuleId)
3690  {
3691  if(m_auiModuleVersion[i] < 0x4601)
3692  {
3693  warning("module version does not support function");
3695  return m_iErrorState;
3696  }
3697  }
3698  }
3700 
3701  return m_iErrorState;
3702 }
3703 
3704 int CDevice::setKpPWMLimit(int iModuleId, long iValue)
3705 {
3706  m_iErrorState = 0;
3707  if(m_bInitFlag == false)
3708  {
3709  warning("device not initialized");
3711  return m_iErrorState;
3712  }
3713  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
3714  {
3715  warning("wrong module id");
3717  return m_iErrorState;
3718  }
3719  for(int i = 0; i < m_iModuleCount; i++)
3720  {
3721  if(m_aiModuleId[i] == iModuleId)
3722  {
3723  if(m_auiModuleVersion[i] < 0x4601)
3724  {
3725  warning("module version does not support function");
3727  return m_iErrorState;
3728  }
3729  }
3730  }
3732 
3733  return m_iErrorState;
3734 }
3735 
3736 int CDevice::setCurrentLimit(int iModuleId, float fValue)
3737 {
3738  m_iErrorState = 0;
3739  if(m_bInitFlag == false)
3740  {
3741  warning("device not initialized");
3743  return m_iErrorState;
3744  }
3745  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
3746  {
3747  warning("wrong module id");
3749  return m_iErrorState;
3750  }
3751  for(int i = 0; i < m_iModuleCount; i++)
3752  {
3753  if(m_aiModuleId[i] == iModuleId)
3754  {
3755  if(m_auiModuleVersion[i] < 0x4601)
3756  {
3757  warning("module version does not support function");
3759  return m_iErrorState;
3760  }
3761  }
3762  }
3764 
3765  return m_iErrorState;
3766 }
3767 // ========================================================================== ;
3768 // ;
3769 // ---- I/O functions ------------------------------------------------------- ;
3770 // ;
3771 // ========================================================================== ;
3772 
3773 // ========================================================================== ;
3774 // ;
3775 // ---- exec functions ------------------------------------------------------ ;
3776 // ;
3777 // ========================================================================== ;
3778 
3780 {
3781  unsigned short uiVersion;
3782  std::vector<float> afData;
3783  if(m_bInitFlag == false)
3784  {
3785  warning("device not initialized");
3787  return m_iErrorState;
3788  }
3789  m_aiModuleId.clear();
3790  m_auiModuleVersion.clear();
3791 
3792  m_iModuleCount = m_iModuleCountMax; // timout = m_uiTimeOut + 10 * m_iModuleCount for RS232
3793  for(int i = 1; i <= m_iModuleCountMax; i++)
3794  {
3795  debug(0,"searching for module %i", i);
3796  m_iErrorState = getModuleVersion(i, &uiVersion);
3797  if(m_iErrorState == 0)
3798  {
3799  m_aiModuleId.push_back(i);
3800  m_auiModuleVersion.push_back(uiVersion);
3801  debug(0,"found module with ID %i and Version %x", i, uiVersion);
3802  }
3803  else
3804  m_iErrorState = 0;
3805  }
3806  m_iModuleCount = m_aiModuleId.size();
3807  m_iErrorState = 0;
3808  return m_iModuleCount;
3809 }
3810 
3811 int CDevice::homeModule(int iModuleId)
3812 {
3813  m_iErrorState = 0;
3814  if(m_bInitFlag == false)
3815  {
3816  warning("device not initialized");
3818  return m_iErrorState;
3819  }
3820  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
3821  {
3822  warning("wrong module id");
3824  return m_iErrorState;
3825  }
3826  m_iErrorState = writeCommand(iModuleId, CMDID_HOME);
3827 
3828  return m_iErrorState;
3829 }
3830 
3831 int CDevice::haltModule(int iModuleId)
3832 {
3833  m_iErrorState = 0;
3834  if(m_bInitFlag == false)
3835  {
3836  warning("device not initialized");
3838  return m_iErrorState;
3839  }
3840  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
3841  {
3842  warning("wrong module id");
3844  return m_iErrorState;
3845  }
3846  m_iErrorState = writeCommand(iModuleId, CMDID_HALT);
3847 
3848  return m_iErrorState;
3849 }
3850 
3851 int CDevice::resetModule(int iModuleId)
3852 {
3853  m_iErrorState = 0;
3854  if(m_bInitFlag == false)
3855  {
3856  warning("device not initialized");
3858  return m_iErrorState;
3859  }
3860  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
3861  {
3862  warning("wrong module id");
3864  return m_iErrorState;
3865  }
3866  m_iErrorState = writeCommand(iModuleId, CMDID_RESET);
3867 
3868  return m_iErrorState;
3869 }
3870 
3871 int CDevice::recalcPIDParams(int iModuleId)
3872 {
3873  m_iErrorState = 0;
3874  if(m_bInitFlag == false)
3875  {
3876  warning("device not initialized");
3878  return m_iErrorState;
3879  }
3880  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
3881  {
3882  warning("wrong module id");
3884  return m_iErrorState;
3885  }
3887 
3888  return m_iErrorState;
3889 }
3890 
3891 int CDevice::saveParameters(int iModuleId)
3892 {
3893  m_iErrorState = 0;
3894  if(m_bInitFlag == false)
3895  {
3896  warning("device not initialized");
3898  return m_iErrorState;
3899  }
3900  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
3901  {
3902  warning("wrong module id");
3904  return m_iErrorState;
3905  }
3907 
3908  return m_iErrorState;
3909 }
3910 
3911 int CDevice::movePos(int iModuleId, float fPos)
3912 {
3913  m_iErrorState = 0;
3914  if(m_bInitFlag == false)
3915  {
3916  warning("device not initialized");
3918  return m_iErrorState;
3919  }
3920  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
3921  {
3922  warning("wrong module id");
3924  return m_iErrorState;
3925  }
3927 
3928  return m_iErrorState;
3929 }
3930 
3931 int CDevice::moveRamp(int iModuleId, float fPos, float fVel, float fAcc)
3932 {
3933  m_iErrorState = 0;
3934  if(m_bInitFlag == false)
3935  {
3936  warning("device not initialized");
3938  return m_iErrorState;
3939  }
3940  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
3941  {
3942  warning("wrong module id");
3944  return m_iErrorState;
3945  }
3949 
3950  return m_iErrorState;
3951 }
3952 
3953 int CDevice::moveVel(int iModuleId, float fVel)
3954 {
3955  m_iErrorState = 0;
3956  if(m_bInitFlag == false)
3957  {
3958  warning("device not initialized");
3960  return m_iErrorState;
3961  }
3962  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
3963  {
3964  warning("wrong module id");
3966  return m_iErrorState;
3967  }
3969 
3970  return m_iErrorState;
3971 }
3972 
3973 int CDevice::moveCur(int iModuleId, float fCur)
3974 {
3975  m_iErrorState = 0;
3976  if(m_bInitFlag == false)
3977  {
3978  warning("device not initialized");
3980  return m_iErrorState;
3981  }
3982  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
3983  {
3984  warning("wrong module id");
3986  return m_iErrorState;
3987  }
3989 
3990  return m_iErrorState;
3991 }
3992 
3993 int CDevice::moveStep(int iModuleId, float fPos, unsigned short uiTime)
3994 {
3995  m_iErrorState = 0;
3996  if(m_bInitFlag == false)
3997  {
3998  warning("device not initialized");
4000  return m_iErrorState;
4001  }
4002  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
4003  {
4004  warning("wrong module id");
4006  return m_iErrorState;
4007  }
4008  m_iErrorState = writeFloatShort(iModuleId, CMDID_SETMOVE, PARID_MOVE_FSTEP, fPos, uiTime);
4009 
4010  return m_iErrorState;
4011 }
4012 
4013 int CDevice::movePosInc(int iModuleId, long iPos)
4014 {
4015  m_iErrorState = 0;
4016  if(m_bInitFlag == false)
4017  {
4018  warning("device not initialized");
4020  return m_iErrorState;
4021  }
4022  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
4023  {
4024  warning("wrong module id");
4026  return m_iErrorState;
4027  }
4029 
4030  return m_iErrorState;
4031 }
4032 
4033 int CDevice::moveRampInc(int iModuleId, long iPos, long iVel, long iAcc)
4034 {
4035  m_iErrorState = 0;
4036  if(m_bInitFlag == false)
4037  {
4038  warning("device not initialized");
4040  return m_iErrorState;
4041  }
4042  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
4043  {
4044  warning("wrong module id");
4046  return m_iErrorState;
4047  }
4051 
4052  return m_iErrorState;
4053 }
4054 
4055 int CDevice::moveVelInc(int iModuleId, long iVel)
4056 {
4057  m_iErrorState = 0;
4058  if(m_bInitFlag == false)
4059  {
4060  warning("device not initialized");
4062  return m_iErrorState;
4063  }
4064  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
4065  {
4066  warning("wrong module id");
4068  return m_iErrorState;
4069  }
4071 
4072  return m_iErrorState;
4073 }
4074 
4075 int CDevice::moveCurInc(int iModuleId, long iCur)
4076 {
4077  m_iErrorState = 0;
4078  if(m_bInitFlag == false)
4079  {
4080  warning("device not initialized");
4082  return m_iErrorState;
4083  }
4084  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
4085  {
4086  warning("wrong module id");
4088  return m_iErrorState;
4089  }
4091 
4092  return m_iErrorState;
4093 }
4094 
4095 int CDevice::moveStepInc(int iModuleId, long iPos, unsigned short uiTime)
4096 {
4097  m_iErrorState = 0;
4098  if(m_bInitFlag == false)
4099  {
4100  warning("device not initialized");
4102  return m_iErrorState;
4103  }
4104  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
4105  {
4106  warning("wrong module id");
4108  return m_iErrorState;
4109  }
4110  m_iErrorState = writeLongShort(iModuleId, CMDID_SETMOVE, PARID_MOVE_ISTEP, iPos, uiTime);
4111 
4112  return m_iErrorState;
4113 }
4114 
4115 int CDevice::movePosExtended(int iModuleId, float fPos,
4116  unsigned long* puiState, unsigned char* pucDio, float* pfPos)
4117 {
4118  m_iErrorState = 0;
4119  if(m_bInitFlag == false)
4120  {
4121  warning("device not initialized");
4123  return m_iErrorState;
4124  }
4125  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
4126  {
4127  warning("wrong module id");
4129  return m_iErrorState;
4130  }
4131  unsigned char ucState = 0;
4132  m_iErrorState = writeFloatReadFloatUnsignedChars(iModuleId, CMDID_SETMOVE, PARID_MOVE_FRAMP_EXT, fPos, pfPos, &ucState, pucDio);
4133  if(m_iErrorState == 0)
4134  charStateToLongState(ucState, puiState);
4135 
4136  return m_iErrorState;
4137 }
4138 
4139 int CDevice::moveRampExtended(int iModuleId, float fPos, float fVel, float fAcc,
4140  unsigned long* puiState, unsigned char* pucDio, float* pfPos)
4141 {
4142  m_iErrorState = 0;
4143  if(m_bInitFlag == false)
4144  {
4145  warning("device not initialized");
4147  return m_iErrorState;
4148  }
4149  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
4150  {
4151  warning("wrong module id");
4153  return m_iErrorState;
4154  }
4155  unsigned char ucState = 0;
4158  m_iErrorState = writeFloatReadFloatUnsignedChars(iModuleId, CMDID_SETMOVE, PARID_MOVE_FRAMP_EXT, fPos, pfPos, &ucState, pucDio);
4159  if(m_iErrorState == 0)
4160  charStateToLongState(ucState, puiState);
4161 
4162  return m_iErrorState;
4163 }
4164 
4165 int CDevice::moveVelExtended(int iModuleId, float fVel,
4166  unsigned long* puiState, unsigned char* pucDio, float* pfPos)
4167 {
4168  m_iErrorState = 0;
4169  if(m_bInitFlag == false)
4170  {
4171  warning("device not initialized");
4173  return m_iErrorState;
4174  }
4175  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
4176  {
4177  warning("wrong module id");
4179  return m_iErrorState;
4180  }
4181  unsigned char ucState = 0;
4182  m_iErrorState = writeFloatReadFloatUnsignedChars(iModuleId, CMDID_SETMOVE, PARID_MOVE_FVEL_EXT, fVel, pfPos, &ucState, pucDio);
4183  if(m_iErrorState == 0)
4184  charStateToLongState(ucState, puiState);
4185 
4186  return m_iErrorState;
4187 }
4188 
4189 int CDevice::moveCurExtended(int iModuleId, float fCur,
4190  unsigned long* puiState, unsigned char* pucDio, float* pfPos)
4191 {
4192  m_iErrorState = 0;
4193  if(m_bInitFlag == false)
4194  {
4195  warning("device not initialized");
4197  return m_iErrorState;
4198  }
4199  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
4200  {
4201  warning("wrong module id");
4203  return m_iErrorState;
4204  }
4205  unsigned char ucState = 0;
4206  m_iErrorState = writeFloatReadFloatUnsignedChars(iModuleId, CMDID_SETMOVE, PARID_MOVE_FCUR_EXT, fCur, pfPos, &ucState, pucDio);
4207  if(m_iErrorState == 0)
4208  charStateToLongState(ucState, puiState);
4209 
4210  return m_iErrorState;
4211 }
4212 
4213 int CDevice::moveStepExtended(int iModuleId, float fPos, unsigned short uiTime,
4214  unsigned long* puiState, unsigned char* pucDio, float* pfPos)
4215 {
4216  m_iErrorState = 0;
4217  if(m_bInitFlag == false)
4218  {
4219  warning("device not initialized");
4221  return m_iErrorState;
4222  }
4223  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
4224  {
4225  warning("wrong module id");
4227  return m_iErrorState;
4228  }
4229  unsigned char ucState = 0;
4230  m_iErrorState = writeFloatShortReadFloatUnsignedChars(iModuleId, CMDID_SETMOVE, PARID_MOVE_FSTEP_EXT, fPos, uiTime, pfPos, &ucState, pucDio);
4231  if(m_iErrorState == 0)
4232  charStateToLongState(ucState, puiState);
4233  return m_iErrorState;
4234 }
4235 
4236 // ========================================================================== ;
4237 // ;
4238 // ---- wait functions ------------------------------------------------------ ;
4239 // ;
4240 // ========================================================================== ;
4241 
4242 int CDevice::waitForHomeEnd(int iModuleId, unsigned long uiTimeOut)
4243 {
4244  int iRetVal;
4245  unsigned long uiTime, uiState;
4246  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
4247  {
4248  warning("wrong module id");
4250  return m_iErrorState;
4251  }
4252  m_clTimer.start();
4253  while(1)
4254  {
4255  Sleep(1);
4256  iRetVal = getModuleState(iModuleId, &uiState);
4257  if (iRetVal < 0)
4258  {
4259  debug(1,"com error in waitForHomeEnd()");
4260  break;
4261  }
4262  if (uiState & STATEID_MOD_ERROR)
4263  {
4264  debug(1, "module error in waitForHomeEnd()");
4265  iRetVal=ERRID_DEV_MODULEERROR;
4266  break;
4267  }
4268  if ((uiState & STATEID_MOD_HOME) && (uiState & STATEID_MOD_RAMP_END))
4269  {
4270  debug(2, "reached home position in waitForHomeEnd()");
4271  iRetVal=0;
4272  break;
4273  }
4274  m_clTimer.stop();
4275  uiTime = (unsigned long)(1000 * m_clTimer.executionTime());
4276  if (uiTime > uiTimeOut)
4277  {
4278  debug(1, "timeout in waitForHomeEnd()");
4279  iRetVal=ERRID_DEV_WAITTIMEOUT;
4280  break;
4281  }
4282  }
4283  return iRetVal;
4284 }
4285 
4286 int CDevice::waitForMotionEnd(int iModuleId, unsigned long uiTimeOut)
4287 {
4288  int iRetVal;
4289  unsigned long uiTime, uiState;
4290  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
4291  {
4292  warning("wrong module id");
4294  return m_iErrorState;
4295  }
4296  m_clTimer.start();
4297  while(1)
4298  {
4299  Sleep(1);
4300  iRetVal = getModuleState(iModuleId, &uiState);
4301  if (iRetVal < 0)
4302  {
4303  debug(1,"com error in waitForMotionEnd()");
4304  break;
4305  }
4306  if (uiState & STATEID_MOD_ERROR)
4307  {
4308  debug(1, "module error in waitForMotionEnd()");
4309  iRetVal=ERRID_DEV_MODULEERROR;
4310  break;
4311  }
4312  if (!(uiState & STATEID_MOD_MOTION))
4313  {
4314  debug(2, "finished motion in waitForMotionEnd()");
4315  iRetVal=0;
4316  break;
4317  }
4318  m_clTimer.stop();
4319  uiTime = (unsigned long)(1000 * m_clTimer.executionTime());
4320  if (uiTime > uiTimeOut)
4321  {
4322  debug(1, "timeout in waitForMotionEnd()");
4323  iRetVal=ERRID_DEV_WAITTIMEOUT;
4324  break;
4325  }
4326  }
4327  return iRetVal;
4328 }
4329 
4330 int CDevice::waitForRampEnd(int iModuleId, unsigned long uiTimeOut)
4331 {
4332  int iRetVal;
4333  unsigned long uiTime, uiState;
4334  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
4335  {
4336  warning("wrong module id");
4338  return m_iErrorState;
4339  }
4340  m_clTimer.start();
4341  while(1)
4342  {
4343  Sleep(1);
4344  iRetVal = getModuleState(iModuleId, &uiState);
4345  if (iRetVal < 0)
4346  {
4347  debug(1,"com error in waitForRampEnd()");
4348  break;
4349  }
4350  if (uiState & STATEID_MOD_ERROR)
4351  {
4352  debug(1, "module error in waitForRampEnd()");
4353  iRetVal=ERRID_DEV_MODULEERROR;
4354  break;
4355  }
4356  if (uiState & STATEID_MOD_RAMP_END)
4357  {
4358  debug(2, "reached ramp end position in waitForRampEnd()");
4359  iRetVal=0;
4360  break;
4361  }
4362  m_clTimer.stop();
4363  uiTime = (unsigned long)(1000 * m_clTimer.executionTime());
4364  if (uiTime > uiTimeOut)
4365  {
4366  debug(1, "timeout in waitForRampEnd()");
4367  iRetVal=ERRID_DEV_WAITTIMEOUT;
4368  break;
4369  }
4370  }
4371  return iRetVal;
4372 }
4373 
4374 int CDevice::waitForRampDec(int iModuleId, unsigned long uiTimeOut)
4375 {
4376  int iRetVal;
4377  unsigned long uiTime, uiState;
4378  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
4379  {
4380  warning("wrong module id");
4382  return m_iErrorState;
4383  }
4384  m_clTimer.start();
4385  while(1)
4386  {
4387  Sleep(1);
4388  iRetVal = getModuleState(iModuleId, &uiState);
4389  if (iRetVal < 0)
4390  {
4391  debug(1,"com error in waitForRampDec()");
4392  break;
4393  }
4394  if (uiState & STATEID_MOD_ERROR)
4395  {
4396  debug(1, "module error in waitForRampDec()");
4397  iRetVal=ERRID_DEV_MODULEERROR;
4398  break;
4399  }
4400  if (uiState & STATEID_MOD_RAMP_DEC)
4401  {
4402  debug(2, "reached ramp end position in waitForRampDec()");
4403  iRetVal=0;
4404  break;
4405  }
4406  m_clTimer.stop();
4407  uiTime = (unsigned long)(1000 * m_clTimer.executionTime());
4408  if (uiTime > uiTimeOut)
4409  {
4410  debug(1, "timeout in waitForRampDec()");
4411  iRetVal=ERRID_DEV_WAITTIMEOUT;
4412  break;
4413  }
4414  }
4415  return iRetVal;
4416 }
4417 
4418 int CDevice::waitForRampSteady(int iModuleId, unsigned long uiTimeOut)
4419 {
4420  int iRetVal;
4421  unsigned long uiTime, uiState;
4422  if(iModuleId < 0 || iModuleId > m_iModuleCountMax)
4423  {
4424  warning("wrong module id");
4426  return m_iErrorState;
4427  }
4428  m_clTimer.start();
4429  while(1)
4430  {
4431  Sleep(1);
4432  iRetVal = getModuleState(iModuleId, &uiState);
4433  if (iRetVal < 0)
4434  {
4435  debug(1,"com error in waitForRampSteady()");
4436  break;
4437  }
4438  if (uiState & STATEID_MOD_ERROR)
4439  {
4440  debug(1, "module error in waitForRampSteady()");
4441  iRetVal=ERRID_DEV_MODULEERROR;
4442  break;
4443  }
4444  if (uiState & STATEID_MOD_RAMP_STEADY)
4445  {
4446  debug(2, "reached ramp end position in waitForRampSteady()");
4447  iRetVal=0;
4448  break;
4449  }
4450  m_clTimer.stop();
4451  uiTime = (unsigned long)(1000 * m_clTimer.executionTime());
4452  if (uiTime > uiTimeOut)
4453  {
4454  debug(1, "timeout in waitForRampSteady()");
4455  iRetVal=ERRID_DEV_WAITTIMEOUT;
4456  break;
4457  }
4458  }
4459  return iRetVal;
4460 }
4461 
4462 int CDevice::waitForHomeEndAll(unsigned long uiTimeOut)
4463 {
4464  int i, iRetVal = ERRID_DEV_NOMODULES;
4465  bool bExitFlag = false;
4466  unsigned long uiTime, uiState;
4467  m_clTimer.start();
4468  do
4469  {
4470  Sleep(1);
4471  bExitFlag = true;
4472  for(i = 0; i < m_iModuleCount;i++)
4473  {
4474  iRetVal = getModuleState(m_aiModuleId[i], &uiState);
4475  if (iRetVal < 0)
4476  {
4477  debug(1,"com error in waitForHomeEndAll()");
4478  return iRetVal;
4479  }
4480  if (uiState & STATEID_MOD_ERROR)
4481  {
4482  debug(1, "module error in waitForHomeEndAll()");
4483  iRetVal=ERRID_DEV_MODULEERROR;
4484  return iRetVal;
4485  }
4486  if (!(uiState & STATEID_MOD_HOME) || !(uiState & STATEID_MOD_RAMP_END))
4487  {
4488  debug(2, "module %i not home end in waitForHomeEndAll()", m_aiModuleId[i]);
4489  bExitFlag = false;
4490  break;
4491  }
4492  }
4493  m_clTimer.stop();
4494  uiTime = (unsigned long)(1000 * m_clTimer.executionTime());
4495  if (uiTime > uiTimeOut)
4496  {
4497  debug(1, "timeout in waitForHomeEndAll()");
4498  iRetVal=ERRID_DEV_WAITTIMEOUT;
4499  return iRetVal;
4500  }
4501  }while(!bExitFlag);
4502  return iRetVal;
4503 }
4504 
4505 int CDevice::waitForMotionEndAll(unsigned long uiTimeOut)
4506 {
4507  int i, iRetVal = ERRID_DEV_NOMODULES;
4508  bool bExitFlag = false;
4509  unsigned long uiTime, uiState;
4510  m_clTimer.start();
4511  do
4512  {
4513  Sleep(1);
4514  bExitFlag = true;
4515  for(i = 0; i < m_iModuleCount;i++)
4516  {
4517  iRetVal = getModuleState(m_aiModuleId[i], &uiState);
4518  if (iRetVal < 0)
4519  {
4520  debug(1,"com error in waitForMotionEndAll()");
4521  return iRetVal;
4522  }
4523  if (uiState & STATEID_MOD_ERROR)
4524  {
4525  debug(1, "module error in waitForMotionEndAll()");
4526  iRetVal=ERRID_DEV_MODULEERROR;
4527  return iRetVal;
4528  }
4529  if (uiState & STATEID_MOD_MOTION)
4530  {
4531  debug(2, "module %i not motion end in waitForMotionEndAll()", m_aiModuleId[i]);
4532  bExitFlag = false;
4533  break;
4534  }
4535  }
4536  m_clTimer.stop();
4537  uiTime = (unsigned long)(1000 * m_clTimer.executionTime());
4538  if (uiTime > uiTimeOut)
4539  {
4540  debug(1, "timeout in waitForMotionEndAll()");
4541  iRetVal=ERRID_DEV_WAITTIMEOUT;
4542  return iRetVal;
4543  }
4544  }while(!bExitFlag);
4545  return iRetVal;
4546 }
4547 
4548 int CDevice::waitForRampEndAll(unsigned long uiTimeOut)
4549 {
4550  int i, iRetVal = ERRID_DEV_NOMODULES;
4551  bool bExitFlag = false;
4552  unsigned long uiTime, uiState;
4553  m_clTimer.start();
4554  do
4555  {
4556  Sleep(1);
4557  bExitFlag = true;
4558  for(i = 0; i < m_iModuleCount;i++)
4559  {
4560  iRetVal = getModuleState(m_aiModuleId[i], &uiState);
4561  if (iRetVal < 0)
4562  {
4563  debug(1,"com error in waitForRampEndAll()");
4564  return iRetVal;
4565  }
4566  if (uiState & STATEID_MOD_ERROR)
4567  {
4568  debug(1, "module error in waitForRampEndAll()");
4569  iRetVal=ERRID_DEV_MODULEERROR;
4570  return iRetVal;
4571  }
4572  if (!(uiState & STATEID_MOD_RAMP_END))
4573  {
4574  debug(2, "module %i not ramp end in waitForRampEndAll()", m_aiModuleId[i]);
4575  bExitFlag = false;
4576  break;
4577  }
4578  }
4579  m_clTimer.stop();
4580  uiTime = (unsigned long)(1000 * m_clTimer.executionTime());
4581  if (uiTime > uiTimeOut)
4582  {
4583  debug(1, "timeout in waitForRampEndAll()");
4584  iRetVal=ERRID_DEV_WAITTIMEOUT;
4585  return iRetVal;
4586  }
4587  }while(!bExitFlag);
4588  return iRetVal;
4589 }
4590 
4592 {
4593  m_iErrorState = 0;
4594  if(m_bInitFlag == false)
4595  {
4596  warning("device not initialized");
4598  return m_iErrorState;
4599  }
4601  return m_iErrorState;
4602 }
4603 
4604 
4605 // ========================================================================== ;
4606 // ;
4607 // ---- broadcast functions -------------------------------------------------- ;
4608 // ;
4609 // ========================================================================== ;
4610 
4612 {
4613  m_iErrorState = 0;
4614  if(m_bInitFlag == false)
4615  {
4616  warning("device not initialized");
4618  return m_iErrorState;
4619  }
4621  return m_iErrorState;
4622 }
4623 
4625 {
4626  m_iErrorState = 0;
4627  if(m_bInitFlag == false)
4628  {
4629  warning("device not initialized");
4631  return m_iErrorState;
4632  }
4634  return m_iErrorState;
4635 }
4636 
4638 {
4639  m_iErrorState = 0;
4640  if(m_bInitFlag == false)
4641  {
4642  warning("device not initialized");
4644  return m_iErrorState;
4645  }
4647  return m_iErrorState;
4648 }
4649 
4651 {
4652  m_iErrorState = 0;
4653  if(m_bInitFlag == false)
4654  {
4655  warning("device not initialized");
4657  return m_iErrorState;
4658  }
4660  return m_iErrorState;
4661 }
4662 
4663 int CDevice::setBaudRateAll(unsigned char ucBaudRateId)
4664 {
4665  m_iErrorState = 0;
4666  if(m_bInitFlag == false)
4667  {
4668  warning("device not initialized");
4670  return m_iErrorState;
4671  }
4672  m_iErrorState = writeAll( CMDID_BAUDRATE, ucBaudRateId );
4673  reinit(ucBaudRateId);
4674  return m_iErrorState;
4675 }
4676 
4678 {
4679  m_iErrorState = 0;
4680  if(m_bInitFlag == false)
4681  {
4682  warning("device not initialized");
4684  return m_iErrorState;
4685  }
4687  return m_iErrorState;
4688 }
4689 
4691 {
4692  m_iErrorState = 0;
4693  if(m_bInitFlag == false)
4694  {
4695  warning("device not initialized");
4697  return m_iErrorState;
4698  }
4700  return m_iErrorState;
4701 }
4702 
4703 // ========================================================================== ;
4704 // ;
4705 // ---- Special functions for internal use ---------------------------------- ;
4706 // ;
4707 // ========================================================================== ;
4708 int CDevice::xmit8Bytes(int iModuleId, void* pBytes )
4709 {
4710  m_iErrorState = 0;
4711  if(m_bInitFlag == false)
4712  {
4713  warning("device not initialized");
4715  return m_iErrorState;
4716  }
4717  m_iErrorState = write8Bytes(iModuleId, false, pBytes );
4718  return m_iErrorState;
4719 }
4720 
4721 int CDevice::xack8Bytes(int iModuleId, void* pBytes )
4722 {
4723  m_iErrorState = 0;
4724  if(m_bInitFlag == false)
4725  {
4726  warning("device not initialized");
4728  return m_iErrorState;
4729  }
4730  m_iErrorState = write8Bytes( iModuleId, true, pBytes );
4731  return m_iErrorState;
4732 }
4733 
4734 int CDevice::doInternal(int iModuleId, void* pBytes )
4735 { unsigned char toSend[8];
4736  m_iErrorState = 0;
4737  if(m_bInitFlag == false)
4738  {
4739  warning("device not initialized");
4741  return m_iErrorState;
4742  }
4743  toSend[0] = 0x04;
4744  memcpy( &toSend[1], pBytes, 7 );
4745  m_iErrorState = write8Bytes( iModuleId, true, toSend );
4746  memcpy( pBytes, &toSend[1], 7 );
4747  return m_iErrorState;
4748 }
4749 
4750 int CDevice::getStateInternal(int iModuleId, unsigned long* pStat )
4751 { m_iErrorState = 0;
4752  if(m_bInitFlag == false)
4753  {
4754  warning("device not initialized");
4756  return m_iErrorState;
4757  }
4758  m_iErrorState = getUnsignedLong( iModuleId, pStat );
4759  return m_iErrorState;
4760 }
4761 
4762 // ========================================================================== ;
4763 // ;
4764 // ---- Init functions ------------------------------------------------------ ;
4765 // ;
4766 // ========================================================================== ;
4767 
4768 CDevice* newDevice(const char* acInitString)
4769 {
4770  char* pcToken;
4771  char acString[128];
4772  strncpy(acString,acInitString,128);
4773  pcToken = strtok( acString, ":" );
4774  if( !pcToken )
4775  {
4776  printf("CDevice* newDevice(const char* acInitString): wrong format, no ':' found!\n");
4777  return NULL;
4778  }
4779  if( strcmp( pcToken, "RS232" ) == 0 )
4780  {
4781  return new CRS232Device();
4782  }
4783 #ifdef USE_ESD
4784  if( strcmp( pcToken, "ESD" ) == 0 )
4785  {
4786  return new CESDDevice();
4787  }
4788 #endif
4789 #ifdef USE_PCAN
4790  if( strcmp( pcToken, "PCAN" ) == 0 )
4791  {
4792  return new CPCanDevice();
4793  }
4794 #endif
4795 #ifdef USE_SOCKET_CAN
4796  if( strcmp( pcToken, "SOCKETCAN" ) == 0 )
4797  {
4798  return new SocketCANDevice();
4799  }
4800 #endif
4801 #if defined(_WIN32)
4802  if( strcmp( pcToken, "CP5X11" ) == 0 )
4803  {
4804  return new CCP5X11Device();
4805  }
4806 #endif
4807  printf("CDevice* newDevice(const char* acInitString): wrong format, no device found!\n");
4808  return NULL;
4809 }
#define PARID_ACT_FMOTSUPPLY
#define PARID_ACT_FMINPOS
int getMinMotorVoltage(int iModuleId, float *pfValue)
Definition: Device.cpp:1904
#define PARID_MOVE_ISTEP
int getMaxLogicVoltage(int iModuleId, float *pfValue)
Definition: Device.cpp:1872
int homeModule(int iModuleId)
Definition: Device.cpp:3811
int serveWatchdogAll(void)
Definition: Device.cpp:4650
#define PARID_DEF_FLINEARRATIO
#define PARID_DEF_A0
int getDefDamp(int iModuleId, short *piValue)
Definition: Device.cpp:565
#define PARID_DEF_ADDRESS
int getHomeVel(int iModuleId, float *pfValue)
Definition: Device.cpp:1392
virtual int writeFloatReadFloatUnsignedChars(int iModuleId, int iCommandId, int iParameterId, float fData, float *pfData, unsigned char *pucData1, unsigned char *pucData2)=0
#define PARID_MOVE_FRAMP_EXT
int setMaxDeltaPos(int iModuleId, float fValue)
Definition: Device.cpp:2576
#define PARID_ACT_FMOTCUR
#define PARID_DEF_BRAKETIMEOUT
int getDioData(int iModuleId, unsigned long *puiValue)
Definition: Device.cpp:825
int getMinPos(int iModuleId, float *pfValue)
Definition: Device.cpp:965
int setDefBrakeTimeOut(int iModuleId, unsigned short uiValue)
Definition: Device.cpp:3160
#define PARID_DEF_FMINPOS
CDevice(void)
default constructor
Definition: Device.cpp:72
char m_acName[128]
Definition: Device.h:41
#define PARID_DEF_FMAXDELTAPOS
#define PARID_ACT_MAXMOTOR
int getDefBrakeTimeOut(int iModuleId, unsigned short *puiValue)
Definition: Device.cpp:464
int waitForMotionEndAll(unsigned long uiTimeOut=60000)
Definition: Device.cpp:4505
int getDamp(int iModuleId, short *piValue)
Definition: Device.cpp:885
const char * getRevision()
gets the revision string of the class
Definition: Device.cpp:116
int getDefBurnCount(int iModuleId, unsigned char *pucValue)
Definition: Device.cpp:364
int setDefIncPerTurn(int iModuleId, unsigned long uiValue)
Definition: Device.cpp:3128
#define TYPEID_MOD_LINEAR
Definition: m5apiw32.h:156
int xack8Bytes(int iModuleId, void *pBytes)
Definition: Device.cpp:4721
int getSavePos(int iModuleId, float *pfValue)
Definition: Device.cpp:1106
int getDefMaxCur(int iModuleId, float *pfValue)
Definition: Device.cpp:705
#define PARID_ACT_MINLOGIC
int updateModuleIdMap()
Definition: Device.cpp:3779
int getLogicSupply(int iModuleId, float *pfValue)
Definition: Device.cpp:1808
#define PARID_DEF_FCUROFFSET
int getIPolVel(int iModuleId, float *pValue)
Definition: Device.cpp:1138
int setRampAcc(int iModuleId, float fValue)
Definition: Device.cpp:2800
int setMaxMotorVoltage(int iModuleId, float fValue)
Definition: Device.cpp:3416
int setMinPos(int iModuleId, float fValue)
Definition: Device.cpp:2476
#define PARID_ACT_DAMP
#define ERRID_DEV_WRONGMODULEID
Definition: m5apiw32.h:232
#define PARID_ACT_RAWTEMP
int setModuleSerialNo(int iModuleId, unsigned long uiValue)
Definition: Device.cpp:3096
int setDefCANBaudRate(int iModuleId, unsigned char uiValue)
Definition: Device.cpp:3224
virtual int writeLong(int iModuleId, int iCommandId, int iParameterId, long iData)=0
#define PARID_DEF_FMAXACC
#define PARID_ACT_RAWLOGICSUPPLY
int getHMaxCurOvershootTime(int iModuleId, long *piValue)
Definition: Device.cpp:2192
int getTemperature(int iModuleId, float *pfValue)
Definition: Device.cpp:1776
int xmit8Bytes(int iModuleId, void *pBytes)
Definition: Device.cpp:4708
int setConfig(int iModuleId, unsigned long puiValue)
Definition: Device.cpp:2336
int waitForHomeEnd(int iModuleId, unsigned long uiTimeOut=60000)
Definition: Device.cpp:4242
bool getInitFlag()
gets the init flag
Definition: Device.cpp:111
#define STATEID_MOD_RAMP_STEADY
Definition: m5apiw32.h:70
int setHMaxCurOvershootTime(int iModuleId, long iValue)
Definition: Device.cpp:3672
int setA0(int iModuleId, short iValue)
Definition: Device.cpp:2416
int haltModule(int iModuleId)
Definition: Device.cpp:3831
#define PARID_ACT_MAXPWMOUTPUT
#define PARID_ACT_IMAXVEL
#define PARID_ACT_RAWMOTCUR
int setMinLogicVoltage(int iModuleId, float fValue)
Definition: Device.cpp:3320
int getMaxVelInc(int iModuleId, long *piValue)
Definition: Device.cpp:1278
virtual int reinit(unsigned char ucBaudRateId)=0
int setDefGearRatio(int iModuleId, float fValue)
Definition: Device.cpp:2968
#define PARID_DEF_FMAXPOS
#define PARID_ACT_STATE
char m_acRevision[20]
Definition: Device.h:43
#define PARID_MOVE_FVEL_EXT
int getCur(int iModuleId, float *pfCur)
Definition: Device.cpp:945
int setNominalMotorCurrent(int iModuleId, float fValue)
Definition: Device.cpp:3448
int m_iModuleCountMax
Definition: Device.h:46
int waitForMotionEnd(int iModuleId, unsigned long uiTimeOut=60000)
Definition: Device.cpp:4286
#define PARID_ACT_IHOMEOFFSET
#define CMDID_WATCHDOG
#define CMDID_RESET
int getRawMotorCurrent(int iModuleId, short *piValue)
Definition: Device.cpp:1488
virtual int readFloat(int iModuleId, int iCommandId, int iParameterId, float *pfData)=0
#define PARID_MOVE_FSTEP
int getDefDioData(int iModuleId, unsigned long *puiValue)
Definition: Device.cpp:504
void stop()
Definition: StopWatch.cpp:236
int setDamp(int iModuleId, short iValue)
Definition: Device.cpp:2456
int getDeltaPos(int iModuleId, float *pfValue)
Definition: Device.cpp:1066
#define PARID_ACT_LOADDELTATIME
#define PARID_ACT_FPOSSTATEDIO
int getMaxPos(int iModuleId, float *pfValue)
Definition: Device.cpp:985
void error(const int iErrorCode, const char *pcErrorMessage,...) const
Definition: Message.cpp:204
int waitForRampEnd(int iModuleId, unsigned long uiTimeOut=60000)
Definition: Device.cpp:4330
#define PARID_ACT_FRAMPACC
int getDeltaPosInc(int iModuleId, long *piValue)
Definition: Device.cpp:1318
std::vector< int > m_aiModuleId
Definition: Device.h:47
int getLoadDeltaTime(int iModuleId, unsigned short *piValue)
Definition: Device.cpp:1680
#define PARID_ACT_DIODATA
#define STATEID_MOD_MOTION
Definition: m5apiw32.h:68
#define PARID_ACT_FRAMPVEL
#define PARID_ACT_IMAXDELTAPOS
#define PARID_MOVE_FRAMP
#define PARID_ACT_FHOMEVEL
int getMotorOvershootTime(int iModuleId, long *piValue)
Definition: Device.cpp:2128
int getMinPosInc(int iModuleId, long *piValue)
Definition: Device.cpp:1238
int getLogicUndershootTime(int iModuleId, long *piValue)
Definition: Device.cpp:2032
#define PARID_DEF_CANBAUDRATE
int setMinMotorVoltage(int iModuleId, float fValue)
Definition: Device.cpp:3384
int setDefSetup(int iModuleId, unsigned long uiValue)
Definition: Device.cpp:3288
#define PARID_ACT_LOGICOVERSHOOT
#define PARID_ACT_A0
int getMotorSupply(int iModuleId, float *pfValue)
Definition: Device.cpp:1744
int setMotorOvershootTime(int iModuleId, long iValue)
Definition: Device.cpp:3608
virtual int writeFloat(int iModuleId, int iCommandId, int iParameterId, float fData)=0
virtual int readFloatUnsignedChars(int iModuleId, int iCommandId, int iParameterId, float *pfData, unsigned char *pucData1, unsigned char *pucData2)=0
#define PARID_ACT_IMAXPOS
#define PARID_DEF_C0
#define PARID_MOVE_IRAMP
int getIncRatio(int iModuleId, float *pValue)
Definition: Device.cpp:805
virtual int readLong(int iModuleId, int iCommandId, int iParameterId, long *piData)=0
#define PARID_DEF_FMAXVEL
int moveVelInc(int iModuleId, long iVel)
Definition: Device.cpp:4055
#define CMDID_GETPARAM
int setC0(int iModuleId, short iValue)
Definition: Device.cpp:2436
int getDefMinPos(int iModuleId, float *pfValue)
Definition: Device.cpp:625
#define PARID_MOVE_FSTEP_EXT
#define ERRID_DEV_MODULEERROR
Definition: m5apiw32.h:233
int moveVelExtended(int iModuleId, float fCur, unsigned long *puiState, unsigned char *pucDio, float *pfPos)
Definition: Device.cpp:4165
#define ERRID_DEV_NOTINITIALIZED
Definition: m5apiw32.h:211
int getDefHomeOffset(int iModuleId, float *pfValue)
Definition: Device.cpp:585
int getMaxPWMOutput(int iModuleId, long *piValue)
Definition: Device.cpp:2288
int getDefSetup(int iModuleId, unsigned long *puiValue)
Definition: Device.cpp:272
int setHomeVel(int iModuleId, float fValue)
Definition: Device.cpp:2696
int getDefIncPerTurn(int iModuleId, unsigned long *puiValue)
Definition: Device.cpp:484
int setMaxDeltaPosInc(int iModuleId, long iValue)
Definition: Device.cpp:2676
int waitForRampEndAll(unsigned long uiTimeOut=60000)
Definition: Device.cpp:4548
#define PARID_ACT_MAXLOADGRADIENT
double executionTime()
Definition: StopWatch.cpp:166
#define PARID_ACT_FMAXCUR
CDevice & operator=(const CDevice &rclDevice)
Definition: Device.cpp:99
int getMotorCurrent(int iModuleId, float *pfValue)
Definition: Device.cpp:1712
#define CONFIGID_MOD_LINEAR
Definition: m5apiw32.h:109
int getDefLinearRatio(int iModuleId, float *pfValue)
Definition: Device.cpp:404
int getDefC0(int iModuleId, short *piValue)
Definition: Device.cpp:545
int moveVel(int iModuleId, float fVel)
Definition: Device.cpp:3953
int getDefGearRatio(int iModuleId, float *pfValue)
Definition: Device.cpp:384
int getVel(int iModuleId, float *pfVel)
Definition: Device.cpp:925
#define PARID_DEF_DAMP
#define PARID_DEF_FGEARRATIO
void setInitString(const char *acInitString)
Definition: Device.cpp:2331
int setDefHomeAcc(int iModuleId, float fValue)
Definition: Device.cpp:3064
int getMaxVel(int iModuleId, float *pfValue)
Definition: Device.cpp:1006
int getStateDioPos(int iModuleId, unsigned long *puiState, unsigned char *pucDio, float *pfPos)
Definition: Device.cpp:1358
#define PARID_ACT_FMAXDELTAPOS
#define PARID_ACT_SYNCTIME
int setMaxPosInc(int iModuleId, long iValue)
Definition: Device.cpp:2616
int getC0(int iModuleId, short *piValue)
Definition: Device.cpp:865
int getRawTemperature(int iModuleId, short *piValue)
Definition: Device.cpp:1552
int setLogicOvershootTime(int iModuleId, long iValue)
Definition: Device.cpp:3544
int saveParameters(int iModuleId)
Definition: Device.cpp:3891
virtual int writeAll(int iCommandId, int iParameterId)=0
int setDefAddress(int iModuleId, unsigned char uiValue)
Definition: Device.cpp:3192
int haltAll(void)
Definition: Device.cpp:4637
int getMaxMotorVoltage(int iModuleId, float *pfValue)
Definition: Device.cpp:1936
void charStateToLongState(unsigned char uiShort, unsigned long *puiState)
Definition: Device.cpp:45
std::vector< unsigned short > m_auiModuleVersion
Definition: Device.h:48
int setBaudRateAll(unsigned char ucBaudRateId)
Definition: Device.cpp:4663
#define PARID_ACT_IDELTAPOS
int setDioData(int iModuleId, unsigned long uiValue)
Definition: Device.cpp:2396
int getSyncTime(int iModuleId, short *piValue)
Definition: Device.cpp:1456
int getModuleSerialNo(int iModuleId, unsigned long *puiValue)
Definition: Device.cpp:231
int getDefMaxDeltaPos(int iModuleId, float *pfValue)
Definition: Device.cpp:725
int getVelInc(int iModuleId, long *piValue)
Definition: Device.cpp:1198
int movePosExtended(int iModuleId, float fPos, unsigned long *puiState, unsigned char *pucDio, float *pfPos)
Definition: Device.cpp:4115
#define PARID_DEF_SETUP
int getHomeOffsetInc(int iModuleId, long *piValue)
Definition: Device.cpp:785
#define PARID_ACT_FHOMEOFFSET
int getNomCurOvershootTime(int iModuleId, long *piValue)
Definition: Device.cpp:2160
#define PARID_ACT_KP_PWMLIM
void start()
Definition: StopWatch.cpp:211
#define PARID_ACT_FIPOLVEL
#define PARID_DEF_FMAXCUR
int getMotorUndershootTime(int iModuleId, long *piValue)
Definition: Device.cpp:2096
int moveCurExtended(int iModuleId, float fCur, unsigned long *puiState, unsigned char *pucDio, float *pfPos)
Definition: Device.cpp:4189
int setCurrentLimit(int iModuleId, float fValue)
Definition: Device.cpp:3736
#define PARID_ACT_NOMCUROVERSHOOT
void warning(const char *pcWarningMessage,...) const
Definition: Message.cpp:257
#define PARID_ACT_FMAXACC
int getDefMaxVel(int iModuleId, float *pfValue)
Definition: Device.cpp:665
#define PARID_ACT_FLOGICSUPPLY
virtual ~CDevice()
destructor
Definition: Device.cpp:89
int getDefA0(int iModuleId, short *piValue)
Definition: Device.cpp:525
int setSyncTime(int iModuleId, short iValue)
Definition: Device.cpp:2840
int setRampVelInc(int iModuleId, long iValue)
Definition: Device.cpp:2780
int getLoadLimit(int iModuleId, long *piValue)
Definition: Device.cpp:1616
int getKpPWMLimit(int iModuleId, long *piValue)
Definition: Device.cpp:2224
#define PARID_ACT_IPOS
int setNomCurOvershootTime(int iModuleId, long iValue)
Definition: Device.cpp:3640
int getRawLogicSupply(int iModuleId, short *piValue)
Definition: Device.cpp:1584
#define PARID_ACT_LOADLIMIT
#define PARID_MOVE_ICUR
#define PARID_DEF_FHOMEVEL
int getDefCurOffset(int iModuleId, float *pfValue)
Definition: Device.cpp:424
int moveCurInc(int iModuleId, long iCur)
Definition: Device.cpp:4075
#define PARID_DEF_FCURRATIO
int getMaxAccInc(int iModuleId, long *piValue)
Definition: Device.cpp:1298
int setLoadDeltaTime(int iModuleId, unsigned short iValue)
Definition: Device.cpp:2936
virtual int writeCommand(int iModuleId, int iCommandId)=0
int setMaxAccInc(int iModuleId, long iValue)
Definition: Device.cpp:2656
#define PARID_ACT_MOTORUNDERSHOOT
#define PARID_ACT_FTEMP
#define PARID_ACT_FVEL
bool m_bInitFlag
Definition: Device.h:40
int getDefBaudRate(int iModuleId, unsigned char *pucValue)
Definition: Device.cpp:304
int setMaxVelInc(int iModuleId, long iValue)
Definition: Device.cpp:2636
int moveRampInc(int iModuleId, long iPos, long iVel, long iAcc)
Definition: Device.cpp:4033
int getDefHomeVel(int iModuleId, float *pfValue)
Definition: Device.cpp:605
int recalcPIDParams(int iModuleId)
Definition: Device.cpp:3871
#define PARID_ACT_MINMOTOR
int setDefLinRatio(int iModuleId, float fValue)
Definition: Device.cpp:3000
int getPos(int iModuleId, float *pfPos)
Definition: Device.cpp:905
int getMaxPosInc(int iModuleId, long *piValue)
Definition: Device.cpp:1258
int setRampAccInc(int iModuleId, long iValue)
Definition: Device.cpp:2820
#define PARID_ACT_MOTOROVERSHOOT
#define CMDID_SETMOVE
int setKpPWMLimit(int iModuleId, long iValue)
Definition: Device.cpp:3704
int getMaximumMotorCurrent(int iModuleId, float *pfValue)
Definition: Device.cpp:2000
int homeAll(void)
Definition: