Example #1
0
    def analiseImg(self, imgPath):
        print("analiseImg [%s]" % imgPath)
        img = Image.load(imgPath, keep_data=True)
        size = img.size
        self.wSize = size
        print("image size:", size)

        self.steps = self.analiseSteps(img)
        print("found legend steps", len(self.steps))

        cPath = "%s_casch_" % imgPath
        cCover = "%s_cover" % cPath
        cPolis = "%s_polis" % cPath
        cMeshs = "%s_meshs" % cPath
        if self.fa.isFile(cMeshs):
            print("pickle meshs :) ?")
            m = DataSR_restore(cMeshs)
            self.polis = {}
            print("got from cashe file steps", len(m))
            for si, k in enumerate(m.keys()):
                print("restoring step", k)
                print("meshes", len(m[k]))
                m0 = Polygon()
                meshs = m[k]
                for me in meshs:
                    print("points:", len(me))
                    #print("->",me)
                    m1 = Polygon(me).simplify(0.1, preserve_topology=True)
                    m0 = m0.union(m1).simplify(0.1, preserve_topology=True)
                self.polis[int(k)] = m0
                print("poli DONE area", self.polis[int(k)].area)

        else:
            self.cover, self.polis, self.meshs = self.analiseCover(img)
            DataSR_save(self.meshs, cMeshs)
Example #2
0
    def saveTriaItems(self):
        print("saveTriaItems", len(self.triaItems))
        ts = []
        for t in self.triaItems:
            ts.append(t.getDict())

        print("status of saving", DataSR_save(ts, self.fileStoragePath))
Example #3
0
    def saveConfig(self):
        print("ScreenWidgets.saveConfig")  #,self.wConfig)

        print(" clean stuff befoare save to file")
        for s in self.wConfig:
            for w in s:
                w['obj'] = ''

        #print("-------------------------------------------")
        #print(self.wConfig)
        #print("-------------------------------------------")

        print("save config Widgets res:",
              DataSR_save(self.wConfig, self.wConfigPath))
Example #4
0
	def on_recordToFile(self):
		#print("on_recordToFile ",self.recordToFile)
		if self.recordToFile == "active":
			self.recordToFile = "ready"
			if len(self.toFileList)>0:
				fileName = "%srecord_%s.rec"% (
					self.gui.workingFolderAdress,
					self.th.getNiceFileNameFromTimestamp() 
					)
				DataSR_save(self.toFileList, fileName)
				print("writing lines (%s) to file %s"%(len(self.toFileList),fileName))
				self.toFileList = []
			self.gui.rl.ids.b_sensorsRecToFil.text = "Record to file"	
		else:
			self.recordToFile = "active"
			self.gui.rl.ids.b_sensorsRecToFil.text = "recording ..."	
Example #5
0
 def saveData(self):
     print("odometer save data")
     print("    res", DataSR_save(self.data, self.dataFilePath))
Example #6
0
	def calibrateIter(self):
		print("calibrate iter [%s]"%self.calibrateStep)
		step = self.calibrateStep
		calLastFor = self.th.getTimestamp() - self.calibationTimeStart
		
		if calLastFor > (60*5): # 5 min
			self.calibrateStep = 0
			self.queryMessage.dismiss()
		
		if step == 1:
			bufLen = len(self.calBuf)
			self.calCompas.append(self.comCal.hdg)
			comRes = self.sinWaveAnalitic(self.calCompas)
			print("	calibrate gyro [ ups %s downs %s ]" % ( comRes['ups'], comRes['downs'] ) )
			gf = self.gyroFlipt.getVals()
			self.calBuf['x'].append(gf[0])
			self.calBuf['y'].append(gf[1])
			self.calBuf['z'].append(gf[2])
			self.calHeel.append(self.orientation.x)
			self.calPitch.append(self.orientation.y)
			
			print("z axis:")
			print( self.sinWaveAnalitic(self.calBuf['z']) )
			print("compas axis:")
			print( comRes )

			whatInOn = str("calibrating in progress ... [%s/2][%s/2] %s"%(comRes['ups'],comRes['downs'],round(self.comCal.hdg,1)))
			
			self.queryMessage.ids.bt_cancel.text = str(
				self.th.getNiceHowMuchTimeItsTaking( calLastFor ) 
				)
			
			#self.gui.rl.ids.bModSimCal.text = whatInOn
			self.queryMessage.title = whatInOn
			
			waitUpTo = 2
			if comRes['ups'] == waitUpTo and comRes['downs'] == waitUpTo:
				step = 2
			
		if step == 2:
			avgx = sum(self.calBuf['x'])/len(self.calBuf['x'])
			avgy = sum(self.calBuf['y'])/len(self.calBuf['y'])
			avgz = sum(self.calBuf['z'])/len(self.calBuf['z'])
			
			tSpand = float(self.th.getTimestamp() - self.calTStart)
			heelHz = (self.sinWaveAnalitic(self.calBuf['x'],4)['downs']/tSpand)
			pitchHz = (self.sinWaveAnalitic(self.calBuf['y'],4)['downs']/tSpand)
			self.gui.rl.ids.lModSimGyroHeelHz.text = str(round(heelHz,2))
			self.gui.rl.ids.lModSimGyroPitchHz.text = str(round(pitchHz,2))
			
			print("	avg ",avgx,avgy, avgz)
			self.gyroFlipt.setOffset([avgx,avgy,avgz])
			
			self.orientation.setOffset([
				sum(self.calHeel)/len(self.calHeel),
				sum(self.calPitch)/len(self.calPitch),
				0.0
				])
			
			self.calBuf = {'x':[], 'y':[],'z':[]}
			self.calCompas = []
			self.calibrateStep = 0 
			self.gui.rl.ids.bModSimCal.text = str("Calibrated at %s"%self.th.getNiceDateFromTimestamp())
			self.queryMessage.dismiss()
		
			dataToFila = {
				"gyroFlipt.offset": [avgx,avgy,avgz],
				"orientation.offset": [
					sum(self.calHeel)/len(self.calHeel),
					sum(self.calPitch)/len(self.calPitch),
					0.0
					],
				"heelHz": heelHz,
				"pitchHz": pitchHz
				}
			
			DataSR_save(dataToFila, "ykpilot_calibration.conf")
			print("config file on drive. ykpilot_calibration.conf")
Example #7
0
            print("------------ trackback ------------")
            print("-------------print_exc")
            traceback.print_exc(limit=100, file=sys.stdout)
            print("-------------print_exc")

    # not android
    else:
        print("not android host")
        g = gui()
        g.run()

        print("force to save config for ykpilot")
        g.on_pause()

        print("end process trying to save qrl status to file")
        data = g.driver9.qa.q_table
        file = "./qs_q_table_test2.zip"
        res = DataSR_save(data, file, True)
        print("saved ? res", res)

print("------------ trackback ------------")
print(traceback.format_exc())
'''
TODO
[] - vfb load in kivy
[] - load page on add widget list of widgets
[] - load page on add widget form

[+] - screen sensors on load page
'''