-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInitialization.py
More file actions
69 lines (48 loc) · 2.21 KB
/
Initialization.py
File metadata and controls
69 lines (48 loc) · 2.21 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
# Various serial numbers and things
from Utils import timeout
import Settings
def fullInitialization():
"""
Determine if the TLBP2 device is available and ready to be used
"""
print('='*50)
print(' '*15 + 'TLBP2 INITIALIZATION')
print('='*50)
print("Howdy!\n")
print("This procedure will ensure that the Thorlabs Beam Profiler is ready to be used with this library" +
print("\nThe library will require that you have .NET Desktop Runtime installed, as it runs a C# server in the" +
"\nbackground to control the beam profiler:")
print(' '*5 + "https://dotnet.microsoft.com/download/dotnet/3.1")
print(' '*5 + 'Even if you run a 64-bit system, you will need to install the x86 .NET Desktop Runtime!')
while True:
try:
print("Attempting to connect to the beam profiler...", end='')
import TLBP2Control
bpDevice = TLBP2Control.TLBP2()
status = bpDevice.connect()
# Measure just to make sure it doesn't throw an error
measure = bpDevice.getMeasurement()
if status == 0:
print('connection successful!')
else:
raise Exception()
bpDevice.disconnect()
break
except:
print('connection failed!')
print('\nSince the beam profiler could not be found, please follow these diagnostic steps:')
print(' '*5 + '1. Make sure that the beam profiler is plugged into the computer')
print(' '*5 + '2. Make sure that the beam profiler is detected by the manufacturer software:')
print(' '*10 + 'https://www.thorlabs.com/software_pages/ViewSoftwarePage.cfm?Code=Beam')
print('\nOnce you have gone through these steps, you may type \'retry\' to attempt connection again' +
'\nor \'exit\' to exit the initialization procedure.')
print('>>> ', end='')
key = input()
if key == 'retry':
continue
elif key == 'exit':
return
print('Initialization complete!')
# So that the file can be run from the command line
if __name__ == "__main__":
fullInitialization()