BioImager  4.9.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
asdk.py
1#!/usr/bin/env python3
2
3
19
20"""Alpao deformable mirrors SDK.
21"""
22
23import ctypes
24import os
25from ctypes import c_char_p, c_double, c_int, c_size_t, c_uint32
26
27
28if os.name in ("nt", "ce"):
29 SDK = ctypes.WinDLL("ASDK")
30else:
31 # Not actually tested yet
32 SDK = ctypes.CDLL("libasdk.so")
33
34
35class DM(ctypes.Structure):
36 pass
37
38
39pDM = ctypes.POINTER(DM)
40
41# We have this "typedefs" to ease matching with alpao's headers.
42CStr = c_char_p
43Scalar = c_double
44Scalar_p = ctypes.POINTER(Scalar)
45UInt = c_uint32
46Size_T = c_size_t
47
48COMPL_STAT = c_int # enum for function completion status
49SUCCESS = 0
50FAILURE = -1
51
52
53def make_prototype(name, argtypes, restype=COMPL_STAT):
54 func = getattr(SDK, name)
55 func.argtypes = argtypes
56 func.restype = restype
57 return func
58
59
60Get = make_prototype("asdkGet", [pDM, CStr, Scalar_p])
61
62GetLastError = make_prototype(
63 "asdkGetLastError", [ctypes.POINTER(UInt), CStr, Size_T]
64)
65
66Init = make_prototype("asdkInit", [CStr], pDM)
67
68Release = make_prototype("asdkRelease", [pDM])
69
70Send = make_prototype("asdkSend", [pDM, Scalar_p])
71
72SendPattern = make_prototype("asdkSendPattern", [pDM, Scalar_p, UInt, UInt])
73
74Set = make_prototype("asdkSet", [pDM, CStr, Scalar])
75
76Stop = make_prototype("asdkStop", [pDM])