template = Template( name='test sans', description='example sans data', modules=modules, wires=wires, instrument=SANS_INS.id, ) #f = open("/home/elakian/tem.txt","w") #f.write("Template: ") #f.write( simplejson.dumps(wireit.template_to_wireit_diagram(template))) #f.write("\n") #f.write("Lang: ") #f.write(simplejson.dumps(wireit.instrument_to_wireit_language(SANS_INS))) #f.close() print 'TEMPLATE', simplejson.dumps( wireit.template_to_wireit_diagram(template)) #print 'RAW_INSTRUMENT: ', wireit.instrument_to_wireit_language(SANS_INS) print 'LANGUAGE', simplejson.dumps( wireit.instrument_to_wireit_language(SANS_INS)) run_template(template, config) #get_plottable(template,config,14,'OneD') #result = get_plottable(template, config, 14, 'OneD') #datadir=os.path.join(os.path.dirname(__file__),'ncnr_sample_data') #filedict={'empty_1m':os.path.join(datadir,'SILIC001.SA3_SRK_S101'), #'empty_4m':os.path.join(datadir,'SILIC002.SA3_SRK_S102'), #'empty_cell_1m':os.path.join(datadir,'SILIC003.SA3_SRK_S103'), #'blocked_1m':os.path.join(datadir,'SILIC004.SA3_SRK_S104'), #'trans_empty_cell_4m':os.path.join(datadir,'SILIC005.SA3_SRK_S105'), #'trans_sample_4m':os.path.join(datadir,'SILIC006.SA3_SRK_S106'),
position=[20, 40]) joinMod_d2 = dict(module='joinMod', version='0.0', config=[], position=[20, 60]) joinMod_d3 = dict(module='joinMod', version='0.0', config=[], position=[40, 50]) # 2 wires wire1 = dict(source=[0, 'output'], target=[2, 'input']) wire2 = dict(source=[1, 'output'], target=[2, 'input']) diag = wireit.template_to_wireit_diagram( core.Template('testy', 'Template Testing', [joinMod_d1, joinMod_d2, joinMod_d3], [wire1, wire2], 'tas')) format_diag = '' def diag_to_WireIt_str(diagram): underlying_module = core.lookup_module('joinMod') print underlying_module.icon diag_str = '' diag_to_WireIt_str(diag) print diag #wire_it diagram
joinMod = join.join_module() joinMod.id = 'joinMod' core.register_module(joinMod) # 3 join mods joinMod_d1 = dict(module='joinMod',version='0.0', config=[], position=[20,40]) joinMod_d2 = dict(module='joinMod',version='0.0', config=[], position=[20,60]) joinMod_d3 = dict(module='joinMod',version='0.0', config=[], position=[40,50]) # 2 wires wire1 = dict(source=[0,'output'], target=[2,'input']) wire2 = dict(source=[1,'output'], target=[2,'input']) diag = wireit.template_to_wireit_diagram(core.Template('testy','Template Testing', [joinMod_d1, joinMod_d2, joinMod_d3], [wire1, wire2], 'tas')) format_diag = '' def diag_to_WireIt_str(diagram): underlying_module = core.lookup_module('joinMod') print underlying_module.icon diag_str = '' diag_to_WireIt_str(diag) print diag #wire_it diagram f = open('wireit_diagram.txt', 'w') for i in diag: format_diag += str(i).replace("'", '') + ": " + str(diag[i]) + ',\n \t'
] config = dict((n, d['config']) for (n, d) in enumerate(modules)) template = Template(name='test sans', description='example sans data', modules=modules, wires=wires, instrument=SANS_INS.id, ) #f = open("/home/elakian/tem.txt","w") #f.write("Template: ") #f.write( simplejson.dumps(wireit.template_to_wireit_diagram(template))) #f.write("\n") #f.write("Lang: ") #f.write(simplejson.dumps(wireit.instrument_to_wireit_language(SANS_INS))) #f.close() print 'TEMPLATE', simplejson.dumps(wireit.template_to_wireit_diagram(template)) #print 'RAW_INSTRUMENT: ', wireit.instrument_to_wireit_language(SANS_INS) print 'LANGUAGE', simplejson.dumps(wireit.instrument_to_wireit_language(SANS_INS)) run_template(template, config) #get_plottable(template,config,14,'OneD') #result = get_plottable(template, config, 14, 'OneD') #datadir=os.path.join(os.path.dirname(__file__),'ncnr_sample_data') #filedict={'empty_1m':os.path.join(datadir,'SILIC001.SA3_SRK_S101'), #'empty_4m':os.path.join(datadir,'SILIC002.SA3_SRK_S102'), #'empty_cell_1m':os.path.join(datadir,'SILIC003.SA3_SRK_S103'), #'blocked_1m':os.path.join(datadir,'SILIC004.SA3_SRK_S104'), #'trans_empty_cell_4m':os.path.join(datadir,'SILIC005.SA3_SRK_S105'), #'trans_sample_4m':os.path.join(datadir,'SILIC006.SA3_SRK_S106'), #'blocked_4m':os.path.join(datadir,'SILIC007.SA3_SRK_S107'),
{}, {}, {}, ] template = Template( name='test tas', description='example TAS diagram', modules=modules, wires=wires, instrument=BT7.id, ) # verify wire json objects print "== instrument\n", ppjson(json.dumps(instrument_to_wireit_language(BT7))) print "== menu\n", ppjson(json.dumps(instrument_to_wireit_menu(BT7))) tjson = json.dumps(template_to_wireit_diagram(template)) print "== diagram\n", ppjson(tjson) t = wireit_diagram_to_template(json.loads(tjson), instrument=BT7) print "== template\n", t.name, ":", t.description pprint(t.modules) pprint(t.wires) # run the reductions print "== calc" result = run_template(template, config) pprint(result) # commented out (for now) because it writes to system files #open("../www/instrument/BT7definition.json",'w').write(json.dumps(instrument_to_wireit_language(BT7))) #open("../www/instrument/BT7menu.json","w").write(json.dumps(instrument_to_wireit_menu(BT7))) #open("../www/diagram/BT7example.json","w").write(json.dumps(template_to_wireit_diagram(template)))