def main(args, repetitions=1, type_of_benchmark=BenchmarkType.Full_Monitor): print args, repetitions #try: #has_monitor = args[3] #has_timing = args[4] cid = 1234 #random.randint(0, 1000) if (args[0] == 'App' and args[1] == 'Buyer'): buyer = create_buyer_app(cid, args[2], repetitions) #if has_monitor: buyer.set_monitor_on() #else: buyer.set_monitor_off() #if has_timing: timeit(buyer.start, type_of_benchmark, repetitions) #else: buyer.start() elif (args[0] == 'App' and args[1] == 'Seller'): seller = create_seller_app(cid, args[2], repetitions) seller.set_monitor_on() #else: seller.set_monitor_off() timeit(seller.start, type_of_benchmark, repetitions) #else: seller.start() elif (args[0] == 'Monitor' and args[1] == 'Buyer'): monitor_buyer = apps_utils.start_monitor( cid, args[2], args[1], apps_utils.get_lt_full_name("PurchasingAtBuyer.txt")) elif (args[0] == 'Monitor' and args[1] == 'Seller'): monitor_seller = apps_utils.start_monitor( cid, args[2], args[1], apps_utils.get_lt_full_name("PurchasingAtSeller.txt"))
def create_data_acquisition_conversation(cid): participants = [[ 'carol', 'A', apps_utils.get_lt_full_name('DataAcquisition_at_A.spr') ], ['bob', 'U', apps_utils.get_lt_full_name('DataAcquisition_at_U.spr')], [ 'alice', 'I', apps_utils.get_lt_full_name('DataAcquisition_at_I.spr') ]] conversation = apps_utils.BaseConversation(cid, participants) return conversation
def create_logic_conversation(cid): participants = [ [ 'alice', 'client', apps_utils.get_lt_full_name('ecoop\LogicExample_at_Client.spr') ], [ 'bob', 'server', apps_utils.get_lt_full_name('ecoop\LogicExample_at_Server.spr') ] ] conversation = apps_utils.BaseConversation(cid, participants) return conversation
def create_seller_app(cid, participant, repetitions=20): role = 'Seller' lt_file = apps_utils.get_lt_full_name(gen.get_local_type_file_name(local_type_file_name, role)) print lt_file gen.generate_protocol(repetitions, lt_file, gen.ParticipantData(role)) full_trace = gen.generate_client(repetitions, gen.ParticipantData(role)) full_trace = full_trace + [[LocalType.SEND, 'END', 'Buyer']] seller_app = apps_utils.BaseApp(cid, role, participant, full_trace, lt_file, create_buyer_seller_conversation) return seller_app
def create_client_app(cid, participant): role = 'client' lt_file = apps_utils.get_lt_full_name("ecoop\LogicExample_at_Client.spr") event_trace = [[LocalType.RESV, 'Balance', 'Server', '1'], [LocalType.RESV, 'OverdraftLimit', 'Server', '1'], [LocalType.SEND, 'MakePayment', 'Server', '1'], [LocalType.RESV, 'Balance', 'Server', 1], [LocalType.RESV, 'OverdraftLimit', 'Server', '1'], [LocalType.SEND, 'CloseAccount', 'Server', '1']] full_trace = event_trace full_trace = full_trace + [[LocalType.SEND, 'END', 'Seller']] app = apps_utils.BaseApp(cid, role, participant, full_trace, lt_file) return app
def create_server_app(cid, participant): role = 'server' lt_file = apps_utils.get_lt_full_name("ecoop\LogicExample_at_Server.spr") event_trace = [[LocalType.SEND, 'Balance1', 'Client', '1'], [LocalType.SEND, 'OverdraftLimit1', 'Client', '1'], [LocalType.RESV, 'MakePayment', 'Client', '1'], [LocalType.SEND, 'Balance', 'Client', '1'], [LocalType.SEND, 'OverdraftLimit', 'Client', '1'], [LocalType.RESV, 'CloseAccount', 'Client', '1']] full_trace = event_trace full_trace = full_trace + [[LocalType.SEND, 'END', 'Client']] app = apps_utils.BaseApp(cid, role, participant, full_trace, lt_file, create_logic_conversation) return app
def create_user_app(cid, participant, repetitions=1): role = 'U' lt_file = apps_utils.get_lt_full_name("DataAcquisition_at_U.spr") event_trace = [[LocalType.SEND, 'Push', 'A'], [LocalType.RESV, 'Formatted', 'A'], [LocalType.RESV, 'Formatted', 'A'], [LocalType.SEND, 'Stop', 'A']] full_trace = event_trace full_trace = full_trace + [[LocalType.SEND, 'END', 'A']] app = apps_utils.BaseApp(cid, role, participant, full_trace, lt_file, create_data_acquisition_conversation) return app
def create_instrument_app(cid, participant, repetitions=1): role = 'I' lt_file = apps_utils.get_lt_full_name("DataAcquisition_at_I.spr") event_trace = [[LocalType.SEND, 'Push', 'A'], [LocalType.RESV, 'StreamMode', 'A'], [LocalType.SEND, 'Supported', 'A'], [LocalType.RESV, 'ConfigStream', 'A'], [LocalType.SEND, 'Raw', 'A'], [LocalType.SEND, 'Raw', 'A'], [LocalType.RESV, 'Stop', 'A']] full_trace = event_trace full_trace = full_trace + [[LocalType.SEND, 'END', 'A']] app = apps_utils.BaseApp(cid, role, participant, full_trace, lt_file) return app
def main(args): print args try: cid = 1234 if (args[0] == 'App'): app = app_map.get(args[1])(cid, args[2]) app.set_monitor_on() app.start() elif (args[0] == 'Monitor'): apps_utils.start_monitor( cid, args[2], args[1], apps_utils.get_lt_full_name("ecoop\LogicExample_at_%s.spr" % (args[1]))) except Exception as e: print e print 'Error' sys.exit()
def create_buyer_app(cid, participant, repetitions=20): role = 'Buyer' lt_file = apps_utils.get_lt_full_name("Benchmark_BuyerApp.spr") event_trace = [[LocalType.RESV, 'Confirmation', 'Seller', '1'], [LocalType.SEND, 'OK', 'Seller', '-1'], [LocalType.RESV, 'Confirmation', 'Seller', '1'], [LocalType.SEND, 'OK', 'Seller', '-1']] full_trace = event_trace for i in range(0, repetitions): full_trace = full_trace + event_trace end_trace = [[LocalType.RESV, 'OutOfStock', 'Seller']] full_trace = full_trace + end_trace + [[LocalType.SEND, 'END', 'Seller']] buyer_app = apps_utils.BaseApp(cid, role, participant, full_trace, lt_file) return buyer_app
def main(args): repetitions = 1 print args, try: cid = 1234 if (args[0] == 'App'): app = app_map.get(args[1])(cid, args[2], repetitions) app.set_monitor_on() app.start() elif (args[0] == 'Monitor'): monitor = apps_utils.start_monitor( cid, args[2], args[1], apps_utils.get_lt_full_name("DataAcquisition_at_%s.spr" % (args[1]))) except Exception as e: print e print 'Error' sys.exit()
def create_agent_app(cid, participant, repetitions=1): role = 'A' lt_file = apps_utils.get_lt_full_name("DataAcquisition_at_A.spr") event_trace = [[LocalType.RESV, 'Push', 'U'], [LocalType.SEND, 'StreamMode', 'I'], [LocalType.RESV, 'Supported', 'I'], [LocalType.SEND, 'ConfigStream', 'I'], [LocalType.RESV, 'Raw', 'I'], [LocalType.SEND, 'Formatted', 'U'], [LocalType.RESV, 'Raw', 'I'], [LocalType.SEND, 'Formatted', 'U'], [LocalType.RESV, 'Stop', 'U'], [LocalType.SEND, 'Stop', 'I']] full_trace = event_trace for i in range(0, repetitions): full_trace = full_trace + event_trace full_trace = full_trace + [[LocalType.SEND, 'END', 'I']] app = apps_utils.BaseApp(cid, role, participant, full_trace, lt_file, create_data_acquisition_conversation) return app
def create_buyer_seller_conversation(cid): participants = [['alice', 'seller', apps_utils.get_lt_full_name('Benchmark_SellerApp.spr')], ['bob', 'buyer', apps_utils.get_lt_full_name('Benchmark_BuyerApp.spr')]] conversation = apps_utils.BaseConversation(cid, participants) return conversation
def create_buyer_seller_conversation(cid): participants = [['alice', 'seller', apps_utils.get_lt_full_name(gen.get_local_type_file_name(local_type_file_name, 'Seller'))], ['bob', 'buyer', apps_utils.get_lt_full_name(gen.get_local_type_file_name(local_type_file_name, 'Buyer'))]] conversation = apps_utils.BaseConversation(cid, participants) return conversation