-
-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multiple instances of a statechart reg #94
Comments
Hello, There is no intrinsic limitation on the number of statecharts that Sismic can execute simultaneously. The only limitation will come from the performance of the machine. To execute many statecharts at once, the easiest way is to store them in a list: from sismic.io import import_from_yaml
from sismic.interpreter import Interpreter
statechart = import_from_yaml(filepath='elevator.yaml')
interpreters = [Interpreter(statechart) for i in range(10000)]
# Let's send the elevators to different floors
for i, interpreter in enumerate(interpreters):
interpreter.queue('floorSelected', floor=i % 4)
interpreter.execute()
# Let's check the current floor
print([i.context['current'] for i in interpreters]) .... this displays |
It depends on the complexity of your statecharts. Have a look at the following discussion: #89 |
Thanks. This sure seems like something i can use. So my idea is to have multiple elevators running ..and then be able to interact with each elevator from a different program .. while maintaining the state.. also ftom the state chart seems like i retrive operation or event supported using api o Ex in the above example floorSelected is the event or operation. What about parameter type ? Floor selected event expects a parameter of type int. Can i get event parameter types for a event supported as well ? Or is it expected that i know this cause i created the statechart? I will give sismic a try sure it is an intetesting project. |
It is expected that you know these parameters (it should be part of the documented "API" of your statecharts), following Python's spirit. However, there is a way to retrieve the list of supported events for a given statechart with Have a look at the second part of https://sismic.readthedocs.io/en/latest/execution.html#using-interpreter for more information. |
I have question . In the documentation elevator or stop watch statecharts are explained. What is the upper limit for statecharts , ex , how many elevators can i create or how many stop watches can i create ? I really like the idea of YAML , and all the features , My use case is more like - creating multiple state machines , each maintaining its own state and able to interact with these state machines also would like to retain the current state between crashes and restarts. For instance , i want to create 1k elevators or 10k elevators and interact with each elevator . Any suggestions?
Thanks
The text was updated successfully, but these errors were encountered: