Skip to content

Commit

Permalink
Update ThorlabsPM100.py
Browse files Browse the repository at this point in the history
Added Conversionfactor and create Port properties
  • Loading branch information
felix92 authored Jul 17, 2020
1 parent 29b5bcd commit ac487bf
Showing 1 changed file with 38 additions and 24 deletions.
62 changes: 38 additions & 24 deletions ThorlabsPM100.py
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()

0 comments on commit ac487bf

Please sign in to comment.