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.pvcam.dllFunction Class Reference

Public Member Functions

def __init__ (self, name, args=[], argnames=[], buf_len=-1, lib=_lib)
 
def __call__ (self, *args, **kwargs)
 

Public Attributes

 f
 
 fargs
 
 fargnames
 
 name
 
 inp
 
 in_args
 
 out_args
 
 buf_len
 

Detailed Description

Expose a DLL function to python.

(Again, largely nicked from PYME.)

Definition at line 733 of file pvcam.py.

Constructor & Destructor Documentation

◆ __init__()

def microscope.cameras.pvcam.dllFunction.__init__ (   self,
  name,
  args = [],
  argnames = [],
  buf_len = -1,
  lib = _lib 
)

Definition at line 738 of file pvcam.py.

738 def __init__(self, name, args=[], argnames=[], buf_len=-1, lib=_lib):
739 self.f = getattr(lib, name)
740 self.f.restype = rs_bool
741 self.f.argtypes = [stripMeta(a) for a in args]
742
743 self.fargs = args
744 self.fargnames = argnames
745 self.name = name
746
747 self.inp = [not isinstance(a, OUTPUT) for a in args]
748 self.in_args = [a for a in args if not isinstance(a, OUTPUT)]
749 self.out_args = [a for a in args if isinstance(a, OUTPUT)]
750
751 self.buf_len = buf_len
752
753 docstring = name + "\n\nArguments:\n===========\n"
754 for i in range(len(args)):
755 an = ""
756 if i < len(argnames):
757 an = argnames[i]
758 docstring += "\t%s\t%s\n" % (args[i], an)
759
760 self.f.__doc__ = docstring
761

Member Function Documentation

◆ __call__()

def microscope.cameras.pvcam.dllFunction.__call__ (   self,
args,
**  kwargs 
)

Definition at line 762 of file pvcam.py.

762 def __call__(self, *args, **kwargs):
763 ars = []
764 i = 0
765 ret = []
766 # pl_get_param buffer length depends on the parameter being fetched, so
767 # use kwargs to pass buffer length.
768 if "buf_len" in kwargs:
769 bs = kwargs["buf_len"]
770 elif self.name == "pl_get_enum_param":
771 # last argument is buffer length
772 bs = args[-1]
773 elif self.buf_len >= 0:
774 bs = self.buf_len
775 else:
776 bs = 256
777 # May have been passed a ctype; if so, fetch its value.
778 if isinstance(bs, ctypes._SimpleCData):
779 bs = bs.value
780
781 for j in range(len(self.inp)):
782 if self.inp[j]: # an input
783 if self.f.argtypes[j] is CALLBACK and not isinstance(
784 args[i], CALLBACK
785 ):
786 ars.append(CALLBACK(args[i]))
787 else:
788 ars.append(args[i])
789 i += 1
790 else: # an output
791 r, ar = self.fargs[j].get_var(bs)
792 ars.append(ar)
793 ret.append(r)
794 # print r, r._type_
795
796 # print (self.name, ars)
797 res = self.f(*ars)
798 # print res
799
800 if res == False:
801 err_code = _lib.pl_error_code()
802 err_msg = ctypes.create_string_buffer(ERROR_MSG_LEN)
803 _lib.pl_error_message(err_code, err_msg)
805 "pvcam error %d: %s" % (err_code, err_msg.value)
806 )
807
808 if len(ret) == 0:
809 return None
810 if len(ret) == 1:
811 return ret[0]
812 else:
813 return ret
814
815

Member Data Documentation

◆ buf_len

microscope.cameras.pvcam.dllFunction.buf_len

Definition at line 751 of file pvcam.py.

◆ f

microscope.cameras.pvcam.dllFunction.f

Definition at line 739 of file pvcam.py.

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

◆ fargnames

microscope.cameras.pvcam.dllFunction.fargnames

Definition at line 744 of file pvcam.py.

◆ fargs

microscope.cameras.pvcam.dllFunction.fargs

Definition at line 743 of file pvcam.py.

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

◆ in_args

microscope.cameras.pvcam.dllFunction.in_args

Definition at line 748 of file pvcam.py.

◆ inp

microscope.cameras.pvcam.dllFunction.inp

Definition at line 747 of file pvcam.py.

◆ name

microscope.cameras.pvcam.dllFunction.name

◆ out_args

microscope.cameras.pvcam.dllFunction.out_args

Definition at line 749 of file pvcam.py.


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