How to use UNION type to receive different types in one CPN place?

187 Views Asked by At

I want to use a union in a way a place can receive two different types of "request", in my Coloured Petri Net model.

I have the following declarations:

colset AUTHENTICATION = product INT * STRING;
colset REQUEST_PUB = product AUTHENTICATION * STRING * REAL;
colset REQUEST_SUB = product AUTHENTICATION * STRING * INT;
colset REQUEST_PUBSUB = union REQUEST_PUB + REQUEST_SUB;

I have the following configuration:

Transition ------> Place (REQUEST_PUBSUB) <------ Transition

The right transition is sending ((int, string), string, real) and the left transition is sending ((int, string), string, int). Since the place is of type REQUEST_PUBSUB, which is a union of REQUEST_PUB and REQUEST_SUB, theoretically this should work, once ((int, string), string, real) is clearly a valid REQUEST_PUB and ((int, string), string, int) is clearly a valid REQUEST_SUB.

But this is not working and I am receiving the following errors:

Error: expression doesn't match constraint [tycon mismatch]
expression: (INT * STRING) * STRING * REAL
constraint: REQUEST_PUBSUB ms
in expression ((int, string), string, real): REQUEST_PUBSUB ms
Elaborate failure

And

Error: expression doesn't match constraint [tycon mismatch]
expression: (INT * STRING) * STRING * INT
constraint: REQUEST_PUBSUB ms
in expression ((int, string), string, int): REQUEST_PUBSUB ms
Elaborate failure

Can anyone help me with this? I think the description is clear, but I can complement it with more information if necessary.

1

There are 1 best solutions below

0
On BEST ANSWER

I solved it specifying the identifiers for the union types:

colset REQUEST_PUBSUB = union pub_req:REQUEST_PUB + sub_req:REQUEST_SUB;

Then, for right transition arc I used pub_req((int, string), string, real) and for left transition arc I used sub_req((int, string), string, int).