-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTLPMX.py
More file actions
7399 lines (5956 loc) · 385 KB
/
Copy pathTLPMX.py
File metadata and controls
7399 lines (5956 loc) · 385 KB
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
"""
Direct method to communicate wit hthe TLPMX.dll file. Under the MIT license
"""
import os
from ctypes import cdll,c_long,c_uint32,c_uint16,c_uint8,byref,create_string_buffer,c_bool, c_char, c_char_p,c_int,c_int16,c_int8,c_double,c_float,sizeof,c_voidp, Structure
_VI_ERROR = (-2147483647-1)
VI_ON = 1
VI_OFF = 0
TLPM_VID_THORLABS = (0x1313) # Thorlabs
TLPM_PID_TLPM_DFU = (0x8070) # PM100D with DFU interface enabled
TLPM_PID_PM100A_DFU = (0x8071) # PM100A with DFU interface enabled
TLPM_PID_PM100USB = (0x8072) # PM100USB with DFU interface enabled
TLPM_PID_PM160USB_DFU = (0x8073) # PM160 on USB with DFU interface enabled
TLPM_PID_PM160TUSB_DFU = (0x8074) # PM160T on USB with DFU interface enabled
TLPM_PID_PM400_DFU = (0x8075) # PM400 on USB with DFU interface enabled
TLPM_PID_PM101_DFU = (0x8076) # PM101 on USB with DFU interface enabled (Interface 0 TMC, Interface 1 DFU)
TLPM_PID_PM102_DFU = (0x8077) # PM102 on USB with DFU interface enabled (Interface 0 TMC, Interface 1 DFU)
TLPM_PID_PM103_DFU = (0x807A) # PM103 on USB with DFU interface enabled (Interface 0 TMC, Interface 1 DFU)
TLPM_PID_PM100D = (0x8078) # PM100D w/o DFU interface
TLPM_PID_PM100A = (0x8079) # PM100A w/o DFU interface
TLPM_PID_PM160USB = (0x807B) # PM160 on USB w/o DFU interface
TLPM_PID_PM160TUSB = (0x807C) # PM160T on USB w/o DFU interface
TLPM_PID_PM400 = (0x807D) # PM400 on USB w/o DFU interface
TLPM_PID_PM101 = (0x807E) # reserved
TLPM_PID_PMTest = (0x807F) # PM Test Platform
TLPM_PID_PM200 = (0x80B0) # PM200
TLPM_PID_PM5020 = (0x80BB) # PM5020 1 channel benchtop powermeter (Interface 0 TMC, Interface 1 DFU)
TLPM_PID_PM6x_DFU = (0x80B4) # PM6x on USB with DFU interface enabled (Interface 0 TMC, Interface 1 DFU)
TLPM_PID_PM100Dx_DFU = (0x8099) # PM100D2\D3 Generation on USB with DFU interface enabled (Interface 0 TMC, Interface 1 DFU)
TLPM_FIND_PATTERN = "USB?*INSTR{VI_ATTR_MANF_ID==0x1313 && (VI_ATTR_MODE _CODE==0x8070 || VI_ATTR_MODE _CODE==0x8078)}"
PM100A_FIND_PATTERN = "USB?*INSTR{VI_ATTR_MANF_ID==0x1313 && (VI_ATTR_MODE _CODE==0x8071 || VI_ATTR_MODE _CODE==0x8079)}"
PM100USB_FIND_PATTERN = "USB?*INSTR{VI_ATTR_MANF_ID==0x1313 && VI_ATTR_MODE _CODE==0x8072}"
PM160USB_FIND_PATTERN = "USB?*INSTR{VI_ATTR_MANF_ID==0x1313 && (VI_ATTR_MODE _CODE==0x8073 || VI_ATTR_MODE _CODE==0x807B)}"
PM160TUSB_FIND_PATTERN = "USB?*INSTR{VI_ATTR_MANF_ID==0x1313 && (VI_ATTR_MODE _CODE==0x8074 || VI_ATTR_MODE _CODE==0x807C)}"
PM200_FIND_PATTERN = "USB?*INSTR{VI_ATTR_MANF_ID==0x1313 && VI_ATTR_MODE _CODE==0x80B0}"
PM400_FIND_PATTERN = "USB?*INSTR{VI_ATTR_MANF_ID==0x1313 && (VI_ATTR_MODE _CODE==0x8075 || VI_ATTR_MODE _CODE==0x807D)}"
PM101_FIND_PATTERN = "USB?*INSTR{VI_ATTR_MANF_ID==0x1313 && (VI_ATTR_MODE _CODE==0x8076)}"
PM102_FIND_PATTERN = "USB?*INSTR{VI_ATTR_MANF_ID==0x1313 && (VI_ATTR_MODE _CODE==0x8077)}"
PM103_FIND_PATTERN = "USB?*INSTR{VI_ATTR_MANF_ID==0x1313 && VI_ATTR_MODE _CODE==0x807A}"
PMTest_FIND_PATTERN = "USB?*INSTR{VI_ATTR_MANF_ID==0x1313 && VI_ATTR_MODE _CODE==0x807F}"
PM100_FIND_PATTERN = "USB?*::0x1313::0x807?::?*::INSTR"
PM5020_FIND_PATTERN = "USB?*INSTR{VI_ATTR_MANF_ID==0x1313 && VI_ATTR_MODE _CODE==0x80BB}"
PM100D3rdGen_FIND_PATTERN = "USB?*INSTR{VI_ATTR_MANF_ID==0x1313 && VI_ATTR_MODE _CODE==0x8099}"
PMxxx_FIND_PATTERN = "USB?*INSTR{VI_ATTR_MANF_ID==0x1313 && (VI_ATTR_MODE _CODE==0x8070 || VI_ATTR_MODE _CODE==0x8078 || " \
"VI_ATTR_MODEL_CODE==0x8071 || VI_ATTR_MODEL_CODE==0x8079 || " \
"VI_ATTR_MODEL_CODE==0x8072 || " \
"VI_ATTR_MODEL_CODE==0x8073 || VI_ATTR_MODEL_CODE==0x807B || " \
"VI_ATTR_MODEL_CODE==0x8074 || VI_ATTR_MODEL_CODE==0x807C || " \
"VI_ATTR_MODEL_CODE==0x8075 || VI_ATTR_MODEL_CODE==0x807D || " \
"VI_ATTR_MODEL_CODE==0x8076 || VI_ATTR_MODEL_CODE==0x807E || " \
"VI_ATTR_MODEL_CODE==0x8077 || VI_ATTR_MODEL_CODE==0x807F || " \
"VI_ATTR_MODEL_CODE==0x8099 ||" \
"VI_ATTR_MODEL_CODE==0x807A || VI_ATTR_MODEL_CODE==0x80BB ||" \
"VI_ATTR_MODEL_CODE==0x80B0 || VI_ATTR_MODEL_CODE==0x80B4)}"
PMBT_FIND_PATTERN = "ASR ?*::INSTR{VI_ATTR_MANF_ID==0x1313 && (VI_ATTR_MODE _CODE==0x807C || VI_ATTR_MODE _CODE==0x807B)}"
PMUART_FIND_PATTERN_VISA = "ASRL?*::INSTR"
PMUART_FIND_PATTERN_COM = "COM?*"
PMNET_FIND_PATTERN = "TCPIP?*::INSTR{(VI_ATTR_TCPIP_DEVICE_NAME==\"PM5020\" || VI_ATTR_TCPIP_DEVICE_NAME==\"PM103E\" || " \
"VI_ATTR_TCPIP_DEVICE_NAME==\"PM60\" || VI_ATTR_TCPIP_DEVICE_NAME==\"PM61\" || " \
"VI_ATTR_TCPIP_DEVICE_NAME==\"PM62\" || VI_ATTR_TCPIP_DEVICE_NAME==\"PM63\" || VI_ATTR_TCPIP_DEVICE_NAME==\"PM64\" ||" \
"VI_ATTR_TCPIP_DEVICE_NAME==\"PM400\" || " \
"VI_ATTR_TCPIP_DEVICE_NAME==\"PM100D3\" || VI_ATTR_TCPIP_DEVICE_NAME==\"PM100D2\" || " \
"VI_ATTR_TCPIP_DEVICE_NAME==\"PM103\" || VI_ATTR_TCPIP_DEVICE_NAME==\"PM103A\" || VI_ATTR_TCPIP_DEVICE_NAME==\"PM103R\" || VI_ATTR_TCPIP_DEVICE_NAME==\"PM103U\" || " \
"VI_ATTR_TCPIP_DEVICE_NAME==\"PM102\" || VI_ATTR_TCPIP_DEVICE_NAME==\"PM102A\" || VI_ATTR_TCPIP_DEVICE_NAME==\"PM102R\" || VI_ATTR_TCPIP_DEVICE_NAME==\"PM102U\" || " \
"VI_ATTR_TCPIP_DEVICE_NAME==\"PM101\" || VI_ATTR_TCPIP_DEVICE_NAME==\"PM101A\" || VI_ATTR_TCPIP_DEVICE_NAME==\"PM101R\" || VI_ATTR_TCPIP_DEVICE_NAME==\"PM101U\" || " \
"VI_ATTR_TCPIP_DEVICE_NAME==\"PM100USB\" || " \
"VI_ATTR_TCPIP_DEVICE_NAME==\"PM100D\" || VI_ATTR_TCPIP_DEVICE_NAME==\"PM100A\" || VI_ATTR_TCPIP_DEVICE_NAME==\"PM200\" || " \
"VI_ATTR_TCPIP_DEVICE_NAME==\"PM160\" || VI_ATTR_TCPIP_DEVICE_NAME==\"PM160T\")}"
PMBTH_FIND_PATTERN = "BTHLE?*"
TLPM_BUFFER_SIZE = 256 # General buffer size
TLPM_ERR_DESCR_BUFFER_SIZE = 512 # Buffer size for error messages
VI_INSTR_WARNING_OFFSET = (0x3FFC0900 )
VI_INSTR_ERROR_OFFSET = (_VI_ERROR + 0x3FFC0900 )
VI_INSTR_ERROR_NOT_SUPP_INTF = (VI_INSTR_ERROR_OFFSET + 0x01 )
VI_INSTR_WARN_OVERFLOW = (VI_INSTR_WARNING_OFFSET + 0x01 )
VI_INSTR_WARN_UNDERRUN = (VI_INSTR_WARNING_OFFSET + 0x02 )
VI_INSTR_WARN_NAN = (VI_INSTR_WARNING_OFFSET + 0x03 )
TLPM_ATTR_SET_VAL = (0)
TLPM_ATTR_MIN_VAL = (1)
TLPM_ATTR_MAX_VAL = (2)
TLPM_ATTR_DFLT_VAL = (3)
TLPM_ATTR_AUTO_VAL = (9)
TLPM_DEFAULT_CHANNEL = (1)
TLPM_SENSOR_CHANNEL1 = (1)
TLPM_SENSOR_CHANNEL2 = (2)
TLPM_TRIGGER_SRC_CHANNEL_1 = (1)
TLPM_TRIGGER_SRC_CHANNEL_2 = (2)
TLPM_TRIGGER_SRC_FRONT_AUX = (3)
TLPM_TRIGGER_SRC_REAR = (4)
TLPM_INDEX_1 = (1)
TLPM_INDEX_2 = (2)
TLPM_INDEX_3 = (3)
TLPM_INDEX_4 = (4)
TLPM_INDEX_5 = (5)
TLPM_PEAK_FILTER_NONE = (0)
TLPM_PEAK_FILTER_OVER = (1)
TLPM_REG_STB = (0) # < Status Byte Register
TLPM_REG_SRE = (1) # < Service Request Enable
TLPM_REG_ESB = (2) # < Standard Event Status Register
TLPM_REG_ESE = (3) # < Standard Event Enable
TLPM_REG_OPER_COND = (4) # < Operation Condition Register
TLPM_REG_OPER_EVENT = (5) # < Operation Event Register
TLPM_REG_OPER_ENAB = (6) # < Operation Event Enable Register
TLPM_REG_OPER_PTR = (7) # < Operation Positive Transition Filter
TLPM_REG_OPER_NTR = (8) # < Operation Negative Transition Filter
TLPM_REG_QUES_COND = (9) # < Questionable Condition Register
TLPM_REG_QUES_EVENT = (10) # < Questionable Event Register
TLPM_REG_QUES_ENAB = (11) # < Questionable Event Enable Reg.
TLPM_REG_QUES_PTR = (12) # < Questionable Positive Transition Filter
TLPM_REG_QUES_NTR = (13) # < Questionable Negative Transition Filter
TLPM_REG_MEAS_COND = (14) # < Measurement Condition Register
TLPM_REG_MEAS_EVENT = (15) # < Measurement Event Register
TLPM_REG_MEAS_ENAB = (16) # < Measurement Event Enable Register
TLPM_REG_MEAS_PTR = (17) # < Measurement Positive Transition Filter
TLPM_REG_MEAS_NTR = (18) # < Measurement Negative Transition Filter
TLPM_REG_AUX_COND = (19) # < Auxiliary Condition Register
TLPM_REG_AUX_EVENT = (20) # < Auxiliary Event Register
TLPM_REG_AUX_ENAB = (21) # < Auxiliary Event Enable Register
TLPM_REG_AUX_PTR = (22) # < Auxiliary Positive Transition Filter
TLPM_REG_AUX_NTR = (23) # < Auxiliary Negative Transition Filter
TLPM_REG_OPER_COND_1 = (24) # < Operation Condition Register Channel 1
TLPM_REG_OPER_COND_2 = (25) # < Operation Condition Register Channel 2
TLPM_REG_AUX_DET_COND = (26) # < Auxiliary Condition Register DET
TLPM_STATBIT_STB_AUX = (0x01) # < Auxiliary summary
TLPM_STATBIT_STB_MEAS = (0x02) # < Device Measurement Summary
TLPM_STATBIT_STB_EAV = (0x04) # < Error available
TLPM_STATBIT_STB_QUES = (0x08) # < Questionable Status Summary
TLPM_STATBIT_STB_MAV = (0x10) # < Message available
TLPM_STATBIT_STB_ESB = (0x20) # < Event Status Bit
TLPM_STATBIT_STB_MSS = (0x40) # < Master summary status
TLPM_STATBIT_STB_OPER = (0x80) # < Operation Status Summary
TLPM_STATBIT_ESR_OPC = (0x01) # < Operation complete
TLPM_STATBIT_ESR_RQC = (0x02) # < Request control
TLPM_STATBIT_ESR_QYE = (0x04) # < Query error
TLPM_STATBIT_ESR_DDE = (0x08) # < Device-Specific error
TLPM_STATBIT_ESR_EXE = (0x10) # < Execution error
TLPM_STATBIT_ESR_CME = (0x20) # < Command error
TLPM_STATBIT_ESR_URQ = (0x40) # < User request
TLPM_STATBIT_ESR_PON = (0x80) # < Power on
TLPM_STATBIT_QUES_VOLT = (0x0001) # < questionable voltage measurement
TLPM_STATBIT_QUES_CURR = (0x0002) # < questionable current measurement
TLPM_STATBIT_QUES_TIME = (0x0004) # < questionable time measurement
TLPM_STATBIT_QUES_POW = (0x0008) # < questionable power measurement
TLPM_STATBIT_QUES_TEMP = (0x0010) # < questionable temperature measurement
TLPM_STATBIT_QUES_FREQ = (0x0020) # < questionable frequency measurement
TLPM_STATBIT_QUES_PHAS = (0x0040) # < questionable phase measurement
TLPM_STATBIT_QUES_MOD = (0x0080) # < questionable modulation measurement
TLPM_STATBIT_QUES_CAL = (0x0100) # < questionable calibration
TLPM_STATBIT_QUES_ENER = (0x0200) # < questionable energy measurement
TLPM_STATBIT_QUES_10 = (0x0400) # < reserved
TLPM_STATBIT_QUES_11 = (0x0800) # < reserved
TLPM_STATBIT_QUES_12 = (0x1000) # < reserved
TLPM_STATBIT_QUES_INST = (0x2000) # < instrument summary
TLPM_STATBIT_QUES_WARN = (0x4000) # < command warning
TLPM_STATBIT_QUES_15 = (0x8000) # < reserved
TLPM_STATBIT_OPER_CAL = (0x0001) # < The instrument is currently performing a calibration.
TLPM_STATBIT_OPER_SETT = (0x0002) # < The instrument is waiting for signals it controls to stabilize enough to begin measurements.
TLPM_STATBIT_OPER_RANG = (0x0004) # < The instrument is currently changing its range.
TLPM_STATBIT_OPER_SWE = (0x0008) # < A sweep is in progress.
TLPM_STATBIT_OPER_MEAS = (0x0010) # < The instrument is actively measuring.
TLPM_STATBIT_OPER_TRIG = (0x0020) # < The instrument is in a ?wait for trigger? state of the trigger model.
TLPM_STATBIT_OPER_ARM = (0x0040) # < The instrument is in a ?wait for arm? state of the trigger model.
TLPM_STATBIT_OPER_CORR = (0x0080) # < The instrument is currently performing a correction (Auto-PID tune).
TLPM_STATBIT_OPER_SENS = (0x0100) # < Optical powermeter sensor connected and operable.
TLPM_STATBIT_OPER_DATA = (0x0200) # < Measurement data ready for fetch.
TLPM_STATBIT_OPER_THAC = (0x0400) # < Thermopile accelerator active.
TLPM_STATBIT_OPER_11 = (0x0800) # < reserved
TLPM_STATBIT_OPER_12 = (0x1000) # < reserved
TLPM_STATBIT_OPER_INST = (0x2000) # < One of n multiple logical instruments is reporting OPERational status.
TLPM_STATBIT_OPER_PROG = (0x4000) # < A user-defined programming is currently in the run state.
TLPM_STATBIT_OPER_15 = (0x8000) # < reserved
TLPM_STATBIT_MEAS_0 = (0x0001) # < reserved
TLPM_STATBIT_MEAS_1 = (0x0002) # < reserved
TLPM_STATBIT_MEAS_2 = (0x0004) # < reserved
TLPM_STATBIT_MEAS_3 = (0x0008) # < reserved
TLPM_STATBIT_MEAS_4 = (0x0010) # < reserved
TLPM_STATBIT_MEAS_5 = (0x0020) # < reserved
TLPM_STATBIT_MEAS_6 = (0x0040) # < reserved
TLPM_STATBIT_MEAS_7 = (0x0080) # < reserved
TLPM_STATBIT_MEAS_8 = (0x0100) # < reserved
TLPM_STATBIT_MEAS_9 = (0x0200) # < reserved
TLPM_STATBIT_MEAS_10 = (0x0400) # < reserved
TLPM_STATBIT_MEAS_11 = (0x0800) # < reserved
TLPM_STATBIT_MEAS_12 = (0x1000) # < reserved
TLPM_STATBIT_MEAS_13 = (0x2000) # < reserved
TLPM_STATBIT_MEAS_14 = (0x4000) # < reserved
TLPM_STATBIT_MEAS_15 = (0x8000) # < reserved
TLPM_STATBIT_AUX_NTC = (0x0001) # < Auxiliary NTC temperature sensor connected.
TLPM_STATBIT_AUX_EMM = (0x0002) # < External measurement module connected.
TLPM_STATBIT_AUX_UPCS = (0x0004) # < User Power Calibration supported by this instrument
TLPM_STATBIT_AUX_UPCA = (0x0008) # < User Power Calibration active status
TLPM_STATBIT_AUX_EXPS = (0x0010) # < External power supply connected
TLPM_STATBIT_AUX_BATC = (0x0020) # < Battery charging
TLPM_STATBIT_AUX_BATL = (0x0040) # < Battery low
TLPM_STATBIT_AUX_IPS = (0x0080) # < Apple(tm) authentification supported. True if an authentification co-processor is installed.
TLPM_STATBIT_AUX_IPF = (0x0100) # < Apple(tm) authentification failed. True if the authentification setup procedure failed.
TLPM_STATBIT_AUX_9 = (0x0200) # < reserved
TLPM_STATBIT_AUX_10 = (0x0400) # < reserved
TLPM_STATBIT_AUX_11 = (0x0800) # < reserved
TLPM_STATBIT_AUX_12 = (0x1000) # < reserved
TLPM_STATBIT_AUX_13 = (0x2000) # < reserved
TLPM_STATBIT_AUX_14 = (0x4000) # < reserved
TLPM_STATBIT_AUX_15 = (0x8000) # < reserved
TLPM_WINTERTIME = (0)
TLPM_SUMMERTIME = (1)
TLPM_LINE_FREQ_50 = (50) # < line frequency in Hz
TLPM_LINE_FREQ_60 = (60) # < line frequency in Hz
TLPM_INPUT_FILTER_STATE_OFF = (0)
TLPM_INPUT_FILTER_STATE_ON = (1)
TLPM_ACCELERATION_STATE_OFF = (0)
TLPM_ACCELERATION_STATE_ON = (1)
TLPM_ACCELERATION_MANUAL = (0)
TLPM_ACCELERATION_AUTO = (1)
TLPM_STAT_DARK_ADJUST_FINISHED = (0)
TLPM_STAT_DARK_ADJUST_RUNNING = (1)
TLPM_AUTORANGE_CURRENT_OFF = (0)
TLPM_AUTORANGE_CURRENT_ON = (1)
TLPM_CURRENT_REF_OFF = (0)
TLPM_CURRENT_REF_ON = (1)
TLPM_AUTORANGE_ENERGY_OFF = (0)
TLPM_AUTORANGE_ENERGY_ON = (1)
TLPM_ENERGY_REF_OFF = (0)
TLPM_ENERGY_REF_ON = (1)
TLPM_FREQ_MODE_CW = (0)
TLPM_FREQ_MODE_PEAK = (1)
TLPM_AUTORANGE_POWER_OFF = (0)
TLPM_AUTORANGE_POWER_ON = (1)
TLPM_POWER_REF_OFF = (0)
TLPM_POWER_REF_ON = (1)
TLPM_POWER_UNIT_WATT = (0)
TLPM_POWER_UNIT_DBM = (1)
SENSOR_SWITCH_POS_1 = (1)
SENSOR_SWITCH_POS_2 = (2)
TLPM_AUTORANGE_VOLTAGE_OFF = (0)
TLPM_AUTORANGE_VOLTAGE_ON = (1)
TLPM_VOLTAGE_REF_OFF = (0)
TLPM_VOLTAGE_REF_ON = (1)
TLPM_ANALOG_ROUTE_PUR = (0)
TLPM_ANALOG_ROUTE_CBA = (1)
TLPM_ANALOG_ROUTE_CMA = (2)
TLPM_ANALOG_ROUTE_GEN = (3)
TLPM_ANALOG_ROUTE_FUNC = (4)
TLPM_ANALOG_ROUTE_CUST = (5)
TLPM_ANALOG_ROUTE_GDBM = (6)
TLPM_MEAS_POWER = (0)
TLPM_MEAS_CURRENT = (1)
TLPM_MEAS_VOLTAGE = (2)
TLPM_MEAS_PDENSITY = (3)
TLPM_MEAS_ENERGY = (4)
TLPM_MEAS_EDENSITY = (5)
TLPM_IODIR_INP = (VI_OFF)
TLPM_IODIR_OUTP = (VI_ON)
TLPM_IOLVL_LOW = (VI_OFF)
TLPM_IOLVL_HIGH = (VI_ON)
DIGITAL_IO_CONFIG_INPUT = (0)
DIGITAL_IO_CONFIG_OUTPUT = (1)
DIGITAL_IO_CONFIG_INPUT_ALT = (2)
DIGITAL_IO_CONFIG_OUTPUT_ALT = (3)
I2C_OPER_INTER = (0)
I2C_OPER_SLOW = (1)
I2C_OPER_FAST = (2)
FAN_OPER_OFF = (0)
FAN_OPER_FULL = (1)
FAN_OPER_OPEN_LOOP = (2)
FAN_OPER_CLOSED_LOOP = (3)
FAN_OPER_TEMPER_CTRL = (4)
FAN_TEMPER_SRC_HEAD = (0)
FAN_TEMPER_SRC_EXT_NTC = (1)
SENSOR_TYPE_NONE = 0x0 # No sensor. This value is used to mark sensor data for 'no sensor connected'.
SENSOR_TYPE_PD_SINGLE = 0x1 # Single photodiode sensor. Only one ipd input active at the same time.
SENSOR_TYPE_THERMO = 0x2 # Thermopile sensor
SENSOR_TYPE_PYRO = 0x3 # Pyroelectric sensor
SENSOR_TYPE_4Q = 0x4 # 4Q Sensor
SENSOR_SUBTYPE_NONE = 0x0 # No sensor. This value is used to mark RAM data structure for 'no sensor connected'. Do not write this value to the EEPROM.
SENSOR_SUBTYPE_PD_ADAPTER = 0x01 # Photodiode adapter (no temperature sensor)
SENSOR_SUBTYPE_PD_SINGLE_STD = 0x02 # Standard single photodiode sensor (no temperature sensor)
SENSOR_SUBTYPE_PD_SINGLE_FSR = 0x03 # One single photodiode. Filter position set by a slide on the sensor selects responsivity data set to use. (no temperature sensor)
SENSOR_SUBTYPE_PD_SINGLE_STD_T = 0x12 # Standard single photodiode sensor (with temperature sensor)
SENSOR_SUBTYPE_THERMO_ADAPTER = 0x01 # Thermopile adapter (no temperature sensor)
SENSOR_SUBTYPE_THERMO_STD = 0x02 # Standard thermopile sensor (no temperature sensor)
SENSOR_SUBTYPE_THERMO_STD_T = 0x12 # Standard thermopile sensor (with temperature sensor)
SENSOR_SUBTYPE_PYRO_ADAPTER = 0x01 # Pyroelectric adapter (no temperature sensor)
SENSOR_SUBTYPE_PYRO_STD = 0x02 # Standard pyroelectric sensor (no temperature sensor)
SENSOR_SUBTYPE_PYRO_STD_T = 0x12 # Standard pyroelectric sensor (with temperature sensor)
TLPM_SENS_FLAG_IS_UNDEFINED = 0x0000 # Undefined sensor
TLPM_SENS_FLAG_IS_POWER = 0x0001 # Power sensor
TLPM_SENS_FLAG_IS_ENERGY = 0x0002 # Energy sensor
TLPM_SENS_FLAG_IS_RESP_SET = 0x0010 # Responsivity settable
TLPM_SENS_FLAG_IS_WAVEL_SET = 0x0020 # Wavelength settable
TLPM_SENS_FLAG_IS_TAU_SET = 0x0040 # Time constant tau settable
TLPM_SENS_FLAG_HAS_TEMP = 0x0100 # Temperature sensor included
TLPM_SENS_XFLAG_AUTORANGE = 0x0001 # can auto range
TLPM_SENS_XFLAG_IS_ADAPTER = 0x0002 # is adapter
TLPM_SENS_XFLAG_IS_WAVEL_SET = 0x0004 # Energy sensor
TLPM_SENS_XFLAG_IS_RESP_SET = 0x0008 # Wavelength settable
TLPM_SENS_XFLAG_IS_ACC_SET = 0x0010 # can set acceleration
TLPM_SENS_XFLAG_IS_BW_SET = 0x0020 # can set bandwidth
TLPM_SENS_XFLAG_DECT_PEAK = 0x0040 # can detect peak
TLPM_SENS_XFLAG_MEAS_FREQ = 0x0080 # can meas frequency
TLPM_SENS_XFLAG_IS_ZERO_SET = 0x0100 # can start zeroing
TLPM_SENS_XFLAG_IS_TAU_SET = 0x0200 # can set tau
TLPM_SENS_XFLAG_MEAS_POS = 0x0400 # can meas position x,y
TLPM_SENS_XFLAG_PHOTOMETRIC = 0x0800 # can meas photometric
TLPM_SENS_XFLAG_HAS_TEMP = 0x1000 # Temperature sensor included
class TLPMX:
def __init__(self, resourceName = None, IDQuery = False, resetDevice = False):
"""
This function initializes the instrument driver session and performs the following initialization actions:
(1) Opens a session to the Default Resource Manager resource and a session to the specified device using the Resource Name.
(2) Performs an identification query on the instrument.
(3) Resets the instrument to a known state.
(4) Sends initialization commands to the instrument.
(5) Returns an instrument handle which is used to distinguish between different sessions of this instrument driver.
Notes:
(1) Each time this function is invoked a unique session is opened.
Args:
resourceName (create_string_buffer)
IDQuery (c_bool):This parameter specifies whether an identification query is performed during the initialization process.
VI_TRUE (1): Do query (default).
VI_FALSE (0): Skip query.
resetDevice (c_bool):This parameter specifies whether the instrument is reset during the initialization process.
VI_TRUE (1) - instrument is reset (default)
VI_FALSE (0) - no reset
"""
if sizeof(c_voidp) == 4:
dll_name = "TLPMX_32.dll"
# dllabspath = os.path.dirname(os.path.abspath(__file__)) + os.path.sep + dll_name
dllabspath = "C:\\Program Files (x86)\\IVI Foundation\\VISA\\WinNT\\Bin\\" + dll_name
self.dll = cdll.LoadLibrary(dllabspath)
else:
dll_name = "TLPMX_64.dll"
# dllabspath = os.path.dirname(os.path.abspath(__file__)) + os.path.sep + dll_name
dllabspath = "C:\\Program Files\\IVI Foundation\\VISA\\Win64\\Bin\\" + dll_name
self.dll = cdll.LoadLibrary(dllabspath)
self.devSession = c_long()
self.devSession.value = 0
if resourceName!= None:
pInvokeResult = self.dll.TLPMX_init(resourceName, IDQuery, resetDevice, byref(self.devSession))
self.__testForError(pInvokeResult)
def __testForError(self, status):
if status < 0:
self.__throwError(status)
return status
def __throwError(self, code):
msg = create_string_buffer(1024)
self.dll.TLPMX_errorMessage(self.devSession, c_int(code), msg)
raise NameError(c_char_p(msg.raw).value)
def open(self, resourceName, IDQuery, resetDevice):
"""
This function initializes the instrument driver session and performs the following initialization actions:
(1) Opens a session to the Default Resource Manager resource and a session to the specified device using the Resource Name.
(2) Performs an identification query on the instrument.
(3) Resets the instrument to a known state.
(4) Sends initialization commands to the instrument.
(5) Returns an instrument handle which is used to distinguish between different sessions of this instrument driver.
Notes:
(1) Each time this function is invoked a unique session is opened.
Args:
resourceName (create_string_buffer)
IDQuery (c_bool):This parameter specifies whether an identification query is performed during the initialization process.
VI_TRUE (1): Do query (default).
VI_FALSE (0): Skip query.
resetDevice (c_bool):This parameter specifies whether the instrument is reset during the initialization process.
VI_TRUE (1) - instrument is reset (default)
VI_FALSE (0) - no reset
Returns:
int: The return value, 0 is for success
"""
self.dll.TLPMX_close(self.devSession)
self.devSession.value = 0
pInvokeResult = self.dll.TLPMX_init(resourceName, IDQuery, resetDevice, byref(self.devSession))
self.__testForError(pInvokeResult)
return pInvokeResult
def initWithEncryption(self, IDQuery, reset, password, pInstr):
"""
This function initializes the instrument driver session and performs the following initialization actions:
(1) Opens a session to the Default Resource Manager resource and a session to the specified device using the Resource Name.
(2) Performs an identification query on the instrument.
(3) Resets the instrument to a known state.
(4) Sends initialization commands to the instrument.
(5) Returns an instrument handle which is used to distinguish between different sessions of this instrument driver.
Notes:
(1) Each time this function is invoked a unique session is opened.
Args:
IDQuery(c_int16) : This parameter specifies whether an identification query is performed during the initialization process.
VI_TRUE (1): Do query (default).
VI_FALSE (0): Skip query.
reset(c_int16) : This parameter specifies whether the instrument is reset during the initialization process.
VI_TRUE (1) - instrument is reset (default)
VI_FALSE (0) - no reset
password(c_char_p) : Password for encryption over ethernet communication.
pInstr(ViPSession use with byref) : This parameter returns an instrument handle that is used in all subsequent calls to distinguish between different sessions of this instrument driver.
Returns:
int: The return value, 0 is for success
"""
pInvokeResult = self.dll.TLPMX_initWithEncryption(self.devSession, IDQuery, reset, password, pInstr)
self.__testForError(pInvokeResult)
return pInvokeResult
def close(self):
"""
This function closes the instrument driver session.
Note: The instrument must be reinitialized to use it again.
Returns:
int: The return value, 0 is for success
"""
pInvokeResult = self.dll.TLPMX_close(self.devSession)
return pInvokeResult
def findRsrc(self, resourceCount):
"""
This function finds all driver compatible devices attached to the PC and returns the number of found devices.
Note:
(1) The function additionally stores information like system name about the found resources internally. This information can be retrieved with further functions from the class, e.g. <Get Resource Description> and :func:`getRsrcInfo`.
(2) To list Ethernet and Bluetooth devices, enable the search for these devices with functions setEnableNetSearch and setEnableBthSearch.
Args:
resourceCount(c_uint32 use with byref) : The number of connected devices that are supported by this driver.
Returns:
int: The return value, 0 is for success
"""
pInvokeResult = self.dll.TLPMX_findRsrc(self.devSession, resourceCount)
self.__testForError(pInvokeResult)
return pInvokeResult
def getRsrcName(self, index, resourceName):
"""
This function gets the resource name string needed to open a device with :func:`init`.
Notes:
(1) The data provided by this function was updated at the last call of :func:`findRsrc`.
Args:
index(c_uint32) : This parameter accepts the index of the device to get the resource descriptor from.
Notes:
(1) The index is zero based. The maximum index to be used here is one less than the number of devices found by the last call of <Find Resources>.
resourceName(create_string_buffer(1024) use with byref) : This parameter returns the resource descriptor. Use this descriptor to specify the device in <Initialize>.
Notes:
(1) The array must contain at least TLPM_BUFFER_SIZE (256) elements ViChar[256].
Returns:
int: The return value, 0 is for success
"""
pInvokeResult = self.dll.TLPMX_getRsrcName(self.devSession, index, resourceName)
self.__testForError(pInvokeResult)
return pInvokeResult
def getRsrcInfo(self, index, modelName, serialNumber, manufacturer, deviceAvailable):
"""
This function gets information about a connected resource.
Notes:
(1) The data provided by this function was updated at the last call of :func:`findRsrc`.
Args:
index(c_uint32) : This parameter accepts the index of the device to get the resource descriptor from.
Notes:
(1) The index is zero based. The maximum index to be used here is one less than the number of devices found by the last call of <Find Resources>.
modelName(create_string_buffer(1024) use with byref) : This parameter returns the model name of the device.
Notes:
(1) The array must contain at least TLPM_BUFFER_SIZE (256) elements ViChar[256].
(2) You may pass VI_NULL if you do not need this parameter.
(3) Serial interfaces over Bluetooth will return the interface name instead of the device model name.
serialNumber(create_string_buffer(1024) use with byref) : This parameter returns the serial number of the device.
Notes:
(1) The array must contain at least TLPM_BUFFER_SIZE (256) elements ViChar[256].
(2) You may pass VI_NULL if you do not need this parameter.
(3) The serial number is not available for serial interfaces over Bluetooth.
manufacturer(create_string_buffer(1024) use with byref) : This parameter returns the manufacturer name of the device.
Notes:
(1) The array must contain at least TLPM_BUFFER_SIZE (256) elements ViChar[256].
(2) You may pass VI_NULL if you do not need this parameter.
(3) The manufacturer name is not available for serial interfaces over Bluetooth.
deviceAvailable(c_int16 use with byref) : Returns the information if the device is available.
Devices that are not available are used by other applications.
Notes:
(1) You may pass VI_NULL if you do not need this parameter.
Returns:
int: The return value, 0 is for success
"""
pInvokeResult = self.dll.TLPMX_getRsrcInfo(self.devSession, index, modelName, serialNumber, manufacturer, deviceAvailable)
self.__testForError(pInvokeResult)
return pInvokeResult
def writeRegister(self, reg, value):
"""
This function writes the content of any writable instrument register. Refer to your instrument's user's manual for more details on status structure registers.
Remarks:
(1) Be aware the condition and the event registers are read only!
Args:
reg(c_int16) : Specifies the register to be used for operation. This parameter can be any of the following constants:
TLPM_REG_SRE (1): Service Request Enable
TLPM_REG_ESE (3): Standard Event Enable
TLPM_REG_OPER_ENAB (6): Operation Event Enable Register
TLPM_REG_OPER_PTR (7): Operation Positive Transition
TLPM_REG_OPER_NTR (8): Operation Negative Transition
TLPM_REG_QUES_ENAB (11): Questionable Event Enable Reg.
TLPM_REG_QUES_PTR (12): Questionable Positive Transition
TLPM_REG_QUES_NTR (13): Questionable Negative Transition
TLPM_REG_MEAS_ENAB (16): Measurement Event Enable Register
TLPM_REG_MEAS_PTR (17): Measurement Positive Transition
TLPM_REG_MEAS_NTR (18): Measurement Negative Transition
TLPM_REG_AUX_ENAB (21): Auxiliary Event Enable Register
TLPM_REG_AUX_PTR (22): Auxiliary Positive Transition
TLPM_REG_AUX_NTR (23): Auxiliary Negative Transition
value(c_int16) : This parameter specifies the new value of the selected register.
These register bits are defined:
STATUS BYTE bits (see IEEE488.2-1992 §11.2)
TLPM_STATBIT_STB_AUX (0x01): Auxiliary summary
TLPM_STATBIT_STB_MEAS (0x02): Device Measurement Summary
TLPM_STATBIT_STB_EAV (0x04): Error available
TLPM_STATBIT_STB_QUES (0x08): Questionable Status Summary
TLPM_STATBIT_STB_MAV (0x10): Message available
TLPM_STATBIT_STB_ESB (0x20): Event Status Bit
TLPM_STATBIT_STB_MSS (0x40): Master summary status
TLPM_STATBIT_STB_OPER (0x80): Operation Status Summary
STANDARD EVENT STATUS REGISTER bits (see IEEE488.2-1992 §11.5.1)
TLPM_STATBIT_ESR_OPC (0x01): Operation complete
TLPM_STATBIT_ESR_RQC (0x02): Request control
TLPM_STATBIT_ESR_QYE (0x04): Query error
TLPM_STATBIT_ESR_DDE (0x08): Device-Specific error
TLPM_STATBIT_ESR_EXE (0x10): Execution error
TLPM_STATBIT_ESR_CME (0x20): Command error
TLPM_STATBIT_ESR_URQ (0x40): User request
TLPM_STATBIT_ESR_PON (0x80): Power on
QUESTIONABLE STATUS REGISTER bits (see SCPI 99.0 §9)
TLPM_STATBIT_QUES_VOLT (0x0001): Questionable voltage measurement
TLPM_STATBIT_QUES_CURR (0x0002): Questionable current measurement
TLPM_STATBIT_QUES_TIME (0x0004): Questionable time measurement
TLPM_STATBIT_QUES_POW (0x0008): Questionable power measurement
TLPM_STATBIT_QUES_TEMP (0x0010): Questionable temperature measurement
TLPM_STATBIT_QUES_FREQ (0x0020): Questionable frequency measurement
TLPM_STATBIT_QUES_PHAS (0x0040): Questionable phase measurement
TLPM_STATBIT_QUES_MOD (0x0080): Questionable modulation measurement
TLPM_STATBIT_QUES_CAL (0x0100): Questionable calibration
TLPM_STATBIT_QUES_ENER (0x0200): Questionable energy measurement
TLPM_STATBIT_QUES_10 (0x0400): Reserved
TLPM_STATBIT_QUES_11 (0x0800): Reserved
TLPM_STATBIT_QUES_12 (0x1000): Reserved
TLPM_STATBIT_QUES_INST (0x2000): Instrument summary
TLPM_STATBIT_QUES_WARN (0x4000): Command warning
TLPM_STATBIT_QUES_15 (0x8000): Reserved
OPERATION STATUS REGISTER bits (see SCPI 99.0 §9)
TLPM_STATBIT_OPER_CAL (0x0001): The instrument is currently performing a calibration.
TLPM_STATBIT_OPER_SETT (0x0002): The instrument is waiting for signals to stabilize for measurements.
TLPM_STATBIT_OPER_RANG (0x0004): The instrument is currently changing its range.
TLPM_STATBIT_OPER_SWE (0x0008): A sweep is in progress.
TLPM_STATBIT_OPER_MEAS (0x0010): The instrument is actively measuring.
TLPM_STATBIT_OPER_TRIG (0x0020): The instrument is in a “wait for trigger” state of the trigger model.
TLPM_STATBIT_OPER_ARM (0x0040): The instrument is in a “wait for arm” state of the trigger model.
TLPM_STATBIT_OPER_CORR (0x0080): The instrument is currently performing a correction (Auto-PID tune).
TLPM_STATBIT_OPER_SENS (0x0100): Optical powermeter sensor connected and operable.
TLPM_STATBIT_OPER_DATA (0x0200): Measurement data ready for fetch.
TLPM_STATBIT_OPER_THAC (0x0400): Thermopile accelerator active.
TLPM_STATBIT_OPER_11 (0x0800): Reserved
TLPM_STATBIT_OPER_12 (0x1000): Reserved
TLPM_STATBIT_OPER_INST (0x2000): One of n multiple logical instruments is reporting OPERational status.
TLPM_STATBIT_OPER_PROG (0x4000): A user-defined programming is currently in the run state.
TLPM_STATBIT_OPER_15 (0x8000): Reserved
Thorlabs defined MEASRUEMENT STATUS REGISTER bits
TLPM_STATBIT_MEAS_0 (0x0001): Reserved
TLPM_STATBIT_MEAS_1 (0x0002): Reserved
TLPM_STATBIT_MEAS_2 (0x0004): Reserved
TLPM_STATBIT_MEAS_3 (0x0008): Reserved
TLPM_STATBIT_MEAS_4 (0x0010): Reserved
TLPM_STATBIT_MEAS_5 (0x0020): Reserved
TLPM_STATBIT_MEAS_6 (0x0040): Reserved
TLPM_STATBIT_MEAS_7 (0x0080): Reserved
TLPM_STATBIT_MEAS_8 (0x0100): Reserved
TLPM_STATBIT_MEAS_9 (0x0200): Reserved
TLPM_STATBIT_MEAS_10 (0x0400): Reserved
TLPM_STATBIT_MEAS_11 (0x0800): Reserved
TLPM_STATBIT_MEAS_12 (0x1000): Reserved
TLPM_STATBIT_MEAS_13 (0x2000): Reserved
TLPM_STATBIT_MEAS_14 (0x4000): Reserved
TLPM_STATBIT_MEAS_15 (0x8000): Reserved
Thorlabs defined Auxiliary STATUS REGISTER bits
TLPM_STATBIT_AUX_NTC (0x0001): Auxiliary NTC temperature sensor connected.
TLPM_STATBIT_AUX_EMM (0x0002): External measurement module connected.
TLPM_STATBIT_AUX_2 (0x0004): Reserved
TLPM_STATBIT_AUX_3 (0x0008): Reserved
TLPM_STATBIT_AUX_EXPS (0x0010): External power supply connected
TLPM_STATBIT_AUX_BATC (0x0020): Battery charging
TLPM_STATBIT_AUX_BATL (0x0040): Battery low
TLPM_STATBIT_AUX_IPS (0x0080): Apple(tm) authentification supported.
TLPM_STATBIT_AUX_IPF (0x0100): Apple(tm) authentification failed.
TLPM_STATBIT_AUX_9 (0x0200): Reserved
TLPM_STATBIT_AUX_10 (0x0400): Reserved
TLPM_STATBIT_AUX_11 (0x0800): Reserved
TLPM_STATBIT_AUX_12 (0x1000): Reserved
TLPM_STATBIT_AUX_13 (0x2000): Reserved
TLPM_STATBIT_AUX_14 (0x4000): Reserved
TLPM_STATBIT_AUX_15 (0x8000): Reserved
Returns:
int: The return value, 0 is for success
"""
pInvokeResult = self.dll.TLPMX_writeRegister(self.devSession, reg, value)
self.__testForError(pInvokeResult)
return pInvokeResult
def readRegister(self, reg, value):
"""
This function reads the content of any readable instrument register. Refer to your instrument's user's manual for more details on status structure registers.
Remarks:
(1) Reading the event register will clear the event bitmask
Args:
reg(c_int16) : Specifies the register to be used for operation. This parameter can be any of the following constants:
TLPM_REG_STB (0): Status Byte Register
TLPM_REG_SRE (1): Service Request Enable
TLPM_REG_ESB (2): Standard Event Status Register
TLPM_REG_ESE (3): Standard Event Enable
TLPM_REG_OPER_COND (4): Operation Condition Register
TLPM_REG_OPER_EVENT (5): Operation Event Register
TLPM_REG_OPER_ENAB (6): Operation Event Enable Register
TLPM_REG_OPER_PTR (7): Operation Positive Transition
TLPM_REG_OPER_NTR (8): Operation Negative Transition
TLPM_REG_QUES_COND (9): Questionable Condition Register
TLPM_REG_QUES_EVENT (10): Questionable Event Register
TLPM_REG_QUES_ENAB (11): Questionable Event Enable Reg.
TLPM_REG_QUES_PTR (12): Questionable Positive Transition
TLPM_REG_QUES_NTR (13): Questionable Negative Transition
TLPM_REG_MEAS_COND (14): Measurement Condition Register
TLPM_REG_MEAS_EVENT (15): Measurement Event Register
TLPM_REG_MEAS_ENAB (16): Measurement Event Enable Register
TLPM_REG_MEAS_PTR (17): Measurement Positive Transition
TLPM_REG_MEAS_NTR (18): Measurement Negative Transition
TLPM_REG_AUX_COND (19): Auxiliary Condition Register
TLPM_REG_AUX_EVENT (20): Auxiliary Event Register
TLPM_REG_AUX_ENAB (21): Auxiliary Event Enable Register
TLPM_REG_AUX_PTR (22): Auxiliary Positive Transition
TLPM_REG_AUX_NTR (23): Auxiliary Negative Transition
value(c_int16 use with byref) : This parameter returns the value of the selected register.
These register bits are defined:
STATUS BYTE bits (see IEEE488.2-1992 §11.2)
TLPM_STATBIT_STB_AUX (0x01): Auxiliary summary
TLPM_STATBIT_STB_MEAS (0x02): Device Measurement Summary
TLPM_STATBIT_STB_EAV (0x04): Error available
TLPM_STATBIT_STB_QUES (0x08): Questionable Status Summary
TLPM_STATBIT_STB_MAV (0x10): Message available
TLPM_STATBIT_STB_ESB (0x20): Event Status Bit
TLPM_STATBIT_STB_MSS (0x40): Master summary status
TLPM_STATBIT_STB_OPER (0x80): Operation Status Summary
STANDARD EVENT STATUS REGISTER bits (see IEEE488.2-1992 §11.5.1)
TLPM_STATBIT_ESR_OPC (0x01): Operation complete
TLPM_STATBIT_ESR_RQC (0x02): Request control
TLPM_STATBIT_ESR_QYE (0x04): Query error
TLPM_STATBIT_ESR_DDE (0x08): Device-Specific error
TLPM_STATBIT_ESR_EXE (0x10): Execution error
TLPM_STATBIT_ESR_CME (0x20): Command error
TLPM_STATBIT_ESR_URQ (0x40): User request
TLPM_STATBIT_ESR_PON (0x80): Power on
QUESTIONABLE STATUS REGISTER bits (see SCPI 99.0 §9)
TLPM_STATBIT_QUES_VOLT (0x0001): Questionable voltage measurement
TLPM_STATBIT_QUES_CURR (0x0002): Questionable current measurement
TLPM_STATBIT_QUES_TIME (0x0004): Questionable time measurement
TLPM_STATBIT_QUES_POW (0x0008): Questionable power measurement
TLPM_STATBIT_QUES_TEMP (0x0010): Questionable temperature measurement
TLPM_STATBIT_QUES_FREQ (0x0020): Questionable frequency measurement
TLPM_STATBIT_QUES_PHAS (0x0040): Questionable phase measurement
TLPM_STATBIT_QUES_MOD (0x0080): Questionable modulation measurement
TLPM_STATBIT_QUES_CAL (0x0100): Questionable calibration
TLPM_STATBIT_QUES_ENER (0x0200): Questionable energy measurement
TLPM_STATBIT_QUES_10 (0x0400): Reserved
TLPM_STATBIT_QUES_11 (0x0800): Reserved
TLPM_STATBIT_QUES_12 (0x1000): Reserved
TLPM_STATBIT_QUES_INST (0x2000): Instrument summary
TLPM_STATBIT_QUES_WARN (0x4000): Command warning
TLPM_STATBIT_QUES_15 (0x8000): Reserved
OPERATION STATUS REGISTER bits (see SCPI 99.0 §9)
TLPM_STATBIT_OPER_CAL (0x0001): The instrument is currently performing a calibration.
TLPM_STATBIT_OPER_SETT (0x0002): The instrument is waiting for signals to stabilize for measurements.
TLPM_STATBIT_OPER_RANG (0x0004): The instrument is currently changing its range.
TLPM_STATBIT_OPER_SWE (0x0008): A sweep is in progress.
TLPM_STATBIT_OPER_MEAS (0x0010): The instrument is actively measuring.
TLPM_STATBIT_OPER_TRIG (0x0020): The instrument is in a “wait for trigger” state of the trigger model.
TLPM_STATBIT_OPER_ARM (0x0040): The instrument is in a “wait for arm” state of the trigger model.
TLPM_STATBIT_OPER_CORR (0x0080): The instrument is currently performing a correction (Auto-PID tune).
TLPM_STATBIT_OPER_SENS (0x0100): Optical powermeter sensor connected and operable.
TLPM_STATBIT_OPER_DATA (0x0200): Measurement data ready for fetch.
TLPM_STATBIT_OPER_THAC (0x0400): Thermopile accelerator active.
TLPM_STATBIT_OPER_11 (0x0800): Reserved
TLPM_STATBIT_OPER_12 (0x1000): Reserved
TLPM_STATBIT_OPER_INST (0x2000): One of n multiple logical instruments is reporting OPERational status.
TLPM_STATBIT_OPER_PROG (0x4000): A user-defined programming is currently in the run state.
TLPM_STATBIT_OPER_15 (0x8000): Reserved
Thorlabs defined MEASRUEMENT STATUS REGISTER bits
TLPM_STATBIT_MEAS_0 (0x0001): Reserved
TLPM_STATBIT_MEAS_1 (0x0002): Reserved
TLPM_STATBIT_MEAS_2 (0x0004): Reserved
TLPM_STATBIT_MEAS_3 (0x0008): Reserved
TLPM_STATBIT_MEAS_4 (0x0010): Reserved
TLPM_STATBIT_MEAS_5 (0x0020): Reserved
TLPM_STATBIT_MEAS_6 (0x0040): Reserved
TLPM_STATBIT_MEAS_7 (0x0080): Reserved
TLPM_STATBIT_MEAS_8 (0x0100): Reserved
TLPM_STATBIT_MEAS_9 (0x0200): Reserved
TLPM_STATBIT_MEAS_10 (0x0400): Reserved
TLPM_STATBIT_MEAS_11 (0x0800): Reserved
TLPM_STATBIT_MEAS_12 (0x1000): Reserved
TLPM_STATBIT_MEAS_13 (0x2000): Reserved
TLPM_STATBIT_MEAS_14 (0x4000): Reserved
TLPM_STATBIT_MEAS_15 (0x8000): Reserved
Thorlabs defined Auxiliary STATUS REGISTER bits
TLPM_STATBIT_AUX_NTC (0x0001): Auxiliary NTC temperature sensor connected.
TLPM_STATBIT_AUX_EMM (0x0002): External measurement module connected.
TLPM_STATBIT_AUX_2 (0x0004): Reserved
TLPM_STATBIT_AUX_3 (0x0008): Reserved
TLPM_STATBIT_AUX_EXPS (0x0010): External power supply connected
TLPM_STATBIT_AUX_BATC (0x0020): Battery charging
TLPM_STATBIT_AUX_BATL (0x0040): Battery low
TLPM_STATBIT_AUX_IPS (0x0080): Apple(tm) authentification supported.
TLPM_STATBIT_AUX_IPF (0x0100): Apple(tm) authentification failed.
TLPM_STATBIT_AUX_9 (0x0200): Reserved
TLPM_STATBIT_AUX_10 (0x0400): Reserved
TLPM_STATBIT_AUX_11 (0x0800): Reserved
TLPM_STATBIT_AUX_12 (0x1000): Reserved
TLPM_STATBIT_AUX_13 (0x2000): Reserved
TLPM_STATBIT_AUX_14 (0x4000): Reserved
TLPM_STATBIT_AUX_15 (0x8000): Reserved
Returns:
int: The return value, 0 is for success
"""
pInvokeResult = self.dll.TLPMX_readRegister(self.devSession, reg, value)
self.__testForError(pInvokeResult)
return pInvokeResult
def presetRegister(self):
"""
This function presets all status registers to default.
Returns:
int: The return value, 0 is for success
"""
pInvokeResult = self.dll.TLPMX_presetRegister(self.devSession)
self.__testForError(pInvokeResult)
return pInvokeResult
def sendNTPRequest(self, timeMode, timeZone, IPAddress):
"""
This function sends a (Network Time Protocol) NTP - Request to given IP address to update date and time of the powermeter automatically using an external time server.
Notes:
(1) Date and time are displayed on instruments screen and are used as timestamp for data saved to memory card.
(2) The function is only available on PM5020
(3) Requires an active Ethernet connection with the route to the requested server.
Args:
timeMode(c_int16) : 0 for wintertime. 1 for summertime
timeZone(c_int16) : Local time zone offset for GMT. Berlin is +1
IPAddress(c_char_p) : IP address of used NTP server. By default PTB server is used.
Returns:
int: The return value, 0 is for success
"""
pInvokeResult = self.dll.TLPMX_sendNTPRequest(self.devSession, timeMode, timeZone, IPAddress)
self.__testForError(pInvokeResult)
return pInvokeResult
def setTime(self, year, month, day, hour, minute, second):
"""
This function sets the system date and time of the powermeter.
Notes:
(1) Date and time are displayed on instruments screen and are used as timestamp for data saved to memory card.
Args:
year(c_int16) : This parameter specifies the actual year in the format yyyy e.g. 2009.
month(c_int16) : This parameter specifies the actual month in the format mm e.g. 01.
day(c_int16) : This parameter specifies the actual day in the format dd e.g. 15.
hour(c_int16) : This parameter specifies the actual hour in the format hh e.g. 14.
minute(c_int16) : This parameter specifies the actual minute in the format mm e.g. 43.
second(c_int16) : This parameter specifies the actual second in the format ss e.g. 50.
Returns:
int: The return value, 0 is for success
"""
pInvokeResult = self.dll.TLPMX_setTime(self.devSession, year, month, day, hour, minute, second)
self.__testForError(pInvokeResult)
return pInvokeResult
def getTime(self, year, month, day, hour, minute, second):
"""
This function returns the system date and time of the powermeter.
Notes:
(1) Date and time are displayed on instruments screen and are used as timestamp for data saved to memory card.
Args:
year(c_int16 use with byref) : This parameter specifies the actual year in the format yyyy.
month(c_int16 use with byref) : This parameter specifies the actual month in the format mm.
day(c_int16 use with byref) : This parameter specifies the actual day in the format dd.
hour(c_int16 use with byref) : This parameter specifies the actual hour in the format hh.
minute(c_int16 use with byref) : This parameter specifies the actual minute in the format mm.
second(c_int16 use with byref) : This parameter specifies the actual second in the format ss.
Returns:
int: The return value, 0 is for success
"""
pInvokeResult = self.dll.TLPMX_getTime(self.devSession, year, month, day, hour, minute, second)
self.__testForError(pInvokeResult)
return pInvokeResult
def setSummertime(self, timeMode):
"""
This function sets the clock to summertime.
Notes:
(1) Date and time are displayed on instruments screen and are used as timestamp for data saved to memory card.
(2) The function is available on PM5020, PM6x, PM100Dx
Args:
timeMode(c_int16)
Returns:
int: The return value, 0 is for success
"""
pInvokeResult = self.dll.TLPMX_setSummertime(self.devSession, timeMode)
self.__testForError(pInvokeResult)
return pInvokeResult
def getSummertime(self, timeMode):
"""
This function returns if the device uses the summertime.
Notes:
(1) Date and time are displayed on instruments screen and are used as timestamp for data saved to memory card.
(2) The function is available on PM5020, PM6x and PM100Dx
Args:
timeMode(c_int16 use with byref)
Returns:
int: The return value, 0 is for success
"""
pInvokeResult = self.dll.TLPMX_getSummertime(self.devSession, timeMode)
self.__testForError(pInvokeResult)
return pInvokeResult
def setLineFrequency(self, lineFrequency):
"""
This function selects the line frequency.
Notes:
(1) The function is only available on PM100A, PM100D, PM100USB, PM200.
Args:
lineFrequency(c_int16) : This parameter specifies the line frequency.
Accepted values:
TLPM_LINE_FREQ_50 (50): 50Hz
TLPM_LINE_FREQ_60 (60): 60Hz
Returns:
int: The return value, 0 is for success
"""
pInvokeResult = self.dll.TLPMX_setLineFrequency(self.devSession, lineFrequency)
self.__testForError(pInvokeResult)
return pInvokeResult
def getLineFrequency(self, lineFrequency):
"""
This function returns the selected line frequency.
Notes:
(1) The function is only available on PM100A, PM100D, PM100USB, PM200.
Args:
lineFrequency(c_int16 use with byref) : This parameter returns the selected line frequency in Hz.
Returns:
int: The return value, 0 is for success
"""
pInvokeResult = self.dll.TLPMX_getLineFrequency(self.devSession, lineFrequency)
self.__testForError(pInvokeResult)
return pInvokeResult
def getBatteryVoltage(self, voltage):
"""
This function is used to obtain the battery voltage readings from the instrument. It optains the latest battery voltage measurement result.
Remarks:
(1) Supported for PM160, PM160T, PM6x, PM100Dx
(2) if USB cable connected: this function will obtain the loading voltage. Only with USB cable disconnected (Bluetooth connection) the actual battery voltage can be read.
Args:
voltage(c_double use with byref) : This parameter returns the battery voltage in volts [V].
Returns:
int: The return value, 0 is for success
"""
pInvokeResult = self.dll.TLPMX_getBatteryVoltage(self.devSession, voltage)
self.__testForError(pInvokeResult)
return pInvokeResult
def setDispBrightness(self, val):
"""
This function sets the display brightness.
Args:
val(c_double) : This parameter specifies the display brightness.
Range : 0.0 .. 1.0
Default : 1.0
Returns:
int: The return value, 0 is for success
"""
pInvokeResult = self.dll.TLPMX_setDispBrightness(self.devSession, val)
self.__testForError(pInvokeResult)
return pInvokeResult
def getDispBrightness(self, pVal):
"""
This function returns the display brightness.
Args:
pVal(c_double use with byref) : This parameter returns the display brightness. Value range is 0.0 to 1.0.
Returns:
int: The return value, 0 is for success
"""
pInvokeResult = self.dll.TLPMX_getDispBrightness(self.devSession, pVal)
self.__testForError(pInvokeResult)
return pInvokeResult