-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathLaserController.py
More file actions
55 lines (39 loc) · 1.58 KB
/
LaserController.py
File metadata and controls
55 lines (39 loc) · 1.58 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
import InstrumentController
import logging
# Class for controlling the Laser Controller
# Inherits from InstrumentController
class LaserController(InstrumentController.InstrumentController):
def __init__(self, resource_manager, resource_address):
super().__init__(resource_manager, resource_address)
# Turns the laser on
def laser_on(self):
self.send_command(':LASER ON')
# Turns the laser off
def laser_off(self):
self.send_command(':LASER OFF')
# Sets the current in mA
def set_current(self, current):
# Convert the current value from mA to A and format it in scientific notation
current_in_A = "{:.2e}".format(int(current) * 10**-3)
self.send_command(f':ILD:SET {current_in_A}')
#logging.info(f"Current set to {current_in_A} A")
# Gets the current in mA
def get_current(self):
current_in_A = self.query(':ILD:ACT?')
current_in_mA = float(current_in_A) * 1000
return current_in_mA
def get_min_current(self):
return self.query(':ILD:MIN?')
def get_max_current(self):
return self.query(':ILD:MAX?')
# Sets the thermistor resistance in Ohms
def set_thm_res(self, res):
self.send_command(f':RESI:SET {res}')
def get_thm_res(self):
return self.query(':RESI:ACT?')
def raise_current(self, amount):
current = self.get_current()
self.set_current(current + amount)
def lower_current(self, amount):
current = self.get_current()
self.set_current(current - amount)