|
@@ -89,8 +89,6 @@ Element function sanitize(new_runtime_model : Element, old_runtime_model : Eleme
|
|
|
instantiate_attribute(new_runtime_model, element_name, "memory", read_attribute(old_runtime_model, element_name, "memory"))
|
|
|
instantiate_attribute(new_runtime_model, element_name, "signal", read_attribute(old_runtime_model, element_name, "signal"))
|
|
|
else:
|
|
|
- if (mm_type_name == "DelayBlock"):
|
|
|
- instantiate_attribute(new_runtime_model, element_name, "memory", 0.0)
|
|
|
instantiate_attribute(new_runtime_model, element_name, "signal", 0.0)
|
|
|
|
|
|
if (dict_in(old_runtime_model["model"], "time")):
|
|
@@ -122,6 +120,8 @@ Void function create_schedule(model : Element, old_model : Element, start_time :
|
|
|
String new_schedule
|
|
|
Boolean ready
|
|
|
|
|
|
+ // TODO add algebraic loop detection (not solution...)
|
|
|
+
|
|
|
all_blocks = allInstances(model, "Block")
|
|
|
visited = create_node()
|
|
|
to_visit = create_node()
|
|
@@ -160,6 +160,9 @@ Void function create_schedule(model : Element, old_model : Element, start_time :
|
|
|
schedule = new_schedule
|
|
|
list_delete(to_visit, list_len(to_visit) - 1)
|
|
|
set_add(visited, element_name)
|
|
|
+ log("Scheduled " + element_name)
|
|
|
+ else:
|
|
|
+ log("Delay " + element_name)
|
|
|
|
|
|
return !
|
|
|
|
|
@@ -256,13 +259,15 @@ Void function step_simulation(model : Element):
|
|
|
selected = readAssociationSource(model, set_pop(incoming))
|
|
|
signal = float_division(1.0, cast_s2f(cast_v2s(read_attribute(model, selected, "signal"))))
|
|
|
elif (blocktype == "DelayBlock"):
|
|
|
- if (cast_s2i(cast_v2s(read_attribute(model, time, "current_time"))) == 0):
|
|
|
+ if (element_eq(read_attribute(model, block, "memory"), read_root())):
|
|
|
+ // No memory yet, so use initial condition
|
|
|
incoming = allIncomingAssociationInstances(model, block, "InitialCondition")
|
|
|
while (read_nr_out(incoming) > 0):
|
|
|
selected = readAssociationSource(model, set_pop(incoming))
|
|
|
signal = cast_s2f(cast_v2s(read_attribute(model, selected, "signal")))
|
|
|
else:
|
|
|
signal = read_attribute(model, block, "memory")
|
|
|
+ unset_attribute(model, block, "memory")
|
|
|
set_add(delay_blocks, block)
|
|
|
|
|
|
unset_attribute(model, block, "signal")
|
|
@@ -276,7 +281,6 @@ Void function step_simulation(model : Element):
|
|
|
incoming = allIncomingAssociationInstances(model, block, "Link")
|
|
|
while (read_nr_out(incoming) > 0):
|
|
|
selected = readAssociationSource(model, set_pop(incoming))
|
|
|
- unset_attribute(model, block, "memory")
|
|
|
instantiate_attribute(model, block, "memory", cast_s2f(cast_v2s(read_attribute(model, selected, "signal"))))
|
|
|
|
|
|
// Increase simulation time
|
|
@@ -300,13 +304,9 @@ Void function execute_cbd(design_model : Element):
|
|
|
String cmd
|
|
|
Boolean running
|
|
|
|
|
|
- log("New model")
|
|
|
old_runtime_model = instantiate_model(import_node("models/CausalBlockDiagrams_Runtime"))
|
|
|
- log("Retype")
|
|
|
runtime_model = retype_to_runtime(design_model)
|
|
|
- log("Sanitize")
|
|
|
runtime_model = sanitize(runtime_model, old_runtime_model)
|
|
|
- log("Finished")
|
|
|
running = False
|
|
|
while (True):
|
|
|
if (running):
|
|
@@ -360,8 +360,11 @@ Void function execute_cbd(design_model : Element):
|
|
|
output("Successfully made modifications to design model!")
|
|
|
|
|
|
old_runtime_model = runtime_model
|
|
|
+ log("Retype")
|
|
|
runtime_model = retype_to_runtime(design_model)
|
|
|
+ log("Sanitize")
|
|
|
runtime_model = sanitize(runtime_model, old_runtime_model)
|
|
|
+ log("All done!")
|
|
|
elif (cmd == "verify"):
|
|
|
verify_result = conformance_scd(runtime_model)
|
|
|
if (verify_result != "OK"):
|