Object Diagrams: slots work

This commit is contained in:
Joeri Exelmans 2024-09-03 14:00:55 +02:00
parent d2c996f4f7
commit 2b22be01ec
8 changed files with 79 additions and 704 deletions

View file

@ -6,9 +6,17 @@ from uuid import UUID
from services.scd import SCD
from framework.conformance import Conformance
from services.od import OD
from transformation.ramify import ramify
from services.primitives.integer_type import Integer
import sys
def create_integer_node(state, i: int):
node = state.create_node()
integer_t = Integer(node, state)
integer_t.create(i)
return node
def main():
state = DevState()
root = state.read_root() # id: 0
@ -42,11 +50,21 @@ def main():
print_tree(tgt, max_depth, depth+1)
print("explore...")
print_tree(root, 1)
print_tree(root, 2)
int_type_id = state.read_dict(state.read_root(), "Integer")
int_type = UUID(state.read_value(int_type_id))
scd2 = SCD(scd_node, state)
for el in scd2.list_elements():
print(el)
model_id = state.create_node()
scd = SCD(model_id, state)
scd.create_class("A")
scd.create_model_ref("Integer", int_type)
scd.create_attribute_link("A", "Integer", "size", False)
scd.create_class("B")
scd.create_association("A2B", "A", "B",
src_min_c=1,
@ -55,15 +73,16 @@ def main():
tgt_max_c=2,
)
print_tree(model_id, 1)
print_tree(model_id, 2)
conf = Conformance(state, model_id, scd_node)
print("Check nominal conformance...")
print(conf.check_nominal(log=True))
print("Check structural conformance...")
print(conf.check_structural(log=True))
print("Check nominal conformance (again)...")
print(conf.check_nominal(log=True))
# print("Check structural conformance...")
# print(conf.check_structural(log=True))
# print("Check nominal conformance (again)...")
# print(conf.check_nominal(log=True))
inst_id = state.create_node()
od = OD(model_id, inst_id, state)
@ -72,8 +91,13 @@ def main():
od.create_object("b", "B")
od.create_link("A2B", "a", "b")
od.create_slot("size", "a", od.create_integer_value(42))
print("checking conformance....")
conf2 = Conformance(state, inst_id, model_id)
print(conf2.check_nominal(log=True))
# ramify(state, model_id)
if __name__ == "__main__":
main()