|
@@ -15,7 +15,7 @@ Creating a model
|
|
|
|
|
|
Creating a new instance of PetriNets is simple, and can be done using the *model_add* operation of the wrapper::
|
|
|
|
|
|
- >>> model_add("my_pn", "PetriNets")
|
|
|
+ >>> model_add("models/my_pn", "formalisms/PetriNets")
|
|
|
|
|
|
The first parameter of the operation indicates the name that we would like to give to our newly created model.
|
|
|
This name is available to all users, and is therefore a unique identifier.
|
|
@@ -24,11 +24,23 @@ The value needs to be a name that is available in the Modelverse, and readable t
|
|
|
|
|
|
To get a list of currently available models, users can query the Modelverse with the *model_list* operation::
|
|
|
|
|
|
- >>> model_list()
|
|
|
- [("PetriNets", "SimpleClassDiagrams"), ("SimpleClassDiagrams", "SimpleClassDiagrams"), ("ProcessModel", "SimpleClassDiagrams"), ...]
|
|
|
+ >>> model_list("")
|
|
|
+ ["formalisms/", "models/", "administration/", "users/", "type mappings/"]
|
|
|
|
|
|
-This list contains the various models, and the metamodel of these models.
|
|
|
-Note that this operation does not specify anything about the permissions of the supplied models.
|
|
|
+This list contains the various entries in the specified location.
|
|
|
+Note that this operation does not specify anything about the permissions of the supplied entries.
|
|
|
+Entries that end with a forward slash (/) are folders, and can subsequently be listed::
|
|
|
+
|
|
|
+ >>> model_list("formalisms")
|
|
|
+ ["Bottom", "SimpleClassDiagrams", "Tracability", ...]
|
|
|
+
|
|
|
+ >>> model_list("users/admin")
|
|
|
+ []
|
|
|
+
|
|
|
+Depending on permissions, not all folders can be listed::
|
|
|
+
|
|
|
+ >>> model_list("administration")
|
|
|
+ PermissionDenied("administration")
|
|
|
|
|
|
Modifying a model
|
|
|
-----------------
|
|
@@ -43,7 +55,7 @@ Create
|
|
|
|
|
|
1. *instantiate* creates a new instance in the model, for example a new PetriNet place::
|
|
|
|
|
|
- >>> instantiate("my_pn", "Place")
|
|
|
+ >>> instantiate("models/my_pn", "Place")
|
|
|
__12345
|
|
|
|
|
|
The operation requires the model on which we are working, and the type of the element you want to instantiate.
|
|
@@ -52,20 +64,20 @@ Create
|
|
|
|
|
|
When instantiating an edge, the optional *edge* parameter must be passed with the identifiers to connect::
|
|
|
|
|
|
- >>> instantiate("my_pn", "Place")
|
|
|
+ >>> instantiate("models/my_pn", "Place")
|
|
|
p1
|
|
|
- >>> instantiate("my_pn", "Transition")
|
|
|
+ >>> instantiate("models/my_pn", "Transition")
|
|
|
t1
|
|
|
- >>> instantiate("my_pn", "P2T", edge=("p1", "t1"))
|
|
|
+ >>> instantiate("models/my_pn", "P2T", edge=("p1", "t1"))
|
|
|
p2t1
|
|
|
|
|
|
2. *attr_assign* assigns attributes of a specific model element.
|
|
|
For example, it specifies the name and number of tokens of our PetriNet place::
|
|
|
|
|
|
- >>> instantiate("my_pn", "Place")
|
|
|
+ >>> instantiate("models/my_pn", "Place")
|
|
|
p1
|
|
|
- >>> attr_assign("my_pn", "p1", "name", "place 1")
|
|
|
- >>> attr_assign("my_pn", "p1", "tokens", 2)
|
|
|
+ >>> attr_assign("models/my_pn", "p1", "name", "place 1")
|
|
|
+ >>> attr_assign("models/my_pn", "p1", "tokens", 2)
|
|
|
|
|
|
The value of the attribute can be any simple primitive: string, integer, float, or boolean.
|
|
|
When the attribute already exists, its value is overwritten.
|
|
@@ -76,39 +88,39 @@ Read
|
|
|
|
|
|
1. *read* reads out basic information about a queried element, such as its type and the source and target (if it is an edge)::
|
|
|
|
|
|
- >>> instantiate("my_pn", "Place")
|
|
|
+ >>> instantiate("models/my_pn", "Place")
|
|
|
p1
|
|
|
- >>> read("my_pn", "p1")
|
|
|
+ >>> read("models/my_pn", "p1")
|
|
|
("Place, None)
|
|
|
- >>> instantiate("my_pn", "Transition")
|
|
|
+ >>> instantiate("models/my_pn", "Transition")
|
|
|
t1
|
|
|
- >>> instantiate("my_pn", "P2T", edge=("p1", "t1"))
|
|
|
+ >>> instantiate("models/my_pn", "P2T", edge=("p1", "t1"))
|
|
|
p2t1
|
|
|
- >>> read("my_pn", "p2t1")
|
|
|
+ >>> read("models/my_pn", "p2t1")
|
|
|
("P2T", ("p1", "t1"))
|
|
|
|
|
|
2. *read_attrs* reads out the attributes of a specific element, in a dictionary form.
|
|
|
This operation can be used to read out, for example, the number of tokens of a specific place::
|
|
|
|
|
|
- >>> instantiate("my_pn", "Place")
|
|
|
+ >>> instantiate("models/my_pn", "Place")
|
|
|
p1
|
|
|
- >>> attr_assign("my_pn", "p1", "name", "place 1")
|
|
|
- >>> attr_assign("my_pn", "p1", "tokens", 2)
|
|
|
- >>> read_attrs("my_pn", "p1")
|
|
|
+ >>> attr_assign("models/my_pn", "p1", "name", "place 1")
|
|
|
+ >>> attr_assign("models/my_pn", "p1", "tokens", 2)
|
|
|
+ >>> read_attrs("models/my_pn", "p1")
|
|
|
{"name": "place 1", "tokens": 2}
|
|
|
|
|
|
3. *types* reads out the list of types that can be instantiated in this model.
|
|
|
All calls to instantiate should act upon one of these types.
|
|
|
For PetriNets, this returns the concepts of the domain::
|
|
|
|
|
|
- >>> types()
|
|
|
+ >>> types("models/my_pn")
|
|
|
["Place", "Transition", "P2T", "T2P", ...]
|
|
|
|
|
|
4. *element_list_nice* reads out a simple JSON-like representation of the model.
|
|
|
This includes all information about the model and can be used to fetch the complete model in one go.
|
|
|
For example, to read out a simple PetriNet::
|
|
|
|
|
|
- >>> element_list_nice("my_pn")
|
|
|
+ >>> element_list_nice("models/my_pn")
|
|
|
[{"id": "p1", "type": "Place", "name": "place 1", "tokens": 1},
|
|
|
{"id": "p2", "type": "Place", "name": "place 2", "tokens": 2},
|
|
|
{"id": "t1", "type": "Transition"},
|
|
@@ -120,7 +132,7 @@ Read
|
|
|
This takes into account inheritance relation.
|
|
|
For example, to read out all outgoing P2T links of a place::
|
|
|
|
|
|
- >>> read_outgoing("my_pn", "p1", "P2T")
|
|
|
+ >>> read_outgoing("models/my_pn", "p1", "P2T")
|
|
|
["p2t"]
|
|
|
|
|
|
It is possible to get all outgoing associations as well, by leaving the type empty (the empty string).
|
|
@@ -128,7 +140,7 @@ Read
|
|
|
6. *read_incoming* similarly reads out all incoming associations of a certain type, for a specific element.
|
|
|
For example, to read out all incoming T2P links of a place::
|
|
|
|
|
|
- >>> read_incoming("my_pn", "p2", "T2P")
|
|
|
+ >>> read_incoming("models/my_pn", "p2", "T2P")
|
|
|
["t2p"]
|
|
|
|
|
|
Again, the type can be set to the empty string to return all incoming associations.
|
|
@@ -136,20 +148,20 @@ Read
|
|
|
7. *read_association_source* reads out the source of a specific association, and can be used in conjunction with *read_outgoing* and *read_incoming*.
|
|
|
For example, to read out which is the source of an arc::
|
|
|
|
|
|
- >>> read_association_source("my_pn", "p2t")
|
|
|
+ >>> read_association_source("models/my_pn", "p2t")
|
|
|
p1
|
|
|
|
|
|
8. *read_association_destination* similarly reads out the destination of a specific association.
|
|
|
For example, to read out the target of an arc::
|
|
|
|
|
|
- >>> read_association_destination("my_pn", "p2t")
|
|
|
+ >>> read_association_destination("models/my_pn", "p2t")
|
|
|
t1
|
|
|
|
|
|
9. *connections_between* reads out the set of all association types that can be created between two elements in the model.
|
|
|
This also takes into account inheritance information.
|
|
|
For example, to find out which association types can connect a place and transition::
|
|
|
|
|
|
- >>> connections_between("my_pn", "p1", "t1")
|
|
|
+ >>> connections_between("models/my_pn", "p1", "t1")
|
|
|
["P2T"]
|
|
|
|
|
|
If no associations are allowed, the list is empty.
|
|
@@ -157,7 +169,7 @@ Read
|
|
|
10. *all_instances* read out the set of all instances of a specific type in the model.
|
|
|
For example, to find all Places in our PetriNet model::
|
|
|
|
|
|
- >>> all_instances("my_pn", "Place")
|
|
|
+ >>> all_instances("models/my_pn", "Place")
|
|
|
["p1", "p2"]
|
|
|
|
|
|
Delete
|
|
@@ -169,15 +181,15 @@ Delete
|
|
|
Associations, however, are removed.
|
|
|
For example, to remove place p1::
|
|
|
|
|
|
- >>> element_list_nice("my_pn")
|
|
|
+ >>> element_list_nice("models/my_pn")
|
|
|
[{"id": "p1", "type": "Place", "name": "place 1", "tokens": 1},
|
|
|
{"id": "p2", "type": "Place", "name": "place 2", "tokens": 2},
|
|
|
{"id": "t1", "type": "Transition"},
|
|
|
{"id": "p2t", "type": "P2T", "__source": "p1", "__target": "t1", "weight": 1},
|
|
|
{"id": "t2p", "type": "T2P", "__source": "t1", "__target": "p2", "weight": 2},
|
|
|
]
|
|
|
- >>> delete_element("my_pn", "p1")
|
|
|
- >>> element_list_nice("my_pn")
|
|
|
+ >>> delete_element("models/my_pn", "p1")
|
|
|
+ >>> element_list_nice("models/my_pn")
|
|
|
[{"id": "p2", "type": "Place", "name": "place 2", "tokens": 2},
|
|
|
{"id": "t1", "type": "Transition"},
|
|
|
{"id": "t2p", "type": "T2P", "__source": "t1", "__target": "p2", "weight": 2},
|