Skip to content

add function to change obis cw or modulated#1438

Open
d-perez-1 wants to merge 1 commit into
python-microscopy:masterfrom
d-perez-1:op_mode_obis
Open

add function to change obis cw or modulated#1438
d-perez-1 wants to merge 1 commit into
python-microscopy:masterfrom
d-perez-1:op_mode_obis

Conversation

@d-perez-1
Copy link
Copy Markdown

Is this a bugfix or an enhancement?
Enhancement

Proposed changes:
Add function to select operation mode for obis lasers. Choose between CW power, digital, and analogue modulation. Tested and works for USB connection to controller for 594 (LS) and 405 (LX) Obis.

def GetPower(self):
return self.power

def SetOpMode(self,mode):
Copy link
Copy Markdown
Contributor

@David-Baddeley David-Baddeley Oct 15, 2023

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):


def SetOpMode(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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants