Example #1
0
    def run(self):
        # AHRS
        self.isRunning = True
        count = 0
        #self.computerVisionProcess.start()

        # Logging System
        # Search through the directory we're in to find the next highest number for the file name.
        highestNum = 0
        for file in glob.glob('*.csv'):
            if file.startswith("exLog"):
                currentNum = int(file[5:-4])
                if currentNum > highestNum:
                    highestNum = currentNum

        highestNum += 1

        self.fileName = 'exLog' + str(highestNum)
        self.log = externalLoggingSystem.exLog(self.fileName)
        startTime = time.time()
        while self.isRunning:
            time.sleep(.01)
            if not self.isDebug:
                # Write to the log file every tenth of a second
                if time.time() - startTime >= .1:
                    #print "Calling writeData()"
                    #self.writeData()
                    startTime = time.time()

                #self.emit(QtCore.SIGNAL("requestCVData()"))
                self.emit(QtCore.SIGNAL("requestGuiData()"))

                self.computerVisionComm.setParameters(self.cvData)

                # Send data over sockets
                if self.computerVisionConnected:
                    self.computerVisionComm.sendParameters()

                self.getSensorData()
                self.detectionData = self.computerVisionComm.detectionData
                data = {
                    "ahrs": self.ahrsData,
                    "dvl": self.dvlGuiData,
                    "pmud": self.pmudGuiData,
                    "sib": self.sibGuiData,
                    "hydras": self.hydrasPingerData
                }

                self.emit(QtCore.SIGNAL("finished(PyQt_PyObject)"), data)
            else:
                #self.emit(QtCore.SIGNAL("requestCVData()"))
                #print "Test:  " + str(self.cvData)
                self.computerVisionComm.setParameters(self.cvData)
                if self.computerVisionConnected:
                    self.computerVisionComm.sendParameters()

                self.getSensorData()
                self.detectionData = self.computerVisionComm.detectionData
                #print self.detectionData

                self.emit(QtCore.SIGNAL("requestGuiData()"))

                data = {
                    "ahrs": self.ahrsGuiData,
                    "dvl": self.dvlGuiData,
                    "pmud": self.pmudGuiData,
                    "sib": self.sibGuiData,
                    "hydras": self.hydrasPingerData
                }

                if data != self.prevData:
                    self.prevData = data
                    self.emit(QtCore.SIGNAL("finished(PyQt_PyObject)"), data)
Example #2
0
    def run(self):
        # AHRS
        self.isRunning = True
        count = 0
        #self.computerVisionProcess.start()

        # Logging System
        # Search through the directory we're in to find the next highest number for the file name.
        highestNum = 0
        for file in glob.glob('*.csv'):
            if file.startswith("exLog"):
                currentNum = int(file[5:-4])
                if currentNum > highestNum:
                    highestNum = currentNum

        highestNum += 1

        self.fileName = 'exLog' + str(highestNum)
        self.log = externalLoggingSystem.exLog(self.fileName)
        startTime = time.time()
        while self.isRunning:
            time.sleep(.01)
            if not self.isDebug:
                # Write to the log file every tenth of a second
                if time.time() - startTime >= .1:
                    #print "Calling writeData()"
                    #self.writeData()
                    startTime = time.time()

                #self.emit(QtCore.SIGNAL("requestCVData()"))
                self.emit(QtCore.SIGNAL("requestGuiData()"))

                self.computerVisionComm.setParameters(self.cvData)

                # Send data over sockets
                if self.computerVisionConnected:
                    self.computerVisionComm.sendParameters()

                self.getSensorData()
                self.detectionData = self.computerVisionComm.detectionData
                data = {
                    "ahrs": self.ahrsData,
                    "dvl": self.dvlGuiData,
                    "pmud": self.pmudGuiData,
                    "sib": self.sibGuiData,
                    "hydras": self.hydrasPingerData
                }

                self.emit(QtCore.SIGNAL("finished(PyQt_PyObject)"), data)
            else:
                #self.emit(QtCore.SIGNAL("requestCVData()"))
                #print "Test:  " + str(self.cvData)
                self.computerVisionComm.setParameters(self.cvData)
                if self.computerVisionConnected:
                    self.computerVisionComm.sendParameters()

                self.getSensorData()
                self.detectionData = self.computerVisionComm.detectionData

                # Reconnect to the maestro after the kill switch
                '''
		try:
			self.maestroSerial.write(' ')
		except:
			#print "Couldn't write to maestro!, trying to reconnect"
			try:
				ports = glob.glob("/dev/ttyACM*")
				maestroPort =  None
				maestroPortNumber = 0
				for port in ports:
					#print "Trying port: ", port
					portNumber = int(port[11:])
					if portNumber <= maestroPortNumber:
						maestroPort = port
						maestroPortNumber = portNumber
				#print "Using port: ", maestroPort
				self.maestroSerial.close()
				self.maestroSerial = serial.Serial(maestroPort, 9600)
				#print "Connected to maestro after killing!"
			except:
				pass
				#print "Couldn't connect to maestro after killing."
		'''
                #print self.detectionData

                self.emit(QtCore.SIGNAL("requestGuiData()"))

                data = {
                    "ahrs": self.ahrsGuiData,
                    "dvl": self.dvlGuiData,
                    "pmud": self.pmudGuiData,
                    "sib": self.sibGuiData,
                    "hydras": self.hydrasPingerData
                }

                if data != self.prevData:
                    self.prevData = data
                    self.emit(QtCore.SIGNAL("finished(PyQt_PyObject)"), data)