-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Conversionfactor and create Port properties
- Loading branch information
Showing
1 changed file
with
38 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,61 @@ | ||
#!/usr/bin/env python3 | ||
# -*- coding: utf-8 -*- | ||
|
||
from ThorlabsPM100 import ThorlabsPM100, USBTMC | ||
|
||
# Copyright (C) DATE MBI-Division-B | ||
# MIT License, refer to LICENSE file | ||
# Author: / Email: (set year in DATE above please) | ||
from tango import AttrQuality, AttrWriteType, DispLevel, DevState, DebugIt | ||
from tango.server import Device, attribute, command, pipe, device_property | ||
|
||
from ThorlabsPM100 import ThorlabsPM100, USBTMC | ||
class ThorlabsPM100Tango(Device): | ||
|
||
from tango import AttrWriteType, DispLevel, DevState | ||
from tango.server import Device, attribute | ||
Port = device_property( | ||
dtype="str", | ||
default_value="/dev/usbtmc0", | ||
) | ||
|
||
wavelength = attribute(label="Wavelength (nm)", dtype=float, | ||
display_level=DispLevel.OPERATOR, | ||
access=AttrWriteType.READ_WRITE, | ||
doc="Correction wavelength") | ||
|
||
class ThorlabsPM100TDS(Device): | ||
power = attribute(label="Power (W)", dtype=float, | ||
display_level=DispLevel.OPERATOR, | ||
access=AttrWriteType.READ, | ||
doc="Measured power") | ||
|
||
wavelength = attribute(label="Wavelength (nm)", | ||
dtype=float, | ||
display_level=DispLevel.OPERATOR, | ||
access=AttrWriteType.READ_WRITE, | ||
doc="Correction wavelength") | ||
conversion = attribute(label="Conversionfactor", dtype=float, | ||
display_level=DispLevel.OPERATOR, | ||
access=AttrWriteType.READ_WRITE, | ||
doc="Conversionfactor", | ||
memorized=True, | ||
hw_memorized=True,) | ||
|
||
power = attribute(label="Power (W)", | ||
dtype=float, | ||
display_level=DispLevel.OPERATOR, | ||
access=AttrWriteType.READ, | ||
doc="Measured power") | ||
|
||
def init_device(self): | ||
Device.init_device(self) | ||
self.inst = USBTMC(device="/dev/usbtmc0") | ||
self.inst = USBTMC(device=self.Port) | ||
self.power_meter = ThorlabsPM100(inst=self.inst) | ||
self._conversion_factor = 1.0 | ||
self.set_state(DevState.ON) | ||
|
||
def read_wavelength(self): | ||
return self.power_meter.sense.correction.wavelength | ||
|
||
def write_wavelength(self, wav): | ||
self.wavelength = wav | ||
self.power_meter.sense.correction.wavelength = wav | ||
|
||
def read_conversion(self): | ||
return self._conversion_factor | ||
|
||
def write_conversion(self, value): | ||
self._conversion_factor = value | ||
|
||
def read_power(self): | ||
return self.power_meter.read | ||
self.debug_stream('read power') | ||
power = self.power_meter.read | ||
return power * self._conversion_factor | ||
|
||
def read_Test(self): | ||
return self.Test | ||
|
||
|
||
if __name__ == "__main__": | ||
ThorlabsPM100TDS.run_server() | ||
ThorlabsPM100Tango.run_server() |