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
microscope.cameras.atmcd.dllFunction Class Reference

Public Member Functions

def __init__ (self, name, args=[], argnames=[], rstatus=False, lib=_dll)
 
def __call__ (self, *args)
 

Public Attributes

 f
 
 fargs
 
 fargnames
 
 name
 
 in_args
 
 out_args
 
 rstatus
 
 buf_size_arg_pos
 
 arr_size_arg_pos
 
 arr_size_pos
 

Detailed Description

A wrapper class for DLL functions to make them available in python.

Definition at line 624 of file atmcd.py.

Constructor & Destructor Documentation

◆ __init__()

def microscope.cameras.atmcd.dllFunction.__init__ (   self,
  name,
  args = [],
  argnames = [],
  rstatus = False,
  lib = _dll 
)

Definition at line 627 of file atmcd.py.

627 def __init__(self, name, args=[], argnames=[], rstatus=False, lib=_dll):
628 # the library function
629 self.f = getattr(lib, name)
630 # dll call return type
631 self.f.restype = c_uint
632 # dll call parameter types
633 self.f.argtypes = [stripMeta(a) for a in args]
634 # dll call parameters, with their meta wrappers
635 self.fargs = args
636 # dll call parameter names, used to generate helpstrings
637 self.fargnames = argnames
638 # the function name
639 self.name = name
640 # input arguments
641 self.in_args = [a for a in args if not isinstance(a, OUTPUT)]
642 # output arguments
643 self.out_args = [a for a in args if isinstance(a, OUTPUT)]
644 # Indicates that this function should return the status code it generates.
645 self.rstatus = rstatus
646 # Find any arguments that set string buffer or array sizes.
647 self.buf_size_arg_pos = -1
648 self.arr_size_arg_pos = -1
649 for i in range(len(self.in_args)):
650 if isinstance(self.in_args[i], _OUTSTRLEN):
651 self.buf_size_arg_pos = i
652 if isinstance(self.in_args[i], _OUTARRSIZE):
653 self.arr_size_pos = i
654 # Generate a docstring.
655 ds = name + "\n\nArguments:\n===========\n"
656 for i in range(len(args)):
657 an = ""
658 if i < len(argnames):
659 an = argnames[i]
660 ds += "\t%s\t%s\n" % (args[i], an)
661 self.f.__doc__ = ds
662

Member Function Documentation

◆ __call__()

def microscope.cameras.atmcd.dllFunction.__call__ (   self,
args 
)
Parse arguments, allocate any required storage, and execute the call.

Definition at line 663 of file atmcd.py.

663 def __call__(self, *args):
664 """Parse arguments, allocate any required storage, and execute the call."""
665 # The C function arguments
666 c_args = []
667 i = 0
668 ret = []
669
670 if self.buf_size_arg_pos >= 0:
671 try:
672 bs = args[self.buf_size_arg_pos]
673 except:
674 bs = 255
675 else:
676 bs = 255
677 # Sort input and output arguments, allocating output storage as required.
678 i = 0
679 for farg in self.fargs:
680 if isinstance(farg, OUTPUT):
681 if isinstance(farg, OUTARR):
682 size = args[self.arr_size_arg_pos]
683 else:
684 size = bs
685 r, c_arg = farg.getVar(size)
686 c_args.append(c_arg)
687 ret.append(r)
688 elif isinstance(farg, _OUTSTRLEN):
689 c_args.append(bs)
690 elif isinstance(args[i], Enum):
691 c_args.append(args[i].value)
692 i += 1
693 else:
694 c_args.append(args[i])
695 i += 1
696
697 # Make the library call, tolerating a few DRV_ERROR_ACKs
698 status = DRV_ERROR_ACK
699 ack_err_count = -1
700 while status == DRV_ERROR_ACK and ack_err_count < 3:
701 ack_err_count += 1
702 status = self.f(*c_args)
703 ret = [extract_value(r) for r in ret]
704 if len(ret) == 1:
705 ret = ret[0]
706 elif len(ret) == 0:
707 ret = None
708 # A few functions indicate state using the returned status code instead
709 # of filling a variable passed by reference pointer.
710 if self.rstatus:
711 if status == DRV_SUCCESS:
712 return True
713 elif status in [
714 DRV_INVALID_AMPLIFIER,
715 DRV_INVALID_MODE,
716 DRV_INVALID_COUNTCONVERT_MODE,
717 DRV_INVALID_FILTER,
718 ]:
719 return False
720 elif status in [
721 DRV_TEMP_OFF,
722 DRV_TEMP_STABILIZED,
723 DRV_TEMP_NOT_REACHED,
724 DRV_TEMP_DRIFT,
725 DRV_TEMP_NOT_STABILIZED,
726 ]:
727 return (status, ret)
728 else:
729 raise AtmcdException(status)
730 # Most functions return values via pointers, or have no return.
731 if not status == DRV_SUCCESS:
732 raise AtmcdException(status)
733 return ret
734
735

References microscope.cameras.atmcd.dllFunction.arr_size_arg_pos, microscope.cameras._SDK3.dllFunction.buf_size_arg_pos, microscope.cameras.atmcd.dllFunction.buf_size_arg_pos, microscope.cameras._SDK3.dllFunction.f, microscope.cameras.atmcd.dllFunction.f, microscope.cameras.pvcam.dllFunction.f, BioImager.ImageJ.RoiEncoder.f, microscope.cameras._SDK3.dllFunction.fargs, microscope.cameras.atmcd.dllFunction.fargs, microscope.cameras.pvcam.dllFunction.fargs, and microscope.cameras.atmcd.dllFunction.rstatus.

Member Data Documentation

◆ arr_size_arg_pos

microscope.cameras.atmcd.dllFunction.arr_size_arg_pos

Definition at line 648 of file atmcd.py.

Referenced by microscope.cameras.atmcd.dllFunction.__call__().

◆ arr_size_pos

microscope.cameras.atmcd.dllFunction.arr_size_pos

Definition at line 653 of file atmcd.py.

◆ buf_size_arg_pos

microscope.cameras.atmcd.dllFunction.buf_size_arg_pos

Definition at line 647 of file atmcd.py.

Referenced by microscope.cameras.atmcd.dllFunction.__call__().

◆ f

microscope.cameras.atmcd.dllFunction.f

Definition at line 629 of file atmcd.py.

Referenced by microscope.cameras.atmcd.dllFunction.__call__().

◆ fargnames

microscope.cameras.atmcd.dllFunction.fargnames

Definition at line 637 of file atmcd.py.

◆ fargs

microscope.cameras.atmcd.dllFunction.fargs

Definition at line 635 of file atmcd.py.

Referenced by microscope.cameras.atmcd.dllFunction.__call__().

◆ in_args

microscope.cameras.atmcd.dllFunction.in_args

Definition at line 641 of file atmcd.py.

◆ name

microscope.cameras.atmcd.dllFunction.name

◆ out_args

microscope.cameras.atmcd.dllFunction.out_args

Definition at line 643 of file atmcd.py.

◆ rstatus

microscope.cameras.atmcd.dllFunction.rstatus

Definition at line 645 of file atmcd.py.

Referenced by microscope.cameras.atmcd.dllFunction.__call__().


The documentation for this class was generated from the following file: