-
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.
- Loading branch information
Showing
7 changed files
with
181 additions
and
111 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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
__pycache__/ | ||
.DS_Store | ||
.vscode | ||
site/ | ||
|
||
# Distribution / packaging | ||
bin/ | ||
build/ | ||
develop-eggs/ | ||
dist/ | ||
eggs/ | ||
lib/ | ||
lib64/ | ||
parts/ | ||
sdist/ | ||
var/ | ||
*.egg-info/ | ||
.installed.cfg | ||
*.egg |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from setuptools import setup, find_packages | ||
|
||
setup( | ||
name="tangods_thorlabspm100", | ||
version="0.0.1", | ||
description="Tango Device for ThorlabsPM100", | ||
author="Daniel Schick", | ||
author_email="dschick@mbi-berlin.de", | ||
python_requires=">=3.6", | ||
entry_points={"console_scripts": ["ThorlabsPM100 = tangods_thorlabspm100:main"]}, | ||
license="MIT", | ||
packages=["tangods_thorlabspm100"], | ||
install_requires=[ | ||
"pytango", | ||
"ThorlabsPM100", | ||
], | ||
url="https://github.com/MBI-Div-b/pytango-ThorlabsPM100", | ||
keywords=[ | ||
"tango device", | ||
"tango", | ||
"pytango", | ||
"thorlabsPM100" | ||
], | ||
) |
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 |
---|---|---|
@@ -0,0 +1,126 @@ | ||
#!/usr/bin/python3 -u | ||
|
||
from ThorlabsPM100 import ThorlabsPM100 as tlpm100 | ||
from ThorlabsPM100 import USBTMC | ||
|
||
from tango import AttrQuality, AttrWriteType, DispLevel, DevState, DebugIt | ||
from tango.server import Device, attribute, command, pipe, device_property | ||
|
||
|
||
class ThorlabsPM100(Device): | ||
Port = device_property( | ||
dtype="str", | ||
default_value="/dev/ttyTLPM100", | ||
) | ||
|
||
sn = attribute( | ||
label="SN", dtype="str", access=AttrWriteType.READ, doc="Sensor serial number" | ||
) | ||
|
||
model = attribute( | ||
label="Model", dtype="str", access=AttrWriteType.READ, doc="Sensor model" | ||
) | ||
|
||
wavelength = attribute( | ||
label="Wavelength", | ||
dtype="float", | ||
display_level=DispLevel.OPERATOR, | ||
access=AttrWriteType.READ_WRITE, | ||
doc="Correction wavelength", | ||
) | ||
|
||
power = attribute( | ||
label="Power", | ||
dtype="float", | ||
format="%8.3f", | ||
display_level=DispLevel.OPERATOR, | ||
access=AttrWriteType.READ, | ||
doc="Measured power", | ||
) | ||
|
||
conversion = attribute( | ||
label="Conversion factor", | ||
dtype="float", | ||
format="%6.3e", | ||
display_level=DispLevel.OPERATOR, | ||
access=AttrWriteType.READ_WRITE, | ||
doc="Conversion factor", | ||
memorized=True, | ||
hw_memorized=True, | ||
) | ||
|
||
auto_range = attribute( | ||
label="Auto range", | ||
dtype="bool", | ||
display_level=DispLevel.OPERATOR, | ||
access=AttrWriteType.READ_WRITE, | ||
) | ||
|
||
upper_range = attribute( | ||
label="Range", | ||
dtype="float", | ||
format="%6.3e", | ||
display_level=DispLevel.OPERATOR, | ||
access=AttrWriteType.READ_WRITE, | ||
) | ||
|
||
def init_device(self): | ||
Device.init_device(self) | ||
self.set_state(DevState.INIT) | ||
|
||
try: | ||
self.info_stream("Connecting on Port: {:s}".format(self.Port)) | ||
self.inst = USBTMC(device=self.Port) | ||
self.power_meter = tlpm100(inst=self.inst) | ||
self.set_state(DevState.ON) | ||
idn = self.power_meter.system.sensor.idn.split(",") | ||
self.__model = idn[0] | ||
self.__sn = idn[1] | ||
self.info_stream( | ||
"Connected to {:s} with SN: {:s}".format(self.__model, self.__sn) | ||
) | ||
except: | ||
self.info_stream("Not able to connect on Port: {:s}".format(self.Port)) | ||
self.set_state(DevState.OFF) | ||
|
||
self.__conversion_factor = 1.0 | ||
|
||
def read_sn(self): | ||
return self.__sn | ||
|
||
def read_model(self): | ||
return self.__model | ||
|
||
def read_wavelength(self): | ||
return self.power_meter.sense.correction.wavelength | ||
|
||
def write_wavelength(self, value): | ||
self.wavelength = value | ||
self.power_meter.sense.correction.wavelength = value | ||
|
||
def read_auto_range(self): | ||
return bool(self.power_meter.sense.power.dc.range.auto) | ||
|
||
def write_auto_range(self, value): | ||
self.power_meter.sense.power.dc.range.auto = int(value) | ||
|
||
def read_upper_range(self): | ||
return float(self.power_meter.sense.power.dc.range.upper) | ||
|
||
def write_upper_range(self, value): | ||
self.power_meter.sense.power.dc.range.upper = value | ||
|
||
def read_conversion(self): | ||
return self.__conversion_factor | ||
|
||
def write_conversion(self, value): | ||
self.__conversion_factor = value | ||
|
||
def read_power(self): | ||
self.debug_stream("read power") | ||
power = self.power_meter.read | ||
return float(power * self.__conversion_factor) | ||
|
||
|
||
if __name__ == "__main__": | ||
ThorlabsPM100.run_server() |
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
from .ThorlabsPM100Tango import ThorlabsPM100 | ||
|
||
|
||
def main(): | ||
import sys | ||
import tango.server | ||
|
||
args = ["ThorlabsPM100"] + sys.argv[1:] | ||
tango.server.run((ThorlabsPM100,), args=args) |
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from . import main | ||
|
||
main() |