135 lines
No EOL
3.2 KiB
Python
135 lines
No EOL
3.2 KiB
Python
MAX_ROUT_Y = 4
|
|
|
|
sourc_x = 0
|
|
sourc_y = 1
|
|
|
|
dest_x = 3
|
|
dest_y = 3
|
|
|
|
GEN_TASK_START = """ <tasks>
|
|
<task id="0">
|
|
<start min="0" max="0"/>
|
|
<duration min="-1" max="-1"/>
|
|
<repeat min="1" max="1"/>
|
|
<generates>
|
|
<possibility id="0">
|
|
<probability value="1"/>
|
|
<destinations>"""
|
|
GEN_TASK_END = """ </destinations>
|
|
</possibility>
|
|
</generates>
|
|
</task>"""
|
|
|
|
REQ_TASK_START = """ <task id="{}">
|
|
<start max="0" min="0"/>
|
|
<duration max="-1" min="-1"/>
|
|
<repeat max="1" min="1"/>"""
|
|
|
|
REQ_TASK_END = " </task>"
|
|
|
|
LAST_TASK = """ <task id="{}">
|
|
<start max="0" min="0"/>
|
|
<duration max="-1" min="-1"/>
|
|
<repeat max="1" min="1"/>
|
|
<requires>
|
|
<requirement id="0">
|
|
<type value="0"/>
|
|
<source value="0"/>
|
|
<count max="{}" min="{}"/>
|
|
</requirement>
|
|
</requires>
|
|
</task>"""
|
|
|
|
REQ_TASK_REQ = """ <requires>
|
|
<requirement id="0">
|
|
<type value="2"/>
|
|
<source value="0"/>
|
|
<count max="1" min="1"/>
|
|
</requirement>
|
|
</requires>"""
|
|
|
|
REQ_TASK_GEN = """ <generates>
|
|
<possibility id="0">
|
|
<probability value="1"/>
|
|
<destinations>
|
|
<destination id="0">
|
|
<delay min="0" max="100"/>
|
|
<interval min="100" max="100"/>
|
|
<count min="1" max="1"/>
|
|
<type value="0"/>
|
|
<task value="{}"/>
|
|
</destination>
|
|
</destinations>
|
|
</possibility>
|
|
</generates>"""
|
|
|
|
DEST_HEADER = " <destination id=\"{}\">"
|
|
DEST_H_END = " </destination>"
|
|
|
|
DELAY_TAG = " <delay min=\"0\" max=\"100\"/>"
|
|
INTERVAL_TAG = " <interval min=\"100\" max=\"100\"/>"
|
|
COUNT_TAG = " <count min=\"1\" max=\"1\"/>"
|
|
TYPE_TAG = " <type value=\"2\"/>"
|
|
TASK_TAG = " <task value=\"{}\"/>"
|
|
CONFIG_TAG = " <config link=\"{}\" destination=\"{}\"/>"
|
|
|
|
|
|
BIND = """ <bind>
|
|
<task value="{}"/>
|
|
<node value="{}"/>
|
|
</bind>"""
|
|
|
|
|
|
id = 0
|
|
print("**********************FOR data.xml**********************")
|
|
print(GEN_TASK_START)
|
|
for x in range(sourc_x, dest_x):
|
|
print(DEST_HEADER.format(id))
|
|
print(DELAY_TAG)
|
|
print(INTERVAL_TAG)
|
|
print(COUNT_TAG)
|
|
print(TYPE_TAG)
|
|
print(TASK_TAG.format(id+1))
|
|
link = 0 if id==0 else 2
|
|
print(CONFIG_TAG.format(link, 1))
|
|
print(DEST_H_END)
|
|
id+=1
|
|
|
|
for y in range(sourc_y, dest_y+1):
|
|
print(DEST_HEADER.format(id))
|
|
print(DELAY_TAG)
|
|
print(INTERVAL_TAG)
|
|
print(COUNT_TAG)
|
|
print(TYPE_TAG)
|
|
print(TASK_TAG.format(id+1))
|
|
link = 2 if y == sourc_y else 4
|
|
dest = 0 if y == dest_y else 3
|
|
print(CONFIG_TAG.format(link, dest))
|
|
print(DEST_H_END)
|
|
id+=1
|
|
print(GEN_TASK_END)
|
|
|
|
|
|
for i in range(1, id):
|
|
print()
|
|
print(REQ_TASK_START.format(i))
|
|
print(REQ_TASK_REQ)
|
|
print(REQ_TASK_GEN.format(id))
|
|
print(REQ_TASK_END)
|
|
|
|
print()
|
|
print(LAST_TASK.format(id, id-1, id-1))
|
|
|
|
print()
|
|
print("**********************FOR map.xml**********************")
|
|
x = sourc_x
|
|
y = sourc_y
|
|
for i in range (0, id+1):
|
|
print(BIND.format(i, x*MAX_ROUT_Y+y))
|
|
if(y == dest_y):
|
|
x = sourc_x
|
|
y = sourc_y
|
|
elif(x == dest_x):
|
|
y += 1
|
|
else:
|
|
x +=1 |