示例#1
0
    def setParameter(self, name, value):
        """Set parameter. The value is automatically typecast to the correct data type corresponding to the type of parameter.

        .. note:: Setting a parameter with this function does not automatically change the configuration in the camera. In order to apply all changes, :py:func:`sendConfiguration` has to be called.

        :param str name: Name of the parameter exactly as stated in the PICam SDK manual.
        :param mixed value: New parameter value. If the parameter value cannot be changed, a warning is printed to stdout.
        """
        prm = pit.PicamParameter[name]

        exists = pit.pibln()
        self.lib.Picam_DoesParameterExist(self.cam, prm, ptr(exists))
        if not exists:
            print("Ignoring parameter", name)
            print("  Parameter does not exist for current camera!")
            return

        access = pit.piint()
        self.lib.Picam_GetParameterValueAccess(self.cam, prm, ptr(access))
        if pit.PicamValueAccessLookup[access.value] not in [
                "ReadWrite", "ReadWriteTrivial"
        ]:
            print("Ignoring parameter", name)
            print("  Not allowed to overwrite parameter!")
            return
        if pit.PicamValueAccessLookup[access.value] == "ReadWriteTrivial":
            print("WARNING: Parameter", name, " allows only one value!")

        # get type of parameter
        type = pit.piint()
        self.lib.Picam_GetParameterValueType(self.cam, prm, ptr(type))

        if type.value not in pit.PicamValueTypeLookup:
            print("Ignoring parameter", name)
            print("  Not a valid parameter type:", type.value)
            return

        if pit.PicamValueTypeLookup[type.value] in [
                "Integer", "Boolean", "Enumeration"
        ]:
            val = pit.piint(value)
            self.lib.Picam_SetParameterIntegerValue(self.cam, prm, val)

        if pit.PicamValueTypeLookup[type.value] == "LargeInteger":
            val = pit.pi64s(value)
            self.lib.Picam_SetParameterLargeIntegerValue(self.cam, prm, val)

        if pit.PicamValueTypeLookup[type.value] == "FloatingPoint":
            val = pit.piflt(value)
            self.lib.Picam_SetParameterFloatingPointValue(self.cam, prm, val)

        if pit.PicamValueTypeLookup[type.value] == "Rois":
            self.lib.Picam_SetParameterRoisValue(self.cam, prm, ptr(value))

        if pit.PicamValueTypeLookup[type.value] == "Pulse":
            self.lib.Picam_SetParameterPulseValue(self.cam, prm, ptr(value))

        if pit.PicamValueTypeLookup[type.value] == "Modulations":
            self.lib.Picam_SetParameterModulationsValue(
                self.cam, prm, ptr(value))
示例#2
0
 def StartAcquisition(self, N=1, timeout=10000):
     self.available = pit.PicamAvailableData()
     errors = pit.piint()
     running = pit.pibln()
     self.lib.Picam_IsAcquisitionRunning(self.cam, ptr(running))
     if running.value:
         print("ERROR: acquisition still running")
         return []
     t = time.time()
     self.lib.Picam_Acquire(self.cam, pit.pi64s(N), pit.piint(timeout),
                            ptr(self.available), ptr(errors))
     print("Durée de l'acquisition : %f s" % (time.time() - t))
示例#3
0
    def AcquisitionAssy(self, N=int(1)):
        #asynchronously initiates data acquisition and returns immediately.
        print('start Acquisiotn asynchrone')
        running = pit.pibln()
        self.lib.Picam_IsAcquisitionRunning(self.cam, ptr(running))
        #        print(running.value)
        #if running.value:
        #   print("ERROR: acquisition still running")
        #  return []
        t = time.time()
        self.setParameter("ReadoutCount", N)
        self.sendConfiguration()
        #print(self.getParameter("ReadoutCount"))

        self.lib.Picam_StartAcquisition(self.cam)
        print("Durée de l'acquisition : %f s" % (time.time() - t))
示例#4
0
 def Acquisition(self, N=1, timeout=10000):
     print('Acquire')
     self.available = pit.PicamAvailableData()
     errors = pit.piint()
     running = pit.pibln()
     self.lib.Picam_IsAcquisitionRunning(self.cam, ptr(running))
     #print('running value',running.value)
     if running.value:
         print("ERROR: acquisition still running")
         return []
     t = time.time()
     self.lib.Picam_Acquire(self.cam, pit.pi64s(N), pit.piint(timeout),
                            ptr(self.available), ptr(errors))
     #(cameraHandel,readoutcount,readouttimeout,outpoutParameter=avaible,outpouterrors)
     # print(self.getParameter("ReadoutCount"))
     print("Durée de l'acquisition : %f s" % (time.time() - t))
     #        print(errors)
     return t
示例#5
0
    def getParameter(self, name):
        prm = pit.PicamParameter[name]
        exists = pit.pibln()
        self.lib.Picam_DoesParameterExist(self.cam, prm, ptr(exists))

        # get type of parameter
        type = pit.piint()
        self.lib.Picam_GetParameterValueType(self.cam, prm, ptr(type))

        if pit.PicamValueTypeLookup[type.value] in [
                "Integer", "Boolean", "Enumeration"
        ]:
            val = pit.piint()

            # test whether we can read the value directly from hardware
            cr = pit.pibln()
            self.lib.Picam_CanReadParameter(self.cam, prm, ptr(cr))
            if cr.value:
                if self.lib.Picam_ReadParameterIntegerValue(
                        self.cam, prm, ptr(val)) == 0:
                    return val.value
            else:
                if self.lib.Picam_GetParameterIntegerValue(
                        self.cam, prm, ptr(val)) == 0:
                    return val.value

        if pit.PicamValueTypeLookup[type.value] == "LargeInteger":
            val = pit.pi64s()
            if self.lib.Picam_GetParameterLargeIntegerValue(
                    self.cam, prm, ptr(val)) == 0:
                return val.value

        if pit.PicamValueTypeLookup[type.value] == "FloatingPoint":
            val = pit.piflt()

            # NEW
            # test whether we can read the value directly from hardware
            cr = pit.pibln()
            self.lib.Picam_CanReadParameter(self.cam, prm, ptr(cr))
            if cr.value:
                if self.lib.Picam_ReadParameterFloatingPointValue(
                        self.cam, prm, ptr(val)) == 0:
                    return val.value
            else:
                if self.lib.Picam_GetParameterFloatingPointValue(
                        self.cam, prm, ptr(val)) == 0:
                    return val.value

        if pit.PicamValueTypeLookup[type.value] == "Rois":
            val = ptr(pit.PicamRois())
            if self.lib.Picam_GetParameterRoisValue(self.cam, prm,
                                                    ptr(val)) == 0:
                self.roisPtr.append(val)
                return val.contents

        if pit.PicamValueTypeLookup[type.value] == "Pulse":
            val = ptr(pit.PicamPulse())
            if self.lib.Picam_GetParameterPulseValue(self.cam, prm,
                                                     ptr(val)) == 0:
                self.pulsePtr.append(val)
                return val.contents

        if pit.PicamValueTypeLookup[type.value] == "Modulations":
            val = ptr(pit.PicamModulations())
            if self.lib.Picam_GetParameterModulationsValue(
                    self.cam, prm, ptr(val)) == 0:
                self.modPtr.append(val)
                return val.contents

        return None
示例#6
0
 def IsAcquisitionRunning(self):
     running = pit.pibln()
     self.lib.Picam_IsAcquisitionRunning(self.cam, ptr(running))
     #        print('isRunning')
     #        print(running.value)
     return running.value