本文整理汇总了Python中transmitter.Transmitter类的典型用法代码示例。如果您正苦于以下问题:Python Transmitter类的具体用法?Python Transmitter怎么用?Python Transmitter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Transmitter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
def main():
nrx=3
# Create a tx
ntx=3
ta = None
#ta = SampleRate()
transmitter = Transmitter(ntx,ta)
# Create a channel
chan = TraceChan()
num_chans=1
length = chan.create_chan(transmitter.Ntx,nrx)
#ta = OracleRA(chan)
#transmitter.set_transmit_ra(ta)
#receiver = Receiver(MaxTputRA(),nrx)
#receiver = Receiver(MinEngRA(),nrx)
receiver = Receiver(EngTputRA(),nrx)
#receiver = Receiver(EffSnrRA(),nrx)
#receiver = Receiver(RxSampleRate(),nrx)
#receiver = Receiver(RxOracle(),nrx)
#length =10
for num in range(0,length):
pkt = transmitter.transmit_pkt()
chan.apply_channel(pkt)
#print chan.curr_chan
#print pkt
# Create receiver
receiver.receive_pkt(pkt)
ack_pkt = receiver.get_feedback_pkt()
transmitter.process_ack(ack_pkt)
示例2: test_set_transmitter_exactly_once
def test_set_transmitter_exactly_once(self):
tt = Transmitter()
url = 'whee.com'
username = 'boyhowdy'
account = Account(url, username, None)
tt.set_account(account)
aa = ElyxerEntry()
aa.set_transmitter(tt)
self.assertRaises(TransmitterAlreadyExistsError, lambda: aa.set_transmitter(tt))
示例3: test_upload_entry
def test_upload_entry(self):
tt = Transmitter()
tt.set_account(self.account_with_good_password)
filename = 'test_files/entry_test'
entry = ElyxerEntry()
entry.set_transmitter(tt)
entry.load(filename)
entry.set_title('WoooYAH!')
tt.publish_entry(entry)
示例4: main
def main():
if len(sys.argv) == 6:
filename = sys.argv[1]
card_type = sys.argv[2]
energy_constraint = sys.argv[3]
chan_pred = eval(sys.argv[4])
increment = eval(sys.argv[5])
print "filename: " + str(filename)
else:
print "Correct usage: python simulate_maxtput.py trace_file card_type tx/rx pred(True/False)"
sys.exit(1)
nrx = 3
# Create a tx
ntx = 3
ta = None
transmitter = Transmitter(ntx, ta)
# Create a channel
chan = TraceChan(filename)
num_chans = 1
length = chan.create_chan(transmitter.Ntx, nrx)
extname = (
filename.split("/")[-1].split(".")[0]
+ "_"
+ card_type
+ "_"
+ energy_constraint
+ "_pred"
+ str(chan_pred)
+ "_inc"
+ str(increment)
)
# print extname
receiver = PPrReceiver(PPrMinEngRA(card_type, energy_constraint, chan_pred), nrx, extname)
if length > 10000:
length = 10000
# length = 2
for num in range(0, length):
itr_tic = time.clock()
pkt = transmitter.transmit_pkt()
chan.apply_channel(pkt)
# print chan.curr_chan
# print pkt
# Create receiver
receiver.receive_pkt(pkt)
ack_pkt = receiver.get_feedback_pkt()
transmitter.process_ack(ack_pkt)
itr_toc = time.clock()
示例5: test_publish_image
def test_publish_image(self):
Image.set_abs_reference_dir_from_html_file(self.filename)
account = AccountManager.get_default_account()
tt = Transmitter()
tt.set_account(account)
image = Image("some <img src='Suzanne.jpg' /> string")
before = image.get_remote_src()
self.assertEqual(before, None)
tt.publish_image(image)
after = image.get_remote_src()
self.assertNotEqual(after, None)
示例6: __init__
def __init__(self):
self.__transmitter = Transmitter()
self.__configpath = self.__set_configpath()
self.__config = self.__init_config()
self.__default_account = AccountManager.get_default_account()
self.__accounts = []
self.__load_accounts_from_config()
示例7: main
def main():
if len(sys.argv) == 7:
filename = sys.argv[1]
card_type = sys.argv[2]
energy_constraint = sys.argv[3]
chan_pred = eval(sys.argv[4])
threshold = eval(sys.argv[5])
increment = eval(sys.argv[6])
print "filename: "+str(filename)
else:
print "Correct usage: python simulate_engtput.py trace_file card_type tx/rx pred(True/False) threshold chan_increment"
sys.exit(1)
nrx=3
# Create a tx
ntx=3
ta = None
transmitter = Transmitter(ntx,ta)
# Create a channel
chan = TraceChan(filename, increment)
length = chan.create_chan(transmitter.Ntx,nrx)
extname=filename.split('/')[-1].split('.')[0]+"_"+card_type+"_"+energy_constraint+"_pred"+str(chan_pred)+"th"+str(threshold)+"_inc"+str(increment)
receiver = Receiver(EngTputRA(card_type,energy_constraint,chan_pred,threshold),nrx,extname)
if length > 10000: length = 10000
for num in range(0,length):
pkt = transmitter.transmit_pkt()
chan.apply_channel(pkt)
#print chan.curr_chan
#print pkt
# Create receiver
receiver.receive_pkt(pkt)
ack_pkt = receiver.get_feedback_pkt()
transmitter.process_ack(ack_pkt)
示例8: main
def main():
if len(sys.argv) == 5:
filename = sys.argv[1]
card_type = sys.argv[2]
energy_constraint = sys.argv[3]
chan_pred = eval(sys.argv[4])
print "filename: "+str(filename)
else:
print "Correct usage: python simulate_effsnr.py trace_file card_type tx/rx pred(True/False)"
sys.exit(1)
nrx=3
# Create a tx
ntx=3
ta = None
transmitter = Transmitter(ntx,ta)
# Create a channel
chan = TraceChan(filename)
num_chans=1
length = chan.create_chan(transmitter.Ntx,nrx)
extname=filename.split('/')[-1].split('.')[0]+"_"+card_type+"_"+energy_constraint+"_pred"+str(chan_pred)
receiver = Receiver(EffSnrRAEng(card_type,energy_constraint,chan_pred),nrx,extname)
for num in range(0,length):
pkt = transmitter.transmit_pkt()
chan.apply_channel(pkt)
#print chan.curr_chan
#print pkt
# Create receiver
receiver.receive_pkt(pkt)
ack_pkt = receiver.get_feedback_pkt()
transmitter.process_ack(ack_pkt)
示例9: main
def main():
if len(sys.argv) == 5:
filename = sys.argv[1]
card_type = sys.argv[2]
energy_constraint = sys.argv[3]
chan_pred = False
increment = 1
print "filename: "+str(filename)
elif len(sys.argv) == 6:
filename = sys.argv[1]
card_type = sys.argv[2]
energy_constraint = sys.argv[3]
chan_pred = False
increment = eval(sys.argv[5])
print "filename: "+str(filename)
else:
print "Correct usage: python simulate_effsnr.py trace_file card_type tx/rx pred(True/False) chan_increment"
sys.exit(1)
nrx=3
# Create a tx
ntx=3
ta = None
transmitter = Transmitter(ntx,ta)
# Create a channel
chan = TraceChan(filename,increment)
length = chan.create_chan(transmitter.Ntx,nrx)
ta = OraclePPrMaxTputRA(card_type,energy_constraint,chan)
transmitter.set_transmit_ra(ta)
extname=ta.name+"_"+filename.split('/')[-1].split('.')[0]+"_"+card_type+"_"+energy_constraint+"_pred"+str(chan_pred)+"_inc"+str(increment)
receiver = PPrReceiver(RxOracle(card_type,energy_constraint),nrx,extname)
if length > 10000: length = 10000
#length =10
for num in range(0,length):
pkt = transmitter.transmit_pkt()
chan.apply_channel(pkt)
#print chan.curr_chan
#print pkt
# Create receiver
receiver.receive_pkt(pkt)
ack_pkt = receiver.get_feedback_pkt()
transmitter.process_ack(ack_pkt)
示例10: start
def start():
get_arguments()
# Transmitter.transmit returns the new size of a block
new_block_size = Transmitter.transmit(parameter_dict[K],
parameter_dict[F])
# for T trials, repeat the simulation
for i in range(parameter_dict[T]):
# clear this trial's variables
trials_time = 0
trials_received_frames = 0
trials_failed_frames = 0
# Set the first seed for the simulation
Simulator.set_seed(parameter_dict[TSeeds][i])
while (trials_time <= parameter_dict[R]):
trials_received_blocks = 0 # new frame
trials_failed_blocks = 0 # new frame
# set the number of blocks to be transmitted in this frame
transmissions = parameter_dict[K]
if (parameter_dict[K] == 0):
transmissions = 1
# For K blocks (or 1 if K == 0), simulate the transmission
for j in range(transmissions): # range starts at 0
# frame_failure = 0 if block was transmitted successfully
block_failure = handle_block(new_block_size,
parameter_dict[E],
parameter_dict[K])
# record block success or failure
if (block_failure > 0):
trials_failed_blocks += 1
else:
trials_received_blocks += 1
# set trials_time to number of bits and response overhead
trials_time += (parameter_dict[F] +
(parameter_dict[K] * Transmitter.r)
+ parameter_dict[A])
# update number of transmitted frames
Statistics.update(Statistics.total_frames)
# frame failed, resend the frame
if(trials_failed_blocks >= 1):
trials_failed_frames += 1
# the last frame being sent (no longer needed) see forums
#elif(trials_time > parameter_dict[R]):
# pass
# successful transmition
else:
Statistics.update(Statistics.correctly_received_frames)
trials_received_frames += 1
#a print("Trial number:", i)
#a print("Received Frames", trials_received_frames)
#a print("Failed Frames", trials_failed_frames)
# Assume: Take all K*(F+r) trials_time units into account
# even if in last frame
Statistics.append(Statistics.throughput_averages,
((parameter_dict[F] * trials_received_frames)
/ trials_time))
if(trials_received_frames != 0):
# Assume: Take all frames into account, even last frame
Statistics.append(Statistics.frame_averages,
(trials_received_frames + trials_failed_frames) /
trials_received_frames)
else:
Statistics.append(Statistics.frame_averages, 0)
# Add to total time
Statistics.statistics_dict[Statistics.total_time] += trials_time
# Call Print Statements
#a print()
#a print("----------------------------------------------")
print_input(sys.argv)
Statistics.set_final_values(parameter_dict[F], parameter_dict[R])
Statistics.print_frame_ci()
Statistics.print_throughput_ci()
示例11: InitLogging
logging.basicConfig(level=logging.DEBUG,
format="%(asctime)s %(filename)s[line:%(lineno)d] %(levelname)s %(message)s",
datefmt="%Y-%m-%d %H:%M:%S",
filename=filename,
filemode="w")
console = logging.StreamHandler()
console.setLevel(logging.NOTSET)
formatter = logging.Formatter("%(asctime)s %(filename)s[line:%(lineno)d] %(levelname)s %(message)s")
console.setFormatter(formatter)
logging.getLogger('').addHandler(console)
if __name__ == '__main__':
InitLogging()
handler = Handler()
receiver = Receiver()
transmitter = Transmitter()
receiver.connect()
td1 = threading.Thread(target=handler.run)
td2 = threading.Thread(target=receiver.run)
td3 = threading.Thread(target=transmitter.run)
td1.start()
td2.start()
td3.start()
# main loop
while True:
if handler.is_runing() and receiver.is_runing() and transmitter.is_runing():
msg = receiver.fetch()
while msg != None:
handler.push(msg)
示例12: Transmitter
else:
logging.debug("MC running NOT on RPi")
GPIO.setmode(GPIO.BCM)
GPIO.setup(LED, GPIO.OUT) # status LED
GPIO.output(LED, GPIO.HIGH) # switch on to indicate software startup
GPIO.setup(RELEASE, GPIO.OUT) # release pin
GPIO.output(RELEASE, GPIO.LOW) # disable release
GPIO.setup(RELEASE_FB, GPIO.IN) # release feedback pin
GPIO.setup(HEADSHOT, GPIO.OUT) # set shutoff to output
GPIO.output(HEADSHOT, GPIO.LOW) # disable shutoff
GPIO.setup(CAMERA, GPIO.OUT) # set cam power to output
GPIO.output(CAMERA, GPIO.HIGH) # enable camera power
# setup the transmitter thread
txthread = Transmitter()
txthread.setDaemon(True)
txthread.start()
# setup the GPS-listener thread
gpsthread = GPSListener()
gpsthread.setDaemon(True)
gpsthread.start()
# wait for at least a 2D-Fix from the GPS
while GPSListener.fix < 2:
pass
logging.info("MC GPS fix OK")
# indicate GPS fix on LED
for i in range(1,15):
示例13: test_check_credentials_bogus
def test_check_credentials_bogus(self):
tt = Transmitter()
tt.set_account(self.bogus_account)
self.assertEquals(tt.check_credentials(), 'host not found')
示例14: test_check_credentials_no_password
def test_check_credentials_no_password(self):
tt = Transmitter()
tt.set_account(self.account_with_no_password)
self.assertEquals(tt.check_credentials(), True)
示例15: test_check_credentials_bad_password
def test_check_credentials_bad_password(self):
tt = Transmitter()
tt.set_account(self.account_with_bad_password)
self.assertEquals(tt.check_credentials(), 'username/password error')