msl.equipment.resources.thorlabs.kinesis.kcube_solenoid module

This module provides all the functionality required to control a KCube Solenoid (KSC101).

class msl.equipment.resources.thorlabs.kinesis.kcube_solenoid.KCubeSolenoid(record)[source]

Bases: MotionControl

A wrapper around Thorlabs.MotionControl.KCube.Solenoid.dll.

The properties for a KCubeSolenoid connection supports the following key-value pairs in the Connections Database:

'device_name': str, the device name found in ThorlabsDefaultSettings.xml [default: None]

Do not instantiate this class directly. Use the connect() method to connect to the equipment.

Parameters

record (EquipmentRecord) – A record from an Equipment-Register Database.

check_connection()[source]

Check connection.

Returns

bool – Whether the USB is listed by the FTDI controller.

clear_message_queue()[source]

Clears the device message queue.

close()[source]

Disconnect and close the device.

enable_last_msg_timer(enable, msg_timeout=0)[source]

Enables the last message monitoring timer.

This can be used to determine whether communications with the device is still good.

Parameters
  • enable (bool) – True to enable monitoring otherwise False to disable.

  • msg_timeout (int) – The last message error timeout in ms. Set to 0 to disable.

get_cycle_params()[source]

Gets the cycle parameters.

Returns

  • int – The On Time parameter. Range 250 to 100,000,000 in steps of 1 milliseconds (0.250s to 10,000s).

  • int – The Off Time parameter. Range 250 to 100,000,000 in steps of 1 milliseconds (0.250s to 10,000s).

  • int – The Number of Cycles parameter. Range 0 to 1000,000 where 0 represents unlimited.

Raises

ThorlabsError – If not successful.

get_cycle_params_block()[source]

Get the cycle parameters.

Returns

structs.SC_CycleParameters – The cycle parameters.

Raises

ThorlabsError – If not successful.

get_digital_outputs()[source]

Gets the digital output bits.

Returns

int – Bit mask of states of the 4 digital output pins.

get_hardware_info()[source]

Gets the hardware information from the device.

Returns

structs.TLI_HardwareInformation – The hardware information.

Raises

ThorlabsError – If not successful.

get_hardware_info_block()[source]

Gets the hardware information in a block.

Returns

structs.TLI_HardwareInformation – The hardware information.

Raises

ThorlabsError – If not successful.

get_hub_bay()[source]

Gets the hub bay number this device is fitted to.

Returns

int – Either the number, or 0x00 if unknown, or 0xff if not on a hub.

get_led_switches()[source]

Get the LED indicator bits on cube.

Returns

int – Sum of: 8 to indicate moving 2 to indicate end of track and 1 to flash on identify command.

get_mmi_params()[source]

Get the MMI Parameters for the KCube Display Interface.

Deprecated: calls get_mmi_params_ext()

Returns

  • int – The display intensity, range 0 to 100%.

  • int – The display timeout, range 0 to 480 in minutes (0 is off, otherwise the inactivity period before dimming the display).

  • int – The display dimmed intensity, range 0 to 10 (after the timeout period the device display will dim).

Raises

ThorlabsError – If not successful.

get_mmi_params_block()[source]

Gets the MMI parameters for the device.

Warning

This function is currently not in the DLL, as of v1.11.2, but it is in the header file.

Returns

structs.KSC_MMIParams – Options for controlling the MMI.

Raises

ThorlabsError – If not successful.

get_mmi_params_ext()[source]

Get the MMI Parameters for the KCube Display Interface.

Returns

  • int – The display intensity, range 0 to 100%.

  • int – The display timeout, range 0 to 480 in minutes (0 is off, otherwise the inactivity period before dimming the display).

  • int – The display dimmed intensity, range 0 to 10 (after the timeout period the device display will dim).

Raises

ThorlabsError – If not successful.

get_next_message()[source]

Get the next Message Queue item. See messages.

Returns

  • int – The message type.

  • int – The message ID.

  • int – The message data.

Raises

ThorlabsError – If not successful.

get_operating_mode()[source]

Gets the Operating Mode.

Returns

enums.SC_OperatingModes – The current operating mode.

get_operating_state()[source]

Gets the current operating state.

Returns

enums.SC_OperatingStates – The current operating state.

get_software_version()[source]

Gets version number of the device software.

Returns

str – The device software version.

get_solenoid_state()[source]

Gets the current solenoid state.

Returns

enums.SC_SolenoidStates – The current solenoid state.

get_status_bits()[source]

Get the current status bits.

This returns the latest status bits received from the device. To get new status bits, use request_status() or use the polling function, start_polling()

Returns

int – The status bits from the device.

get_trigger_config_params()[source]

Get the Trigger Configuration Parameters.

Returns

Raises

ThorlabsError – If not successful.

get_trigger_config_params_block()[source]

Gets the trigger configuration parameters block.

Returns

structs.KSC_TriggerConfig – Options for controlling the trigger configuration.

Raises

ThorlabsError – If not successful.

has_last_msg_timer_overrun()[source]

Queries if the time since the last message has exceeded the lastMsgTimeout set by enable_last_msg_timer().

This can be used to determine whether communications with the device is still good.

Returns

boolTrue if last message timer has elapsed or False if monitoring is not enabled or if time of last message received is less than lastMsgTimeout.

identify()[source]

Sends a command to the device to make it identify itself.

load_settings()[source]

Update device with stored settings.

The settings are read from ThorlabsDefaultSettings.xml, which gets created when the Kinesis software is installed.

Raises

ThorlabsError – If not successful.

load_named_settings(settings_name)[source]

Update device with named settings.

Parameters

settings_name (str) – The name of the device to load the settings for. Examples for the value of setting_name can be found in ThorlabsDefaultSettings.xml`, which gets created when the Kinesis software is installed.

Raises

ThorlabsError – If not successful.

message_queue_size()[source]

Gets the size of the message queue.

Returns

int – The number of messages in the queue.

open()[source]

Open the device for communication.

Raises

ThorlabsError – If not successful.

persist_settings()[source]

Persist the devices current settings.

Raises

ThorlabsError – If not successful.

polling_duration()[source]

Gets the polling loop duration.

Returns

int – The time between polls in milliseconds or 0 if polling is not active.

register_message_callback(callback)[source]

Registers a callback on the message queue.

Parameters

callback (MotionControlCallback) – A function to be called whenever messages are received.

request_cycle_params()[source]

Requests the cycle parameters.

Raises

ThorlabsError – If not successful.

request_digital_outputs()[source]

Requests the digital output bits.

Raises

ThorlabsError – If not successful.

request_hub_bay()[source]

Requests the hub bay number this device is fitted to.

Raises

ThorlabsError – If not successful.

request_led_switches()[source]

Requests the LED indicator bits on the cube.

Raises

ThorlabsError – If not successful.

request_mmi_params()[source]

Requests the MMI Parameters for the KCube Display Interface.

Raises

ThorlabsError – If not successful.

request_operating_mode()[source]

Requests the operating mode.

Raises

ThorlabsError – If not successful.

request_operating_state()[source]

Requests the operating state.

Raises

ThorlabsError – If not successful.

request_settings()[source]

Requests that all settings are download from device.

This function requests that the device upload all it’s settings to the DLL.

Raises

ThorlabsError – If not successful.

request_status()[source]

Requests the status from the device.

This needs to be called to get the device to send it’s current status bits. Note, this is called automatically if Polling is enabled for the device using start_polling().

Raises

ThorlabsError – If not successful.

request_status_bits()[source]

Request the status bits which identify the current motor state.

This needs to be called to get the device to send it’s current status bits. Note, this is called automatically if Polling is enabled for the device using start_polling().

Raises

ThorlabsError – If not successful.

request_trigger_config_params()[source]

Requests the Trigger Configuration Parameters.

Raises

ThorlabsError – If not successful.

set_cycle_params(on_time, off_time, num_cycles)[source]

Sets the cycle parameters.

Parameters
  • on_time (int) – The On Time parameter. Range 250 to 100,000,000 in steps of 1 milliseconds (0.250s to 10,000s).

  • off_time (int) – The Off Time parameter. Range 250 to 100,000,000 in steps of 1 milliseconds (0.250s to 10,000s).

  • num_cycles (int) – The Number of Cycles parameter Range 0 to 1,000,000 where 0 represent unlimited.

Raises

ThorlabsError – If not successful.

set_cycle_params_block(cycle_params)[source]

Sets the cycle parameters.

Parameters

cycle_params (structs.SC_CycleParameters) – The new cycle parameters.

Raises

ThorlabsError – If not successful.

set_digital_outputs(outputs_bits)[source]

Sets the digital output bits.

Parameters

outputs_bits (int) – Bit mask to set the states of the 4 digital output pins.

Raises

ThorlabsError – If not successful.

set_led_switches(led_switches)[source]

Set the LED indicator bits on the cube.

Parameters

led_switches (int) – Sum of: 8 to indicate moving 2 to indicate end of track and 1 to flash on identify command.

Raises

ThorlabsError – If not successful.

set_mmi_params(display_intensity)[source]

Set the MMI Parameters for the KCube Display Interface.

Deprecated: superceded by set_mmi_params_ext()

Parameters

display_intensity (int) – The display intensity, range 0 to 100%.

Raises

ThorlabsError – If not successful.

set_mmi_params_block(mmi_params)[source]

Sets the MMI parameters for the device.

Warning

This function is currently not in the DLL, as of v1.11.2, but it is in the header file.

Parameters

mmi_params (structs.KSC_MMIParams) – Options for controlling the MMI.

Raises

ThorlabsError – If not successful.

set_mmi_params_ext(intensity, timeout, dim_intensity)[source]

Set the MMI Parameters for the KCube Display Interface.

Parameters
  • intensity (int) – The display intensity, range 0 to 100%.

  • timeout (int) – The display timeout, range 0 to 480 in minutes (0 is off, otherwise the inactivity period before dimming the display).

  • dim_intensity (int) – The display dimmed intensity, range 0 to 10 (after the timeout period the device display will dim).

Raises

ThorlabsError – If not successful.

set_operating_mode(mode)[source]

Sets the operating mode.

Parameters

mode (enums.SC_OperatingModes) – The required operating mode as a SC_OperatingModes enum value or member name.

Raises

ThorlabsError – If not successful.

set_operating_state(state)[source]

Sets the operating state.

Parameters

state (enums.SC_OperatingStates) – The required operating state as a SC_OperatingStates enum value or member name.

Raises

ThorlabsError – If not successful.

set_trigger_config_params(mode1, polarity1, mode2, polarity2)[source]

Set the trigger configuration parameters.

Parameters
Raises

ThorlabsError – If not successful.

set_trigger_config_params_block(trigger_config_params)[source]

Sets the trigger configuration parameters block.

Parameters

trigger_config_params (structs.KSC_TriggerConfig) – Options for controlling the trigger configuration.

Raises

ThorlabsError – If not successful.

start_polling(milliseconds)[source]

Starts the internal polling loop.

This function continuously requests position and status messages.

Parameters

milliseconds (int) – The polling rate, in milliseconds.

Raises

ThorlabsError – If not successful.

stop_polling()[source]

Stops the internal polling loop.

time_since_last_msg_received()[source]

Gets the time, in milliseconds, since tha last message was received.

This can be used to determine whether communications with the device is still good.

Returns

int – The time, in milliseconds, since the last message was received.

wait_for_message()[source]

Wait for next Message Queue item. See messages.

Returns

  • int – The message type.

  • int – The message ID.

  • int – The message data.

Raises

ThorlabsError – If not successful.