|
@@ -18,8 +18,6 @@ Boolean function main(model : Element):
|
|
|
time = set_pop(allInstances(model, "FullRuntime/Time"))
|
|
|
current_time = read_attribute(model, time, "current_time")
|
|
|
|
|
|
- log("Probe blocks: " + cast_string(set_len(allInstances(model, "FullRuntime/ProbeBlock"))))
|
|
|
-
|
|
|
schedule_init = create_schedule(model)
|
|
|
schedule_run = read_root()
|
|
|
|
|
@@ -32,7 +30,6 @@ Boolean function main(model : Element):
|
|
|
schedule = schedule_run
|
|
|
current_time = step_simulation(model, schedule, current_time)
|
|
|
|
|
|
- log("Finishing simulation, as we got input!")
|
|
|
instantiate_attribute(model, time, "current_time", current_time)
|
|
|
output("CLOSE")
|
|
|
return True!
|
|
@@ -57,7 +54,7 @@ Element function create_schedule(model : Element):
|
|
|
dict_add(predecessors, element_name, create_node())
|
|
|
|
|
|
if (is_nominal_instance(model, element_name, "FullRuntime/ICBlock")):
|
|
|
- if (element_eq(read_attribute(model, element_name, "last_in"), read_root())):
|
|
|
+ if (bool_not(is_physical_float(read_attribute(model, element_name, "last_in")))):
|
|
|
incoming_links = allIncomingAssociationInstances(model, element_name, "FullRuntime/InitialCondition")
|
|
|
else:
|
|
|
incoming_links = create_node()
|
|
@@ -186,11 +183,9 @@ Boolean function solve_scc(model : Element, scc : Element):
|
|
|
list_append(m, t)
|
|
|
i = i + 1
|
|
|
|
|
|
- log("Matrix ready!")
|
|
|
// Matrix initialized to 0.0
|
|
|
i = 0
|
|
|
while (i < read_nr_out(scc)):
|
|
|
- log("Creating matrix row")
|
|
|
// First element of scc
|
|
|
block = scc[i]
|
|
|
blocktype = read_type(model, block)
|
|
@@ -204,15 +199,11 @@ Boolean function solve_scc(model : Element, scc : Element):
|
|
|
elif (blocktype == "FullRuntime/MultiplyBlock"):
|
|
|
constant = 1.0
|
|
|
|
|
|
- log("Generating matrix for " + blocktype)
|
|
|
- log("Block: " + block)
|
|
|
incoming = allIncomingAssociationInstances(model, block, "Link")
|
|
|
|
|
|
Integer index_to_write_constant
|
|
|
index_to_write_constant = -1
|
|
|
- log("Iterating over incoming")
|
|
|
while (read_nr_out(incoming) > 0):
|
|
|
- log("Iteration")
|
|
|
selected = readAssociationSource(model, set_pop(incoming))
|
|
|
|
|
|
if (set_in(scc, selected)):
|
|
@@ -260,7 +251,6 @@ Boolean function solve_scc(model : Element, scc : Element):
|
|
|
i = i + 1
|
|
|
|
|
|
// Constructed a complete matrix, so we can start!
|
|
|
- log("Constructed matrix to solve:")
|
|
|
log(matrix2string(m))
|
|
|
|
|
|
// Solve matrix now
|
|
@@ -344,7 +334,7 @@ Float function step_simulation(model : Element, schedule : Element, time : Float
|
|
|
signal = float_division(1.0, cast_float(read_attribute(model, selected, "signal")))
|
|
|
elif (blocktype == "FullRuntime/DelayBlock"):
|
|
|
signal = 0.0
|
|
|
- if (element_eq(read_attribute(model, block, "last_in"), read_root())):
|
|
|
+ if (bool_not(is_physical_float(read_attribute(model, block, "last_in")))):
|
|
|
// No memory yet, so use initial condition
|
|
|
incoming = allAssociationOrigins(model, block, "FullRuntime/InitialCondition")
|
|
|
while (set_len(incoming) > 0):
|
|
@@ -354,7 +344,7 @@ Float function step_simulation(model : Element, schedule : Element, time : Float
|
|
|
signal = read_attribute(model, block, "last_in")
|
|
|
set_add(memory_blocks, block)
|
|
|
elif (blocktype == "FullRuntime/IntegratorBlock"):
|
|
|
- if (element_eq(read_attribute(model, block, "last_in"), read_root())):
|
|
|
+ if (bool_not(is_physical_float(read_attribute(model, block, "last_in")))):
|
|
|
// No history yet, so use initial values
|
|
|
incoming = allAssociationOrigins(model, block, "FullRuntime/InitialCondition")
|
|
|
while (set_len(incoming) > 0):
|
|
@@ -365,7 +355,7 @@ Float function step_simulation(model : Element, schedule : Element, time : Float
|
|
|
instantiate_attribute(model, block, "last_out", signal)
|
|
|
set_add(memory_blocks, block)
|
|
|
elif (blocktype == "FullRuntime/DerivatorBlock"):
|
|
|
- if (element_eq(read_attribute(model, block, "last_in"), read_root())):
|
|
|
+ if (bool_not(is_physical_float(read_attribute(model, block, "last_in")))):
|
|
|
// No history yet, so use initial values
|
|
|
incoming = allAssociationOrigins(model, block, "FullRuntime/InitialCondition")
|
|
|
while (set_len(incoming) > 0):
|