1
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
"""
|
"""
|
||||||
Andor SDK3 Camera Discovery and Connection Test
|
Andor SDK3 Camera Discovery and Connection Test
|
||||||
Direct SDK usage without pylablib dependency
|
Direct SDK usage without pylablib dependency
|
||||||
@@ -21,7 +22,7 @@ try:
|
|||||||
if os.path.exists(path) or path == "atcore.dll":
|
if os.path.exists(path) or path == "atcore.dll":
|
||||||
try:
|
try:
|
||||||
lib = ctypes.WinDLL(path)
|
lib = ctypes.WinDLL(path)
|
||||||
print(f"Loaded SDK from: {path}")
|
print(f"[OK] Loaded SDK from: {path}")
|
||||||
break
|
break
|
||||||
except OSError:
|
except OSError:
|
||||||
continue
|
continue
|
||||||
@@ -32,7 +33,7 @@ try:
|
|||||||
)
|
)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f" Failed to load Andor SDK3 library: {e}")
|
print(f"[ERROR] Failed to load Andor SDK3 library: {e}")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
# Define function signatures
|
# Define function signatures
|
||||||
@@ -113,16 +114,16 @@ print("=" * 60)
|
|||||||
print("\n[1] Initializing Andor SDK3 library...")
|
print("\n[1] Initializing Andor SDK3 library...")
|
||||||
code = lib.AT_InitialiseLibrary()
|
code = lib.AT_InitialiseLibrary()
|
||||||
check_error(code, "AT_InitialiseLibrary")
|
check_error(code, "AT_InitialiseLibrary")
|
||||||
print("Library initialized successfully")
|
print("[OK] Library initialized successfully")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Get number of cameras (using system handle = 1)
|
# Get number of cameras (using system handle = 1)
|
||||||
print("\n[2] Detecting cameras...")
|
print("\n[2] Detecting cameras...")
|
||||||
num_cameras = get_int_feature(1, "DeviceCount")
|
num_cameras = get_int_feature(1, "DeviceCount")
|
||||||
print(f"Found {num_cameras} camera(s)")
|
print(f"[OK] Found {num_cameras} camera(s)")
|
||||||
|
|
||||||
if num_cameras == 0:
|
if num_cameras == 0:
|
||||||
print("\n<EFBFBD> No cameras detected. Please check:")
|
print("\n[WARNING] No cameras detected. Please check:")
|
||||||
print(" - Camera is powered on")
|
print(" - Camera is powered on")
|
||||||
print(" - USB/PCIe connection is secure")
|
print(" - USB/PCIe connection is secure")
|
||||||
print(" - Drivers are installed correctly")
|
print(" - Drivers are installed correctly")
|
||||||
@@ -132,7 +133,7 @@ try:
|
|||||||
handle = ctypes.c_int()
|
handle = ctypes.c_int()
|
||||||
code = lib.AT_Open(0, ctypes.byref(handle))
|
code = lib.AT_Open(0, ctypes.byref(handle))
|
||||||
check_error(code, "AT_Open")
|
check_error(code, "AT_Open")
|
||||||
print(f"Camera opened (handle: {handle.value})")
|
print(f"[OK] Camera opened (handle: {handle.value})")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Get camera information
|
# Get camera information
|
||||||
@@ -159,28 +160,22 @@ try:
|
|||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
try:
|
|
||||||
sensor_temp = lib.AT_GetFloat(handle.value, "SensorTemperature")
|
|
||||||
# Note: would need to define AT_GetFloat properly for this
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
|
|
||||||
print("-" * 60)
|
print("-" * 60)
|
||||||
print("Camera information retrieved successfully")
|
print("[OK] Camera information retrieved successfully")
|
||||||
|
|
||||||
finally:
|
finally:
|
||||||
# Close camera
|
# Close camera
|
||||||
print("\n[5] Closing camera...")
|
print("\n[5] Closing camera...")
|
||||||
code = lib.AT_Close(handle.value)
|
code = lib.AT_Close(handle.value)
|
||||||
check_error(code, "AT_Close")
|
check_error(code, "AT_Close")
|
||||||
print("Camera closed")
|
print("[OK] Camera closed")
|
||||||
|
|
||||||
finally:
|
finally:
|
||||||
# Finalize library
|
# Finalize library
|
||||||
print("\n[6] Shutting down SDK library...")
|
print("\n[6] Shutting down SDK library...")
|
||||||
code = lib.AT_FinaliseLibrary()
|
code = lib.AT_FinaliseLibrary()
|
||||||
check_error(code, "AT_FinaliseLibrary")
|
check_error(code, "AT_FinaliseLibrary")
|
||||||
print("Library shutdown complete")
|
print("[OK] Library shutdown complete")
|
||||||
|
|
||||||
print("\n" + "=" * 60)
|
print("\n" + "=" * 60)
|
||||||
print("Test completed successfully!")
|
print("Test completed successfully!")
|
||||||
|
|||||||
Reference in New Issue
Block a user