-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathLoadFile.py
More file actions
125 lines (99 loc) · 4.55 KB
/
LoadFile.py
File metadata and controls
125 lines (99 loc) · 4.55 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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
import xml.etree.ElementTree as ET
from UniversalClasses import State
from UniversalClasses import AffinityRule
from UniversalClasses import TransitionRule
from UniversalClasses import Assembly
# 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
seed_assembly = Assembly()
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")
display_label = state_tag.get("DisplayLabel")
display_label_color = state_tag.get("DisplayLabelColor")
display_label_font = state_tag.get("DisplayLabelFont")
if display_label is None:
tempState = State(label, color)
else:
if display_label_font is None:
tempState = State(label, color, display_label, display_label_color)
else:
tempState = State(label, color, display_label, display_label_color, display_label_font)
CompleteStateSet.append(tempState)
# Record Initial States
for state_tag in treeroot.findall("InitialStates/State"):
label = state_tag.get("Label")
color = state_tag.get("Color")
display_label = state_tag.get("DisplayLabel")
display_label_color = state_tag.get("DisplayLabelColor")
display_label_font = state_tag.get("DisplayLabelFont")
if display_label is None:
tempState = State(label, color)
else:
if display_label_font is None:
tempState = State(label, color, display_label, display_label_color)
else:
tempState = State(label, color, display_label, display_label_color, display_label_font)
InitialStateSet.append(tempState)
# Record Seed States
for state_tag in treeroot.findall("SeedStates/State"):
label = state_tag.get("Label")
color = state_tag.get("Color")
display_label = state_tag.get("DisplayLabel")
display_label_color = state_tag.get("DisplayLabelColor")
display_label_font = state_tag.get("DisplayLabelFont")
if display_label is None:
tempState = State(label, color)
else:
if display_label_font is None:
tempState = State(label, color, display_label, display_label_color)
else:
tempState = State(label, color, display_label, display_label_color, display_label_font)
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)