def main(): name_gen = NameGenerator() device_map = {} tree = device_parser.parse_data('../xmls/data_grouped.xml') devices_data = device_parser.parse_groupings( tree) # could become a bottleneck if xmls get large enough aps = None while True: inp = input_str(MENU_STR, valid={'a', 'p', 'r', 'q', 'd'}) print() if inp == 'a': dev_key = input_device_model(devices_data, '') key, value = device_parser.search_data(tree, dev_key) device_map[name_gen.generate_name(key)] = value if inp == 'd': valid = set(device_map.keys()) if len(valid) > 0: to_delete = input_str( 'Which device do you want to delete? {}: '.format(valid), valid) del device_map[to_delete] else: print('There are no devices to delete\n') if inp == 'p': print(set(device_map.keys())) if inp == 'c': pass if inp == 'r': input_generators = create_ig_map(make_input_generators(device_map)) aps = AdvancedPowerStripT2( 'LG LED HiDef TV', ['Microsoft Xbox One', 'Dolby Surround Sound'], 60, move_time=75, is_on=False) integration_period = input_int('Enter integration period: ') run_sim(integration_period, input_generators, aps) device_map['aps'] = {'on': 1.5, 'off': 0.0} #write_to_ifile('csvs/test_APS.csv', integration_period, list(input_generators.values())) #analyze_data('csvs/test_APS.csv', integration_period, device_map) write_to_ifile('../csvs/test_APS.csv', integration_period, list(input_generators.values())) analyze_data('../csvs/test_APS.csv', integration_period, device_map) print() if inp == 'q': return
def main(): name_gen = NameGenerator() device_map = {} tree = device_parser.parse_data('../xmls/data_grouped.xml') devices_data = device_parser.parse_groupings(tree) while True: inp = input_str(MENU_STR, valid={'a', 'p', 'r', 'q', 'd'}) print() if inp == 'a': dev_key = input_device_model(devices_data, '') key, value = device_parser.search_data(tree, dev_key) device_map[name_gen.generate_name(key)] = value if inp == 'd': valid = set(device_map.keys()) if len(valid) > 0: to_delete = input_str( 'Which device do you want to delete? {}: '.format(valid), valid) del device_map[to_delete] else: print('There are no devices to delete\n') if inp == 'p': print(set(device_map.keys())) if inp == 'r': input_generators = make_input_generators(device_map) integration_period = input_int('Enter integration period: ') # save = input_str('Enter Save Name: ') run_sim(integration_period, input_generators) write_to_ifile('../csvs/test_group.csv', integration_period, input_generators) analyze_data('../csvs/test_group.csv', integration_period, device_map) # # write_to_ifile('../csvs/{}.csv'.format(save), integration_period, input_generators) # analyze_data('../csvs/test_group.csv'.format(save), integration_period, device_map) if inp == 'q': return print()
def test_largescale(): s = Stopwatch() integration_factor = 5 device_map = device_parser.build_device_map( device_parser.parse_data('../xmls/test.xml')) test_size = 10000 histogram = OrderedDict() for i in range(5): time = 0.0 for j in range(5): s.start() generate_test_input(device_map, test_size, file_name='test_input1.csv') s.stop() print('Generating test input of size {}: '.format(test_size), s.read()) s.reset() s.start() analyze_data_nograph('../csvs/test_input1.csv', integration_factor, device_map) s.stop() print('Processing input of size {}: '.format(test_size), s.read()) time += s.read() s.reset() print('Average time for input of size {}: '.format(test_size), time / 5) histogram[test_size] = time / 5 test_size *= 2 print(histogram) for i, j in histogram.items(): print(' size | time ') print('{0:5d}|{1:5f}'.format(i, j))