|
@@ -9,6 +9,13 @@ from pypdevs.simulator import Simulator
|
|
|
|
|
|
import json
|
|
import json
|
|
|
|
|
|
|
|
+def get_object_constructor(code):
|
|
|
|
+ with open(".code.alc", "w") as f:
|
|
|
|
+ f.write(code)
|
|
|
|
+ f.flush()
|
|
|
|
+ constructors = do_compile(".code.alc", "interface/HUTN/grammars/actionlanguage.g", "CD")
|
|
|
|
+ return constructors
|
|
|
|
+
|
|
def translate(operation):
|
|
def translate(operation):
|
|
return {
|
|
return {
|
|
"CN": "create_node",
|
|
"CN": "create_node",
|
|
@@ -134,6 +141,7 @@ class MvKState(object):
|
|
self.current_user = None
|
|
self.current_user = None
|
|
self.loaded_primitives = False
|
|
self.loaded_primitives = False
|
|
self.execution_counter = 0
|
|
self.execution_counter = 0
|
|
|
|
+ self.all_failed = True
|
|
|
|
|
|
def __str__(self):
|
|
def __str__(self):
|
|
return "\nMvK: %s\n" % self.mvk + \
|
|
return "\nMvK: %s\n" % self.mvk + \
|
|
@@ -273,6 +281,9 @@ class ModelverseKernel(AtomicDEVS):
|
|
return {}
|
|
return {}
|
|
|
|
|
|
def timeAdvance(self):
|
|
def timeAdvance(self):
|
|
|
|
+ if self.state.phase == "init_user" and self.state.all_failed:
|
|
|
|
+ # Make this a parameter
|
|
|
|
+ return 200
|
|
if self.state.commands is not None:
|
|
if self.state.commands is not None:
|
|
return 0
|
|
return 0
|
|
elif self.state.waiting:
|
|
elif self.state.waiting:
|
|
@@ -470,9 +481,18 @@ class System(CoupledDEVS):
|
|
self.connectPorts(self.mvk.to_mvi, self.mvk2mvi.input_port)
|
|
self.connectPorts(self.mvk.to_mvi, self.mvk2mvi.input_port)
|
|
self.connectPorts(self.mvk2mvi.output_port, self.mvi.from_mvk)
|
|
self.connectPorts(self.mvk2mvi.output_port, self.mvi.from_mvk)
|
|
|
|
|
|
-operations = [
|
|
|
|
- "test",
|
|
|
|
- ]
|
|
|
|
|
|
+code = \
|
|
|
|
+ """
|
|
|
|
+include "primitives.alh"
|
|
|
|
+
|
|
|
|
+Element function main():
|
|
|
|
+\tlog("Executed the code!")
|
|
|
|
+\treturn
|
|
|
|
+ """
|
|
|
|
+
|
|
|
|
+operations = [get_object_constructor(f.read()) for f in files] + \
|
|
|
|
+ get_object_constructor(code) + \
|
|
|
|
+ get_link_and_load("main", files + ["code.alc"])
|
|
|
|
|
|
args = {
|
|
args = {
|
|
"username": "test_user",
|
|
"username": "test_user",
|