本文整理汇总了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)
示例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))
示例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)
示例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()