Question

So I have the following Object structure:

Class Node
RSSI: int

I need to write a OCL invariant for the requirement that the the RSSI values of all Node objects do not differ by more than 2. I tried to solve it with an iterate expression but since you can't really use variables IN OCL to store current max and min values (or at least im not aware of how to do that) I don't know how to do that. Can anyone help me with that?

Était-ce utile?

La solution

You can use allInstances:

context: Node
inv: Node->allInstances()
         ->forAll(n1, n2| -2 <= n1.RSSI-n2.RSSI and n1.RSSI-n2.RSSI <= 2)
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top