-
Notifications
You must be signed in to change notification settings - Fork 1
/
XPS_C8_drivers.py
executable file
·2945 lines (2147 loc) · 101 KB
/
XPS_C8_drivers.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# XPS Python class
#
# for XPS-C8 Firmware V2.5.x
#
# See Programmer's manual for more information on XPS function calls
### modofied by julien for python 3.6 :
### encode and decode in def __sendAndReceive (self, socketId, command) function
####
import socket
class XPS:
# Defines
MAX_NB_SOCKETS = 100
# Global variables
__sockets = {}
__usedSockets = {}
__nbSockets = 0
# Initialization Function
def __init__ (self):
XPS.__nbSockets = 0
for socketId in range(self.MAX_NB_SOCKETS):
XPS.__usedSockets[socketId] = 0
# Send command and get return
def __sendAndReceive (self, socketId, command):
try:
XPS.__sockets[socketId].send(command.encode())
ret = XPS.__sockets[socketId].recv(1024).decode()
while (ret.find(',EndOfAPI') == -1):
ret += XPS.__sockets[socketId].recv(1024).decode()
except socket.timeout:
return [-2, '']
#except socket.error (errNb, errString):
# return [-2, '']
for i in range(len(ret)):
if (ret[i] == ','):
return [int(ret[0:i]), ret[i+1:-9]]
# TCP_ConnectToServer
def TCP_ConnectToServer (self, IP, port, timeOut):
socketId = 0
if (XPS.__nbSockets < self.MAX_NB_SOCKETS):
while (XPS.__usedSockets[socketId] == 1 and socketId < self.MAX_NB_SOCKETS):
socketId += 1
if (socketId == self.MAX_NB_SOCKETS):
return -1
else:
return -1
XPS.__usedSockets[socketId] = 1
XPS.__nbSockets += 1
try:
XPS.__sockets[socketId] = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
XPS.__sockets[socketId].connect((IP, port))
XPS.__sockets[socketId].settimeout(timeOut)
XPS.__sockets[socketId].setblocking(1)
except socket.error:
return -1
return socketId
# TCP_SetTimeout
def TCP_SetTimeout (self, socketId, timeOut):
if (XPS.__usedSockets[socketId] == 1):
XPS.__sockets[socketId].settimeout(timeOut)
# TCP_CloseSocket
def TCP_CloseSocket (self, socketId):
if (socketId >= 0 and socketId < self.MAX_NB_SOCKETS):
try:
XPS.__sockets[socketId].close()
XPS.__usedSockets[socketId] = 0
XPS.__nbSockets -= 1
except socket.error:
pass
# GetLibraryVersion
def GetLibraryVersion (self):
return ['XPS-C8 Firmware V2.5.x']
# ControllerStatusGet : Read controller current status
def ControllerStatusGet (self, socketId):
if (XPS.__usedSockets[socketId] == 0):
return
command = 'ControllerStatusGet(int *)'
[error, returnedString] = self.__sendAndReceive(socketId, command)
if (error != 0):
return [error, returnedString]
i, j, retList = 0, 0, [error]
while ((i+j) < len(returnedString) and returnedString[i+j] != ','):
j += 1
retList.append(eval(returnedString[i:i+j]))
return retList
# ControllerStatusStringGet : Return the controller status string corresponding to the controller status code
def ControllerStatusStringGet (self, socketId, ControllerStatusCode):
if (XPS.__usedSockets[socketId] == 0):
return
command = 'ControllerStatusStringGet(' + str(ControllerStatusCode) + ',char *)'
[error, returnedString] = self.__sendAndReceive(socketId, command)
return [error, returnedString]
# ElapsedTimeGet : Return elapsed time from controller power on
def ElapsedTimeGet (self, socketId):
if (XPS.__usedSockets[socketId] == 0):
return
command = 'ElapsedTimeGet(double *)'
[error, returnedString] = self.__sendAndReceive(socketId, command)
if (error != 0):
return [error, returnedString]
i, j, retList = 0, 0, [error]
while ((i+j) < len(returnedString) and returnedString[i+j] != ','):
j += 1
retList.append(eval(returnedString[i:i+j]))
return retList
# ErrorStringGet : Return the error string corresponding to the error code
def ErrorStringGet (self, socketId, ErrorCode):
if (XPS.__usedSockets[socketId] == 0):
return
command = 'ErrorStringGet(' + str(ErrorCode) + ',char *)'
[error, returnedString] = self.__sendAndReceive(socketId, command)
return [error, returnedString]
# FirmwareVersionGet : Return firmware version
def FirmwareVersionGet (self, socketId):
if (XPS.__usedSockets[socketId] == 0):
return
command = 'FirmwareVersionGet(char *)'
[error, returnedString] = self.__sendAndReceive(socketId, command)
return [error, returnedString]
# TCLScriptExecute : Execute a TCL script from a TCL file
def TCLScriptExecute (self, socketId, TCLFileName, TaskName, ParametersList):
if (XPS.__usedSockets[socketId] == 0):
return
command = 'TCLScriptExecute(' + TCLFileName + ',' + TaskName + ',' + ParametersList + ')'
[error, returnedString] = self.__sendAndReceive(socketId, command)
return [error, returnedString]
# TCLScriptExecuteAndWait : Execute a TCL script from a TCL file and wait the end of execution to return
def TCLScriptExecuteAndWait (self, socketId, TCLFileName, TaskName, InputParametersList):
if (XPS.__usedSockets[socketId] == 0):
return
command = 'TCLScriptExecuteAndWait(' + TCLFileName + ',' + TaskName + ',' + InputParametersList + ',char *)'
[error, returnedString] = self.__sendAndReceive(socketId, command)
return [error, returnedString]
# TCLScriptExecuteWithPriority : Execute a TCL script with defined priority
def TCLScriptExecuteWithPriority (self, socketId, TCLFileName, TaskName, TaskPriorityLevel, ParametersList):
if (XPS.__usedSockets[socketId] == 0):
return
command = 'TCLScriptExecuteWithPriority(' + TCLFileName + ',' + TaskName + ',' + TaskPriorityLevel + ',' + ParametersList + ')'
[error, returnedString] = self.__sendAndReceive(socketId, command)
return [error, returnedString]
# TCLScriptKill : Kill TCL Task
def TCLScriptKill (self, socketId, TaskName):
if (XPS.__usedSockets[socketId] == 0):
return
command = 'TCLScriptKill(' + TaskName + ')'
[error, returnedString] = self.__sendAndReceive(socketId, command)
return [error, returnedString]
# TimerGet : Get a timer
def TimerGet (self, socketId, TimerName):
if (XPS.__usedSockets[socketId] == 0):
return
command = 'TimerGet(' + TimerName + ',int *)'
[error, returnedString] = self.__sendAndReceive(socketId, command)
if (error != 0):
return [error, returnedString]
i, j, retList = 0, 0, [error]
while ((i+j) < len(returnedString) and returnedString[i+j] != ','):
j += 1
retList.append(eval(returnedString[i:i+j]))
return retList
# TimerSet : Set a timer
def TimerSet (self, socketId, TimerName, FrequencyTicks):
if (XPS.__usedSockets[socketId] == 0):
return
command = 'TimerSet(' + TimerName + ',' + str(FrequencyTicks) + ')'
[error, returnedString] = self.__sendAndReceive(socketId, command)
return [error, returnedString]
# Reboot : Reboot the controller
def Reboot (self, socketId):
if (XPS.__usedSockets[socketId] == 0):
return
command = 'Reboot()'
[error, returnedString] = self.__sendAndReceive(socketId, command)
return [error, returnedString]
# Login : Log in
def Login (self, socketId, Name, Password):
if (XPS.__usedSockets[socketId] == 0):
return
command = 'Login(' + Name + ',' + Password + ')'
[error, returnedString] = self.__sendAndReceive(socketId, command)
return [error, returnedString]
# CloseAllOtherSockets : Close all socket beside the one used to send this command
def CloseAllOtherSockets (self, socketId):
if (XPS.__usedSockets[socketId] == 0):
return
command = 'CloseAllOtherSockets()'
[error, returnedString] = self.__sendAndReceive(socketId, command)
return [error, returnedString]
# HardwareDateAndTimeGet : Return hardware date and time
def HardwareDateAndTimeGet (self, socketId):
if (XPS.__usedSockets[socketId] == 0):
return
command = 'HardwareDateAndTimeGet(char *)'
[error, returnedString] = self.__sendAndReceive(socketId, command)
return [error, returnedString]
# HardwareDateAndTimeSet : Set hardware date and time
def HardwareDateAndTimeSet (self, socketId, DateAndTime):
if (XPS.__usedSockets[socketId] == 0):
return
command = 'HardwareDateAndTimeSet(' + DateAndTime + ')'
[error, returnedString] = self.__sendAndReceive(socketId, command)
return [error, returnedString]
# EventAdd : ** OBSOLETE ** Add an event
def EventAdd (self, socketId, PositionerName, EventName, EventParameter, ActionName, ActionParameter1, ActionParameter2, ActionParameter3):
if (XPS.__usedSockets[socketId] == 0):
return
command = 'EventAdd(' + PositionerName + ',' + EventName + ',' + EventParameter + ',' + ActionName + ',' + ActionParameter1 + ',' + ActionParameter2 + ',' + ActionParameter3 + ')'
[error, returnedString] = self.__sendAndReceive(socketId, command)
return [error, returnedString]
# EventGet : ** OBSOLETE ** Read events and actions list
def EventGet (self, socketId, PositionerName):
if (XPS.__usedSockets[socketId] == 0):
return
command = 'EventGet(' + PositionerName + ',char *)'
[error, returnedString] = self.__sendAndReceive(socketId, command)
return [error, returnedString]
# EventRemove : ** OBSOLETE ** Delete an event
def EventRemove (self, socketId, PositionerName, EventName, EventParameter):
if (XPS.__usedSockets[socketId] == 0):
return
command = 'EventRemove(' + PositionerName + ',' + EventName + ',' + EventParameter + ')'
[error, returnedString] = self.__sendAndReceive(socketId, command)
return [error, returnedString]
# EventWait : ** OBSOLETE ** Wait an event
def EventWait (self, socketId, PositionerName, EventName, EventParameter):
if (XPS.__usedSockets[socketId] == 0):
return
command = 'EventWait(' + PositionerName + ',' + EventName + ',' + EventParameter + ')'
[error, returnedString] = self.__sendAndReceive(socketId, command)
return [error, returnedString]
# EventExtendedConfigurationTriggerSet : Configure one or several events
def EventExtendedConfigurationTriggerSet (self, socketId, ExtendedEventName, EventParameter1, EventParameter2, EventParameter3, EventParameter4):
if (XPS.__usedSockets[socketId] == 0):
return
command = 'EventExtendedConfigurationTriggerSet('
for i in range(len(ExtendedEventName)):
if (i > 0):
command += ','
command += ExtendedEventName[i] + ',' + EventParameter1[i] + ',' + EventParameter2[i] + ',' + EventParameter3[i] + ',' + EventParameter4[i]
command += ')'
[error, returnedString] = self.__sendAndReceive(socketId, command)
return [error, returnedString]
# EventExtendedConfigurationTriggerGet : Read the event configuration
def EventExtendedConfigurationTriggerGet (self, socketId):
if (XPS.__usedSockets[socketId] == 0):
return
command = 'EventExtendedConfigurationTriggerGet(char *)'
[error, returnedString] = self.__sendAndReceive(socketId, command)
return [error, returnedString]
# EventExtendedConfigurationActionSet : Configure one or several actions
def EventExtendedConfigurationActionSet (self, socketId, ExtendedActionName, ActionParameter1, ActionParameter2, ActionParameter3, ActionParameter4):
if (XPS.__usedSockets[socketId] == 0):
return
command = 'EventExtendedConfigurationActionSet('
for i in range(len(ExtendedActionName)):
if (i > 0):
command += ','
command += ExtendedActionName[i] + ',' + ActionParameter1[i] + ',' + ActionParameter2[i] + ',' + ActionParameter3[i] + ',' + ActionParameter4[i]
command += ')'
[error, returnedString] = self.__sendAndReceive(socketId, command)
return [error, returnedString]
# EventExtendedConfigurationActionGet : Read the action configuration
def EventExtendedConfigurationActionGet (self, socketId):
if (XPS.__usedSockets[socketId] == 0):
return
command = 'EventExtendedConfigurationActionGet(char *)'
[error, returnedString] = self.__sendAndReceive(socketId, command)
return [error, returnedString]
# EventExtendedStart : Launch the last event and action configuration and return an ID
def EventExtendedStart (self, socketId):
if (XPS.__usedSockets[socketId] == 0):
return
command = 'EventExtendedStart(int *)'
[error, returnedString] = self.__sendAndReceive(socketId, command)
if (error != 0):
return [error, returnedString]
i, j, retList = 0, 0, [error]
while ((i+j) < len(returnedString) and returnedString[i+j] != ','):
j += 1
retList.append(eval(returnedString[i:i+j]))
return retList
# EventExtendedAllGet : Read all event and action configurations
def EventExtendedAllGet (self, socketId):
if (XPS.__usedSockets[socketId] == 0):
return
command = 'EventExtendedAllGet(char *)'
[error, returnedString] = self.__sendAndReceive(socketId, command)
return [error, returnedString]
# EventExtendedGet : Read the event and action configuration defined by ID
def EventExtendedGet (self, socketId, ID):
if (XPS.__usedSockets[socketId] == 0):
return
command = 'EventExtendedGet(' + str(ID) + ',char *,char *)'
[error, returnedString] = self.__sendAndReceive(socketId, command)
return [error, returnedString]
# EventExtendedRemove : Remove the event and action configuration defined by ID
def EventExtendedRemove (self, socketId, ID):
if (XPS.__usedSockets[socketId] == 0):
return
command = 'EventExtendedRemove(' + str(ID) + ')'
[error, returnedString] = self.__sendAndReceive(socketId, command)
return [error, returnedString]
# EventExtendedWait : Wait events from the last event configuration
def EventExtendedWait (self, socketId):
if (XPS.__usedSockets[socketId] == 0):
return
command = 'EventExtendedWait()'
[error, returnedString] = self.__sendAndReceive(socketId, command)
return [error, returnedString]
# GatheringConfigurationGet : Read different mnemonique type
def GatheringConfigurationGet (self, socketId):
if (XPS.__usedSockets[socketId] == 0):
return
command = 'GatheringConfigurationGet(char *)'
[error, returnedString] = self.__sendAndReceive(socketId, command)
return [error, returnedString]
# GatheringConfigurationSet : Configuration acquisition
def GatheringConfigurationSet (self, socketId, Type):
if (XPS.__usedSockets[socketId] == 0):
return
command = 'GatheringConfigurationSet('
for i in range(len(Type)):
if (i > 0):
command += ','
command += Type[i]
command += ')'
[error, returnedString] = self.__sendAndReceive(socketId, command)
return [error, returnedString]
# GatheringCurrentNumberGet : Maximum number of samples and current number during acquisition
def GatheringCurrentNumberGet (self, socketId):
if (XPS.__usedSockets[socketId] == 0):
return
command = 'GatheringCurrentNumberGet(int *,int *)'
[error, returnedString] = self.__sendAndReceive(socketId, command)
if (error != 0):
return [error, returnedString]
i, j, retList = 0, 0, [error]
for paramNb in range(2):
while ((i+j) < len(returnedString) and returnedString[i+j] != ','):
j += 1
retList.append(eval(returnedString[i:i+j]))
i, j = i+j+1, 0
return retList
# GatheringStopAndSave : Stop acquisition and save data
def GatheringStopAndSave (self, socketId):
if (XPS.__usedSockets[socketId] == 0):
return
command = 'GatheringStopAndSave()'
[error, returnedString] = self.__sendAndReceive(socketId, command)
return [error, returnedString]
# GatheringDataAcquire : Acquire a configured data
def GatheringDataAcquire (self, socketId):
if (XPS.__usedSockets[socketId] == 0):
return
command = 'GatheringDataAcquire()'
[error, returnedString] = self.__sendAndReceive(socketId, command)
return [error, returnedString]
# GatheringDataGet : Get a data line from gathering buffer
def GatheringDataGet (self, socketId, IndexPoint):
if (XPS.__usedSockets[socketId] == 0):
return
command = 'GatheringDataGet(' + str(IndexPoint) + ',char *)'
[error, returnedString] = self.__sendAndReceive(socketId, command)
return [error, returnedString]
# GatheringDataMultipleLinesGet : Get multiple data lines from gathering buffer
def GatheringDataMultipleLinesGet (self, socketId, IndexPoint, NumberOfLines):
if (XPS.__usedSockets[socketId] == 0):
return
command = 'GatheringDataMultipleLinesGet(' + str(IndexPoint) + ',' + str(NumberOfLines) + ',char *)'
[error, returnedString] = self.__sendAndReceive(socketId, command)
return [error, returnedString]
# GatheringReset : Empty the gathered data in memory to start new gathering from scratch
def GatheringReset (self, socketId):
if (XPS.__usedSockets[socketId] == 0):
return
command = 'GatheringReset()'
[error, returnedString] = self.__sendAndReceive(socketId, command)
return [error, returnedString]
# GatheringRun : Start a new gathering
def GatheringRun (self, socketId, DataNumber, Divisor):
if (XPS.__usedSockets[socketId] == 0):
return
command = 'GatheringRun(' + str(DataNumber) + ',' + str(Divisor) + ')'
[error, returnedString] = self.__sendAndReceive(socketId, command)
return [error, returnedString]
# GatheringRunAppend : Re-start the stopped gathering to add new data
def GatheringRunAppend (self, socketId):
if (XPS.__usedSockets[socketId] == 0):
return
command = 'GatheringRunAppend()'
[error, returnedString] = self.__sendAndReceive(socketId, command)
return [error, returnedString]
# GatheringStop : Stop the data gathering (without saving to file)
def GatheringStop (self, socketId):
if (XPS.__usedSockets[socketId] == 0):
return
command = 'GatheringStop()'
[error, returnedString] = self.__sendAndReceive(socketId, command)
return [error, returnedString]
# GatheringExternalConfigurationSet : Configuration acquisition
def GatheringExternalConfigurationSet (self, socketId, Type):
if (XPS.__usedSockets[socketId] == 0):
return
command = 'GatheringExternalConfigurationSet('
for i in range(len(Type)):
if (i > 0):
command += ','
command += Type[i]
command += ')'
[error, returnedString] = self.__sendAndReceive(socketId, command)
return [error, returnedString]
# GatheringExternalConfigurationGet : Read different mnemonique type
def GatheringExternalConfigurationGet (self, socketId):
if (XPS.__usedSockets[socketId] == 0):
return
command = 'GatheringExternalConfigurationGet(char *)'
[error, returnedString] = self.__sendAndReceive(socketId, command)
return [error, returnedString]
# GatheringExternalCurrentNumberGet : Maximum number of samples and current number during acquisition
def GatheringExternalCurrentNumberGet (self, socketId):
if (XPS.__usedSockets[socketId] == 0):
return
command = 'GatheringExternalCurrentNumberGet(int *,int *)'
[error, returnedString] = self.__sendAndReceive(socketId, command)
if (error != 0):
return [error, returnedString]
i, j, retList = 0, 0, [error]
for paramNb in range(2):
while ((i+j) < len(returnedString) and returnedString[i+j] != ','):
j += 1
retList.append(eval(returnedString[i:i+j]))
i, j = i+j+1, 0
return retList
# GatheringExternalDataGet : Get a data line from external gathering buffer
def GatheringExternalDataGet (self, socketId, IndexPoint):
if (XPS.__usedSockets[socketId] == 0):
return
command = 'GatheringExternalDataGet(' + str(IndexPoint) + ',char *)'
[error, returnedString] = self.__sendAndReceive(socketId, command)
return [error, returnedString]
# GatheringExternalStopAndSave : Stop acquisition and save data
def GatheringExternalStopAndSave (self, socketId):
if (XPS.__usedSockets[socketId] == 0):
return
command = 'GatheringExternalStopAndSave()'
[error, returnedString] = self.__sendAndReceive(socketId, command)
return [error, returnedString]
# GlobalArrayGet : Get global array value
def GlobalArrayGet (self, socketId, Number):
if (XPS.__usedSockets[socketId] == 0):
return
command = 'GlobalArrayGet(' + str(Number) + ',char *)'
[error, returnedString] = self.__sendAndReceive(socketId, command)
return [error, returnedString]
# GlobalArraySet : Set global array value
def GlobalArraySet (self, socketId, Number, ValueString):
if (XPS.__usedSockets[socketId] == 0):
return
command = 'GlobalArraySet(' + str(Number) + ',' + ValueString + ')'
[error, returnedString] = self.__sendAndReceive(socketId, command)
return [error, returnedString]
# DoubleGlobalArrayGet : Get double global array value
def DoubleGlobalArrayGet (self, socketId, Number):
if (XPS.__usedSockets[socketId] == 0):
return
command = 'DoubleGlobalArrayGet(' + str(Number) + ',double *)'
[error, returnedString] = self.__sendAndReceive(socketId, command)
if (error != 0):
return [error, returnedString]
i, j, retList = 0, 0, [error]
while ((i+j) < len(returnedString) and returnedString[i+j] != ','):
j += 1
retList.append(eval(returnedString[i:i+j]))
return retList
# DoubleGlobalArraySet : Set double global array value
def DoubleGlobalArraySet (self, socketId, Number, DoubleValue):
if (XPS.__usedSockets[socketId] == 0):
return
command = 'DoubleGlobalArraySet(' + str(Number) + ',' + str(DoubleValue) + ')'
[error, returnedString] = self.__sendAndReceive(socketId, command)
return [error, returnedString]
# GPIOAnalogGet : Read analog input or analog output for one or few input
def GPIOAnalogGet (self, socketId, GPIOName):
if (XPS.__usedSockets[socketId] == 0):
return
command = 'GPIOAnalogGet('
for i in range(len(GPIOName)):
if (i > 0):
command += ','
command += GPIOName[i] + ',' + 'double *'
command += ')'
[error, returnedString] = self.__sendAndReceive(socketId, command)
if (error != 0):
return [error, returnedString]
i, j, retList = 0, 0, [error]
for paramNb in range(len(GPIOName)):
while ((i+j) < len(returnedString) and returnedString[i+j] != ','):
j += 1
retList.append(eval(returnedString[i:i+j]))
i, j = i+j+1, 0
return retList
# GPIOAnalogSet : Set analog output for one or few output
def GPIOAnalogSet (self, socketId, GPIOName, AnalogOutputValue):
if (XPS.__usedSockets[socketId] == 0):
return
command = 'GPIOAnalogSet('
for i in range(len(GPIOName)):
if (i > 0):
command += ','
command += GPIOName[i] + ',' + str(AnalogOutputValue[i])
command += ')'
[error, returnedString] = self.__sendAndReceive(socketId, command)
return [error, returnedString]
# GPIOAnalogGainGet : Read analog input gain (1, 2, 4 or 8) for one or few input
def GPIOAnalogGainGet (self, socketId, GPIOName):
if (XPS.__usedSockets[socketId] == 0):
return
command = 'GPIOAnalogGainGet('
for i in range(len(GPIOName)):
if (i > 0):
command += ','
command += GPIOName[i] + ',' + 'int *'
command += ')'
[error, returnedString] = self.__sendAndReceive(socketId, command)
if (error != 0):
return [error, returnedString]
i, j, retList = 0, 0, [error]
for paramNb in range(len(GPIOName)):
while ((i+j) < len(returnedString) and returnedString[i+j] != ','):
j += 1
retList.append(eval(returnedString[i:i+j]))
i, j = i+j+1, 0
return retList
# GPIOAnalogGainSet : Set analog input gain (1, 2, 4 or 8) for one or few input
def GPIOAnalogGainSet (self, socketId, GPIOName, AnalogInputGainValue):
if (XPS.__usedSockets[socketId] == 0):
return
command = 'GPIOAnalogGainSet('
for i in range(len(GPIOName)):
if (i > 0):
command += ','
command += GPIOName[i] + ',' + str(AnalogInputGainValue[i])
command += ')'
[error, returnedString] = self.__sendAndReceive(socketId, command)
return [error, returnedString]
# GPIODigitalGet : Read digital output or digital input
def GPIODigitalGet (self, socketId, GPIOName):
if (XPS.__usedSockets[socketId] == 0):
return
command = 'GPIODigitalGet(' + GPIOName + ',unsigned short *)'
[error, returnedString] = self.__sendAndReceive(socketId, command)
if (error != 0):
return [error, returnedString]
i, j, retList = 0, 0, [error]
while ((i+j) < len(returnedString) and returnedString[i+j] != ','):
j += 1
retList.append(eval(returnedString[i:i+j]))
return retList
# GPIODigitalSet : Set Digital Output for one or few output TTL
def GPIODigitalSet (self, socketId, GPIOName, Mask, DigitalOutputValue):
if (XPS.__usedSockets[socketId] == 0):
return
command = 'GPIODigitalSet(' + GPIOName + ',' + str(Mask) + ',' + str(DigitalOutputValue) + ')'
[error, returnedString] = self.__sendAndReceive(socketId, command)
return [error, returnedString]
# GroupAccelerationSetpointGet : Return setpoint accelerations
def GroupAccelerationSetpointGet (self, socketId, GroupName, nbElement):
if (XPS.__usedSockets[socketId] == 0):
return
command = 'GroupAccelerationSetpointGet(' + GroupName + ','
for i in range(nbElement):
if (i > 0):
command += ','
command += 'double *'
command += ')'
[error, returnedString] = self.__sendAndReceive(socketId, command)
if (error != 0):
return [error, returnedString]
i, j, retList = 0, 0, [error]
for paramNb in range(nbElement):
while ((i+j) < len(returnedString) and returnedString[i+j] != ','):
j += 1
retList.append(eval(returnedString[i:i+j]))
i, j = i+j+1, 0
return retList
# GroupAnalogTrackingModeEnable : Enable Analog Tracking mode on selected group
def GroupAnalogTrackingModeEnable (self, socketId, GroupName, Type):
if (XPS.__usedSockets[socketId] == 0):
return
command = 'GroupAnalogTrackingModeEnable(' + GroupName + ',' + Type + ')'
[error, returnedString] = self.__sendAndReceive(socketId, command)
return [error, returnedString]
# GroupAnalogTrackingModeDisable : Disable Analog Tracking mode on selected group
def GroupAnalogTrackingModeDisable (self, socketId, GroupName):
if (XPS.__usedSockets[socketId] == 0):
return
command = 'GroupAnalogTrackingModeDisable(' + GroupName + ')'
[error, returnedString] = self.__sendAndReceive(socketId, command)
return [error, returnedString]
# GroupCorrectorOutputGet : Return corrector outputs
def GroupCorrectorOutputGet (self, socketId, GroupName, nbElement):
if (XPS.__usedSockets[socketId] == 0):
return
command = 'GroupCorrectorOutputGet(' + GroupName + ','
for i in range(nbElement):
if (i > 0):
command += ','
command += 'double *'
command += ')'
[error, returnedString] = self.__sendAndReceive(socketId, command)
if (error != 0):
return [error, returnedString]
i, j, retList = 0, 0, [error]
for paramNb in range(nbElement):
while ((i+j) < len(returnedString) and returnedString[i+j] != ','):
j += 1
retList.append(eval(returnedString[i:i+j]))
i, j = i+j+1, 0
return retList
# GroupCurrentFollowingErrorGet : Return current following errors
def GroupCurrentFollowingErrorGet (self, socketId, GroupName, nbElement):
if (XPS.__usedSockets[socketId] == 0):
return
command = 'GroupCurrentFollowingErrorGet(' + GroupName + ','
for i in range(nbElement):
if (i > 0):
command += ','
command += 'double *'
command += ')'
[error, returnedString] = self.__sendAndReceive(socketId, command)
if (error != 0):
return [error, returnedString]
i, j, retList = 0, 0, [error]
for paramNb in range(nbElement):
while ((i+j) < len(returnedString) and returnedString[i+j] != ','):
j += 1
retList.append(eval(returnedString[i:i+j]))
i, j = i+j+1, 0
return retList
# GroupHomeSearch : Start home search sequence
def GroupHomeSearch (self, socketId, GroupName):
if (XPS.__usedSockets[socketId] == 0):
return
command = 'GroupHomeSearch(' + GroupName + ')'
[error, returnedString] = self.__sendAndReceive(socketId, command)
return [error, returnedString]
# GroupHomeSearchAndRelativeMove : Start home search sequence and execute a displacement
def GroupHomeSearchAndRelativeMove (self, socketId, GroupName, TargetDisplacement):
if (XPS.__usedSockets[socketId] == 0):
return
command = 'GroupHomeSearchAndRelativeMove(' + GroupName + ','
for i in range(len(TargetDisplacement)):
if (i > 0):
command += ','
command += str(TargetDisplacement[i])
command += ')'
[error, returnedString] = self.__sendAndReceive(socketId, command)
return [error, returnedString]
# GroupInitialize : Start the initialization
def GroupInitialize (self, socketId, GroupName):
if (XPS.__usedSockets[socketId] == 0):
return
command = 'GroupInitialize(' + GroupName + ')'
[error, returnedString] = self.__sendAndReceive(socketId, command)
return [error, returnedString]
# GroupInitializeWithEncoderCalibration : Start the initialization with encoder calibration
def GroupInitializeWithEncoderCalibration (self, socketId, GroupName):
if (XPS.__usedSockets[socketId] == 0):
return
command = 'GroupInitializeWithEncoderCalibration(' + GroupName + ')'
[error, returnedString] = self.__sendAndReceive(socketId, command)
return [error, returnedString]
# GroupJogParametersSet : Modify Jog parameters on selected group and activate the continuous move
def GroupJogParametersSet (self, socketId, GroupName, Velocity, Acceleration):
if (XPS.__usedSockets[socketId] == 0):
return
command = 'GroupJogParametersSet(' + GroupName + ','
for i in range(len(Velocity)):
if (i > 0):
command += ','
command += str(Velocity[i]) + ',' + str(Acceleration[i])
command += ')'
[error, returnedString] = self.__sendAndReceive(socketId, command)
return [error, returnedString]
# GroupJogParametersGet : Get Jog parameters on selected group
def GroupJogParametersGet (self, socketId, GroupName, nbElement):
if (XPS.__usedSockets[socketId] == 0):
return
command = 'GroupJogParametersGet(' + GroupName + ','
for i in range(nbElement):
if (i > 0):
command += ','
command += 'double *' + ',' + 'double *'
command += ')'
[error, returnedString] = self.__sendAndReceive(socketId, command)
if (error != 0):
return [error, returnedString]
i, j, retList = 0, 0, [error]
for paramNb in range(nbElement*2):
while ((i+j) < len(returnedString) and returnedString[i+j] != ','):
j += 1
retList.append(eval(returnedString[i:i+j]))
i, j = i+j+1, 0
return retList
# GroupJogCurrentGet : Get Jog current on selected group
def GroupJogCurrentGet (self, socketId, GroupName, nbElement):
if (XPS.__usedSockets[socketId] == 0):
return
command = 'GroupJogCurrentGet(' + GroupName + ','
for i in range(nbElement):
if (i > 0):
command += ','
command += 'double *' + ',' + 'double *'
command += ')'
[error, returnedString] = self.__sendAndReceive(socketId, command)
if (error != 0):
return [error, returnedString]
i, j, retList = 0, 0, [error]
for paramNb in range(nbElement*2):
while ((i+j) < len(returnedString) and returnedString[i+j] != ','):
j += 1
retList.append(eval(returnedString[i:i+j]))
i, j = i+j+1, 0
return retList
# GroupJogModeEnable : Enable Jog mode on selected group
def GroupJogModeEnable (self, socketId, GroupName):
if (XPS.__usedSockets[socketId] == 0):
return
command = 'GroupJogModeEnable(' + GroupName + ')'
[error, returnedString] = self.__sendAndReceive(socketId, command)
return [error, returnedString]
# GroupJogModeDisable : Disable Jog mode on selected group
def GroupJogModeDisable (self, socketId, GroupName):
if (XPS.__usedSockets[socketId] == 0):
return
command = 'GroupJogModeDisable(' + GroupName + ')'