예제 #1
0
						seen = set()
						not_uniq = []
						for name in xmltest.knowledgeRulesNames:
								if(not name in seen):
									seen.add(name)
								else:
									not_uniq.append(name)	
						
						validation_log.append(["Duplicated Knowledge rule names in ResponseCurve, FormulaBased or other :" +  str(not_uniq) +". File : " + path_xml_file +\
											  " with ModelType " + str(cur_modeltype) + " and System " + str(cur_system)])
						
					#check if the flow diagram is correct
					xmltest._scan_systemflowdiagrams(cur_modeltype,cur_system)
					if(len(xmltest.flowdiagrams) > 0 ):
						for cur_flowdiagram in xmltest.flowdiagrams:
							flowdiagram_dict = xmltest._read_systemflowdiagram(cur_modeltype, cur_system, cur_flowdiagram)
							flowdiagram_links = flowdiagram_dict["Links"]

							#check if To in flowdiagram or knowledge rule names
							for nr_fl, flow_link in enumerate(flowdiagram_links):
								#possible to links
								pos_from_links = [x["From_name"] for x in flowdiagram_links[nr_fl:]]
								pos_to_names = pos_from_links + xmltest.knowledgeRulesNames

								#check if valid (all to links are possible)
								if(not(set(flow_link["To_names"]).issubset(set(pos_to_names)))):
									not_present = set(flow_link["To_names"]) - set(pos_to_names)
									validation_log.append(["Following flowdiagram element is not valid, check the To links : From = " +  flow_link["From_name"] +\
											  "; To's invalid = " + str(not_present) + ". File : " + path_xml_file +\
											  " with ModelType " + str(cur_modeltype) + " and System " + str(cur_system)])
예제 #2
0
import os #for dir creation

#xmltest = AutecologyXML(filename = "../../../_knowledgerules/species/Birds/Phalacrocorax carbo.xml")
#xmltest = AutecologyXML(filename = "../../../_knowledgerules/species/Molluscs/Dreissena_polymorpha.xml")
xmltest = AutecologyXML(filename = "../../../_knowledgerules/species/Birds/Alcedo_atthis.xml")
xmltest._readxml()
print(type(xmltest.xmlroot))
xmltest._scan()
xmltest._scan_modeltype(modeltypename = "HSI")
xmltest._scan_system(modeltypename = "HSI", systemname = "adult")
xmltest._scan_systemflowdiagrams(modeltypename = "HSI", systemname = "adult")
print(xmltest.flowdiagrams)
print(xmltest.flowdiagrams_list)

#Create a specific flow diagram
#flowdiagram = xmltest._read_systemflowdiagram(modeltypename = "HSI", systemname = "adult", diagramname ="livingarea_stagnant_waters" )
flowdiagram = xmltest._read_systemflowdiagram(modeltypename = "HSI", systemname = "adult", diagramname ="breeding_area" )
svg_str = xmltest.create_flowdiagram_image(flowdiagram, output = None)
print(svg_str)

# #Write to file
# directory = "test"
# if(not os.path.exists(directory)):
# 	os.makedirs(directory)
# xmltest.create_flowdiagram_image(flowdiagram, output = os.path.join(directory,"example_flowdiagram.svg"))

#show in PyQt
subwindow_flowdiagram = xmltest.visualize_flowdiagram_image(svg_str)
xmltest.show_PyQt_plot(subwindow_flowdiagram)

print("Done.")