Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
105 changes: 105 additions & 0 deletions Python/XA/BBD30X/bbd30x_test_script.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
import platform

from thorlabs_xa.products.bbd30x import Bbd30x
from thorlabs_xa.shared.diagnostics_helper import DiagnosticsHelper
from thorlabs_xa.shared.enums import (
TLMC_AuxIoPortMode,
TLMC_AuxIoPortNumber,
TLMC_DigitalOutput,
TLMC_OperatingMode,
TLMC_RackBayNumber,
TLMC_SettingStringFormat,
)
from thorlabs_xa.shared.params import TLMC_DeviceInfo
from thorlabs_xa.shared.system_manager import SystemManager
from thorlabs_xa.shared.xa_error_factory import XADeviceException

BBD30X_PART_NUMBER = "BBD303"
DEFAULT_TIMEOUT = 5000

SIMULATION_CONFIG_STRING = {
"PartNumber": BBD30X_PART_NUMBER,
"SerialNumber": "103003334",
"Channels": [
{"BayNumber": 1, "SerialNumber": "104003335", "ActuatorType": "DDS220"},
{"BayNumber": 2, "SerialNumber": "104003336", "ActuatorType": "DDS300"},
{"BayNumber": 3, "SerialNumber": "104003337", "ActuatorType": "DDS600"},
],
}


def create_simulation(system_manager: SystemManager) -> TLMC_DeviceInfo | None:
try:
system_manager.create_simulation(SIMULATION_CONFIG_STRING)
except XADeviceException as e:
print(f"Unable to create simulation for {BBD30X_PART_NUMBER}: {e.error_code}")
return None

device_info = TLMC_DeviceInfo()
device_info.device_type_description = BBD30X_PART_NUMBER
device_info.device = SIMULATION_CONFIG_STRING["SerialNumber"]
device_info.transport = ""
return device_info


def main() -> None:
device: Bbd30x | None = None
system_manager = SystemManager.instance()

if platform.system() == "Linux":
system_manager.startup("deviceDiscovery.connections=/dev/ttyUSB0")
else:
system_manager.startup()

devices = system_manager.get_device_list()
device_info: TLMC_DeviceInfo | None = None

for listed_device_info in devices:
if listed_device_info.part_number == BBD30X_PART_NUMBER:
device_info = listed_device_info

if not device_info:
device_info = create_simulation(system_manager)

if not device_info:
print("No compatible BBD30X device available.")
system_manager.shutdown()
return

try:
device = system_manager.open_device_as(device_info.device, device_info.transport, TLMC_OperatingMode.TLMC_OperatingMode_Default, Bbd30x)

DiagnosticsHelper.console(device.get_hardware_info(DEFAULT_TIMEOUT))

application_firmware, device_firmware = device.get_firmware_version_info(DEFAULT_TIMEOUT)
DiagnosticsHelper.console(f"Application firmware: {application_firmware}")
DiagnosticsHelper.console(f"Device firmware: {device_firmware}")

device.set_digital_output_states(TLMC_DigitalOutput.TLMC_DigitalOutput_1)
DiagnosticsHelper.console(f"Digital outputs: {device.get_digital_output_states(DEFAULT_TIMEOUT).name}")

device.set_aux_io_port_mode(
TLMC_AuxIoPortNumber.TLMC_AuxIoPortNumber_Port1,
TLMC_AuxIoPortMode.TLMC_AuxIoPortMode_SoftwareControlled,
)
DiagnosticsHelper.console(
f"Aux mode: {device.get_aux_io_port_mode(TLMC_AuxIoPortNumber.TLMC_AuxIoPortNumber_Port1, DEFAULT_TIMEOUT).name}"
)

DiagnosticsHelper.console(
f"Rack bay 1 state: {device.get_rack_bay_occupied_state(TLMC_RackBayNumber.TLMC_RackBayNumber_1, DEFAULT_TIMEOUT).name}"
)

DiagnosticsHelper.console(device.get_settings(TLMC_SettingStringFormat.TLMC_SettingStringFormat_Json, True))

except XADeviceException as e:
print("Encountered error, code:", e.error_code)
finally:
if device:
device.disconnect()
device.close()
system_manager.shutdown()


if __name__ == "__main__":
main()
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
import platform

from thorlabs_xa.products.bbd30x_logical_channel import Bbd30xLogicalChannel
from thorlabs_xa.shared.diagnostics_helper import DiagnosticsHelper
from thorlabs_xa.shared.enums import TLMC_EnableState, TLMC_MoveMode, TLMC_OperatingMode, TLMC_SettingStringFormat, TLMC_StopMode
from thorlabs_xa.shared.params import TLMC_DeviceInfo
from thorlabs_xa.shared.system_manager import SystemManager
from thorlabs_xa.shared.xa_error_factory import XADeviceException

BBD30X_PART_NUMBER = "BBD303"
BBD30X_PARENT_SERIAL = "103003334"
BBD30X_CHANNEL_SERIAL = "104003335"
DEFAULT_TIMEOUT = 5000

SIMULATION_CONFIG_STRING = {
"PartNumber": BBD30X_PART_NUMBER,
"SerialNumber": BBD30X_PARENT_SERIAL,
"Channels": [
{"BayNumber": 1, "SerialNumber": BBD30X_CHANNEL_SERIAL, "ActuatorType": "DDS220"},
{"BayNumber": 2, "SerialNumber": "104003336", "ActuatorType": "DDS300"},
{"BayNumber": 3, "SerialNumber": "104003337", "ActuatorType": "DDS600"},
],
}


def create_simulation(system_manager: SystemManager) -> TLMC_DeviceInfo | None:
try:
system_manager.create_simulation(SIMULATION_CONFIG_STRING)
except XADeviceException as e:
print(f"Unable to create simulation for {BBD30X_PART_NUMBER}: {e.error_code}")
return None

device_info = TLMC_DeviceInfo()
device_info.device_type_description = "BBD30X Logical Channel"
device_info.device = BBD30X_CHANNEL_SERIAL
device_info.transport = BBD30X_PARENT_SERIAL
return device_info


def main() -> None:
device = None
system_manager = SystemManager.instance()

if platform.system() == "Linux":
system_manager.startup("deviceDiscovery.connections=/dev/ttyUSB0")
else:
system_manager.startup()

device_info: TLMC_DeviceInfo | None = None
for listed_device_info in system_manager.get_device_list():
is_known_serial = listed_device_info.device == BBD30X_CHANNEL_SERIAL
is_logical_description = "logical" in listed_device_info.device_type_description.lower()
if is_known_serial or is_logical_description:
device_info = listed_device_info

if not device_info:
device_info = create_simulation(system_manager)

if not device_info:
print("No compatible BBD30X logical channel available.")
system_manager.shutdown()
return

try:
device = system_manager.open_device_as(device_info.device, device_info.transport, TLMC_OperatingMode.TLMC_OperatingMode_Default, Bbd30xLogicalChannel)

device.set_enable_state(TLMC_EnableState.TLMC_Enabled)
DiagnosticsHelper.console(f"Enable state: {device.get_enable_state(DEFAULT_TIMEOUT)}")

DiagnosticsHelper.console(device.get_hardware_info(DEFAULT_TIMEOUT))

device.move(TLMC_MoveMode.TLMC_MoveMode_ContinuousForward, 300, DEFAULT_TIMEOUT)
device.stop(TLMC_StopMode.TLMC_StopMode_Immediate, DEFAULT_TIMEOUT)

device.request_status(DEFAULT_TIMEOUT)
DiagnosticsHelper.console_object(device.get_universal_status(DEFAULT_TIMEOUT))
DiagnosticsHelper.console_object(device.get_universal_status_bits(DEFAULT_TIMEOUT))

DiagnosticsHelper.console(device.get_settings(TLMC_SettingStringFormat.TLMC_SettingStringFormat_Json, True))

except XADeviceException as e:
print("Encountered error, code:", e.error_code)
finally:
if device:
device.close()
system_manager.shutdown()


if __name__ == "__main__":
main()
77 changes: 77 additions & 0 deletions Python/XA/BPC301/bpc301_test_script.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import platform

from thorlabs_xa.products.bpc301 import Bpc301
from thorlabs_xa.shared.diagnostics_helper import DiagnosticsHelper
from thorlabs_xa.shared.enums import TLMC_EnableState, TLMC_OperatingMode, TLMC_PZ_PositionControlMode, TLMC_SettingStringFormat
from thorlabs_xa.shared.params import TLMC_DeviceInfo
from thorlabs_xa.shared.system_manager import SystemManager
from thorlabs_xa.shared.xa_error_factory import XADeviceException

BPC301_PART_NUMBER = "BPC301"
DEFAULT_TIMEOUT = 5000

SIMULATION_CONFIG_STRING = {"PartNumber": BPC301_PART_NUMBER, "SerialNumber": "71003331"}


def create_simulation(system_manager: SystemManager) -> TLMC_DeviceInfo | None:
try:
system_manager.create_simulation(SIMULATION_CONFIG_STRING)
except XADeviceException as e:
print(f"Unable to create simulation for {BPC301_PART_NUMBER}: {e.error_code}")
return None

device_info = TLMC_DeviceInfo()
device_info.device_type_description = BPC301_PART_NUMBER
device_info.device = SIMULATION_CONFIG_STRING["SerialNumber"]
device_info.transport = ""
return device_info


def main() -> None:
device: Bpc301 | None = None
system_manager = SystemManager.instance()

if platform.system() == "Linux":
system_manager.startup("deviceDiscovery.connections=/dev/ttyUSB0")
else:
system_manager.startup()

device_info: TLMC_DeviceInfo | None = None
for listed_device_info in system_manager.get_device_list():
if listed_device_info.part_number == BPC301_PART_NUMBER:
device_info = listed_device_info

if not device_info:
device_info = create_simulation(system_manager)

if not device_info:
print("No compatible BPC301 device available.")
system_manager.shutdown()
return

try:
device = system_manager.open_device_as(device_info.device, device_info.transport, TLMC_OperatingMode.TLMC_OperatingMode_Default, Bpc301)

device.set_enable_state(TLMC_EnableState.TLMC_Enabled)
DiagnosticsHelper.console(f"Enable state: {device.get_enable_state(DEFAULT_TIMEOUT).name}")
DiagnosticsHelper.console_object(device.get_hardware_info(DEFAULT_TIMEOUT))

device.set_position_control_mode(TLMC_PZ_PositionControlMode.TLMC_PZ_PositionControlMode_OpenLoop, DEFAULT_TIMEOUT)
DiagnosticsHelper.console(f"Position control mode: {device.get_position_control_mode(DEFAULT_TIMEOUT).name}")

device.set_output_voltage(1000)
DiagnosticsHelper.console(f"Piezo voltage: {device.get_output_voltage(DEFAULT_TIMEOUT)}")

DiagnosticsHelper.console(device.get_settings(TLMC_SettingStringFormat.TLMC_SettingStringFormat_Json, True))

except XADeviceException as e:
print("Encountered error, code:", e.error_code)
finally:
if device:
device.disconnect()
device.close()
system_manager.shutdown()


if __name__ == "__main__":
main()
90 changes: 90 additions & 0 deletions Python/XA/BPC30X/bpc30x_test_script.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
import platform

from thorlabs_xa.products.bpc30x import Bpc30x
from thorlabs_xa.shared.diagnostics_helper import DiagnosticsHelper
from thorlabs_xa.shared.enums import TLMC_DigitalOutput, TLMC_OperatingMode, TLMC_RackBayNumber, TLMC_SettingStringFormat
from thorlabs_xa.shared.params import TLMC_DeviceInfo
from thorlabs_xa.shared.system_manager import SystemManager
from thorlabs_xa.shared.xa_error_factory import XADeviceException

BPC30X_PART_NUMBER = "BPC303"
DEFAULT_TIMEOUT = 5000

SIMULATION_CONFIG_STRING = {
"PartNumber": BPC30X_PART_NUMBER,
"SerialNumber": "71003334",
"Channels": [
{"BayNumber": 1, "SerialNumber": "91003335", "ActuatorType": "DDS220"},
{"BayNumber": 2, "SerialNumber": "91003336", "ActuatorType": "DDS300"},
{"BayNumber": 3, "SerialNumber": "91003337", "ActuatorType": "DDS600"},
],
}


def create_simulation(system_manager: SystemManager) -> TLMC_DeviceInfo | None:
try:
system_manager.create_simulation(SIMULATION_CONFIG_STRING)
except XADeviceException as e:
print(f"Unable to create simulation for {BPC30X_PART_NUMBER}: {e.error_code}")
return None

device_info = TLMC_DeviceInfo()
device_info.device_type_description = BPC30X_PART_NUMBER
device_info.device = str(SIMULATION_CONFIG_STRING["SerialNumber"])
device_info.transport = ""
return device_info


def main() -> None:
device: Bpc30x | None = None
system_manager = SystemManager.instance()

if platform.system() == "Linux":
system_manager.startup("deviceDiscovery.connections=/dev/ttyUSB0")
else:
system_manager.startup()

devices = system_manager.get_device_list()
device_info: TLMC_DeviceInfo | None = None

for listed_device_info in devices:
if listed_device_info.part_number == BPC30X_PART_NUMBER:
device_info = listed_device_info

if not device_info:
device_info = create_simulation(system_manager)

if not device_info:
print("No compatible BPC30X device available.")
system_manager.shutdown()
return

try:
device = system_manager.open_device_as(device_info.device, device_info.transport, TLMC_OperatingMode.TLMC_OperatingMode_Default, Bpc30x)

DiagnosticsHelper.console(device.get_hardware_info(DEFAULT_TIMEOUT))

application_firmware, device_firmware = device.get_firmware_version_info(DEFAULT_TIMEOUT)
DiagnosticsHelper.console(f"Application firmware: {application_firmware}")
DiagnosticsHelper.console(f"Device firmware: {device_firmware}")

device.set_digital_output_states(TLMC_DigitalOutput.TLMC_DigitalOutput_1)
DiagnosticsHelper.console(f"Digital outputs: {device.get_digital_output_states(DEFAULT_TIMEOUT).name}")

DiagnosticsHelper.console(
f"Rack bay 1 state: {device.get_rack_bay_occupied_state(TLMC_RackBayNumber.TLMC_RackBayNumber_1, DEFAULT_TIMEOUT).name}"
)

DiagnosticsHelper.console(device.get_settings(TLMC_SettingStringFormat.TLMC_SettingStringFormat_Json, True))

except XADeviceException as e:
print("Encountered error, code:", e.error_code)
finally:
if device:
device.disconnect()
device.close()
system_manager.shutdown()


if __name__ == "__main__":
main()
Loading