-
Notifications
You must be signed in to change notification settings - Fork 26
add function to change obis cw or modulated #1438
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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) | ||
|
|
||
|
|
@@ -138,6 +141,35 @@ def SetPower(self, power): | |
| def GetPower(self): | ||
| return self.power | ||
|
|
||
| def SetOpMode(self,mode): | ||
| """ | ||
| mode = 0: CWP, CW with constant power | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. 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. |
||
| 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() | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
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.