A fully working version of the scheduling language with added examples
This commit is contained in:
parent
ec42f74960
commit
ebfd85a666
126 changed files with 7235 additions and 981 deletions
35
transformation/schedule/schedule_lib/exec_node.py
Normal file
35
transformation/schedule/schedule_lib/exec_node.py
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
from abc import abstractmethod
|
||||
from api.od import ODAPI
|
||||
from .node import Node
|
||||
|
||||
|
||||
class ExecNode(Node):
|
||||
def __init__(self) -> None:
|
||||
super().__init__()
|
||||
|
||||
from .null_node import NullNode
|
||||
self.next_node: dict[str, tuple[ExecNode, str]] = {}
|
||||
for port in self.get_exec_output_gates():
|
||||
self.next_node[port] = (NullNode(), "in")
|
||||
|
||||
def nextState(self, exec_id: int) -> tuple["ExecNode", str]:
|
||||
return self.next_node["out"]
|
||||
|
||||
@staticmethod
|
||||
def get_exec_input_gates():
|
||||
return ["in"]
|
||||
|
||||
@staticmethod
|
||||
def get_exec_output_gates():
|
||||
return ["out"]
|
||||
|
||||
def connect(self, next_state: "ExecNode", from_gate: str, to_gate: str) -> None:
|
||||
if from_gate not in self.get_exec_output_gates():
|
||||
raise Exception(f"from_gate {from_gate} is not a valid port")
|
||||
if to_gate not in next_state.get_exec_input_gates():
|
||||
raise Exception(f"to_gate {to_gate} is not a valid port")
|
||||
self.next_node[from_gate] = (next_state, to_gate)
|
||||
|
||||
@abstractmethod
|
||||
def execute(self, port: str, exec_id: int, od: ODAPI) -> tuple[int, any] | None:
|
||||
return None
|
||||
Loading…
Add table
Add a link
Reference in a new issue