Generic constraints treat data parameters and time stamps uniformly. In the CommaSuite framework, time and data constraints are translated to generic constraints and then evaluated. This is transparent to the user.

Users should always try first to express a constraint as a time or data constraint. If this is not possible due to limited expressive power then generic constraints can be used.

The basic element of a generic constraint is an event pattern, which may match with an observed event. It is described by the following parts:

A step is formed by the "or" of a number of event patterns:

Steps can be combined into a sequence element:

Sequential composition of these sequence elements leads to a sequence formula, where optionally a condition can be added:

Examples
Note that generic constraints have a name and can use variables, similar to time and data constraints.

generic constraints
variables
real t1
real t2
real t3

GCS1
[t1 , command SwitchOn ];
[t2 , any event ];
[t3 , signal SwitchOff , t3 > t1 + 10.7 ]

GCS2
[t1 , in state Operational notification OutOfOrder  ];
[t2 , ! in state Error command SwitchOn ];
[t3 , in state Error reply(Result::OK) to command Reset , t3 < t1 + 100.0]

GCU1
[t1 , command OrderProduct when credit > 0];
[t2 , reply(OrderResult::DELIVERED) , t2 < t1 + 50.0]

GCU2
[ t1 , reply(n,CoinResult::ACCEPTED) to command InsertCoin];
[ t2 , ! reply to command ReturnMoney ];
[ t3 , reply(v) to comman ReturnMoney] & v > 0

Sequence formulas can be combined into a general formula. Any sequence formula is a general formula and for formulas F, F1, F2, the following are also formulas:

Examples
As an advanced example, we show two ways to express that no two signals occur with the same name and same time stamp. Note the use of string variables to denote signal names.

generic constraints
variables
real t1
real t2
real t3
string X
string Y

GC1
NOT { [t1, any signal X];
      [t2, any signal, t1 == t2]
      until
      [t3, any signal Y, t1 == t3 and X == Y]
    }

GC2
[t1, any signal X]
CF
[t2, any signal Y, X != Y]
until
[t3, any signal, t1 != t3]

The next example shows a generic component constraint of a component with ports DevicePort and ApplicationPort called MaxDistance. This constraint expresses that if a reply to command SensorGetData is observed at time t1 with value v1 on DevicePort and next, after an arbitrary number of other events, a reply to command GetData at time t2 with value v2 on ApplicationPort is observed where v2 is greater than v1, then either v1 and v2 are different or t2 – t1 is less than 100. This expresses that command GetData returns a recently obtained value.

generic constraints
variables
real t
real t1
real t2
real v1
real v2
MaxDistance
[ t1, DevicePort::reply(v1) to command SensorGetData ];
[ t, any ApplicationPort::event ] | [ t, any DevicePort::event ]
until [ t2, ApplicationPort::reply(v2) to command GetData, v1 <= v2 ]
where v1 != v2 or t2 - t1 < 100.0