add function to change obis cw or modulated#1438
Conversation
| def GetPower(self): | ||
| return self.power | ||
|
|
||
| def SetOpMode(self,mode): |
There was a problem hiding this comment.
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.
| def SetOpMode(self,mode): | |
| def set_obis_operating_mode(self,mode): |
|
|
||
| def SetOpMode(self,mode): | ||
| """ | ||
| mode = 0: CWP, CW with constant power |
There was a problem hiding this comment.
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 codewith
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.
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.