BioImager  5.0.0
A .NET microscopy imaging application based on Bio library. Supports various microscopes by using imported libraries & GUI automation. Supports XInput game controllers to move stage, take images, run ImageJ macros on images or Bio C# scripts.
Loading...
Searching...
No Matches
BMC.py
Go to the documentation of this file.
1#!/usr/bin/env python3
2
3
19
20"""Boston Micromachines deformable mirrors SDK.
21"""
22
23import ctypes
24import os
25from ctypes import c_char, c_char_p, c_double, c_int, c_uint, c_uint32
26
27
28if os.name in ("nt", "ce"):
29 # Not actually tested yet
30 SDK = ctypes.WinDLL("BMC2")
31else:
32 SDK = ctypes.CDLL("libBMC.so.3")
33
34
35# Definitions from BMCDefs.h
36MAX_PATH = 260
37SERIAL_NUMBER_LEN = 11
38MAX_DM_SIZE = 4096
39
40
41class DM_PRIV(ctypes.Structure):
42 pass
43
44
45class DM_DRIVER(ctypes.Structure):
46 _fields_ = [
47 ("channel_count", c_uint),
48 ("serial_number", c_char * (SERIAL_NUMBER_LEN + 1)),
49 ("reserved", c_uint * 7),
50 ]
51
52
53class DM(ctypes.Structure):
54 _fields_ = [
55 ("Driver_Type", c_uint),
56 ("DevId", c_uint),
57 ("HVA_Type", c_uint),
58 ("use_fiber", c_uint),
59 ("use_CL", c_uint),
60 ("burst_mode", c_uint),
61 ("fiber_mode", c_uint),
62 ("ActCount", c_uint),
63 ("MaxVoltage", c_uint),
64 ("VoltageLimit", c_uint),
65 ("mapping", c_char * MAX_PATH),
66 ("inactive", c_uint * MAX_DM_SIZE),
67 ("profiles_path", c_char * MAX_PATH),
68 ("maps_path", c_char * MAX_PATH),
69 ("cals_path", c_char * MAX_PATH),
70 ("cal", c_char * MAX_PATH),
71 ("serial_number", c_char * (SERIAL_NUMBER_LEN + 1)),
72 ("driver", DM_DRIVER),
73 ("priv", ctypes.POINTER(DM_PRIV)),
74 ]
75
76
77DMHANDLE = ctypes.POINTER(DM)
78
79RC = c_int # enum for error codes
80
81LOGLEVEL = c_int # enum for log-levels
82LOG_ALL = 0
83LOG_TRACE = LOG_ALL
84LOG_DEBUG = 1
85LOG_INFO = 2
86LOG_WARN = 3
87LOG_ERROR = 4
88LOG_FATAL = 5
89LOG_OFF = 6
90
91
92def make_prototype(name, argtypes, restype=RC):
93 func = getattr(SDK, name)
94 func.argtypes = argtypes
95 func.restype = restype
96 return func
97
98
99Open = make_prototype("BMCOpen", [DMHANDLE, c_char_p])
100
101SetArray = make_prototype(
102 "BMCSetArray",
103 [DMHANDLE, ctypes.POINTER(c_double), ctypes.POINTER(c_uint32)],
104)
105
106GetArray = make_prototype(
107 "BMCGetArray", [DMHANDLE, ctypes.POINTER(c_double), c_uint32]
108)
109
110Close = make_prototype("BMCClose", [DMHANDLE])
111
112ErrorString = make_prototype("BMCErrorString", [RC], c_char_p)
113
114ConfigureLog = make_prototype("BMCConfigureLog", [c_char_p, LOGLEVEL])
115
116VersionString = make_prototype("BMCVersionString", [], c_char_p)
make_prototype(name, argtypes, restype=RC)
Definition BMC.py:92