本文整理匯總了Python中receiver.Receiver類的典型用法代碼示例。如果您正苦於以下問題:Python Receiver類的具體用法?Python Receiver怎麽用?Python Receiver使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Receiver類的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: main
def main():
# TODO: parse configuration file to retreive
# sender's and receiver's ip addresses
config_dict = parse_config()
if not config_dict:
print 'no config params'
return
sender_name = config_dict['IP'] + '_sender'
recv_name = config_dict['IP'] + '_receiver'
print 'sender name: ' + sender_name
print 'receiver name: ' + recv_name
s_obj = Sender()
r_obj = Receiver()
s_obj.ip_address = config_dict['IP']
r_obj.ip_address = config_dict['IP']
s_obj.multicast_address = config_dict['multicast']
r_obj.multicast_address = config_dict['multicast']
Pyro4.Daemon.serveSimple(
{
s_obj: sender_name,
r_obj: recv_name
},
ns=False,
port=45000,
host=config_dict["IP"]
)
示例3: ncd_loop
def ncd_loop(doInit, dlThreadNum):
ndutil.setTimezone()
#read config
cnfManager = CnfManager()
cnfManager.load('./ndc.cnf')
cnfData = cnfManager.getCnfData()
#check dirs
ndutil.enableDir(cnfData['dirWorking'])
ndutil.enableDir(cnfData['dirStore'])
#ndlcom
logger = Logger('nDroid-Crawler', cnfData['ndlComHost'], cnfData['ndlComPort'])
logger.logger('Initiating')
dbManager = DbManager(cnfData['dbHost'], cnfData['dbUser'], cnfData['dbPass'], cnfData['dbName'])
if doInit:
dbManager.create_table()
os.system('rm -f %s/*' % cnfData['dirWorking'])
os.system('rm -f %s/*' % cnfData['dirStore'])
#logger.logger('Customizing Spiders')
#spiderGenerator = SpiderGenerator('template', 'spider/spiders')
#for spider in cnfData['spiders']:
# spiderGenerator.gen_spider(spider, cnfData[spider]['startPage'], cnfData[spider]['stopPage'])
rpQueue = Queue()
pdQueue = Queue()
dpQueue = Queue()
pdLock = threading.Lock()
rpcMonitor = RpcMonitor(logger, cnfData['rpcPort'], cnfData['rpcAuth'], 'RpcMonitor')
rpcMonitor.setGlobalInfo(ndutil.getCurrentTimeStr(), 'Standalone', dlThreadNum)
rpcMonitor.setDownloadTotal(pdQueue.qsize())
rpcMonitor.setPdQueueSize(pdQueue.qsize())
botScheduler = BotScheduler(logger, rpcMonitor, cnfData['spiders'], cnfData['spiderCnfs'], 'BotScheduler')
receiver = Receiver(logger, rpcMonitor, rpQueue, cnfData['receiverPort'], 'Receiver')
preProcessor = PreProcessor(logger, rpcMonitor, rpQueue, pdQueue, pdLock, dbManager, 'PreProcessor')
downloader = Downloader([logger, rpcMonitor, pdQueue, dpQueue, pdLock, dlThreadNum, cnfData['dirWorking']], 'Downloader')
processor = Processor(logger, rpcMonitor, dpQueue, pdLock, pdQueue, dbManager, cnfData['dirWorking'], cnfData['dirStore'], 'Processor')
logger.logger('Starting Threads')
rpcMonitor.start()
botScheduler.start()
receiver.start()
preProcessor.start()
downloader.start()
processor.start()
processor.join()
downloader.join()
preProcessor.join()
receiver.join()
botScheduler.join()
rpcMonitor.join()
示例4: start_recvers
def start_recvers(self):
for port in self.cl_port_list:
addr = (self.cl_ip, port)
recver = Receiver(in_queue = self.queue_torecvers,
laddr = addr,
proto = self.proto,
rx_type = self.rx_type,
file_url = 'rx_over_%s.dat' % port,
logto = self.logto )
recver.start()
self.recver_thread_list.append(recver)
示例5: run
def run(self):
self.done = Event()
while not self.done.isSet():
print('Waiting for clients')
client_sock, client_info = self.server_sock.accept()
r = Receiver(self, client_sock, client_info)
r.daemon = True
r.start()
self.server_sock.close()
print('The server socket has been closed')
示例6: 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])
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 = 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) 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)+"_inc"+str(increment)
print extname
receiver = Receiver(MaxTputRA(card_type,energy_constraint,chan_pred),nrx,extname)
#length =22
if length > 10000: length = 10000
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()
print "one itr: "+str(itr_toc - itr_tic)
示例7: main
def main():
users = Users()
receiver = Receiver()
sender = Sender()
while True:
receiver.read_emails(users)
for user in users.users_map.values():
if user.modified:
sender.send_news(user.email, list(user.topics_set))
user.modified = False
print ('Sleeping')
sleep(10)
print ('Waking up')
示例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])
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)"
sys.exit(1)
nrx=3
# Create a tx
ntx=3
ta = None
transmitter = Transmitter(ntx,ta)
# Create a channel
chan = TraceChan(filename, increment)
num_chans=1
length = chan.create_chan(transmitter.Ntx,nrx)
ta = OracleEffSnrRA(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 = Receiver(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)
示例9: Broadcaster
class Broadcaster(object):
def __init__(self):
self._receiver = None
def register(self, receiver):
self._receiver = Receiver(receiver)
def has_receivers(self):
if self._receiver:
return True
else:
return False
def broadcast(self):
self._receiver.notify()
示例10: main
def main():
global indexer, uploader, sender, receiver, downloader
setup_signals()
logging.info("Asink client started at %s" %
(time.strftime("%a, %d %b %Y %X GMT", time.gmtime())))
#create all threads which will be used to process events
indexer = Indexer()
uploader = Uploader()
sender = Sender()
receiver = Receiver()
downloader = Downloader()
#create and set up queues which are used to pass events between threads
uploader_queue = Queue()
indexer.uploader_queue = uploader_queue
uploader.queue = uploader_queue
#set on watcher when initialized
sender_queue = Queue()
uploader.sender_queue = sender_queue
sender.queue = sender_queue
downloader_queue = Queue()
receiver.downloader_queue = downloader_queue
downloader.queue = downloader_queue
#setup storage provider
storage = setup_storage()
uploader.storage = storage.clone()
downloader.storage = storage
#start all threads
watcher.start_watching(uploader_queue)
indexer.start()
uploader.start()
sender.start()
receiver.start()
downloader.start()
#sleep until signaled, which will call sig_handler
while True:
time.sleep(86400) #= 24 hours just for fun
示例11: __init__
def __init__(self, packet_sender):
print 'Init Connection'
self.ee = EventEmitter()
self._sender = Sender(packet_sender)
self._receiver = Receiver(packet_sender)
@self._receiver.ee.on('data')
def on_data(data):
self.ee.emit('data', data)
示例12: welcome_s
def welcome_s(self, data_):
sch_req_id = data_['sch_req_id']
stpdst = data_['tp_dst']
qtorecver = Queue.Queue(0)
qfromrecver = Queue.Queue(0)
laddr = (self.cl_ip, int(stpdst))
recver = Receiver(in_queue = qtorecver,
out_queue = qfromrecver,
laddr = laddr,
proto = self.proto,
rx_type = 'kstardata',
file_url = 'kstardata_%s.dat' % stpdst,
logto = self.logto )
recver.start()
#
self.sinfo_dict[sch_req_id] = {'tp_dst': stpdst,
'qtorecver': qtorecver,
'qfromrecver': qfromrecver }
logging.info('welcome_s:: welcome sinfo=\n%s', pprint.pformat(self.sinfo_dict[sch_req_id]))
threading.Thread(target = self.waitfor_couplingtoend,
kwargs = {'sch_req_id': sch_req_id} ).start()
示例13: handle_block
def handle_block(new_block_size, E, K):
# Simulator.simulate returns the number of bit errors in each block
bit_errors = Simulator.simulate(new_block_size, E)
Statistics.update(Statistics.total_transmitions)
if (bit_errors != 0):
Statistics.update(Statistics.block_errors)
try:
Receiver.receive(bit_errors)
Statistics.update(Statistics.no_error)
Statistics.update(Statistics.correctly_received_blocks)
return 0
except OneBitError:
Statistics.update(Statistics.one_bit_error)
if (K != 0):
Statistics.update(Statistics.correctly_received_blocks)
# Assume: Fixing the error requires 0 trials_time units
return 0
return bit_errors
except MultipleBitErrors:
Statistics.update(Statistics.multiple_bit_errors)
return bit_errors
示例14: main
def main():
sender = Sender('localhost')
sender.connect()
sender.create_queue('inbox')
sender.send_message('inbox', 'hello')
sender.disconnect()
receiver = Receiver('localhost')
receiver.connect()
receiver.receive('inbox')
receiver.disconnect()
示例15: 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])
threshold = eval(sys.argv[5])
print "filename: "+str(filename)
else:
print "Correct usage: python simulate_engtput.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)+"th"+str(threshold)
receiver = Receiver(EffSnrRAEngTput(card_type,energy_constraint,chan_pred,threshold),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)