当前位置: 首页>>代码示例>>Python>>正文


Python ConstBitStream.bitpos方法代码示例

本文整理汇总了Python中bitstring.ConstBitStream.bitpos方法的典型用法代码示例。如果您正苦于以下问题:Python ConstBitStream.bitpos方法的具体用法?Python ConstBitStream.bitpos怎么用?Python ConstBitStream.bitpos使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在bitstring.ConstBitStream的用法示例。


在下文中一共展示了ConstBitStream.bitpos方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: handle_read

# 需要导入模块: from bitstring import ConstBitStream [as 别名]
# 或者: from bitstring.ConstBitStream import bitpos [as 别名]
	def handle_read(self):
		#format: 20 bytes in total. Size: intle:16
		#Incomming messages comes with 160 bytes..
		data0 = self.recv(160);
		if data0:			
			data = ConstBitStream(bytes=data0, length=160)
			#print "All: %s" % data.bin
			
			msize = data.read('intle:16')
			mtype = data.read('intle:16')
			mtime = data.read('intle:64')
			
			# RA: 
			ant_pos = data.bitpos
			ra = data.read('hex:32')
			data.bitpos = ant_pos
			ra_uint = data.read('uintle:32')
			
			# DEC:
			ant_pos = data.bitpos
			dec = data.read('hex:32')
			data.bitpos = ant_pos
			dec_int = data.read('intle:32')
			
			#______ Testing:
			# Sends back to Stellarium the received coordinates, in order to update the field of view indicator
			(sra, sdec, stime) = coords.eCoords2str(float("%f" % ra_uint), float("%f" % dec_int), float("%f" %  mtime))
			self.act_pos(coords.hourStr_2_rad(sra), coords.degStr_2_rad(sdec))
			#______ End Testing
			
			# Emits the signal with received equatorial coordinates (for use in external Qt Gui..)
			self.stell_pos_recv.emit("%f" % ra_uint, "%f" % dec_int, "%f" %  mtime)
开发者ID:AishPadmanabha,项目名称:Arduino-Telescope-Control,代码行数:34,代码来源:telescope_server.py

示例2: handle_read

# 需要导入模块: from bitstring import ConstBitStream [as 别名]
# 或者: from bitstring.ConstBitStream import bitpos [as 别名]
    def handle_read(self):
        #format: 20 bytes in total. Size: intle:16
        #Incomming messages comes with 160 bytes..
        data0 = self.recv(160);
        if data0:            
            data = ConstBitStream(bytes=data0, length=160)
            print "All: %s" % data.bin
 
            msize = data.read('intle:16')
            mtype = data.read('intle:16')
            mtime = data.read('intle:64')
 
            # RA: 
            ant_pos = data.bitpos
            ra = data.read('hex:32')
            data.bitpos = ant_pos
            ra_uint = data.read('uintle:32')
 
            # DEC:
            ant_pos = data.bitpos
            dec = data.read('hex:32')
            data.bitpos = ant_pos
            dec_int = data.read('intle:32')
 
            logging.debug("Size: %d, Type: %d, Time: %d, RA: %d (%s), DEC: %d (%s)" % (msize, mtype, mtime, ra_uint, ra, dec_int, dec))
            (sra, sdec, stime) = coords.eCoords2str(float("%f" % ra_uint), float("%f" % dec_int), float("%f" %  mtime))
 
            #Sends back the coordinates to Stellarium
            self.act_pos(coords.hourStr_2_rad(sra), coords.degStr_2_rad(sdec))
开发者ID:lfortuna,项目名称:TelescopeController,代码行数:31,代码来源:telescope.py

示例3: handle_read

# 需要导入模块: from bitstring import ConstBitStream [as 别名]
# 或者: from bitstring.ConstBitStream import bitpos [as 别名]
    def handle_read(self):
       
        data0 = self.recv(160);
        if data0:            
            data = ConstBitStream(bytes=data0, length=160)
            # print "All: %s" % data.bin
 
            msize = data.read('intle:16')
            mtype = data.read('intle:16')
            mtime = data.read('intle:64')
 
            # RA: 
            ant_pos = data.bitpos
            ra = data.read('hex:32')
            data.bitpos = ant_pos
            ra_uint = data.read('uintle:32')
 
            # DEC:
            ant_pos = data.bitpos
            dec = data.read('hex:32')
            data.bitpos = ant_pos
            dec_int = data.read('intle:32')
             
            logging.debug("Size: %d, Type: %d, Time: %d, RA: %d (%s), DEC: %d (%s)" % (msize, mtype, mtime, ra_uint, ra, dec_int, dec))
                       
            (ra, dec, time) = coords.int_2_rads(ra_uint, dec_int, mtime)

            x = transformar_coordenadas(dec, ra)
            az,alt = x.get_azi_alt()

            #instancia o motor de azimute nos pinos 12, 16, 20 e 21 do RPi
            motor_az = Motor([31,33,35,37])
            motor_az.rpm = 5
            motor_az.mode = 2
            motor_az.move_to(az-self.az_anterior)
            self.az_anterior = az

            #instancia o motor de azimute nos pinos 32, 36, 38 e 40 do RPi
            motor_alt = Motor([32,36,38,40])
            motor_alt.rpm = 5
            motor_alt.mode = 2
            motor_alt.move_to(alt-self.alt_anterior)
            self.alt_anterior = alt

            logging.debug("Azimute: %d, Altitude: %d" % (az,alt))
            
            # envia as cordenadas para o Stellarium
            self.act_pos(ra, dec)
开发者ID:israelps,项目名称:telescopioRpi,代码行数:50,代码来源:servidor.py

示例4: handle_read

# 需要导入模块: from bitstring import ConstBitStream [as 别名]
# 或者: from bitstring.ConstBitStream import bitpos [as 别名]
	def handle_read(self):
		#format: 20 bytes in total. Size: intle:16
		#Incomming messages comes with 160 bytes..
		data0 = self.recv(160);
		if data0:			
			data = ConstBitStream(bytes=data0, length=160)
			#print "All: %s" % data.bin

			msize = data.read('intle:16')
			mtype = data.read('intle:16')
			mtime = data.read('intle:64')

			# RA: 
			ant_pos = data.bitpos
			ra = data.read('hex:32')
			data.bitpos = ant_pos
			ra_uint = data.read('uintle:32')

			# DEC:
			ant_pos = data.bitpos
			dec = data.read('hex:32')
			data.bitpos = ant_pos
			dec_int = data.read('intle:32')

			logging.debug("Size: %d, Type: %d, Time: %d, RA: %d (%s), DEC: %d (%s)" % (msize, mtype, mtime, ra_uint, ra, dec_int, dec))
			(sra, sdec, stime) = coords.eCoords2str(float("%f" % ra_uint), float("%f" % dec_int), float("%f" %  mtime))

			#Sends back the coordinates to Stellarium
			self.act_pos(coords.hourStr_2_rad(sra), coords.degStr_2_rad(sdec))
			calibrate = raw_input("Do you want to calibrate? - Y/N \n")
			if calibrate == "Y":
				
				#Calibration GUI

				app = Tk()
				#app.title("Calibration")

				#app.configure(background = "grey")

				tframe = Frame(app)
				tframe.pack()

				lrframe = Frame(app)
				lrframe.pack()

				dframe = Frame(app)
				dframe.pack()

				bframe = Frame(app)
				bframe.pack(side = BOTTOM)

				def upCallBack():
					ser.write('w\n');
					#tkMessageBox.showinfo( "UP")


				def downCallBack():
					ser.write("s\n");
					#tkMessageBox.showinfo( "DOWN")
				def leftCallBack():
					ser.write("a\n");
					#tkMessageBox.showinfo( "LEFT")

				def rightCallBack():
					ser.write("d\n");
					#tkMessageBox.showinfo( "RIGHT")
				def close_window():
					app.destroy();


				UpButton = Button(tframe, text = "Up", command = upCallBack);
				UpButton.pack()
				DownButton = Button(dframe, text = "Down", command = downCallBack);
				DownButton.pack()
				LeftButton = Button(lrframe, text = "Left", command = leftCallBack);
				LeftButton.pack( side = LEFT)
				RightButton = Button(lrframe, text = "Right", command = rightCallBack);
				RightButton.pack( side = LEFT)
				DoneButton = Button(bframe, text = "Done", command = close_window);
				DoneButton.pack( side = BOTTOM)

				app.mainloop()
开发者ID:shoryaconsul,项目名称:Stellarium_Laser,代码行数:84,代码来源:stellarium_final_3.py


注:本文中的bitstring.ConstBitStream.bitpos方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。