A python library for controlling ITLA and microITLA devices.
Project description
pytla
pytla the Python (Integrable) Tunable Laser Assembly library!
This is meant to be an open source and relatively user friendly way to interact
with Integrable Tubable Laser Assembly lasers.
The pytla package provides a base class ITLA
that can be extended for specific
manufacturer requirements with another yaml register file to specify the new registers.
Current Specs Followed
- OIF-ITLA-MSA-01.3.
- This communication scheme supports microITLA 1.1 devices as well.
- OIF-ITLA-MSA-01.2.
- Some older devices still adhere to the 1.2 standard. These can be accessed
by setting
version='1.2
parameter on ITLA object initialization. Example below. - If you are receiving unexpected execution errors on register functions like
_fcf3
it is likely you need to useversion='1.2'
.
- Some older devices still adhere to the 1.2 standard. These can be accessed
by setting
Status
This is very much a work in progress. Use at your own risk. I would call this pre-alpha but most functionality exists and we use it at SpectrumLab.
Hidden functions for each register (names the same as each register but in lowercase) are available. Some registers still don't have user friendly functions defined for them.
It would be nice if we could include documentation for the hidden register functions for each class in the pytla docs.
Examples
default use (with MSA-01.3 lasers)
# import, initialize, and connect to laser
import itla
import time
from itla.itla_errors import CPExcpetion
laser = itla.ITLA('/dev/ttyUSB0', 9600)
laser.connect()
# Set the frequency to 193.560 THz
laser.set_frequency(193.560)
# Set the power to 10 dBm
laser.set_power(10)
# enable the laser
# enabling takes some time so a CPExcpetion will be thrown
# It is necessary to catch this explicitly so the user
# doesnt continue on without explicitly handling this time delay
# (at least until we implement checking the pending bit in nop)
try:
laser.enable()
except CPException:
time.sleep(30)
More info about features available currently can be found in pytla docs.
version selection
You can also select the 1.2 spec if your laser does not yet support 1.3.
This is as simple as setting version
in initialization of your ITLA
object.
# import, initialize, and connect to laser
import itla
import time
from itla.itla_errors import CPExcpetion
laser = itla.ITLA('/dev/ttyUSB0', 9600, version='1.2')
laser.connect()
# Set the frequency to 193.560 THz
laser.set_frequency(193.560)
# Set the power to 10 dBm
laser.set_power(10)
# enable the laser
# enable the laser
# enabling takes some time so a CPExcpetion will be thrown
# It is necessary to catch this explicitly so the user
# doesnt continue on without explicitly handling this time delay
# (at least until we implement checking the pending bit in nop)
try:
laser.enable()
except CPException:
time.sleep(30)
Currently supported options under version
-
version='1.3'
(OIF-ITLA-MSA-01.3) -
version='1.2'
(OIF-ITLA-MSA-01.2)
Pure Photonics
We have also implemented a class for PurePhotonics lasers as an example of how easy it can be for manufacturers to extend this library to control their own ITLA based lasers.
# import, initialize, and connect to laser
import itla
import time
from itla.itla_errors import CPExcpetion
pplaser = itla.PPLaser('/dev/ttyUSB0')
pplaser.connect()
# Set the frequency to 193.560 THz
laser.set_frequency(193.560)
# Set the power to 10 dBm
laser.set_power(10)
# enable the laser
# enable the laser
# enabling takes some time so a CPExcpetion will be thrown
# It is necessary to catch this explicitly so the user
# doesnt continue on without explicitly handling this time delay
# (at least until we implement checking the pending bit in nop)
try:
laser.enable()
except CPException:
time.sleep(30)
laser.whispermode()
Paradigm
The basic paradigm we have used for implementing this library is one in which functions are created for all registers based on a yaml file specifying and describing each register. These are all implemented as hidden functions with a single underscore.
For simplicity all ITLA register functions are named as follows: assuming
we have some register named REGISTER
in the ITLA documentation the
corresponding function would be _register()
.
For Manufacturers
If you would like to have a specific class available for your particular type of laser please create a yaml file as specified below and submit it for inclusion. Please also provide any details for the order of operations required to enable or activate your features.
This library was designed to be simple to extend for implementing manufacturer specific registers and functions. The first step is to create a yaml file containing all of the additional registers your laser will utilize. Each entry should have the following format.
RegisterName:
register: 0x00
fnname: registername
description: >
Here we provide a description of this particular register for documentation
purposes. It is best to format this the same way you would a docstring as it
will be read as a docstring.
readonly: [true/false]
AEA: [true/false]
signed: [true/false]
MYREGISTER:
register: 0xFE
fnname: myregister
description: >
This is my very own register. I can write a signed integer to it or read it back.
readonly: true
AEA: false
signed: true
You can name your register whatever you'd like and name the function for accessing it to whatever you'd like as long as it is acceptable for python. Generally a best practice is to make the register function name all lowercase and change dashes to underscores. The register value must be numeric. It can be base 10 but best practice is hex values.
Assuming you have installed the pytla package and your yaml register
file is in the same folder as the file with the MyLaser
class you can create a
class with hidden functions for your registers implemented in addition to
the basic ITLA1.3 registers and wrapper functions.
Realistically, unless you are OIF and you are defining a 1.4 or 2.0 spec,
you should not need to write a class that depends directly on ITLABase
.
Instead, you are likely adding functionality to the 1.3 (or older) standard.
from itla.itla13 import ITLA13
class MyLaser(ITLA13):
def __init__(self, port, baudrate=9600):
register_files = ['myregisters.yaml']
super().__init__(port, baudrate=baudrate, register_files=register_files)
def myfunction(self, data=None):
'''This function either writes an integer to register 0xFE or reads an
integer from 0xFE
'''
if data is not None:
response = self._myregister()
elif type(data) is int:
response = self._myregister(data)
else
raise TypeError("Must be an int!")
return int.from_bytes(response, 'big', signed=True)
Acknowlegements
This work was done as a part of projects for
- Montana State University
- Spectrum Lab
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file pytla-0.1.0.tar.gz
.
File metadata
- Download URL: pytla-0.1.0.tar.gz
- Upload date:
- Size: 25.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a7bbe0c0b4fa4b03bf39bddc05906bd07d2b06066bc40ba7d4b2c24f8dfb4d7e |
|
MD5 | ffda024ae899aa32f66bff76b8e58881 |
|
BLAKE2b-256 | 99732a9ffe927e86d57631d1fea63e846bbbc56016fa1ec88793b8997390c0a9 |
File details
Details for the file pytla-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: pytla-0.1.0-py3-none-any.whl
- Upload date:
- Size: 32.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3efb8e9b71466e49226ba7db17a12591f15a525bf8f3e95490caebe1eb6c61cc |
|
MD5 | ec007fcf576a82c5539b94e51ac7b833 |
|
BLAKE2b-256 | bc6b94cb0aae18dd5f44ba8b4d0ba07c4fc7e65573818ed8527e7f989840c20b |