示例#1
0
    def __init__(self):

        obdcomms = obd.obd()
        pidDict = self._SetupValues('all')

        while obdcomms.port:
            for (pid, dict) in pidDict.iteritems():
                try:
                    self._process_pids(pid, dict)
                except:
                    print 'None'
            time.sleep(2)
    def __init__(self):

        obdcomms = obd.obd()
        pidDict = self._SetupValues("all")

        while obdcomms.port:
            for (pid, dict) in pidDict.iteritems():
                try:
                    self._process_pids(pid, dict)
                except:
                    print "None"
            time.sleep(2)
示例#3
0
	def run_backend(self):
		import obd		
		self.obdcomms = obd.obd()	
		self._stop = False
		
		while (not self._stop) and (not xbmc.abortRequested):

			if (not self.obdcomms) or (not self.obdcomms.port):
				self.window.setProperty("OBD-Conn","No BT Comms")
				#log("OBD Serial not connected. Waiting 3s...")
				self.obdcomms = None
				xbmc.sleep(2000)
				self.obdcomms = obd.obd()	
			elif xbmc.getCondVisibility("Window.IsActive(home)"):
				#passDataToSkin('Stuff', ['bob', 'fred'], self.prop_prefix)
				
				pidDict = self._SetupValues('home')
				for (pid, dict) in pidDict.iteritems():
					try:
						if self._process_pids(pid, dict) == 0:	#No data, ign off
							if self.window.getProperty("OBD-Speed") != 'Off':
								self.window.setProperty("OBD-Conn","Ignition Off")
								self.window.setProperty("OBD-Speed",'Off')
								self.obdcomms = None
								#xbmc.executebuiltin('PlayerControl(Stop)')
							break
						else:
							self.window.setProperty("OBD-Conn","OK")
					except:
						log('PID process '+pid+' exception')
						xbmc.executebuiltin('Notification(Error,PID process '+pid+' exception,3000)')
				if self.window.getProperty("OBD-Speed") == 'Off':
					#Ignition on but engine off || Completely off
					self.window.setProperty("OBD-SpeedMPH",'0')
					#self.window.setProperty("OBD-Conn","Speed Empty")
					xbmc.sleep(3000)
				else:
				#Special Cases:
					try:
						boostPerc = int(int(self.window.getProperty("OBD-BoostPress"))-int(self.window.getProperty("OBD-BoostPress"))/20)
					#self.window.setProperty("OBD-BoostPercent",str(boostPerc))
						self.window.getControl(669).setPercent(boostPerc)
						speedMPH = round(float(self.window.getProperty("OBD-Speed"))*0.621371, 1)
						self.window.setProperty("OBD-SpeedMPH",str(speedMPH))
						setMPH = round(float(self.window.getProperty("OBD-CCSet"))*0.621371, 1)
						if setMPH>0:
							self.window.setProperty("OBD-SetMPH",str(setMPH))
						else:
							self.window.clearProperty("OBD-SetMPH")
						rpmPerc = int(int(self.window.getProperty("OBD-RPM"))/50)
						self.window.getControl(670).setPercent(rpmPerc)
						throtPerc = int(float(self.window.getProperty("OBD-Throttle")))
						self.window.getControl(671).setPercent(throtPerc)
						self.calcmpg()
					except:
						xbmc.executebuiltin('Notification(Error,Calculating imperial values from OBD data failed,3000)')
						log("Special cases OBD failed")
				#self.window.setProperty("OBD-RPMPercent",str(rpmPerc))
				#if OBDvolt: self.window.setProperty("OBD-V",OBDvolt)
			else: #on some other screen
				pidDict = self._SetupValues('fuelonly')
				for (pid, dict) in pidDict.iteritems():
					try:
						if self._process_pids(pid, dict) == 0:	#No data, ign off
							if self.window.getProperty("OBD-Speed") != 'Off':
								self.window.setProperty("OBD-Conn","Ignition Off")
								self.window.setProperty("OBD-Speed",'Off')
								self.obdcomms = None
							break
						else:
							self.window.setProperty("OBD-Conn","OK")
					except:
						log('PID process '+pid+' failed')
				if self.window.getProperty("OBD-Speed") == 'Off':
					#Ignition on but engine off || Completely off
					self.window.setProperty("OBD-SpeedMPH",'0')
					#self.window.setProperty("OBD-Conn","Speed Empty")
					xbmc.sleep(3000)
				else:
					self.calcmpg()
			if xbmc.getCondVisibility("IsEmpty(Window(home).Property(obd_backend_running))"):
				self._clear_properties()
				self._stop = True
			xbmc.sleep(350)	#Normal time between samples
示例#4
0
n = 40              # number of images
clipping = np.inf      # maximally acceptable pixel (for saturation correction)
srf = 1.0           # superresolution factor

# how are the filenames generated?
imagepath = '../../obd/data/epsilon_lyrae/'

def y_fname(i):
    return imagepath+"{0:08d}".format(i)+'.png'

test = imageio.imread(y_fname(10))

# intially there is no x
x = np.array([])

for i in range(1,n+1):
  # load the next observed image
  fname = y_fname(i)
  print('Processing {}'.format(fname))
  y = imageio.imread(fname)
  y = y[:,20:132,1].astype(np.float64)   # use only first color channel

  ##### THE MAIN WORK HORSE #####
  x, f = ob.obd(x, y, sf, maxiter)

  fig, ax = plt.subplots(1,3, figsize=(24., 8.))
  ax[0].imshow(y, origin='lower')
  ax[1].imshow(f, origin='upper')
  ax[2].imshow(x, origin='lower')
  plt.show()