-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathLoadFile.py
More file actions
89 lines (70 loc) · 3.03 KB
/
LoadFile.py
File metadata and controls
89 lines (70 loc) · 3.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
import xml.etree.ElementTree as ET
from UniversalClasses import State
from UniversalClasses import AffinityRule
from UniversalClasses import TransitionRule
# System's Affinity Rules
VerticalAffinityRules = []
HorizontalAffinityRules = []
# System's Transition Rules
VerticalTransitionRules = []
HorizontalTransitionRules = []
SeedStateSet = [] # Used in SingleTile mode; States that were marked as potential seeds
# States marked as initial states; states that float around the system looking to attach to something.
InitialStateSet = []
CompleteStateSet = [] # All states in the system
def readxml(file):
tree = ET.parse(file)
treeroot = tree.getroot()
# Record System Temp
global Temp
Temp = treeroot.get("Temp")
# Record All States
for state_tag in treeroot.findall('AllStates/State'):
label = state_tag.get("Label")
color = state_tag.get("Color")
tempState = State(label, color)
CompleteStateSet.append(tempState)
# Record Initial States
for state_tag in treeroot.findall("InitialStates/State"):
label = state_tag.get("Label")
color = state_tag.get("Color")
tempState = State(label, color)
InitialStateSet.append(tempState)
# Record Seed States
for state_tag in treeroot.findall("SeedStates/State"):
label = state_tag.get("Label")
color = state_tag.get("Color")
tempState = State(label, color)
SeedStateSet.append(tempState)
# Record Vertical Transitions
for rule_tag in treeroot.findall("VerticalTransitions/Rule"):
label1 = rule_tag.get("Label1")
label2 = rule_tag.get("Label2")
label1Final = rule_tag.get("Label1Final")
label2Final = rule_tag.get("Label2Final")
tempRule = TransitionRule(
label1, label2, label1Final, label2Final, "v")
VerticalTransitionRules.append(tempRule)
# Record Horizontal Transitions
for rule_tag in treeroot.findall("HorizontalTransitions/Rule"):
label1 = rule_tag.get("Label1")
label2 = rule_tag.get("Label2")
label1Final = rule_tag.get("Label1Final")
label2Final = rule_tag.get("Label2Final")
tempRule = TransitionRule(
label1, label2, label1Final, label2Final, "h")
HorizontalTransitionRules.append(tempRule)
# Record Vertical Affinities
for rule_tag in treeroot.findall("VerticalAffinities/Rule"):
label1 = rule_tag.get("Label1")
label2 = rule_tag.get("Label2")
strength = rule_tag.get("Strength")
tempRule = AffinityRule(label1, label2, "v", strength)
VerticalAffinityRules.append(tempRule)
# Record Horizontal Affinities
for rule_tag in treeroot.findall("HorizontalAffinities/Rule"):
label1 = rule_tag.get("Label1")
label2 = rule_tag.get("Label2")
strength = rule_tag.get("Strength")
tempRule = AffinityRule(label1, label2, "h", strength)
HorizontalAffinityRules.append(tempRule)