Pass parameters - sjdayday/xschema GitHub Wiki
home or [back](Add optional standard semantics)
The simplest way to pass a parameter to any Petri net is to define a place whose marking with some number of tokens is treated as a parameter for the execution of the Petri net. A caller can mark such external input places, and can listen for updates to other external output places to verify the execution of the Petri net.
In the case of external transitions, an instance of an arbitrary client class is instantiated, to execute whenever the transition fires. Optionally, this instance can be passed a context, which can be any object. In the case of Close_hand, the client class is CloseExternalTransition, and its context is just the test grasp example class. (When it fires, the CloseExternalTransition just calls a method in the test class to enable the test to verify that it ran as expected.)
Since an object can be anything, this is the most general way to pass parameters to an external transition. A more specific mechanism is to pass a JSON object to the external transition. The key / value structure of JSON is a natural way to pass parameters. To illustrate this, we add an external transition, TestingApproachExternalTransition, to the Approach x-schema. When this transition fires, it reads the JSON parameters, and then updates them, providing the client a simple way to see the results of its execution. (An external transition also has access to the entire executable Petri net, so it could also mark one or more places. This is both a mechanism to affect subsequent execution and another way to return results to the client.)