newportxps 0.3.0__py3-none-any.whl → 0.9__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -14,6 +14,8 @@
14
14
 
15
15
  import sys
16
16
  import socket
17
+ from collections import defaultdict
18
+ from typing import Callable, Dict, Union, List
17
19
 
18
20
  from .utils import bytes2str, str2bytes
19
21
 
@@ -24,20 +26,47 @@ class XPSException(Exception):
24
26
  def __str__(self):
25
27
  return str(self.msg)
26
28
 
29
+
30
+ class XPSOutputs:
31
+ _PARSERS: Dict[str, Callable[[str], Union[bool, str, float, int]]] = {
32
+ 'bool': bool,
33
+ 'char': lambda x: x,
34
+ 'double': float,
35
+ 'int': int,
36
+ 'short': int,
37
+ 'unsigned short': int,
38
+ }
39
+
40
+ def __init__(self, *output_parameter_types: str):
41
+ self.output_parameter_types = output_parameter_types
42
+ for p in output_parameter_types:
43
+ assert p in self._PARSERS, f'Unknown output parameter type {p}'
44
+
45
+ def __str__(self):
46
+ return ','.join(f'{c_type} *' for c_type in self.output_parameter_types)
47
+
48
+ def parse(self, error: int, response: str):
49
+ if error != 0:
50
+ return [error, response]
51
+
52
+ response_parts = response.split(',', len(self.output_parameter_types))
53
+ parsed_response: List[Union[bool, str, float, int]] = [error]
54
+ for i, c_type in enumerate(self.output_parameter_types):
55
+ parsed_response.append(self._PARSERS[c_type](response_parts[i]))
56
+ return parsed_response
57
+
58
+
27
59
  class XPS:
28
60
  # Defines
29
61
  MAX_NB_SOCKETS = 100
30
62
 
31
63
  # Global variables
32
64
  __sockets = {}
33
- __usedSockets = {}
65
+ __usedSockets = defaultdict(int)
34
66
  __nbSockets = 0
35
67
 
36
68
  # Initialization Function
37
69
  def __init__ (self):
38
- XPS.__nbSockets = 0
39
- for socketId in range(self.MAX_NB_SOCKETS):
40
- XPS.__usedSockets[socketId] = 0
41
70
  self.errorcodes = {}
42
71
 
43
72
  def withValidSocket(fcn):
@@ -60,20 +89,20 @@ class XPS:
60
89
  @withValidSocket
61
90
  def __sendAndReceive (self, socketId, command):
62
91
  # print("SEND REC ", command, type(command))
92
+ suffix = ',EndOfAPI'
63
93
  try:
64
94
  XPS.__sockets[socketId].send(str2bytes(command))
65
95
  ret = bytes2str(XPS.__sockets[socketId].recv(1024))
66
- while (ret.find(',EndOfAPI') == -1):
96
+ while (ret.find(suffix) == -1):
67
97
  ret += bytes2str(XPS.__sockets[socketId].recv(1024))
68
98
  except socket.timeout:
69
- return [-2, '']
99
+ return -2, ''
70
100
  except socket.error as err: # (errNb, errString):
71
101
  print( 'Socket error : ', err.errno, err)
72
- return [-2, '']
102
+ return -2, ''
73
103
 
74
- for i in range(len(ret)):
75
- if (ret[i] == ','):
76
- return [int(ret[0:i]), ret[i+1:-9]]
104
+ error, rest = ret[:-len(suffix)].split(',', 1)
105
+ return int(error), rest
77
106
 
78
107
  def Send(self, socketId=None, cmd=None, check=False):
79
108
  """send and receive command cmd from socketId
@@ -142,49 +171,29 @@ class XPS:
142
171
 
143
172
  # ControllerMotionKernelTimeLoadGet : Get controller motion kernel time load
144
173
  def ControllerMotionKernelTimeLoadGet(self, socketId=None):
145
- command = 'ControllerMotionKernelTimeLoadGet(double *,double *,double *,double *)'
174
+ outputs = XPSOutputs("double", 'double', 'double', 'double')
175
+ command = f'ControllerMotionKernelTimeLoadGet({outputs})'
146
176
  error, returnedString = self.Send(socketId=socketId, cmd=command)
147
- if (error != 0):
148
- return [error, returnedString]
149
-
150
- i, j, retList = 0, 0, [error]
151
- for paramNb in range(4):
152
- while ((i+j) < len(returnedString) and returnedString[i+j] != ','):
153
- j += 1
154
- retList.append(eval(returnedString[i:i+j]))
155
- i, j = i+j+1, 0
156
- return retList
177
+ return outputs.parse(error, returnedString)
157
178
 
158
179
  # ControllerStatusGet : Read controller current status
159
180
  def ControllerStatusGet(self, socketId=None):
181
+ outputs = XPSOutputs('int')
160
182
  error, returnedString = self.Send(socketId=socketId,
161
- cmd='ControllerStatusGet(int *)', check=True)
162
- i, j, retList = 0, 0, [error]
163
- while ((i+j) < len(returnedString) and returnedString[i+j] != ','):
164
- j += 1
165
- retList.append(eval(returnedString[i:i+j]))
166
- return retList
183
+ cmd=f'ControllerStatusGet({outputs})', check=True)
184
+ return outputs.parse(error, returnedString)
167
185
 
168
186
  # ControllerStatusStringGet : Return the controller status string corresponding to the controller status code
169
187
  def ControllerStatusStringGet(self, socketId, ControllerStatusCode):
170
188
  command = 'ControllerStatusStringGet(%s, char *)' % str(ControllerStatusCode)
171
189
  return self.Send(socketId, command)
172
190
 
173
-
174
191
  # ElapsedTimeGet : Return elapsed time from controller power on
175
192
  def ElapsedTimeGet(self, socketId=None):
176
- command = 'ElapsedTimeGet(double *)'
177
- [error, returnedString] = self.Send(socketId, command)
178
- if (error != 0):
179
- return [error, returnedString]
180
-
181
- i, j, retList = 0, 0, [error]
182
- while ((i+j) < len(returnedString) and returnedString[i+j] != ','):
183
- j += 1
184
- retList.append(eval(returnedString[i:i+j]))
185
-
186
- return retList
187
-
193
+ outputs = XPSOutputs('double')
194
+ command = f'ElapsedTimeGet({outputs})'
195
+ error, returnedString = self.Send(socketId, command)
196
+ return outputs.parse(error, returnedString)
188
197
 
189
198
  # ErrorStringGet : Return the error string corresponding to the error code
190
199
  def ErrorStringGet(self, socketId, ErrorCode):
@@ -216,17 +225,10 @@ class XPS:
216
225
 
217
226
  # TimerGet : Get a timer
218
227
  def TimerGet (self, socketId, TimerName):
219
- command = 'TimerGet(' + TimerName + ',int *)'
228
+ outputs = XPSOutputs('int')
229
+ command = f'TimerGet({TimerName},{outputs})'
220
230
  error, returnedString = self.Send(socketId, command)
221
- if (error != 0):
222
- return [error, returnedString]
223
-
224
- i, j, retList = 0, 0, [error]
225
- while ((i+j) < len(returnedString) and returnedString[i+j] != ','):
226
- j += 1
227
- retList.append(eval(returnedString[i:i+j]))
228
-
229
- return retList
231
+ return outputs.parse(error, returnedString)
230
232
 
231
233
  # TimerSet : Set a timer
232
234
  def TimerSet (self, socketId, TimerName, FrequencyTicks):
@@ -306,16 +308,10 @@ class XPS:
306
308
 
307
309
  # EventExtendedStart : Launch the last event and action configuration and return an ID
308
310
  def EventExtendedStart (self, socketId):
309
- command = 'EventExtendedStart(int *)'
311
+ outputs = XPSOutputs('int')
312
+ command = f'EventExtendedStart({outputs})'
310
313
  error, returnedString = self.Send(socketId, command)
311
- if (error != 0):
312
- return [error, returnedString]
313
-
314
- i, j, retList = 0, 0, [error]
315
- while ((i+j) < len(returnedString) and returnedString[i+j] != ','):
316
- j += 1
317
- retList.append(eval(returnedString[i:i+j]))
318
- return retList
314
+ return outputs.parse(error, returnedString)
319
315
 
320
316
  # EventExtendedAllGet : Read all event and action configurations
321
317
  def EventExtendedAllGet (self, socketId):
@@ -349,18 +345,10 @@ class XPS:
349
345
 
350
346
  # GatheringCurrentNumberGet : Maximum number of samples and current number during acquisition
351
347
  def GatheringCurrentNumberGet (self, socketId):
352
- command = 'GatheringCurrentNumberGet(int *,int *)'
348
+ outputs = XPSOutputs('int', 'int')
349
+ command = f'GatheringCurrentNumberGet({outputs})'
353
350
  error, returnedString = self.Send(socketId, command)
354
- if (error != 0):
355
- return [error, returnedString]
356
-
357
- i, j, retList = 0, 0, [error]
358
- for paramNb in range(2):
359
- while ((i+j) < len(returnedString) and returnedString[i+j] != ','):
360
- j += 1
361
- retList.append(eval(returnedString[i:i+j]))
362
- i, j = i+j+1, 0
363
- return retList
351
+ return outputs.parse(error, returnedString)
364
352
 
365
353
  # GatheringStopAndSave : Stop acquisition and save data
366
354
  def GatheringStopAndSave (self, socketId):
@@ -415,19 +403,10 @@ class XPS:
415
403
 
416
404
  # GatheringExternalCurrentNumberGet : Maximum number of samples and current number during acquisition
417
405
  def GatheringExternalCurrentNumberGet (self, socketId):
418
- command = 'GatheringExternalCurrentNumberGet(int *,int *)'
406
+ outputs = XPSOutputs('int', 'int')
407
+ command = f'GatheringExternalCurrentNumberGet({outputs})'
419
408
  error, returnedString = self.Send(socketId, command)
420
- if (error != 0):
421
- return [error, returnedString]
422
-
423
- i, j, retList = 0, 0, [error]
424
- for paramNb in range(2):
425
- while ((i+j) < len(returnedString) and returnedString[i+j] != ','):
426
- j += 1
427
- retList.append(eval(returnedString[i:i+j]))
428
- i, j = i+j+1, 0
429
- return retList
430
-
409
+ return outputs.parse(error, returnedString)
431
410
 
432
411
  # GatheringExternalDataGet : Get a data line from external gathering buffer
433
412
  def GatheringExternalDataGet (self, socketId, IndexPoint):
@@ -448,16 +427,10 @@ class XPS:
448
427
 
449
428
  # DoubleGlobalArrayGet : Get double global array value
450
429
  def DoubleGlobalArrayGet (self, socketId, Number):
451
- command = 'DoubleGlobalArrayGet(' + str(Number) + ',double *)'
430
+ outputs = XPSOutputs('double')
431
+ command = f'DoubleGlobalArrayGet({Number},{outputs})'
452
432
  error, returnedString = self.Send(socketId, command)
453
- if (error != 0):
454
- return [error, returnedString]
455
-
456
- i, j, retList = 0, 0, [error]
457
- while ((i+j) < len(returnedString) and returnedString[i+j] != ','):
458
- j += 1
459
- retList.append(eval(returnedString[i:i+j]))
460
- return retList
433
+ return outputs.parse(error, returnedString)
461
434
 
462
435
  # DoubleGlobalArraySet : Set double global array value
463
436
  def DoubleGlobalArraySet (self, socketId, Number, DoubleValue):
@@ -466,6 +439,7 @@ class XPS:
466
439
 
467
440
  # GPIOAnalogGet : Read analog input or analog output for one or few input
468
441
  def GPIOAnalogGet (self, socketId, GPIOName):
442
+ outputs = XPSOutputs(*(['double'] * len(GPIOName)))
469
443
  command = 'GPIOAnalogGet('
470
444
  for i in range(len(GPIOName)):
471
445
  if (i > 0):
@@ -474,17 +448,7 @@ class XPS:
474
448
  command += ')'
475
449
 
476
450
  error, returnedString = self.Send(socketId, command)
477
- if (error != 0):
478
- return [error, returnedString]
479
-
480
- i, j, retList = 0, 0, [error]
481
- for paramNb in range(len(GPIOName)):
482
- while ((i+j) < len(returnedString) and returnedString[i+j] != ','):
483
- j += 1
484
- retList.append(eval(returnedString[i:i+j]))
485
- i, j = i+j+1, 0
486
- return retList
487
-
451
+ return outputs.parse(error, returnedString)
488
452
 
489
453
  # GPIOAnalogSet : Set analog output for one or few output
490
454
  def GPIOAnalogSet (self, socketId, GPIOName, AnalogOutputValue):
@@ -496,9 +460,9 @@ class XPS:
496
460
  command += ')'
497
461
  return self.Send(socketId, command)
498
462
 
499
-
500
463
  # GPIOAnalogGainGet : Read analog input gain (1, 2, 4 or 8) for one or few input
501
464
  def GPIOAnalogGainGet (self, socketId, GPIOName):
465
+ outputs = XPSOutputs(*(['int'] * len(GPIOName)))
502
466
  command = 'GPIOAnalogGainGet('
503
467
  for i in range(len(GPIOName)):
504
468
  if (i > 0):
@@ -507,17 +471,7 @@ class XPS:
507
471
  command += ')'
508
472
 
509
473
  error, returnedString = self.Send(socketId, command)
510
- if (error != 0):
511
- return [error, returnedString]
512
-
513
- i, j, retList = 0, 0, [error]
514
- for paramNb in range(len(GPIOName)):
515
- while ((i+j) < len(returnedString) and returnedString[i+j] != ','):
516
- j += 1
517
- retList.append(eval(returnedString[i:i+j]))
518
- i, j = i+j+1, 0
519
- return retList
520
-
474
+ return outputs.parse(error, returnedString)
521
475
 
522
476
  # GPIOAnalogGainSet : Set analog input gain (1, 2, 4 or 8) for one or few input
523
477
  def GPIOAnalogGainSet (self, socketId, GPIOName, AnalogInputGainValue):
@@ -532,17 +486,10 @@ class XPS:
532
486
 
533
487
  # GPIODigitalGet : Read digital output or digital input
534
488
  def GPIODigitalGet (self, socketId, GPIOName):
535
-
536
- command = 'GPIODigitalGet(' + GPIOName + ',unsigned short *)'
489
+ outputs = XPSOutputs('unsigned short')
490
+ command = f'GPIODigitalGet({GPIOName},{outputs})'
537
491
  error, returnedString = self.Send(socketId, command)
538
- if (error != 0):
539
- return [error, returnedString]
540
-
541
- i, j, retList = 0, 0, [error]
542
- while ((i+j) < len(returnedString) and returnedString[i+j] != ','):
543
- j += 1
544
- retList.append(eval(returnedString[i:i+j]))
545
- return retList
492
+ return outputs.parse(error, returnedString)
546
493
 
547
494
 
548
495
  # GPIODigitalSet : Set Digital Output for one or few output TTL
@@ -552,24 +499,11 @@ class XPS:
552
499
 
553
500
  # GroupAccelerationSetpointGet : Return setpoint accelerations
554
501
  def GroupAccelerationSetpointGet (self, socketId, GroupName, nbElement):
555
- command = 'GroupAccelerationSetpointGet(' + GroupName + ','
556
- for i in range(nbElement):
557
- if (i > 0):
558
- command += ','
559
- command += 'double *'
560
- command += ')'
502
+ outputs = XPSOutputs(*(['double'] * nbElement))
503
+ command = f'GroupAccelerationSetpointGet({GroupName},{outputs})'
561
504
 
562
505
  error, returnedString = self.Send(socketId, command)
563
- if (error != 0):
564
- return [error, returnedString]
565
-
566
- i, j, retList = 0, 0, [error]
567
- for paramNb in range(nbElement):
568
- while ((i+j) < len(returnedString) and returnedString[i+j] != ','):
569
- j += 1
570
- retList.append(eval(returnedString[i:i+j]))
571
- i, j = i+j+1, 0
572
- return retList
506
+ return outputs.parse(error, returnedString)
573
507
 
574
508
  # GroupAnalogTrackingModeEnable : Enable Analog Tracking mode on selected group
575
509
  def GroupAnalogTrackingModeEnable (self, socketId, GroupName, Type):
@@ -583,46 +517,18 @@ class XPS:
583
517
 
584
518
  # GroupCorrectorOutputGet : Return corrector outputs
585
519
  def GroupCorrectorOutputGet (self, socketId, GroupName, nbElement):
586
- command = 'GroupCorrectorOutputGet(' + GroupName + ','
587
- for i in range(nbElement):
588
- if (i > 0):
589
- command += ','
590
- command += 'double *'
591
- command += ')'
520
+ outputs = XPSOutputs(*(['double'] * nbElement))
521
+ command = f'GroupCorrectorOutputGet({GroupName},{outputs})'
592
522
  error, returnedString = self.Send(socketId, command)
593
- if (error != 0):
594
- return [error, returnedString]
595
-
596
- i, j, retList = 0, 0, [error]
597
- for paramNb in range(nbElement):
598
- while ((i+j) < len(returnedString) and returnedString[i+j] != ','):
599
- j += 1
600
- retList.append(eval(returnedString[i:i+j]))
601
- i, j = i+j+1, 0
602
- return retList
603
-
523
+ return outputs.parse(error, returnedString)
604
524
 
605
525
  # GroupCurrentFollowingErrorGet : Return current following errors
606
526
  def GroupCurrentFollowingErrorGet (self, socketId, GroupName, nbElement):
607
- command = 'GroupCurrentFollowingErrorGet(' + GroupName + ','
608
- for i in range(nbElement):
609
- if (i > 0):
610
- command += ','
611
- command += 'double *'
612
- command += ')'
527
+ outputs = XPSOutputs(*(['double'] * nbElement))
528
+ command = f'GroupCurrentFollowingErrorGet({GroupName},{outputs})'
613
529
 
614
530
  error, returnedString = self.Send(socketId, command)
615
- if (error != 0):
616
- return [error, returnedString]
617
-
618
- i, j, retList = 0, 0, [error]
619
- for paramNb in range(nbElement):
620
- while ((i+j) < len(returnedString) and returnedString[i+j] != ','):
621
- j += 1
622
- retList.append(eval(returnedString[i:i+j]))
623
- i, j = i+j+1, 0
624
- return retList
625
-
531
+ return outputs.parse(error, returnedString)
626
532
 
627
533
  # GroupHomeSearch : Start home search sequence
628
534
  def GroupHomeSearch (self, socketId, GroupName):
@@ -658,47 +564,19 @@ class XPS:
658
564
 
659
565
  # GroupJogParametersGet : Get Jog parameters on selected group
660
566
  def GroupJogParametersGet (self, socketId, GroupName, nbElement):
661
- command = 'GroupJogParametersGet(' + GroupName + ','
662
- for i in range(nbElement):
663
- if (i > 0):
664
- command += ','
665
- command += 'double *' + ',' + 'double *'
666
- command += ')'
567
+ outputs = XPSOutputs(*(['double'] * 2 * nbElement))
568
+ command = f'GroupJogParametersGet({GroupName},{outputs})'
667
569
 
668
570
  error, returnedString = self.Send(socketId, command)
669
- if (error != 0):
670
- return [error, returnedString]
671
-
672
- i, j, retList = 0, 0, [error]
673
- for paramNb in range(nbElement*2):
674
- while ((i+j) < len(returnedString) and returnedString[i+j] != ','):
675
- j += 1
676
- retList.append(eval(returnedString[i:i+j]))
677
- i, j = i+j+1, 0
678
- return retList
571
+ return outputs.parse(error, returnedString)
679
572
 
680
573
  # GroupJogCurrentGet : Get Jog current on selected group
681
574
  def GroupJogCurrentGet (self, socketId, GroupName, nbElement):
682
- command = 'GroupJogCurrentGet(' + GroupName + ','
683
- for i in range(nbElement):
684
- if (i > 0):
685
- command += ','
686
- command += 'double *' + ',' + 'double *'
687
- command += ')'
575
+ outputs = XPSOutputs(*(['double'] * 2 * nbElement))
576
+ command = f'GroupJogCurrentGet({GroupName},{outputs})'
688
577
 
689
578
  error, returnedString = self.Send(socketId, command)
690
- if (error != 0):
691
- return [error, returnedString]
692
-
693
- i, j, retList = 0, 0, [error]
694
- for paramNb in range(nbElement*2):
695
- while ((i+j) < len(returnedString) and returnedString[i+j] != ','):
696
- j += 1
697
- retList.append(eval(returnedString[i:i+j]))
698
- i, j = i+j+1, 0
699
-
700
- return retList
701
-
579
+ return outputs.parse(error, returnedString)
702
580
 
703
581
  # GroupJogModeEnable : Enable Jog mode on selected group
704
582
  def GroupJogModeEnable (self, socketId, GroupName):
@@ -748,99 +626,42 @@ class XPS:
748
626
 
749
627
  # GroupPositionCorrectedProfilerGet : Return corrected profiler positions
750
628
  def GroupPositionCorrectedProfilerGet (self, socketId, GroupName, PositionX, PositionY):
751
- command = 'GroupPositionCorrectedProfilerGet(' + GroupName + ',' + str(PositionX) + ',' + str(PositionY) + ',double *,double *)'
629
+ outputs = XPSOutputs('double', 'double')
630
+ command = f'GroupPositionCorrectedProfilerGet({GroupName},{PositionX},{PositionY},{outputs})'
752
631
  error, returnedString = self.Send(socketId, command)
753
- if (error != 0):
754
- return [error, returnedString]
755
-
756
- i, j, retList = 0, 0, [error]
757
- for paramNb in range(2):
758
- while ((i+j) < len(returnedString) and returnedString[i+j] != ','):
759
- j += 1
760
- retList.append(eval(returnedString[i:i+j]))
761
- i, j = i+j+1, 0
762
- return retList
763
-
632
+ return outputs.parse(error, returnedString)
764
633
 
765
634
  # GroupPositionCurrentGet : Return current positions
766
635
  def GroupPositionCurrentGet (self, socketId, GroupName, nbElement):
767
- command = 'GroupPositionCurrentGet(' + GroupName + ','
768
- for i in range(nbElement):
769
- if (i > 0):
770
- command += ','
771
- command += 'double *'
772
- command += ')'
636
+ outputs = XPSOutputs(*(['double'] * nbElement))
637
+ command = f'GroupPositionCurrentGet({GroupName},{outputs})'
773
638
 
774
639
  error, returnedString = self.Send(socketId, command)
775
- if (error != 0):
776
- return [error, returnedString]
777
-
778
- i, j, retList = 0, 0, [error]
779
- for paramNb in range(nbElement):
780
- while ((i+j) < len(returnedString) and returnedString[i+j] != ','):
781
- j += 1
782
- retList.append(eval(returnedString[i:i+j]))
783
- i, j = i+j+1, 0
784
- return retList
640
+ return outputs.parse(error, returnedString)
785
641
 
786
642
  # GroupPositionPCORawEncoderGet : Return PCO raw encoder positions
787
643
  def GroupPositionPCORawEncoderGet (self, socketId, GroupName, PositionX, PositionY):
788
- command = 'GroupPositionPCORawEncoderGet(' + GroupName + ',' + str(PositionX) + ',' + str(PositionY) + ',double *,double *)'
789
- error, returnedString = self.Send(socketId, command)
790
- if (error != 0):
791
- return [error, returnedString]
644
+ outputs = XPSOutputs('double', 'double')
645
+ command = f'GroupPositionPCORawEncoderGet({GroupName},{PositionX},{PositionY},{outputs})'
792
646
 
793
- i, j, retList = 0, 0, [error]
794
- for paramNb in range(2):
795
- while ((i+j) < len(returnedString) and returnedString[i+j] != ','):
796
- j += 1
797
- retList.append(eval(returnedString[i:i+j]))
798
- i, j = i+j+1, 0
799
- return retList
647
+ error, returnedString = self.Send(socketId, command)
648
+ return outputs.parse(error, returnedString)
800
649
 
801
650
  # GroupPositionSetpointGet : Return setpoint positions
802
651
  def GroupPositionSetpointGet (self, socketId, GroupName, nbElement):
803
- command = 'GroupPositionSetpointGet(' + GroupName + ','
804
- for i in range(nbElement):
805
- if (i > 0):
806
- command += ','
807
- command += 'double *'
808
- command += ')'
652
+ outputs = XPSOutputs(*(['double'] * nbElement))
653
+ command = f'GroupPositionSetpointGet({GroupName},{outputs})'
809
654
 
810
655
  error, returnedString = self.Send(socketId, command)
811
- if (error != 0):
812
- return [error, returnedString]
813
-
814
- i, j, retList = 0, 0, [error]
815
- for paramNb in range(nbElement):
816
- while ((i+j) < len(returnedString) and returnedString[i+j] != ','):
817
- j += 1
818
- retList.append(eval(returnedString[i:i+j]))
819
- i, j = i+j+1, 0
820
- return retList
821
-
656
+ return outputs.parse(error, returnedString)
822
657
 
823
658
  # GroupPositionTargetGet : Return target positions
824
659
  def GroupPositionTargetGet (self, socketId, GroupName, nbElement):
825
- command = 'GroupPositionTargetGet(' + GroupName + ','
826
- for i in range(nbElement):
827
- if (i > 0):
828
- command += ','
829
- command += 'double *'
830
- command += ')'
660
+ outputs = XPSOutputs(*(['double'] * nbElement))
661
+ command = f'GroupPositionTargetGet({GroupName},{outputs})'
831
662
 
832
663
  error, returnedString = self.Send(socketId, command)
833
- if (error != 0):
834
- return [error, returnedString]
835
-
836
- i, j, retList = 0, 0, [error]
837
- for paramNb in range(nbElement):
838
- while ((i+j) < len(returnedString) and returnedString[i+j] != ','):
839
- j += 1
840
- retList.append(eval(returnedString[i:i+j]))
841
- i, j = i+j+1, 0
842
- return retList
843
-
664
+ return outputs.parse(error, returnedString)
844
665
 
845
666
  # GroupReferencingActionExecute : Execute an action in referencing mode
846
667
  def GroupReferencingActionExecute (self, socketId, PositionerName, ReferencingAction, ReferencingSensor, ReferencingParameter):
@@ -857,17 +678,10 @@ class XPS:
857
678
 
858
679
  # GroupStatusGet : Return group status
859
680
  def GroupStatusGet (self, socketId, GroupName):
860
- command = 'GroupStatusGet(' + GroupName + ',int *)'
681
+ outputs = XPSOutputs('int')
682
+ command = f'GroupStatusGet({GroupName},{outputs})'
861
683
  error, returnedString = self.Send(socketId, command)
862
- if (error != 0):
863
- return [error, returnedString]
864
-
865
- i, j, retList = 0, 0, [error]
866
- while ((i+j) < len(returnedString) and returnedString[i+j] != ','):
867
- j += 1
868
- retList.append(eval(returnedString[i:i+j]))
869
- return retList
870
-
684
+ return outputs.parse(error, returnedString)
871
685
 
872
686
  # GroupStatusStringGet : Return the group status string corresponding to the group status code
873
687
  def GroupStatusStringGet (self, socketId, GroupStatusCode):
@@ -875,25 +689,11 @@ class XPS:
875
689
 
876
690
  # GroupVelocityCurrentGet : Return current velocities
877
691
  def GroupVelocityCurrentGet (self, socketId, GroupName, nbElement):
878
- command = 'GroupVelocityCurrentGet(' + GroupName + ','
879
- for i in range(nbElement):
880
- if (i > 0):
881
- command += ','
882
- command += 'double *'
883
- command += ')'
692
+ outputs = XPSOutputs(*(['double'] * nbElement))
693
+ command = f'GroupVelocityCurrentGet({GroupName},{outputs})'
884
694
 
885
695
  error, returnedString = self.Send(socketId, command)
886
- if (error != 0):
887
- return [error, returnedString]
888
-
889
- i, j, retList = 0, 0, [error]
890
- for paramNb in range(nbElement):
891
- while ((i+j) < len(returnedString) and returnedString[i+j] != ','):
892
- j += 1
893
- retList.append(eval(returnedString[i:i+j]))
894
- i, j = i+j+1, 0
895
- return retList
896
-
696
+ return outputs.parse(error, returnedString)
897
697
 
898
698
  # KillAll : Put all groups in 'Not initialized' state
899
699
  def KillAll (self, socketId):
@@ -901,18 +701,10 @@ class XPS:
901
701
 
902
702
  # PositionerAnalogTrackingPositionParametersGet : Read dynamic parameters for one axe of a group for a future analog tracking position
903
703
  def PositionerAnalogTrackingPositionParametersGet (self, socketId, PositionerName):
904
- command = 'PositionerAnalogTrackingPositionParametersGet(' + PositionerName + ',char *,double *,double *,double *,double *)'
704
+ outputs = XPSOutputs('char', 'double', 'double', 'double', 'double')
705
+ command = f'PositionerAnalogTrackingPositionParametersGet({PositionerName},{outputs})'
905
706
  error, returnedString = self.Send(socketId, command)
906
- if (error != 0):
907
- return [error, returnedString]
908
-
909
- i, j, retList = 0, 0, [error]
910
- for paramNb in range(4):
911
- while ((i+j) < len(returnedString) and returnedString[i+j] != ','):
912
- j += 1
913
- retList.append(eval(returnedString[i:i+j]))
914
- i, j = i+j+1, 0
915
- return retList
707
+ return outputs.parse(error, returnedString)
916
708
 
917
709
  # PositionerAnalogTrackingPositionParametersSet : Update dynamic parameters for one axe of a group for a future analog tracking position
918
710
  def PositionerAnalogTrackingPositionParametersSet (self, socketId, PositionerName, GPIOName, Offset, Scale, Velocity, Acceleration):
@@ -921,18 +713,10 @@ class XPS:
921
713
 
922
714
  # PositionerAnalogTrackingVelocityParametersGet : Read dynamic parameters for one axe of a group for a future analog tracking velocity
923
715
  def PositionerAnalogTrackingVelocityParametersGet (self, socketId, PositionerName):
924
- command = 'PositionerAnalogTrackingVelocityParametersGet(' + PositionerName + ',char *,double *,double *,double *,int *,double *,double *)'
716
+ outputs = XPSOutputs('char', 'double', 'double', 'double', 'int', 'double', 'double')
717
+ command = f'PositionerAnalogTrackingVelocityParametersGet({PositionerName},{outputs})'
925
718
  error, returnedString = self.Send(socketId, command)
926
- if (error != 0):
927
- return [error, returnedString]
928
-
929
- i, j, retList = 0, 0, [error]
930
- for paramNb in range(6):
931
- while ((i+j) < len(returnedString) and returnedString[i+j] != ','):
932
- j += 1
933
- retList.append(eval(returnedString[i:i+j]))
934
- i, j = i+j+1, 0
935
- return retList
719
+ return outputs.parse(error, returnedString)
936
720
 
937
721
  # PositionerAnalogTrackingVelocityParametersSet : Update dynamic parameters for one axe of a group for a future analog tracking velocity
938
722
  def PositionerAnalogTrackingVelocityParametersSet (self, socketId, PositionerName, GPIOName, Offset, Scale, DeadBandThreshold, Order, Velocity, Acceleration):
@@ -941,18 +725,10 @@ class XPS:
941
725
 
942
726
  # PositionerBacklashGet : Read backlash value and status
943
727
  def PositionerBacklashGet (self, socketId, PositionerName):
944
- command = 'PositionerBacklashGet(' + PositionerName + ',double *,char *)'
728
+ outputs = XPSOutputs('double', 'char')
729
+ command = f'PositionerBacklashGet({PositionerName},{outputs})'
945
730
  error, returnedString = self.Send(socketId, command)
946
- if (error != 0):
947
- return [error, returnedString]
948
-
949
- i, j, retList = 0, 0, [error]
950
- for paramNb in range(2):
951
- while ((i+j) < len(returnedString) and returnedString[i+j] != ','):
952
- j += 1
953
- retList.append(eval(returnedString[i:i+j]))
954
- i, j = i+j+1, 0
955
- return retList
731
+ return outputs.parse(error, returnedString)
956
732
 
957
733
  # PositionerBacklashSet : Set backlash value
958
734
  def PositionerBacklashSet (self, socketId, PositionerName, BacklashValue):
@@ -974,18 +750,10 @@ class XPS:
974
750
 
975
751
  # PositionerCorrectorNotchFiltersGet : Read filters parameters
976
752
  def PositionerCorrectorNotchFiltersGet (self, socketId, PositionerName):
977
- command = 'PositionerCorrectorNotchFiltersGet(' + PositionerName + ',double *,double *,double *,double *,double *,double *)'
753
+ outputs = XPSOutputs('double', 'double', 'double', 'double', 'double', 'double')
754
+ command = f'PositionerCorrectorNotchFiltersGet({PositionerName},{outputs})'
978
755
  error, returnedString = self.Send(socketId, command)
979
- if (error != 0):
980
- return [error, returnedString]
981
-
982
- i, j, retList = 0, 0, [error]
983
- for paramNb in range(6):
984
- while ((i+j) < len(returnedString) and returnedString[i+j] != ','):
985
- j += 1
986
- retList.append(eval(returnedString[i:i+j]))
987
- i, j = i+j+1, 0
988
- return retList
756
+ return outputs.parse(error, returnedString)
989
757
 
990
758
  # PositionerCorrectorPIDFFAccelerationSet : Update corrector parameters
991
759
  def PositionerCorrectorPIDFFAccelerationSet (self, socketId, PositionerName, ClosedLoopStatus, KP, KI, KD, KS, IntegrationTime,
@@ -998,19 +766,10 @@ class XPS:
998
766
 
999
767
  # PositionerCorrectorPIDFFAccelerationGet : Read corrector parameters
1000
768
  def PositionerCorrectorPIDFFAccelerationGet (self, socketId, PositionerName):
1001
- command = 'PositionerCorrectorPIDFFAccelerationGet(' + PositionerName + ',bool *,double *,double *,double *,double *,double *,double *,double *,double *,double *,double *,double *)'
769
+ outputs = XPSOutputs('bool', 'double', 'double', 'double', 'double', 'double', 'double', 'double', 'double', 'double', 'double', 'double')
770
+ command = f'PositionerCorrectorPIDFFAccelerationGet({PositionerName},{outputs})'
1002
771
  error, returnedString = self.Send(socketId, command)
1003
- if (error != 0):
1004
- return [error, returnedString]
1005
-
1006
- i, j, retList = 0, 0, [error]
1007
- for paramNb in range(12):
1008
- while ((i+j) < len(returnedString) and returnedString[i+j] != ','):
1009
- j += 1
1010
- retList.append(eval(returnedString[i:i+j]))
1011
- i, j = i+j+1, 0
1012
- return retList
1013
-
772
+ return outputs.parse(error, returnedString)
1014
773
 
1015
774
  # PositionerCorrectorPIDFFVelocitySet : Update corrector parameters
1016
775
  def PositionerCorrectorPIDFFVelocitySet (self, socketId, PositionerName, ClosedLoopStatus, KP, KI, KD, KS, IntegrationTime, DerivativeFilterCutOffFrequency, GKP, GKI, GKD, KForm, FeedForwardGainVelocity):
@@ -1021,18 +780,10 @@ class XPS:
1021
780
 
1022
781
  # PositionerCorrectorPIDFFVelocityGet : Read corrector parameters
1023
782
  def PositionerCorrectorPIDFFVelocityGet (self, socketId, PositionerName):
1024
- command = 'PositionerCorrectorPIDFFVelocityGet(' + PositionerName + ',bool *,double *,double *,double *,double *,double *,double *,double *,double *,double *,double *,double *)'
783
+ outputs = XPSOutputs('bool', 'double', 'double', 'double', 'double', 'double', 'double', 'double', 'double', 'double', 'double', 'double')
784
+ command = f'PositionerCorrectorPIDFFVelocityGet({PositionerName},{outputs})'
1025
785
  error, returnedString = self.Send(socketId, command)
1026
- if (error != 0):
1027
- return [error, returnedString]
1028
-
1029
- i, j, retList = 0, 0, [error]
1030
- for paramNb in range(12):
1031
- while ((i+j) < len(returnedString) and returnedString[i+j] != ','):
1032
- j += 1
1033
- retList.append(eval(returnedString[i:i+j]))
1034
- i, j = i+j+1, 0
1035
- return retList
786
+ return outputs.parse(error, returnedString)
1036
787
 
1037
788
  # PositionerCorrectorPIDDualFFVoltageSet : Update corrector parameters
1038
789
  def PositionerCorrectorPIDDualFFVoltageSet (self, socketId, PositionerName, ClosedLoopStatus, KP, KI, KD, KS, IntegrationTime, DerivativeFilterCutOffFrequency, GKP, GKI, GKD, KForm, FeedForwardGainVelocity, FeedForwardGainAcceleration, Friction):
@@ -1043,18 +794,10 @@ class XPS:
1043
794
 
1044
795
  # PositionerCorrectorPIDDualFFVoltageGet : Read corrector parameters
1045
796
  def PositionerCorrectorPIDDualFFVoltageGet (self, socketId, PositionerName):
1046
- command = 'PositionerCorrectorPIDDualFFVoltageGet(' + PositionerName + ',bool *,double *,double *,double *,double *,double *,double *,double *,double *,double *,double *,double *,double *,double *)'
797
+ outputs = XPSOutputs('bool', 'double', 'double', 'double', 'double', 'double', 'double', 'double', 'double', 'double', 'double', 'double', 'double', 'double')
798
+ command = f'PositionerCorrectorPIDDualFFVoltageGet({PositionerName},{outputs})'
1047
799
  error, returnedString = self.Send(socketId, command)
1048
- if (error != 0):
1049
- return [error, returnedString]
1050
-
1051
- i, j, retList = 0, 0, [error]
1052
- for paramNb in range(14):
1053
- while ((i+j) < len(returnedString) and returnedString[i+j] != ','):
1054
- j += 1
1055
- retList.append(eval(returnedString[i:i+j]))
1056
- i, j = i+j+1, 0
1057
- return retList
800
+ return outputs.parse(error, returnedString)
1058
801
 
1059
802
  # PositionerCorrectorPIPositionSet : Update corrector parameters
1060
803
  def PositionerCorrectorPIPositionSet (self, socketId, PositionerName, ClosedLoopStatus, KP, KI, IntegrationTime):
@@ -1063,18 +806,10 @@ class XPS:
1063
806
 
1064
807
  # PositionerCorrectorPIPositionGet : Read corrector parameters
1065
808
  def PositionerCorrectorPIPositionGet (self, socketId, PositionerName):
1066
- command = 'PositionerCorrectorPIPositionGet(' + PositionerName + ',bool *,double *,double *,double *)'
809
+ outputs = XPSOutputs('bool', 'double', 'double', 'double')
810
+ command = f'PositionerCorrectorPIPositionGet({PositionerName},{outputs})'
1067
811
  error, returnedString = self.Send(socketId, command)
1068
- if (error != 0):
1069
- return [error, returnedString]
1070
-
1071
- i, j, retList = 0, 0, [error]
1072
- for paramNb in range(4):
1073
- while ((i+j) < len(returnedString) and returnedString[i+j] != ','):
1074
- j += 1
1075
- retList.append(eval(returnedString[i:i+j]))
1076
- i, j = i+j+1, 0
1077
- return retList
812
+ return outputs.parse(error, returnedString)
1078
813
 
1079
814
  # PositionerCorrectorTypeGet : Read corrector type
1080
815
  def PositionerCorrectorTypeGet (self, socketId, PositionerName):
@@ -1082,18 +817,10 @@ class XPS:
1082
817
 
1083
818
  # PositionerCurrentVelocityAccelerationFiltersGet : Get current velocity and acceleration cutoff frequencies
1084
819
  def PositionerCurrentVelocityAccelerationFiltersGet (self, socketId, PositionerName):
1085
- command = 'PositionerCurrentVelocityAccelerationFiltersGet(' + PositionerName + ',double *,double *)'
820
+ outputs = XPSOutputs('double', 'double')
821
+ command = f'PositionerCurrentVelocityAccelerationFiltersGet({PositionerName},{outputs})'
1086
822
  error, returnedString = self.Send(socketId, command)
1087
- if (error != 0):
1088
- return [error, returnedString]
1089
-
1090
- i, j, retList = 0, 0, [error]
1091
- for paramNb in range(2):
1092
- while ((i+j) < len(returnedString) and returnedString[i+j] != ','):
1093
- j += 1
1094
- retList.append(eval(returnedString[i:i+j]))
1095
- i, j = i+j+1, 0
1096
- return retList
823
+ return outputs.parse(error, returnedString)
1097
824
 
1098
825
  # PositionerCurrentVelocityAccelerationFiltersSet : Set current velocity and acceleration cutoff frequencies
1099
826
  def PositionerCurrentVelocityAccelerationFiltersSet (self, socketId, PositionerName, CurrentVelocityCutOffFrequency, CurrentAccelerationCutOffFrequency):
@@ -1102,18 +829,10 @@ class XPS:
1102
829
 
1103
830
  # PositionerDriverFiltersGet : Get driver filters parameters
1104
831
  def PositionerDriverFiltersGet (self, socketId, PositionerName):
1105
- command = 'PositionerDriverFiltersGet(' + PositionerName + ',double *,double *,double *,double *,double *)'
832
+ outputs = XPSOutputs('double', 'double', 'double', 'double', 'double')
833
+ command = f'PositionerDriverFiltersGet({PositionerName},{outputs})'
1106
834
  error, returnedString = self.Send(socketId, command)
1107
- if (error != 0):
1108
- return [error, returnedString]
1109
-
1110
- i, j, retList = 0, 0, [error]
1111
- for paramNb in range(5):
1112
- while ((i+j) < len(returnedString) and returnedString[i+j] != ','):
1113
- j += 1
1114
- retList.append(eval(returnedString[i:i+j]))
1115
- i, j = i+j+1, 0
1116
- return retList
835
+ return outputs.parse(error, returnedString)
1117
836
 
1118
837
  # PositionerDriverFiltersSet : Set driver filters parameters
1119
838
  def PositionerDriverFiltersSet (self, socketId, PositionerName, KI, NotchFrequency, NotchBandwidth, NotchGain, LowpassFrequency):
@@ -1122,32 +841,17 @@ class XPS:
1122
841
 
1123
842
  # PositionerDriverPositionOffsetsGet : Get driver stage and gage position offset
1124
843
  def PositionerDriverPositionOffsetsGet (self, socketId, PositionerName):
1125
- command = 'PositionerDriverPositionOffsetsGet(' + PositionerName + ',double *,double *)'
844
+ outputs = XPSOutputs('double', 'double')
845
+ command = f'PositionerDriverPositionOffsetsGet({PositionerName},{outputs})'
1126
846
  error, returnedString = self.Send(socketId, command)
1127
- if (error != 0):
1128
- return [error, returnedString]
1129
-
1130
- i, j, retList = 0, 0, [error]
1131
- for paramNb in range(2):
1132
- while ((i+j) < len(returnedString) and returnedString[i+j] != ','):
1133
- j += 1
1134
- retList.append(eval(returnedString[i:i+j]))
1135
- i, j = i+j+1, 0
1136
- return retList
847
+ return outputs.parse(error, returnedString)
1137
848
 
1138
849
  # PositionerDriverStatusGet : Read positioner driver status
1139
850
  def PositionerDriverStatusGet (self, socketId, PositionerName):
1140
- command = 'PositionerDriverStatusGet(' + PositionerName + ',int *)'
851
+ outputs = XPSOutputs('int')
852
+ command = f'PositionerDriverStatusGet({PositionerName},{outputs})'
1141
853
  error, returnedString = self.Send(socketId, command)
1142
- if (error != 0):
1143
- return [error, returnedString]
1144
-
1145
- i, j, retList = 0, 0, [error]
1146
- while ((i+j) < len(returnedString) and returnedString[i+j] != ','):
1147
- j += 1
1148
- retList.append(eval(returnedString[i:i+j]))
1149
- return retList
1150
-
854
+ return outputs.parse(error, returnedString)
1151
855
 
1152
856
  # PositionerDriverStatusStringGet : Return the positioner driver status string corresponding to the positioner error code
1153
857
  def PositionerDriverStatusStringGet (self, socketId, PositionerDriverStatus):
@@ -1156,59 +860,31 @@ class XPS:
1156
860
 
1157
861
  # PositionerEncoderAmplitudeValuesGet : Read analog interpolated encoder amplitude values
1158
862
  def PositionerEncoderAmplitudeValuesGet (self, socketId, PositionerName):
1159
- command = 'PositionerEncoderAmplitudeValuesGet(' + PositionerName + ',double *,double *,double *,double *)'
863
+ outputs = XPSOutputs('double', 'double', 'double', 'double')
864
+ command = f'PositionerEncoderAmplitudeValuesGet({PositionerName},{outputs})'
1160
865
  error, returnedString = self.Send(socketId, command)
1161
- if (error != 0):
1162
- return [error, returnedString]
1163
-
1164
- i, j, retList = 0, 0, [error]
1165
- for paramNb in range(4):
1166
- while ((i+j) < len(returnedString) and returnedString[i+j] != ','):
1167
- j += 1
1168
- retList.append(eval(returnedString[i:i+j]))
1169
- i, j = i+j+1, 0
1170
- return retList
866
+ return outputs.parse(error, returnedString)
1171
867
 
1172
868
  # PositionerEncoderCalibrationParametersGet : Read analog interpolated encoder calibration parameters
1173
869
  def PositionerEncoderCalibrationParametersGet (self, socketId, PositionerName):
1174
- command = 'PositionerEncoderCalibrationParametersGet(' + PositionerName + ',double *,double *,double *,double *)'
870
+ outputs = XPSOutputs('double', 'double', 'double', 'double')
871
+ command = f'PositionerEncoderCalibrationParametersGet({PositionerName},{outputs})'
1175
872
  error, returnedString = self.Send(socketId, command)
1176
- if (error != 0):
1177
- return [error, returnedString]
1178
-
1179
- i, j, retList = 0, 0, [error]
1180
- for paramNb in range(4):
1181
- while ((i+j) < len(returnedString) and returnedString[i+j] != ','):
1182
- j += 1
1183
- retList.append(eval(returnedString[i:i+j]))
1184
- i, j = i+j+1, 0
1185
- return retList
873
+ return outputs.parse(error, returnedString)
1186
874
 
1187
875
  # PositionerErrorGet : Read and clear positioner error code
1188
876
  def PositionerErrorGet (self, socketId, PositionerName):
1189
- command = 'PositionerErrorGet(' + PositionerName + ',int *)'
877
+ outputs = XPSOutputs('int')
878
+ command = f'PositionerErrorGet({PositionerName},{outputs})'
1190
879
  error, returnedString = self.Send(socketId, command)
1191
- if (error != 0):
1192
- return [error, returnedString]
1193
-
1194
- i, j, retList = 0, 0, [error]
1195
- while ((i+j) < len(returnedString) and returnedString[i+j] != ','):
1196
- j += 1
1197
- retList.append(eval(returnedString[i:i+j]))
1198
- return retList
880
+ return outputs.parse(error, returnedString)
1199
881
 
1200
882
  # PositionerErrorRead : Read only positioner error code without clear it
1201
883
  def PositionerErrorRead (self, socketId, PositionerName):
1202
- command = 'PositionerErrorRead(' + PositionerName + ',int *)'
884
+ outputs = XPSOutputs('int')
885
+ command = f'PositionerErrorRead({PositionerName},{outputs})'
1203
886
  error, returnedString = self.Send(socketId, command)
1204
- if (error != 0):
1205
- return [error, returnedString]
1206
-
1207
- i, j, retList = 0, 0, [error]
1208
- while ((i+j) < len(returnedString) and returnedString[i+j] != ','):
1209
- j += 1
1210
- retList.append(eval(returnedString[i:i+j]))
1211
- return retList
887
+ return outputs.parse(error, returnedString)
1212
888
 
1213
889
  # PositionerErrorStringGet : Return the positioner status string corresponding to the positioner error code
1214
890
  def PositionerErrorStringGet (self, socketId, PositionerErrorCode):
@@ -1216,18 +892,10 @@ class XPS:
1216
892
 
1217
893
  # PositionerExcitationSignalGet : Read disturbing signal parameters
1218
894
  def PositionerExcitationSignalGet (self, socketId, PositionerName):
1219
- command = 'PositionerExcitationSignalGet(' + PositionerName + ',int *,double *,double *,double *)'
895
+ outputs = XPSOutputs('int', 'double', 'double', 'double')
896
+ command = f'PositionerExcitationSignalGet({PositionerName},{outputs})'
1220
897
  error, returnedString = self.Send(socketId, command)
1221
- if (error != 0):
1222
- return [error, returnedString]
1223
-
1224
- i, j, retList = 0, 0, [error]
1225
- for paramNb in range(4):
1226
- while ((i+j) < len(returnedString) and returnedString[i+j] != ','):
1227
- j += 1
1228
- retList.append(eval(returnedString[i:i+j]))
1229
- i, j = i+j+1, 0
1230
- return retList
898
+ return outputs.parse(error, returnedString)
1231
899
 
1232
900
  # PositionerExcitationSignalSet : Update disturbing signal parameters
1233
901
  def PositionerExcitationSignalSet (self, socketId, PositionerName, Mode, Frequency, Amplitude, Time):
@@ -1236,29 +904,17 @@ class XPS:
1236
904
 
1237
905
  # PositionerExternalLatchPositionGet : Read external latch position
1238
906
  def PositionerExternalLatchPositionGet (self, socketId, PositionerName):
1239
- command = 'PositionerExternalLatchPositionGet(' + PositionerName + ',double *)'
907
+ outputs = XPSOutputs('double')
908
+ command = f'PositionerExternalLatchPositionGet({PositionerName},{outputs})'
1240
909
  error, returnedString = self.Send(socketId, command)
1241
- if (error != 0):
1242
- return [error, returnedString]
1243
-
1244
- i, j, retList = 0, 0, [error]
1245
- while ((i+j) < len(returnedString) and returnedString[i+j] != ','):
1246
- j += 1
1247
- retList.append(eval(returnedString[i:i+j]))
1248
- return retList
910
+ return outputs.parse(error, returnedString)
1249
911
 
1250
912
  # PositionerHardwareStatusGet : Read positioner hardware status
1251
913
  def PositionerHardwareStatusGet (self, socketId, PositionerName):
1252
- command = 'PositionerHardwareStatusGet(' + PositionerName + ',int *)'
914
+ outputs = XPSOutputs('int')
915
+ command = f'PositionerHardwareStatusGet({PositionerName},{outputs})'
1253
916
  error, returnedString = self.Send(socketId, command)
1254
- if (error != 0):
1255
- return [error, returnedString]
1256
-
1257
- i, j, retList = 0, 0, [error]
1258
- while ((i+j) < len(returnedString) and returnedString[i+j] != ','):
1259
- j += 1
1260
- retList.append(eval(returnedString[i:i+j]))
1261
- return retList
917
+ return outputs.parse(error, returnedString)
1262
918
 
1263
919
  # PositionerHardwareStatusStringGet : Return the positioner hardware status string corresponding to the positioner error code
1264
920
  def PositionerHardwareStatusStringGet (self, socketId, PositionerHardwareStatus):
@@ -1266,16 +922,10 @@ class XPS:
1266
922
 
1267
923
  # PositionerHardInterpolatorFactorGet : Get hard interpolator parameters
1268
924
  def PositionerHardInterpolatorFactorGet (self, socketId, PositionerName):
1269
- command = 'PositionerHardInterpolatorFactorGet(' + PositionerName + ',int *)'
925
+ outputs = XPSOutputs('int')
926
+ command = f'PositionerHardInterpolatorFactorGet({PositionerName},{outputs})'
1270
927
  error, returnedString = self.Send(socketId, command)
1271
- if (error != 0):
1272
- return [error, returnedString]
1273
-
1274
- i, j, retList = 0, 0, [error]
1275
- while ((i+j) < len(returnedString) and returnedString[i+j] != ','):
1276
- j += 1
1277
- retList.append(eval(returnedString[i:i+j]))
1278
- return retList
928
+ return outputs.parse(error, returnedString)
1279
929
 
1280
930
  # PositionerHardInterpolatorFactorSet : Set hard interpolator parameters
1281
931
  def PositionerHardInterpolatorFactorSet (self, socketId, PositionerName, InterpolationFactor):
@@ -1284,33 +934,17 @@ class XPS:
1284
934
 
1285
935
  # PositionerMaximumVelocityAndAccelerationGet : Return maximum velocity and acceleration of the positioner
1286
936
  def PositionerMaximumVelocityAndAccelerationGet (self, socketId, PositionerName):
1287
- command = 'PositionerMaximumVelocityAndAccelerationGet(' + PositionerName + ',double *,double *)'
937
+ outputs = XPSOutputs('double', 'double')
938
+ command = f'PositionerMaximumVelocityAndAccelerationGet({PositionerName},{outputs})'
1288
939
  error, returnedString = self.Send(socketId, command)
1289
- if (error != 0):
1290
- return [error, returnedString]
1291
-
1292
- i, j, retList = 0, 0, [error]
1293
- for paramNb in range(2):
1294
- while ((i+j) < len(returnedString) and returnedString[i+j] != ','):
1295
- j += 1
1296
- retList.append(eval(returnedString[i:i+j]))
1297
- i, j = i+j+1, 0
1298
- return retList
940
+ return outputs.parse(error, returnedString)
1299
941
 
1300
942
  # PositionerMotionDoneGet : Read motion done parameters
1301
943
  def PositionerMotionDoneGet (self, socketId, PositionerName):
1302
- command = 'PositionerMotionDoneGet(' + PositionerName + ',double *,double *,double *,double *,double *)'
944
+ outputs = XPSOutputs('double', 'double', 'double', 'double', 'double')
945
+ command = f'PositionerMotionDoneGet({PositionerName},{outputs})'
1303
946
  error, returnedString = self.Send(socketId, command)
1304
- if (error != 0):
1305
- return [error, returnedString]
1306
-
1307
- i, j, retList = 0, 0, [error]
1308
- for paramNb in range(5):
1309
- while ((i+j) < len(returnedString) and returnedString[i+j] != ','):
1310
- j += 1
1311
- retList.append(eval(returnedString[i:i+j]))
1312
- i, j = i+j+1, 0
1313
- return retList
947
+ return outputs.parse(error, returnedString)
1314
948
 
1315
949
  # PositionerMotionDoneSet : Update motion done parameters
1316
950
  def PositionerMotionDoneSet (self, socketId, PositionerName, PositionWindow, VelocityWindow, CheckingTime, MeanPeriod, TimeOut):
@@ -1324,18 +958,10 @@ class XPS:
1324
958
 
1325
959
  # PositionerPositionCompareAquadBWindowedGet : Read position compare AquadB windowed parameters
1326
960
  def PositionerPositionCompareAquadBWindowedGet (self, socketId, PositionerName):
1327
- command = 'PositionerPositionCompareAquadBWindowedGet(' + PositionerName + ',double *,double *,bool *)'
961
+ outputs = XPSOutputs('double', 'double', 'bool')
962
+ command = f'PositionerPositionCompareAquadBWindowedGet({PositionerName},{outputs})'
1328
963
  error, returnedString = self.Send(socketId, command)
1329
- if (error != 0):
1330
- return [error, returnedString]
1331
-
1332
- i, j, retList = 0, 0, [error]
1333
- for paramNb in range(3):
1334
- while ((i+j) < len(returnedString) and returnedString[i+j] != ','):
1335
- j += 1
1336
- retList.append(eval(returnedString[i:i+j]))
1337
- i, j = i+j+1, 0
1338
- return retList
964
+ return outputs.parse(error, returnedString)
1339
965
 
1340
966
  # PositionerPositionCompareAquadBWindowedSet : Set position compare AquadB windowed parameters
1341
967
  def PositionerPositionCompareAquadBWindowedSet (self, socketId, PositionerName, MinimumPosition, MaximumPosition):
@@ -1350,25 +976,17 @@ class XPS:
1350
976
 
1351
977
  # PositionerPositionCompareAquadBPrescalerGet : Gets PCO AquadB interpolation factor.
1352
978
  def PositionerPositionCompareAquadBPrescalerGet(self, socketId, PositionerName):
1353
- command = 'PositionerPositionCompareAquadBPrescalerGet(' + PositionerName + ',double *)'
979
+ outputs = XPSOutputs('double')
980
+ command = f'PositionerPositionCompareAquadBPrescalerGet({PositionerName},{outputs})'
1354
981
  error, returnedString = self.Send(socketId, command)
1355
- if (error != 0):
1356
- return [error, returnedString]
982
+ return outputs.parse(error, returnedString)
1357
983
 
1358
984
  # PositionerPositionCompareGet : Read position compare parameters
1359
985
  def PositionerPositionCompareGet (self, socketId, PositionerName):
1360
- command = 'PositionerPositionCompareGet(' + PositionerName + ',double *,double *,double *,bool *)'
986
+ outputs = XPSOutputs('double', 'double', 'double', 'bool')
987
+ command = f'PositionerPositionCompareGet({PositionerName},{outputs})'
1361
988
  error, returnedString = self.Send(socketId, command)
1362
- if (error != 0):
1363
- return [error, returnedString]
1364
-
1365
- i, j, retList = 0, 0, [error]
1366
- for paramNb in range(4):
1367
- while ((i+j) < len(returnedString) and returnedString[i+j] != ','):
1368
- j += 1
1369
- retList.append(eval(returnedString[i:i+j]))
1370
- i, j = i+j+1, 0
1371
- return retList
989
+ return outputs.parse(error, returnedString)
1372
990
 
1373
991
  # PositionerPositionCompareSet : Set position compare parameters
1374
992
  def PositionerPositionCompareSet (self, socketId, PositionerName, MinimumPosition, MaximumPosition, PositionStep):
@@ -1387,18 +1005,10 @@ class XPS:
1387
1005
 
1388
1006
  # PositionerPositionComparePulseParametersGet : Get position compare PCO pulse parameters
1389
1007
  def PositionerPositionComparePulseParametersGet (self, socketId, PositionerName):
1390
- command = 'PositionerPositionComparePulseParametersGet(' + PositionerName + ',double *,double *)'
1008
+ outputs = XPSOutputs('double', 'double')
1009
+ command = f'PositionerPositionComparePulseParametersGet({PositionerName},{outputs})'
1391
1010
  error, returnedString = self.Send(socketId, command)
1392
- if (error != 0):
1393
- return [error, returnedString]
1394
-
1395
- i, j, retList = 0, 0, [error]
1396
- for paramNb in range(2):
1397
- while ((i+j) < len(returnedString) and returnedString[i+j] != ','):
1398
- j += 1
1399
- retList.append(eval(returnedString[i:i+j]))
1400
- i, j = i+j+1, 0
1401
- return retList
1011
+ return outputs.parse(error, returnedString)
1402
1012
 
1403
1013
  # PositionerPositionComparePulseParametersSet : Set position compare PCO pulse parameters
1404
1014
  def PositionerPositionComparePulseParametersSet (self, socketId, PositionerName, PCOPulseWidth, EncoderSettlingTime):
@@ -1407,57 +1017,31 @@ class XPS:
1407
1017
 
1408
1018
  # PositionerRawEncoderPositionGet : Get the raw encoder position
1409
1019
  def PositionerRawEncoderPositionGet (self, socketId, PositionerName, UserEncoderPosition):
1410
- command = 'PositionerRawEncoderPositionGet(' + PositionerName + ',' + str(UserEncoderPosition) + ',double *)'
1020
+ outputs = XPSOutputs('double')
1021
+ command = f'PositionerRawEncoderPositionGet({PositionerName},{UserEncoderPosition},{outputs})'
1411
1022
  error, returnedString = self.Send(socketId, command)
1412
- if (error != 0):
1413
- return [error, returnedString]
1414
-
1415
- i, j, retList = 0, 0, [error]
1416
- while ((i+j) < len(returnedString) and returnedString[i+j] != ','):
1417
- j += 1
1418
- retList.append(eval(returnedString[i:i+j]))
1419
- return retList
1023
+ return outputs.parse(error, returnedString)
1420
1024
 
1421
1025
  # PositionersEncoderIndexDifferenceGet : Return the difference between index of primary axis and secondary axis (only after homesearch)
1422
1026
  def PositionersEncoderIndexDifferenceGet (self, socketId, PositionerName):
1423
- command = 'PositionersEncoderIndexDifferenceGet(' + PositionerName + ',double *)'
1027
+ outputs = XPSOutputs('double')
1028
+ command = f'PositionersEncoderIndexDifferenceGet({PositionerName},{outputs})'
1424
1029
  error, returnedString = self.Send(socketId, command)
1425
- if (error != 0):
1426
- return [error, returnedString]
1427
-
1428
- i, j, retList = 0, 0, [error]
1429
- while ((i+j) < len(returnedString) and returnedString[i+j] != ','):
1430
- j += 1
1431
- retList.append(eval(returnedString[i:i+j]))
1432
- return retList
1030
+ return outputs.parse(error, returnedString)
1433
1031
 
1434
1032
  # PositionerSGammaExactVelocityAjustedDisplacementGet : Return adjusted displacement to get exact velocity
1435
1033
  def PositionerSGammaExactVelocityAjustedDisplacementGet (self, socketId, PositionerName, DesiredDisplacement):
1436
- command = 'PositionerSGammaExactVelocityAjustedDisplacementGet(' + PositionerName + ',' + str(DesiredDisplacement) + ',double *)'
1034
+ outputs = XPSOutputs('double')
1035
+ command = f'PositionerSGammaExactVelocityAjustedDisplacementGet({PositionerName},{DesiredDisplacement},{outputs})'
1437
1036
  error, returnedString = self.Send(socketId, command)
1438
- if (error != 0):
1439
- return [error, returnedString]
1440
-
1441
- i, j, retList = 0, 0, [error]
1442
- while ((i+j) < len(returnedString) and returnedString[i+j] != ','):
1443
- j += 1
1444
- retList.append(eval(returnedString[i:i+j]))
1445
- return retList
1037
+ return outputs.parse(error, returnedString)
1446
1038
 
1447
1039
  # PositionerSGammaParametersGet : Read dynamic parameters for one axe of a group for a future displacement
1448
1040
  def PositionerSGammaParametersGet (self, socketId, PositionerName):
1449
- command = 'PositionerSGammaParametersGet(' + PositionerName + ',double *,double *,double *,double *)'
1041
+ outputs = XPSOutputs('double', 'double', 'double', 'double')
1042
+ command = f'PositionerSGammaParametersGet({PositionerName},{outputs})'
1450
1043
  error, returnedString = self.Send(socketId, command)
1451
- if (error != 0):
1452
- return [error, returnedString]
1453
-
1454
- i, j, retList = 0, 0, [error]
1455
- for paramNb in range(4):
1456
- while ((i+j) < len(returnedString) and returnedString[i+j] != ','):
1457
- j += 1
1458
- retList.append(eval(returnedString[i:i+j]))
1459
- i, j = i+j+1, 0
1460
- return retList
1044
+ return outputs.parse(error, returnedString)
1461
1045
 
1462
1046
  # PositionerSGammaParametersSet : Update dynamic parameters for one axe of a group for a future displacement
1463
1047
  def PositionerSGammaParametersSet (self, socketId, PositionerName, Velocity, Acceleration, MinimumTjerkTime, MaximumTjerkTime):
@@ -1466,18 +1050,10 @@ class XPS:
1466
1050
 
1467
1051
  # PositionerSGammaPreviousMotionTimesGet : Read SettingTime and SettlingTime
1468
1052
  def PositionerSGammaPreviousMotionTimesGet (self, socketId, PositionerName):
1469
- command = 'PositionerSGammaPreviousMotionTimesGet(' + PositionerName + ',double *,double *)'
1053
+ outputs = XPSOutputs('double', 'double')
1054
+ command = f'PositionerSGammaPreviousMotionTimesGet({PositionerName},{outputs})'
1470
1055
  error, returnedString = self.Send(socketId, command)
1471
- if (error != 0):
1472
- return [error, returnedString]
1473
-
1474
- i, j, retList = 0, 0, [error]
1475
- for paramNb in range(2):
1476
- while ((i+j) < len(returnedString) and returnedString[i+j] != ','):
1477
- j += 1
1478
- retList.append(eval(returnedString[i:i+j]))
1479
- i, j = i+j+1, 0
1480
- return retList
1056
+ return outputs.parse(error, returnedString)
1481
1057
 
1482
1058
  # PositionerStageParameterGet : Return the stage parameter
1483
1059
  def PositionerStageParameterGet (self, socketId, PositionerName, ParameterName):
@@ -1491,18 +1067,10 @@ class XPS:
1491
1067
 
1492
1068
  # PositionerTimeFlasherGet : Read time flasher parameters
1493
1069
  def PositionerTimeFlasherGet (self, socketId, PositionerName):
1494
- command = 'PositionerTimeFlasherGet(' + PositionerName + ',double *,double *,double *,bool *)'
1070
+ outputs = XPSOutputs('double', 'double', 'double', 'bool')
1071
+ command = f'PositionerTimeFlasherGet({PositionerName},{outputs})'
1495
1072
  error, returnedString = self.Send(socketId, command)
1496
- if (error != 0):
1497
- return [error, returnedString]
1498
-
1499
- i, j, retList = 0, 0, [error]
1500
- for paramNb in range(4):
1501
- while ((i+j) < len(returnedString) and returnedString[i+j] != ','):
1502
- j += 1
1503
- retList.append(eval(returnedString[i:i+j]))
1504
- i, j = i+j+1, 0
1505
- return retList
1073
+ return outputs.parse(error, returnedString)
1506
1074
 
1507
1075
  # PositionerTimeFlasherSet : Set time flasher parameters
1508
1076
  def PositionerTimeFlasherSet (self, socketId, PositionerName, MinimumPosition, MaximumPosition, TimeInterval):
@@ -1519,19 +1087,10 @@ class XPS:
1519
1087
 
1520
1088
  # PositionerUserTravelLimitsGet : Read UserMinimumTarget and UserMaximumTarget
1521
1089
  def PositionerUserTravelLimitsGet (self, socketId, PositionerName):
1522
- command = 'PositionerUserTravelLimitsGet(' + PositionerName + ',double *,double *)'
1090
+ outputs = XPSOutputs('double', 'double')
1091
+ command = f'PositionerUserTravelLimitsGet({PositionerName},{outputs})'
1523
1092
  error, returnedString = self.Send(socketId, command)
1524
- if (error != 0):
1525
- return [error, returnedString]
1526
-
1527
- i, j, retList = 0, 0, [error]
1528
- for paramNb in range(2):
1529
- while ((i+j) < len(returnedString) and returnedString[i+j] != ','):
1530
- j += 1
1531
- retList.append(eval(returnedString[i:i+j]))
1532
- i, j = i+j+1, 0
1533
- return retList
1534
-
1093
+ return outputs.parse(error, returnedString)
1535
1094
 
1536
1095
  # PositionerUserTravelLimitsSet : Update UserMinimumTarget and UserMaximumTarget
1537
1096
  def PositionerUserTravelLimitsSet (self, socketId, PositionerName, UserMinimumTarget, UserMaximumTarget):
@@ -1540,18 +1099,10 @@ class XPS:
1540
1099
 
1541
1100
  # PositionerDACOffsetGet : Get DAC offsets
1542
1101
  def PositionerDACOffsetGet (self, socketId, PositionerName):
1543
- command = 'PositionerDACOffsetGet(' + PositionerName + ',short *,short *)'
1102
+ outputs = XPSOutputs('short', 'short')
1103
+ command = f'PositionerDACOffsetGet({PositionerName},{outputs})'
1544
1104
  error, returnedString = self.Send(socketId, command)
1545
- if (error != 0):
1546
- return [error, returnedString]
1547
-
1548
- i, j, retList = 0, 0, [error]
1549
- for paramNb in range(2):
1550
- while ((i+j) < len(returnedString) and returnedString[i+j] != ','):
1551
- j += 1
1552
- retList.append(eval(returnedString[i:i+j]))
1553
- i, j = i+j+1, 0
1554
- return retList
1105
+ return outputs.parse(error, returnedString)
1555
1106
 
1556
1107
  # PositionerDACOffsetSet : Set DAC offsets
1557
1108
  def PositionerDACOffsetSet (self, socketId, PositionerName, DACOffset1, DACOffset2):
@@ -1560,19 +1111,10 @@ class XPS:
1560
1111
 
1561
1112
  # PositionerDACOffsetDualGet : Get dual DAC offsets
1562
1113
  def PositionerDACOffsetDualGet (self, socketId, PositionerName):
1563
- command = 'PositionerDACOffsetDualGet(' + PositionerName + ',short *,short *,short *,short *)'
1114
+ outputs = XPSOutputs('short', 'short', 'short', 'short')
1115
+ command = f'PositionerDACOffsetDualGet({PositionerName},{outputs})'
1564
1116
  error, returnedString = self.Send(socketId, command)
1565
- if (error != 0):
1566
- return [error, returnedString]
1567
-
1568
- i, j, retList = 0, 0, [error]
1569
- for paramNb in range(4):
1570
- while ((i+j) < len(returnedString) and returnedString[i+j] != ','):
1571
- j += 1
1572
- retList.append(eval(returnedString[i:i+j]))
1573
- i, j = i+j+1, 0
1574
- return retList
1575
-
1117
+ return outputs.parse(error, returnedString)
1576
1118
 
1577
1119
  # PositionerDACOffsetDualSet : Set dual DAC offsets
1578
1120
  def PositionerDACOffsetDualSet (self, socketId, PositionerName, PrimaryDACOffset1, PrimaryDACOffset2, SecondaryDACOffset1, SecondaryDACOffset2):
@@ -1581,31 +1123,17 @@ class XPS:
1581
1123
 
1582
1124
  # PositionerCorrectorAutoTuning : Astrom&Hagglund based auto-tuning
1583
1125
  def PositionerCorrectorAutoTuning (self, socketId, PositionerName, TuningMode):
1584
- command = 'PositionerCorrectorAutoTuning(' + PositionerName + ',' + str(TuningMode) + ',double *,double *,double *)'
1585
- return self.Send(socketId, command)
1586
- if (error != 0):
1587
- return [error, returnedString]
1588
-
1589
- i, j, retList = 0, 0, [error]
1590
- for paramNb in range(3):
1591
- while ((i+j) < len(returnedString) and returnedString[i+j] != ','):
1592
- j += 1
1593
- retList.append(eval(returnedString[i:i+j]))
1594
- i, j = i+j+1, 0
1595
- return retList
1126
+ outputs = XPSOutputs('double', 'double', 'double')
1127
+ command = f'PositionerCorrectorAutoTuning({PositionerName},{TuningMode},{outputs})'
1128
+ error, returnedString = self.Send(socketId, command)
1129
+ return outputs.parse(error, returnedString)
1596
1130
 
1597
1131
  # PositionerAccelerationAutoScaling : Astrom&Hagglund based auto-scaling
1598
1132
  def PositionerAccelerationAutoScaling (self, socketId, PositionerName):
1599
- command = 'PositionerAccelerationAutoScaling(' + PositionerName + ',double *)'
1133
+ outputs = XPSOutputs('double')
1134
+ command = f'PositionerAccelerationAutoScaling({PositionerName},{outputs})'
1600
1135
  error, returnedString = self.Send(socketId, command)
1601
- if (error != 0):
1602
- return [error, returnedString]
1603
-
1604
- i, j, retList = 0, 0, [error]
1605
- while ((i+j) < len(returnedString) and returnedString[i+j] != ','):
1606
- j += 1
1607
- retList.append(eval(returnedString[i:i+j]))
1608
- return retList
1136
+ return outputs.parse(error, returnedString)
1609
1137
 
1610
1138
  # MultipleAxesPVTVerification : Multiple axes PVT trajectory verification
1611
1139
  def MultipleAxesPVTVerification (self, socketId, GroupName, TrajectoryFileName):
@@ -1619,18 +1147,10 @@ class XPS:
1619
1147
 
1620
1148
  # MultipleAxesPVTVerificationResultGet : Multiple axes PVT trajectory verification result get
1621
1149
  def MultipleAxesPVTVerificationResultGet (self, socketId, PositionerName):
1622
- command = 'MultipleAxesPVTVerificationResultGet(' + PositionerName + ',char *,double *,double *,double *,double *)'
1150
+ outputs = XPSOutputs('char', 'double', 'double', 'double', 'double')
1151
+ command = f'MultipleAxesPVTVerificationResultGet({PositionerName},{outputs})'
1623
1152
  error, returnedString = self.Send(socketId, command)
1624
- if (error != 0):
1625
- return [error, returnedString]
1626
-
1627
- i, j, retList = 0, 0, [error]
1628
- for paramNb in range(4):
1629
- while ((i+j) < len(returnedString) and returnedString[i+j] != ','):
1630
- j += 1
1631
- retList.append(eval(returnedString[i:i+j]))
1632
- i, j = i+j+1, 0
1633
- return retList
1153
+ return outputs.parse(error, returnedString)
1634
1154
 
1635
1155
  # MultipleAxesPVTExecution : Multiple axes PVT trajectory execution
1636
1156
  def MultipleAxesPVTExecution (self, socketId, GroupName, TrajectoryFileName, ExecutionNumber):
@@ -1644,16 +1164,10 @@ class XPS:
1644
1164
 
1645
1165
  # MultipleAxesPVTParametersGet : Multiple axes PVT trajectory get parameters
1646
1166
  def MultipleAxesPVTParametersGet (self, socketId, GroupName):
1647
- command = 'MultipleAxesPVTParametersGet(' + GroupName + ',char *,int *)'
1167
+ outputs = XPSOutputs('char', 'int')
1168
+ command = f'MultipleAxesPVTParametersGet({GroupName},{outputs})'
1648
1169
  error, returnedString = self.Send(socketId, command)
1649
- if (error != 0):
1650
- return [error, returnedString]
1651
-
1652
- i, j, retList = 0, 0, [error]
1653
- while ((i+j) < len(returnedString) and returnedString[i+j] != ','):
1654
- j += 1
1655
- retList.append(eval(returnedString[i:i+j]))
1656
- return retList
1170
+ return outputs.parse(error, returnedString)
1657
1171
 
1658
1172
  # MultipleAxesPVTPulseOutputSet : Configure pulse output on trajectory
1659
1173
  def MultipleAxesPVTPulseOutputSet (self, socketId, GroupName, StartElement, EndElement, TimeInterval):
@@ -1662,18 +1176,10 @@ class XPS:
1662
1176
 
1663
1177
  # MultipleAxesPVTPulseOutputGet : Get pulse output on trajectory configuration
1664
1178
  def MultipleAxesPVTPulseOutputGet (self, socketId, GroupName):
1665
- command = 'MultipleAxesPVTPulseOutputGet(' + GroupName + ',int *,int *,double *)'
1179
+ outputs = XPSOutputs('int', 'int', 'double')
1180
+ command = f'MultipleAxesPVTPulseOutputGet({GroupName},{outputs})'
1666
1181
  error, returnedString = self.Send(socketId, command)
1667
- if (error != 0):
1668
- return [error, returnedString]
1669
-
1670
- i, j, retList = 0, 0, [error]
1671
- for paramNb in range(3):
1672
- while ((i+j) < len(returnedString) and returnedString[i+j] != ','):
1673
- j += 1
1674
- retList.append(eval(returnedString[i:i+j]))
1675
- i, j = i+j+1, 0
1676
- return retList
1182
+ return outputs.parse(error, returnedString)
1677
1183
 
1678
1184
  # SingleAxisSlaveModeEnable : Enable the slave mode
1679
1185
  def SingleAxisSlaveModeEnable (self, socketId, GroupName):
@@ -1690,16 +1196,10 @@ class XPS:
1690
1196
 
1691
1197
  # SingleAxisSlaveParametersGet : Get slave parameters
1692
1198
  def SingleAxisSlaveParametersGet (self, socketId, GroupName):
1693
- command = 'SingleAxisSlaveParametersGet(' + GroupName + ',char *,double *)'
1199
+ outputs = XPSOutputs('char', 'double')
1200
+ command = f'SingleAxisSlaveParametersGet({GroupName},{outputs})'
1694
1201
  error, returnedString = self.Send(socketId, command)
1695
- if (error != 0):
1696
- return [error, returnedString]
1697
-
1698
- i, j, retList = 0, 0, [error]
1699
- while ((i+j) < len(returnedString) and returnedString[i+j] != ','):
1700
- j += 1
1701
- retList.append(eval(returnedString[i:i+j]))
1702
- return retList
1202
+ return outputs.parse(error, returnedString)
1703
1203
 
1704
1204
  # SpindleSlaveModeEnable : Enable the slave mode
1705
1205
  def SpindleSlaveModeEnable (self, socketId, GroupName):
@@ -1716,16 +1216,10 @@ class XPS:
1716
1216
 
1717
1217
  # SpindleSlaveParametersGet : Get slave parameters
1718
1218
  def SpindleSlaveParametersGet (self, socketId, GroupName):
1719
- command = 'SpindleSlaveParametersGet(' + GroupName + ',char *,double *)'
1219
+ outputs = XPSOutputs('char', 'double')
1220
+ command = f'SpindleSlaveParametersGet({GroupName},{outputs})'
1720
1221
  error, returnedString = self.Send(socketId, command)
1721
- if (error != 0):
1722
- return [error, returnedString]
1723
-
1724
- i, j, retList = 0, 0, [error]
1725
- while ((i+j) < len(returnedString) and returnedString[i+j] != ','):
1726
- j += 1
1727
- retList.append(eval(returnedString[i:i+j]))
1728
- return retList
1222
+ return outputs.parse(error, returnedString)
1729
1223
 
1730
1224
  # GroupSpinParametersSet : Modify Spin parameters on selected group and activate the continuous move
1731
1225
  def GroupSpinParametersSet (self, socketId, GroupName, Velocity, Acceleration):
@@ -1734,34 +1228,17 @@ class XPS:
1734
1228
 
1735
1229
  # GroupSpinParametersGet : Get Spin parameters on selected group
1736
1230
  def GroupSpinParametersGet (self, socketId, GroupName):
1737
- command = 'GroupSpinParametersGet(' + GroupName + ',double *,double *)'
1231
+ outputs = XPSOutputs('double', 'double')
1232
+ command = f'GroupSpinParametersGet({GroupName},{outputs})'
1738
1233
  error, returnedString = self.Send(socketId, command)
1739
- if (error != 0):
1740
- return [error, returnedString]
1741
-
1742
- i, j, retList = 0, 0, [error]
1743
- for paramNb in range(2):
1744
- while ((i+j) < len(returnedString) and returnedString[i+j] != ','):
1745
- j += 1
1746
- retList.append(eval(returnedString[i:i+j]))
1747
- i, j = i+j+1, 0
1748
- return retList
1749
-
1234
+ return outputs.parse(error, returnedString)
1750
1235
 
1751
1236
  # GroupSpinCurrentGet : Get Spin current on selected group
1752
1237
  def GroupSpinCurrentGet (self, socketId, GroupName):
1753
- command = 'GroupSpinCurrentGet(' + GroupName + ',double *,double *)'
1238
+ outputs = XPSOutputs('double', 'double')
1239
+ command = f'GroupSpinCurrentGet({GroupName},{outputs})'
1754
1240
  error, returnedString = self.Send(socketId, command)
1755
- if (error != 0):
1756
- return [error, returnedString]
1757
-
1758
- i, j, retList = 0, 0, [error]
1759
- for paramNb in range(2):
1760
- while ((i+j) < len(returnedString) and returnedString[i+j] != ','):
1761
- j += 1
1762
- retList.append(eval(returnedString[i:i+j]))
1763
- i, j = i+j+1, 0
1764
- return retList
1241
+ return outputs.parse(error, returnedString)
1765
1242
 
1766
1243
  # GroupSpinModeStop : Stop Spin mode on selected group with specified acceleration
1767
1244
  def GroupSpinModeStop (self, socketId, GroupName, Acceleration):
@@ -1775,39 +1252,22 @@ class XPS:
1775
1252
 
1776
1253
  # XYLineArcVerificationResultGet : XY trajectory verification result get
1777
1254
  def XYLineArcVerificationResultGet (self, socketId, PositionerName):
1778
- command = 'XYLineArcVerificationResultGet(' + PositionerName + ',char *,double *,double *,double *,double *)'
1255
+ outputs = XPSOutputs('char', 'double', 'double', 'double', 'double')
1256
+ command = f'XYLineArcVerificationResultGet({PositionerName},{outputs})'
1779
1257
  error, returnedString = self.Send(socketId, command)
1780
- if (error != 0):
1781
- return [error, returnedString]
1782
-
1783
- i, j, retList = 0, 0, [error]
1784
- for paramNb in range(4):
1785
- while ((i+j) < len(returnedString) and returnedString[i+j] != ','):
1786
- j += 1
1787
- retList.append(eval(returnedString[i:i+j]))
1788
- i, j = i+j+1, 0
1789
- return retList
1258
+ return outputs.parse(error, returnedString)
1790
1259
 
1791
1260
  # XYLineArcExecution : XY trajectory execution
1792
1261
  def XYLineArcExecution (self, socketId, GroupName, TrajectoryFileName, Velocity, Acceleration, ExecutionNumber):
1793
1262
  command = 'XYLineArcExecution(' + GroupName + ',' + TrajectoryFileName + ',' + str(Velocity) + ',' + str(Acceleration) + ',' + str(ExecutionNumber) + ')'
1794
1263
  return self.Send(socketId, command)
1795
1264
 
1796
-
1797
1265
  # XYLineArcParametersGet : XY trajectory get parameters
1798
1266
  def XYLineArcParametersGet (self, socketId, GroupName):
1799
- command = 'XYLineArcParametersGet(' + GroupName + ',char *,double *,double *,int *)'
1267
+ outputs = XPSOutputs('char', 'double', 'double', 'int')
1268
+ command = f'XYLineArcParametersGet({GroupName},{outputs})'
1800
1269
  error, returnedString = self.Send(socketId, command)
1801
- if (error != 0):
1802
- return [error, returnedString]
1803
-
1804
- i, j, retList = 0, 0, [error]
1805
- for paramNb in range(3):
1806
- while ((i+j) < len(returnedString) and returnedString[i+j] != ','):
1807
- j += 1
1808
- retList.append(eval(returnedString[i:i+j]))
1809
- i, j = i+j+1, 0
1810
- return retList
1270
+ return outputs.parse(error, returnedString)
1811
1271
 
1812
1272
  # XYLineArcPulseOutputSet : Configure pulse output on trajectory
1813
1273
  def XYLineArcPulseOutputSet (self, socketId, GroupName, StartLength, EndLength, PathLengthInterval):
@@ -1816,33 +1276,17 @@ class XPS:
1816
1276
 
1817
1277
  # XYLineArcPulseOutputGet : Get pulse output on trajectory configuration
1818
1278
  def XYLineArcPulseOutputGet (self, socketId, GroupName):
1819
- command = 'XYLineArcPulseOutputGet(' + GroupName + ',double *,double *,double *)'
1279
+ outputs = XPSOutputs('double', 'double', 'double')
1280
+ command = f'XYLineArcPulseOutputGet({GroupName},{outputs})'
1820
1281
  error, returnedString = self.Send(socketId, command)
1821
- if (error != 0):
1822
- return [error, returnedString]
1823
-
1824
- i, j, retList = 0, 0, [error]
1825
- for paramNb in range(3):
1826
- while ((i+j) < len(returnedString) and returnedString[i+j] != ','):
1827
- j += 1
1828
- retList.append(eval(returnedString[i:i+j]))
1829
- i, j = i+j+1, 0
1830
- return retList
1282
+ return outputs.parse(error, returnedString)
1831
1283
 
1832
1284
  # XYZGroupPositionCorrectedProfilerGet : Return corrected profiler positions
1833
1285
  def XYZGroupPositionCorrectedProfilerGet (self, socketId, GroupName, PositionX, PositionY, PositionZ):
1834
- command = 'XYZGroupPositionCorrectedProfilerGet(' + GroupName + ',' + str(PositionX) + ',' + str(PositionY) + ',' + str(PositionZ) + ',double *,double *,double *)'
1286
+ outputs = XPSOutputs('double', 'double', 'double')
1287
+ command = f'XYZGroupPositionCorrectedProfilerGet({GroupName},{PositionX},{PositionY},{PositionZ},{outputs})'
1835
1288
  error, returnedString = self.Send(socketId, command)
1836
- if (error != 0):
1837
- return [error, returnedString]
1838
-
1839
- i, j, retList = 0, 0, [error]
1840
- for paramNb in range(3):
1841
- while ((i+j) < len(returnedString) and returnedString[i+j] != ','):
1842
- j += 1
1843
- retList.append(eval(returnedString[i:i+j]))
1844
- i, j = i+j+1, 0
1845
- return retList
1289
+ return outputs.parse(error, returnedString)
1846
1290
 
1847
1291
  # XYZSplineVerification : XYZ trajectory verifivation
1848
1292
  def XYZSplineVerification (self, socketId, GroupName, TrajectoryFileName):
@@ -1851,18 +1295,10 @@ class XPS:
1851
1295
 
1852
1296
  # XYZSplineVerificationResultGet : XYZ trajectory verification result get
1853
1297
  def XYZSplineVerificationResultGet (self, socketId, PositionerName):
1854
- command = 'XYZSplineVerificationResultGet(' + PositionerName + ',char *,double *,double *,double *,double *)'
1298
+ outputs = XPSOutputs('char', 'double', 'double', 'double', 'double')
1299
+ command = f'XYZSplineVerificationResultGet({PositionerName},{outputs})'
1855
1300
  error, returnedString = self.Send(socketId, command)
1856
- if (error != 0):
1857
- return [error, returnedString]
1858
-
1859
- i, j, retList = 0, 0, [error]
1860
- for paramNb in range(4):
1861
- while ((i+j) < len(returnedString) and returnedString[i+j] != ','):
1862
- j += 1
1863
- retList.append(eval(returnedString[i:i+j]))
1864
- i, j = i+j+1, 0
1865
- return retList
1301
+ return outputs.parse(error, returnedString)
1866
1302
 
1867
1303
  # XYZSplineExecution : XYZ trajectory execution
1868
1304
  def XYZSplineExecution (self, socketId, GroupName, TrajectoryFileName, Velocity, Acceleration):
@@ -1871,18 +1307,10 @@ class XPS:
1871
1307
 
1872
1308
  # XYZSplineParametersGet : XYZ trajectory get parameters
1873
1309
  def XYZSplineParametersGet (self, socketId, GroupName):
1874
- command = 'XYZSplineParametersGet(' + GroupName + ',char *,double *,double *,int *)'
1310
+ outputs = XPSOutputs('char', 'double', 'double', 'int')
1311
+ command = f'XYZSplineParametersGet({GroupName},{outputs})'
1875
1312
  error, returnedString = self.Send(socketId, command)
1876
- if (error != 0):
1877
- return [error, returnedString]
1878
-
1879
- i, j, retList = 0, 0, [error]
1880
- for paramNb in range(3):
1881
- while ((i+j) < len(returnedString) and returnedString[i+j] != ','):
1882
- j += 1
1883
- retList.append(eval(returnedString[i:i+j]))
1884
- i, j = i+j+1, 0
1885
- return retList
1313
+ return outputs.parse(error, returnedString)
1886
1314
 
1887
1315
  # OptionalModuleExecute : Execute an optional module
1888
1316
  def OptionalModuleExecute (self, socketId, ModuleFileName, TaskName):
@@ -1911,33 +1339,17 @@ class XPS:
1911
1339
 
1912
1340
  # CPUCoreAndBoardSupplyVoltagesGet : Get power informations
1913
1341
  def CPUCoreAndBoardSupplyVoltagesGet (self, socketId):
1914
- command = 'CPUCoreAndBoardSupplyVoltagesGet(double *,double *,double *,double *,double *,double *,double *,double *)'
1342
+ outputs = XPSOutputs('double', 'double', 'double', 'double', 'double', 'double', 'double', 'double')
1343
+ command = f'CPUCoreAndBoardSupplyVoltagesGet({outputs})'
1915
1344
  error, returnedString = self.Send(socketId, command)
1916
- if (error != 0):
1917
- return [error, returnedString]
1918
-
1919
- i, j, retList = 0, 0, [error]
1920
- for paramNb in range(8):
1921
- while ((i+j) < len(returnedString) and returnedString[i+j] != ','):
1922
- j += 1
1923
- retList.append(eval(returnedString[i:i+j]))
1924
- i, j = i+j+1, 0
1925
- return retList
1345
+ return outputs.parse(error, returnedString)
1926
1346
 
1927
1347
  # CPUTemperatureAndFanSpeedGet : Get CPU temperature and fan speed
1928
1348
  def CPUTemperatureAndFanSpeedGet (self, socketId):
1929
- command = 'CPUTemperatureAndFanSpeedGet(double *,double *)'
1349
+ outputs = XPSOutputs('double', 'double')
1350
+ command = f'CPUTemperatureAndFanSpeedGet({outputs})'
1930
1351
  error, returnedString = self.Send(socketId, command)
1931
- if (error != 0):
1932
- return [error, returnedString]
1933
-
1934
- i, j, retList = 0, 0, [error]
1935
- for paramNb in range(2):
1936
- while ((i+j) < len(returnedString) and returnedString[i+j] != ','):
1937
- j += 1
1938
- retList.append(eval(returnedString[i:i+j]))
1939
- i, j = i+j+1, 0
1940
- return retList
1352
+ return outputs.parse(error, returnedString)
1941
1353
 
1942
1354
  # ActionListGet : Action list
1943
1355
  def ActionListGet (self, socketId):
@@ -1989,7 +1401,10 @@ class XPS:
1989
1401
 
1990
1402
  # HardwareDriverAndStageGet : Smart hardware
1991
1403
  def HardwareDriverAndStageGet (self, socketId, PlugNumber):
1992
- return self.Send(socketId, 'HardwareDriverAndStageGet(%s, char *, char *)' % str(PlugNumber))
1404
+ outputs = XPSOutputs('char', 'char')
1405
+ command = f'HardwareDriverAndStageGet({PlugNumber},{outputs})'
1406
+ error, returnedString = self.Send(socketId, command)
1407
+ return outputs.parse(error, returnedString)
1993
1408
 
1994
1409
  # ObjectsListGet : Group name and positioner name
1995
1410
  def ObjectsListGet (self, socketId):
@@ -2017,33 +1432,17 @@ class XPS:
2017
1432
 
2018
1433
  # GatheringUserDatasGet : Return user data values
2019
1434
  def GatheringUserDatasGet (self, socketId):
2020
- command = 'GatheringUserDatasGet(double *,double *,double *,double *,double *,double *,double *,double *)'
1435
+ outputs = XPSOutputs('double', 'double', 'double', 'double', 'double', 'double', 'double', 'double')
1436
+ command = f'GatheringUserDatasGet({outputs})'
2021
1437
  error, returnedString = self.Send(socketId, command)
2022
- if (error != 0):
2023
- return [error, returnedString]
2024
-
2025
- i, j, retList = 0, 0, [error]
2026
- for paramNb in range(8):
2027
- while ((i+j) < len(returnedString) and returnedString[i+j] != ','):
2028
- j += 1
2029
- retList.append(eval(returnedString[i:i+j]))
2030
- i, j = i+j+1, 0
2031
- return retList
1438
+ return outputs.parse(error, returnedString)
2032
1439
 
2033
1440
  # ControllerMotionKernelPeriodMinMaxGet : Get controller motion kernel min/max periods
2034
1441
  def ControllerMotionKernelPeriodMinMaxGet (self, socketId):
2035
- command = 'ControllerMotionKernelPeriodMinMaxGet(double *,double *,double *,double *,double *,double *)'
2036
- error, returnedString = self.Send(socketId, command)
2037
- if (error != 0):
2038
- return [error, returnedString]
2039
-
2040
- i, j, retList = 0, 0, [error]
2041
- for paramNb in range(6):
2042
- while ((i+j) < len(returnedString) and returnedString[i+j] != ','):
2043
- j += 1
2044
- retList.append(eval(returnedString[i:i+j]))
2045
- i, j = i+j+1, 0
2046
- return retList
1442
+ outputs = XPSOutputs('double', 'double', 'double', 'double', 'double', 'double')
1443
+ command = f'ControllerMotionKernelPeriodMinMaxGet({outputs})'
1444
+ error, returnedString = self.Send(socketId, command)
1445
+ return outputs.parse(error, returnedString)
2047
1446
 
2048
1447
  # ControllerMotionKernelPeriodMinMaxReset : Reset controller motion kernel min/max periods
2049
1448
  def ControllerMotionKernelPeriodMinMaxReset (self, socketId):