コード例 #1
0
    def findallcams(self):
        """Find all cameras of this vendor

        Returns
        -------
        cams : dictionary
            Dictionary of all connected cameras where the key is the unique id
            that can be used to obtain a camera handle. The value is a
            description of the camera presented to the user.

        """
        err0, ndev = self.ueyeapi.is_GetNumberOfCameras()
        self._ce(err0)
        # ndev = int(ndev)

        cams = {}
        # get a device key for each camera and then the info on the camera
        err1, caminfo = self.ueyeapi.is_GetCameraList(camnum=ndev)
        self._ce(err1)

        camnum = int(getattr(caminfo, 'dwCount'))
        log.info('Found %i UEye cameras' % int(camnum))

        caminfolist = getattr(caminfo, 'uci[1]')

        for i in range(camnum):

            serial = getattr(caminfolist[i], 'SerNo[16]')
            manufacturer = 'IDS UEye'
            product = getattr(caminfolist[i], 'Model[16]')
            cams[serial] = '%s_%s_%s' % (manufacturer, product, serial)
            log.debug('Added camera %s_%s_%s' %
                      (manufacturer, product, serial))
        return cams
コード例 #2
0
    def findallcams(self):
        """Find all cameras of this vendor

        Returns
        -------
        cams : dictionary
            Dictionary of all connected cameras where the key is the unique id
            that can be used to obtain a camera handle. The value is a
            description of the camera presented to the user.

        """
        res = {}
        cams = [xiapi.Camera(0)]
        ndev = cams[0].get_number_devices()
        log.info('Found %i ximea cameras' % ndev)
        if ndev == 0:
            log.error('No cameras found')
        for ii in range(ndev - 1):
            cams.append(xiapi.Camera(ii + 1))
        for ii in range(ndev):
            serial = cams[ii].get_device_info_string("device_sn").decode(
                "utf8")
            res[serial] = {
                "serial":
                serial,
                "type":
                cams[ii].get_device_info_string("device_type").decode("utf8"),
                "name":
                cams[ii].get_device_info_string("device_name").decode("utf8"),
            }
        return res
コード例 #3
0
    def findallcams(self):
        """Find all cameras of this vendor

        Returns
        -------
        cams : dictionary
            Dictionary of all connected cameras where the key is the unique id
            that can be used to obtain a camera handle. The value is a
            description of the camera presented to the user.

        """
        self._ce(vrm.VRmUsbCamUpdateDeviceKeyList())
        ndev = vrm.VRmDWORD()
        self._ce(vrm.VRmUsbCamGetDeviceKeyListSize(byref(ndev)))
        ndev = int(ndev.value)
        log.info('Found %i VRM cameras' % ndev)
        cams = {}
        # get a device key for each camera and then the info on the camera
        for nn in range(ndev):
            devkey = vrm.POINTER(vrm.VRmDeviceKey)()
            self._ce(vrm.VRmUsbCamGetDeviceKeyListEntry(nn, byref(devkey)))
            serial = devkey.contents.m_serial
            manufacturer = devkey.contents.mp_manufacturer_str.data.decode(
                'utf-8')
            product = devkey.contents.mp_product_str.data.decode('utf-8')
            cams[serial] = '%s_%s_%s' % (manufacturer, product, serial)
            log.debug('Added camera %s_%s_%s' %
                      (manufacturer, product, serial))
        return cams
コード例 #4
0
ファイル: app.py プロジェクト: martinlink00/loggerapp
def keyboardInterruptHandler(signal, frame):
    guiint.thread.stop()
    log.debug('Thread stopped.')
    log.debug('Going to close all cams now.')
    guiint.sensormngr.closeallcams()
    log.debug('All cams were closed.')
    log.debug('Closing all temperature sensors.')
    guiint.sensormngr.closealltemp()
    log.debug('All temperature sensors closed.')
    log.info("Program was stopped. You can now close the Browser Tab".format(
        signal))
    exit(0)
コード例 #5
0
 def closealltemp(self):
     """Close all temperature sensors in self._connectedtemp."""
     try:
         mydll = ctypes.windll.LoadLibrary(DLLPATH)
         for hand in self._connectedtemp:
             log.info("Closing temperature sensor with the handle %s" %
                      hand)
             mydll.usb_tc08_close_unit(int(hand))
             log.info("Temperature sensor of handle %s has been closed." %
                      hand)
     except:
         pass
コード例 #6
0
ファイル: iter.py プロジェクト: martinlink00/loggerapp
def snapshot(sensor, client):
    starttime = time()
    sensordata = sensor.exporttoinflux()
    if sensordata is not None:
        client.write_points(sensordata)
        endtime = time()
        log.info(
            "Sensor %s of type %s has exported data via a snapshot. This took %f seconds."
            % (sensor.sensor, sensor.type, endtime - starttime))
    else:
        log.warning("Sensor %s of type %s could not export data" %
                    (sensor.sensor, sensor.type))
コード例 #7
0
ファイル: app.py プロジェクト: martinlink00/loggerapp
def update_output(on, rate):
    if on:
        guiint.thread.start()
        guiint.setrate(rate)
        log.info(
            "Data logger is turned on. Periodic sensors export every %f seconds."
            % (guiint.getrate()))
        return 'The datalogger is turned on. Periodic sensors export every %f seconds.' % (
            guiint.getrate())
    else:
        guiint.thread.stop()
        log.info("Data is not being logged at the moment")
        return 'The datalogger is turned off'
コード例 #8
0
 def _initiateni(self):
     """Finds all nidaqmx devices and returns device key."""
     try:
         system = nidaqmx.system.System.local()
         devlist = system.devices
         devstrlist = []
         for device in devlist:
             devstrlist.append(device.name)
             log.info("NI device with the devstring %s was encountered." %
                      device.name)
         return devstrlist
     except:
         return []
コード例 #9
0
    def _initiatetemplist(self):
        """Uses DLL in order to find an connect to all temperature handles. Returns list for said handles."""
        try:
            mydll = ctypes.windll.LoadLibrary(DLLPATH)
        except:
            log.error('Failed to load DLL file usbtc08.dll')
            return None
        id = 1
        templist = []
        devlist = []
        while id != 0:
            id = mydll.usb_tc08_open_unit(
            )  #Returns device handle, or 0 if no device was found, or -1 if an error occured
            if id != -1:
                if id != 0:
                    log.info("Temperature sensor of handle %i encountered." %
                             id)
                    templist.append(str(id))
                    devlist.append(id)
            else:
                err = mydll.usb_tc08_get_last_error(0)
                if err == 1:
                    log.error(
                        'Failed to connect to temperature sensor: USBTC08_ERROR_OS_NOT_SUPPORTED'
                    )
                if err == 2:
                    log.error(
                        'Failed to connect to temperature sensor: USBTC08_ERROR_NO_CHANNELS_SET'
                    )
                if err == 3:
                    log.error(
                        'Failed to connect to temperature sensor: USBTC08_ERROR_INVALID_PARAMETER'
                    )
                if err == 4:
                    log.error(
                        'Failed to connect to temperature sensor: USBTC08_ERROR_VARIANT_NOT_SUPPORTED'
                    )
                if err == 5:
                    log.error(
                        'Failed to connect to temperature sensor: USBTC08_ERROR_INCORRECT_MODE'
                    )
                if err == 6:
                    log.error(
                        'Failed to connect to temperature sensor: USBTC08_ERROR_ENUMERATION_INCOMPLETE'
                    )
                break

        return templist
コード例 #10
0
ファイル: iter.py プロジェクト: martinlink00/loggerapp
def cycle(sensors, client):
    #sensors: dictionary of the format {trigger:sensorlist}
    for trigger in sensors.keys():
        if trigger.checktrigger():
            for sensor in sensors[trigger]:
                starttime = time()
                sensordata = sensor.exporttoinflux()
                if sensordata is not None:
                    client.write_points(sensordata)
                    endtime = time()
                    log.info(
                        "Sensor %s of type %s has exported data via a %s trigger. This took %f seconds."
                        % (sensor.sensor, sensor.type, sensor.trigger,
                           endtime - starttime))
                else:
                    log.warning("Sensor %s of type %s could not export data" %
                                (sensor.sensor, sensor.type))
            sleep(trigger.timeout)
コード例 #11
0
    def startcontacq(self):
        """Start continuous picture acquisition.

        Put acquired images on in the image queue.

        """
        #log.debug('Trying to start camera %s' % self._camid)
        self._cam.start_acquisition()
        if self._imagecapturethread is not None:
            log.error("XIMEA ERROR in start_capture: Capture running")
        else:
            log.info("XIMEA: Start capture.")
            self._imagecapturethread = XiapiDataWatcher(
                "Xiapi_watcher_{}".format(self._camid),
                self,
                self.get_image,
                self._imagequeue,
                daemon=True,
                stop_event_interval=0.05,
            )
            self._imagecapturethread.start()
コード例 #12
0
ファイル: app.py プロジェクト: martinlink00/loggerapp
def manuallysetroi(n_clicks, roiinputx, roiinputy, roiinputw, roiinputh):
    if roiinputx is not None:
        guiint.camviewer.getselectedcam().IA.setroi(posx=roiinputx)
        log.info("ROI x-Coordinate was changed to %f" % (roiinputx))

    if roiinputy is not None:
        guiint.camviewer.getselectedcam().IA.setroi(posy=roiinputy)
        log.info("ROI y-Coordinate was changed to %f" % (roiinputy))

    if roiinputw is not None:
        guiint.camviewer.getselectedcam().IA.setroi(width=roiinputw)
        log.info("ROI width was changed to %f" % (roiinputw))

    if roiinputh is not None:
        guiint.camviewer.getselectedcam().IA.setroi(height=roiinputh)
        log.info("ROI height was changed to %f" % (roiinputh))
コード例 #13
0
    def __init__(self):

        self._cameramanager = self._initiatecamman()

        self._connectedcams = self._connectedcams()

        self._connectedtemp = self._initiatetemplist()

        self._connectedni = self._initiateni()

        self._paramlist = self._paramfromfile()

        self._triggerconf = self._triggerfromfile()

        self._tobeconfigured = self._getmissingsensors()

        self._overlyconfigured = self._getnonconnectedsensors()

        #Rewrite sensorxml file

        for ov in self._overlyconfigured.keys():
            if ov == "camera":
                for cam in self._overlyconfigured[ov]:
                    log.info(
                        "The connected camera %s %s is mentioned in sensorconfig.xml and yet does not seem to be connected."
                        % cam)
                    delnow = input(
                        "Delete camera %s %s from sensorconfig.xml? (y/n)" %
                        cam)
                    if delnow == "y":
                        self._delcamerasensorfromxml(cam[0], cam[1])
                        log.info(
                            "Camera %s %s was deleted from sensorconfig.xml." %
                            cam)
            if ov == "temperature":
                for temp in self._overlyconfigured[ov]:
                    log.info(
                        "The connected temperature sensor %s is mentioned in sensorconfig.xml and yet does not seem to be connected."
                        % temp)
                    delnow = input(
                        "Delete temperature sensor with the handle %s from sensorconfig.xml? (y/n)"
                        % temp)
                    if delnow == "y":
                        self._deltempsensorfromxml(temp)
                        log.info(
                            "Temperature sensor with the handle %s was deleted from sensorconfig.xml."
                            % temp)
            if ov == "nianalog":
                for ni in self._overlyconfigured[ov]:
                    log.info(
                        "The connected national instruments sensor %s is mentioned in sensorconfig.xml and yet does not seem to be connected."
                        % ni)
                    delnow = input(
                        "Delete national instruments sensor with the devstring %s from sensorconfig.xml? (y/n)"
                        % ni)
                    if delnow == "y":
                        self._delnisensorfromxml(ni)
                        log.info(
                            "National instruments sensor with the handle %s was deleted from sensorconfig.xml."
                            % ni)

        for miss in self._tobeconfigured.keys():
            if miss == "camera":
                for cam in self._tobeconfigured[miss]:
                    log.info(
                        "The connected camera %s %s is not yet configured in sensorconfig.xml."
                        % cam)
                    configurenow = input("Configure %s %s now? (y/n) " % cam)
                    if configurenow == "y":
                        nobeams = input(
                            "How many beams are tracked with this camera? ")
                        try:
                            beamlist = range(int(nobeams))
                        except:
                            log.error("Bad input. Config process stopped.")
                            break

                        for beam in beamlist:
                            beamname = input(
                                "What name should beam number %i be logged as? "
                                % (beam + 1))
                            self._addcamerasensortoxml(cam[0], cam[1],
                                                       beamname,
                                                       "(0,0,100,100)")
            if miss == "temperature":
                for temp in self._tobeconfigured[miss]:
                    log.info(
                        "The connected temperature sensor with the handle %s is not yet configured in sensorconfig.xml."
                        % temp)
                    configurenow = input("Configure %s now? (y/n) " % temp)
                    if configurenow == "y":
                        tempid = input(
                            "What name should this sensor be logged as? ")
                        defaultlist = []
                        for i in range(0, 9):
                            st = 'Channel ' + str(i + 1)
                            defaultlist.append(st)
                        self._addtempsensortoxml(tempid, miss, defaultlist)
            if miss == "nianalog":
                for ni in self._tobeconfigured[miss]:
                    log.info(
                        "The connected national instruments sensor with the devstring %s is not yet mentioned in sensorconfig.xml."
                        % ni)
                    configurenow = input("Configure %s now? (y/n) " % ni)
                    if configurenow == "y":
                        eich = input("What eich factor should be used? ")
                        self._addnisensortoxml(ni, eich, "national")

        #Reread edited xml file
        self._paramlist = self._paramfromfile()

        self._tobeconfigured = []

        self._overlyconfigured = []

        self._connectedcamexp = self._initiatecamexpdict()

        self._sensorlist = self._initiatesensorlist()

        self._sensordict = self._initiatesensordict()