A fully working version of the scheduling language with added examples
This commit is contained in:
parent
ec42f74960
commit
ebfd85a666
126 changed files with 7235 additions and 981 deletions
44
examples/geraniums/models/eval_context.py
Normal file
44
examples/geraniums/models/eval_context.py
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
import os
|
||||
|
||||
from jinja2 import Environment, FileSystemLoader
|
||||
|
||||
from api.od import ODAPI
|
||||
from framework.conformance import eval_context_decorator
|
||||
|
||||
|
||||
@eval_context_decorator
|
||||
def _render_geraniums_dot(od: ODAPI, file: str) -> str:
|
||||
__DIR__ = os.path.dirname(__file__)
|
||||
env = Environment(
|
||||
loader=FileSystemLoader(
|
||||
__DIR__
|
||||
)
|
||||
)
|
||||
env.trim_blocks = True
|
||||
env.lstrip_blocks = True
|
||||
template_dot = env.get_template("geraniums_renderer.j2")
|
||||
|
||||
id_count = 0
|
||||
id_map = {}
|
||||
render = {"geraniums": [], "pots": [], "planted": []}
|
||||
|
||||
for name, uuid in od.get_all_instances("Geranium"):
|
||||
render["geraniums"].append((id_count, name, od.get_slot_value(uuid, "flowering")))
|
||||
id_map[uuid] = id_count
|
||||
id_count += 1
|
||||
|
||||
for name, uuid in od.get_all_instances("Pot"):
|
||||
render["pots"].append((id_count, name, od.get_slot_value(uuid, "cracked")))
|
||||
id_map[uuid] = id_count
|
||||
id_count += 1
|
||||
|
||||
for name, uuid in od.get_all_instances("Planted"):
|
||||
render["planted"].append((id_map[od.get_source(uuid)], id_map[od.get_target(uuid)]))
|
||||
|
||||
with open(file, "w", encoding="utf-8") as f_dot:
|
||||
f_dot.write(template_dot.render(**render))
|
||||
return ""
|
||||
|
||||
eval_context = {
|
||||
"render_geraniums_dot": _render_geraniums_dot,
|
||||
}
|
||||
17
examples/geraniums/models/example1.od
Normal file
17
examples/geraniums/models/example1.od
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
f1:Geranium {
|
||||
flowering = True;
|
||||
}
|
||||
f2:Geranium {
|
||||
flowering = False;
|
||||
}
|
||||
f3:Geranium {
|
||||
flowering = True;
|
||||
}
|
||||
|
||||
p1:Pot {
|
||||
cracked = True;
|
||||
}
|
||||
|
||||
:Planted (f1 -> p1)
|
||||
:Planted (f2 -> p1)
|
||||
:Planted (f3 -> p1)
|
||||
47
examples/geraniums/models/example2.od
Normal file
47
examples/geraniums/models/example2.od
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
f1:Geranium {
|
||||
flowering = True;
|
||||
}
|
||||
f2:Geranium {
|
||||
flowering = True;
|
||||
}
|
||||
f3:Geranium {
|
||||
flowering = False;
|
||||
}
|
||||
|
||||
p1:Pot {
|
||||
cracked = True;
|
||||
}
|
||||
|
||||
:Planted (f1 -> p1)
|
||||
:Planted (f2 -> p1)
|
||||
:Planted (f3 -> p1)
|
||||
|
||||
|
||||
|
||||
|
||||
f4:Geranium {
|
||||
flowering = True;
|
||||
}
|
||||
p2:Pot {
|
||||
cracked = True;
|
||||
}
|
||||
:Planted (f4 -> p2)
|
||||
|
||||
|
||||
|
||||
f5:Geranium {
|
||||
flowering = True;
|
||||
}
|
||||
p3:Pot {
|
||||
cracked = False;
|
||||
}
|
||||
:Planted (f5 -> p3)
|
||||
|
||||
|
||||
f6:Geranium {
|
||||
flowering = False;
|
||||
}
|
||||
p4:Pot {
|
||||
cracked = True;
|
||||
}
|
||||
:Planted (f6 -> p4)
|
||||
Loading…
Add table
Add a link
Reference in a new issue