|
@@ -64,7 +64,7 @@ Element function sanitize(new_runtime_model : Element, old_runtime_model : Eleme
|
|
|
String attribute
|
|
|
String time
|
|
|
Element all_attributes
|
|
|
- Integer current_time
|
|
|
+ Float current_time
|
|
|
|
|
|
all_blocks = allInstances(new_runtime_model, "Block")
|
|
|
while (list_len(all_blocks) > 0):
|
|
@@ -89,7 +89,7 @@ Element function sanitize(new_runtime_model : Element, old_runtime_model : Eleme
|
|
|
|
|
|
return new_runtime_model!
|
|
|
|
|
|
-Element function create_schedule(model : Element, start_time : Integer):
|
|
|
+Element function create_schedule(model : Element, start_time : Float):
|
|
|
Element all_blocks
|
|
|
Element visited
|
|
|
Element to_visit
|
|
@@ -143,7 +143,6 @@ String function readType(model : Element, name : String):
|
|
|
return reverseKeyLookup(model["metamodel"]["model"], dict_read_node(model["type_mapping"], model["model"][name]))!
|
|
|
|
|
|
Void function step_simulation(model : Element, schedule : Element):
|
|
|
- // Assume \delta t == 1
|
|
|
String time
|
|
|
Float signal
|
|
|
Element incoming
|
|
@@ -153,8 +152,10 @@ Void function step_simulation(model : Element, schedule : Element):
|
|
|
String blocktype
|
|
|
Element memory_blocks
|
|
|
Integer i
|
|
|
+ Float delta_t
|
|
|
|
|
|
time = "time"
|
|
|
+ delta_t = 0.1
|
|
|
|
|
|
memory_blocks = create_node()
|
|
|
output("SIM_TIME " + cast_v2s(read_attribute(model, time, "current_time")))
|
|
@@ -211,7 +212,7 @@ Void function step_simulation(model : Element, schedule : Element):
|
|
|
selected = readAssociationSource(model, set_pop(incoming))
|
|
|
signal = cast_s2f(cast_v2s(read_attribute(model, selected, "signal")))
|
|
|
else:
|
|
|
- signal = cast_s2f(cast_v2s(read_attribute(model, block, "last_in"))) + cast_s2f(cast_v2s(read_attribute(model, block, "last_out")))
|
|
|
+ signal = cast_s2f(cast_v2s(read_attribute(model, block, "last_in"))) + (delta_t * cast_s2f(cast_v2s(read_attribute(model, block, "last_out"))))
|
|
|
unset_attribute(model, block, "last_in")
|
|
|
unset_attribute(model, block, "last_out")
|
|
|
instantiate_attribute(model, block, "last_out", signal)
|
|
@@ -227,7 +228,7 @@ Void function step_simulation(model : Element, schedule : Element):
|
|
|
incoming = allIncomingAssociationInstances(model, block, "Link")
|
|
|
while (read_nr_out(incoming) > 0):
|
|
|
selected = readAssociationSource(model, set_pop(incoming))
|
|
|
- signal = cast_s2f(cast_v2s(read_attribute(model, selected, "signal"))) - cast_s2f(cast_v2s(read_attribute(model, block, "last_in")))
|
|
|
+ signal = (cast_s2f(cast_v2s(read_attribute(model, selected, "signal"))) - cast_s2f(cast_v2s(read_attribute(model, block, "last_in")))) / delta_t
|
|
|
unset_attribute(model, block, "last_in")
|
|
|
set_add(memory_blocks, block)
|
|
|
|
|
@@ -245,8 +246,8 @@ Void function step_simulation(model : Element, schedule : Element):
|
|
|
instantiate_attribute(model, block, "last_in", cast_s2f(cast_v2s(read_attribute(model, selected, "signal"))))
|
|
|
|
|
|
// Increase simulation time
|
|
|
- Integer new_time
|
|
|
- new_time = cast_s2i(cast_v2s(read_attribute(model, time, "current_time"))) + 1
|
|
|
+ Float new_time
|
|
|
+ new_time = cast_s2f(cast_v2s(read_attribute(model, time, "current_time"))) + delta_t
|
|
|
unset_attribute(model, time, "current_time")
|
|
|
instantiate_attribute(model, time, "current_time", new_time)
|
|
|
|