BioImager  3.9.1
A .NET microscopy imaging library. Supports various microscopes by using imported libraries & GUI automation. Supported libraries include PriorĀ® & ZeissĀ® & all devices supported by Micromanager 2.0 and python-microscope.
Loading...
Searching...
No Matches
asdk.py
1#!/usr/bin/env python3
2
3## Copyright (C) 2020 David Miguel Susano Pinto <carandraug@gmail.com>
4##
5## This file is part of Microscope.
6##
7## Microscope is free software: you can redistribute it and/or modify
8## it under the terms of the GNU General Public License as published by
9## the Free Software Foundation, either version 3 of the License, or
10## (at your option) any later version.
11##
12## Microscope is distributed in the hope that it will be useful,
13## but WITHOUT ANY WARRANTY; without even the implied warranty of
14## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15## GNU General Public License for more details.
16##
17## You should have received a copy of the GNU General Public License
18## along with Microscope. If not, see <http://www.gnu.org/licenses/>.
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])