Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 34 additions & 2 deletions PYME/Acquire/Hardware/Coherent/OBIS.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,15 @@ def __init__(self, serial_port='COM8', turn_on=False, name='OBIS', init_power=5,


time.sleep(1)


self.is_on = False
self.power = 0
self.SetPower(init_power)
self.mode=0
self.SetOpMode(self.mode)
self.MIN_POWER = 1e3 * float(self.query(b'SOUR:POW:LIM:LOW?\r\n', lines_expected=1)[0])
self.MAX_POWER = 1e3 * float(self.query(b'SOUR:POW:LIM:HIGH?\r\n', lines_expected=1)[0])
self.is_on = False


# self.query(b'SYST:COMM:HAND OFF\r\n', lines_expected=0)

Expand Down Expand Up @@ -138,6 +141,35 @@ def SetPower(self, power):
def GetPower(self):
return self.power

def SetOpMode(self,mode):

@David-Baddeley David-Baddeley Oct 15, 2023

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this something we might encounter on other lasers? Do we need operating mode as part of the general laser interface? I don't think we need to answer those yet, but should probably put a TODO with those questions in the comments. In the interim, I think leaving this as an OBIS specific command should be fine, but it might be worth signalling that it is OBIS specific in the method name - e.g.

Suggested change
def SetOpMode(self,mode):
def set_obis_operating_mode(self,mode):

"""
mode = 0: CWP, CW with constant power

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Arbitrary integer constants doesn't make for very readable code (where this is being called). Having class level constants, e.g. CoherentOBISLaser.OBIS_MODE_CW is better style / more readable in calling code ...

compare:

my_laser.SetOpMode(2) # Doesn't convey what this is doing without looking at the laser code

with

m_laser.SetOpMode(my_laser.OBIS_MODE_ANALOG_MOD)

The other pythonic way of doing it would be to take a string, e.g. 'CW', 'ANALOG_MOD', etc ... and do the translation into mode numbers in the method.

mode = 1: digital modulation
mode = 2: analog modulation

LX model can change while on, LS must turn off first - here just turning off first for all

"""
if self.is_on:
turn_back_on=True
else:
turn_back_on=False

self.TurnOff()

if mode==0:
self.query(b'SOUR:AM:INT CWP\r\n',lines_expected=0)
elif mode==1:
self.query(b'SOUR:AM:EXT DIG\r\n',lines_expected=0)
elif mode==2:
self.query(b'SOUR:AM:EXT ANAL\r\n',lines_expected=0)
else:
print('invalid mode')
self.opMode=mode

if turn_back_on:
self.TurnOn()

def Close(self):
print('Shutting down %s' % self.name)
self.TurnOff()
Expand Down