Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def get_laser_state(self):
""" Get laser operation state
@return LaserState: laser state
"""
if self.psu == PSUTypes.SMD6000:
state = self.inst.query('STAT?')
else:
state = self.inst.query('STATUS?')
if 'ENABLED' in state:
return LaserState.ON
elif 'DISABLED' in state:
return LaserState.OFF
else:
return LaserState.UNKNOWN
def get_laser_state(self):
""" Get laser state.
@return LaserState: current laser state
"""
diode = int(self.inst.query('?D'))
state = self.inst.query('?F')
if state in ('SYS ILK', 'KEY ILK'):
return LaserState.LOCKED
elif state == 'SYSTEM OK':
if diode == 1:
return LaserState.ON
elif diode == 0:
return LaserState.OFF
else:
return LaserState.UNKNOWN
else:
return LaserState.UNKNOWN
def set_laser_state(self, status):
""" Set laser state
@param LaserState status: desited laser state
@return LaserState: actual laser state
"""
actstat = self.get_laser_state()
if actstat != status:
if status == LaserState.ON:
self.inst.query('ON')
elif status == LaserState.OFF:
self.inst.query('OFF')
return self.get_laser_state()
def set_laser_state(self, status):
""" Set desited laser state.
@param LaserState status: desired laser state
@return LaserState: actual laser state
"""
# TODO: this is big. cannot be called without having LaserState,
# which is only defined in the simple laser interface.
# I think this shoudl be a private method.
actstat = self.get_laser_state()
if actstat != status:
if status == LaserState.ON:
self._communicate('SOUR:AM:STAT ON')
#return self.get_laser_state()
elif status == LaserState.OFF:
self._communicate('SOUR:AM:STAT OFF')
#return self.get_laser_state()
return self.get_laser_state()
def on(self):
""" Turn laser on.
@return LaserState: actual laser state
"""
return self.set_laser_state(LaserState.ON)
def get_laser_state(self):
""" Get laser operation state
@return LaserState: laser state
"""
if self.psu == PSUTypes.SMD6000:
state = self.inst.query('STAT?')
else:
state = self.inst.query('STATUS?')
if 'ENABLED' in state:
return LaserState.ON
elif 'DISABLED' in state:
return LaserState.OFF
else:
return LaserState.UNKNOWN
def on(self):
""" Turn on laser.
@return LaserState: actual laser state
"""
return self.set_laser_state(LaserState.ON)
def get_laser_state(self):
""" Get laser state.
@return LaserState: current laser state
"""
diode = int(self.inst.query('?D'))
state = self.inst.query('?F')
if state in ('SYS ILK', 'KEY ILK'):
return LaserState.LOCKED
elif state == 'SYSTEM OK':
if diode == 1:
return LaserState.ON
elif diode == 0:
return LaserState.OFF
else:
return LaserState.UNKNOWN
else:
return LaserState.UNKNOWN