Skip to content

Commit

Permalink
DEVStone execution loop
Browse files Browse the repository at this point in the history
  • Loading branch information
romancardenas committed Dec 19, 2022
1 parent 143541d commit b53a6f1
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 139 deletions.
36 changes: 30 additions & 6 deletions xdevs/examples/devstone/devstone.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from __future__ import annotations

from abc import ABC
import sys
import time
from typing import Any
from xdevs.models import Atomic, Coupled, Port
from xdevs.sim import Coordinator
from .pystone import pystones

from xdevs.examples.devstone.pystone import pystones

class DelayedAtomic(Atomic):
def __init__(self, name: str, int_delay: float, ext_delay: float, test: bool = False):
Expand Down Expand Up @@ -284,10 +284,34 @@ def n_events(self) -> int:


if __name__ == '__main__':
import sys
sys.setrecursionlimit(10000)
root = HO("HO_root", 50, 50, 0, 0)

try:
model_type = sys.argv[1]
except IndexError:
raise ValueError("first argument must select the model type")
try:
width = int(sys.argv[2])
except ValueError:
raise ValueError("width could not be parsed")
except IndexError:
raise ValueError("second argument must select the width")
try:
depth = int(sys.argv[3])
except ValueError:
raise ValueError("depth could not be parsed")
except IndexError:
raise ValueError("third argument must select the depth")
# TODO add internal and external delays

start = time.time()
root = DEVStone("devstone", model_type, width, depth, 0, 0)
middle = time.time()
coord = Coordinator(root)
coord.initialize()
coord.inject(root.i_in, 0)
middle2 = time.time()
coord.simulate()
end = time.time()
print(f"Model creation time: {middle - start} seconds")
print(f"Engine setup time: {middle2 - middle} seconds")
print(f"Simulation time: {end - middle2} seconds")
54 changes: 0 additions & 54 deletions xdevs/examples/devstone/execution_loop.py

This file was deleted.

78 changes: 0 additions & 78 deletions xdevs/examples/devstone/main.py

This file was deleted.

1 change: 0 additions & 1 deletion xdevs/sim.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,6 @@ def simulate(self, num_iters: int = 10000):
def simulate_time(self, time_interv: float = 10000):
self.clock.time = self.time_next
tf = self.clock.time + time_interv

while self.clock.time < tf:
self.lambdaf()
self.deltfcn()
Expand Down

0 comments on commit b53a6f1

Please sign in to comment.