AOTF controller

This controller (aa_modd18012.py) supplies one class with several methods to communicate with the AOTF driver from AA optoelectronics model: 1MODD18012_0074

copyright:2020by Hyperion Authors, see AUTHORS for more details.
license:BSD, see LICENSE for more details.
class hyperion.controller.aa.aa_modd18012.AaModd18012(settings)

controller class for the driver aa_mod18012 from AA optoelelectronics. This class has all the methods to communicate using serial.

NOTE: Our model has different ranges of frequency (see data sheet)
Line 1 to 6: 82-151 MHz (this drives short wavelengths) Line 7 to 8: 68-82 MHz (this drives long wavelengths)
Parameters:settings (dict) – this includes all the settings needed to connect to the device in question.
blanking(state, mode)

Define the blanking state. If True (False), all channels are on (off). It can be set to ‘internal’ or ‘external’, where external means that the modulation voltage of the channel will be used to define the channel output.

Parameters:
  • state (logical) – State of the blanking
  • mode (string) – external or internal. external is used to follow TTL external modulation
check_channel(channel)

Method to check the key of the channel is correct

Parameters:channel (int) – channel to use
Returns:channel
Return type:int
check_freq(channel, value)

Checks if the frequency asked is valid for the desired channel. Specific of our device. If it is not, it gives the right value.

Parameters:
  • channel (int) – channel to use (can be from 1 to 8 inclusive)
  • value (float) – Frequency value in MHz. If 0 is given, the DEFAULTS[‘frequency’] value is used for the corresponding channel.
Returns:

The channel and value back unless an error.

Return type:

int, new_channel

check_power(value)

checks if the power is in the range supported by the device. Range = (0 , 22) dBm. Gives an error if value is not in the range

Parameters:value (float) – power value in dBm
enable(channel, state)

Enable single channels.

Parameters:
  • channel – channel to use (can be from 1 to 8 inclusive)
  • state (logical) – true for on and false for off
Type:

channel: int

Returns:

state

Return type:

logical

finalize()

Closes the connection to the device

get_states()

Gets the status of all the channels

Returns:message from the driver describing all channel state
Return type:str
initialize()

Initialize the device. It actually connects to the device.

query(message)

Writes and Reads the answer from the device. Basically this method is a write followed by a read with a 10ms wait in the middle.

Parameters:message (string) – Message to be passed to the serial port.
Returns:The reply from the device.
Return type:string
read()

Reads message from the device. It reads until the buffer is clean.

Returns:The messages in the buffer of the device. It removes the end of line characters.
Return type:string
set_all(channel, freq, power, state, mode)

Sets Frequency, power, and state of channel.

Parameters:
  • channel (int) – channel to use (can be from 1 to 8 inclusive)
  • freq (float) – Frequency value in MHz (range depends on the channel)
  • power (float) – Power to set in dBm (0 to 22 )
  • state (logical) – true for on and false for off
  • mode (string) – ‘internal’ or ‘external’
set_frequency(channel, freq)

This function sets RF frequency for a given channel. The device has 8 channels. Channels 1-6 work in the range 82-151 MHz Channels 7-8 work in the range 68-82 MHz

Parameters:
  • channel (int) – channel to set the frequency.
  • freq (float) – Frequency to set in MHz (it has accepted ranges that depends on the channel)
set_operating_mode(channel, mode)

Select the operating mode. Can be internal or external.

Parameters:
  • channel (int) – channel number
  • mode (str) – ‘internal’ or ‘external’
set_powerdb(channel, value)

Power for a given channel (in dBm). Range: (0,22) dBm

Parameters:
  • channel (int) – channel to use
  • value (float) – power value in dBm
store()

stores in the internal memory the values

write(message)

Sends the message to the device.

Parameters:message (string) – message to send to the device.
Returns:the response from the device.
Return type:string
class hyperion.controller.aa.aa_modd18012.AaModd18012Dummy(settings={'dummy': True, 'port': 'COM00'})

This is the dummy controller for the AaModd18012. The idea is to load this class instead of the real one to do testing of higher level functions without the need of the real device to be connected or working.

The logic is that this dummy device will respond as the real device would, with the correct type and size of information is expected.

This class inherits from the real device and the idea is to re-write only the init, the write and the read, so all the other functions remain the same and functioning.

The specific way to achieve this will be different for every device, so it has to be done separately.

To do so, we use a yaml file that tells the dummy class what are the properties of the device. For example, one property for the LCC25 is voltage1, which is the voltage for channel 1. Then from this you can build 2 commands: voltage1? to ask what is the value and voltage1=1 to set it to the value 1. So we build a command list using the CHAR ? and = for each of this properties.

load_properties()

This method loads a yaml file with a dictionary with the available properties for the AaModd18012 and some defaults values. This dictionary is saved in properties and will be modified when a variable is writen, so the dummy device will respond with the previously set value.

read()

Dummy read. Reads the response buffer

write(msg)

Dummy write. It will compare the msg with the COMMANDS

Parameters:msg (str) – Message to write