Cross features
A cross feature allows you to link the value at one end of the connection with the value at the other end. It imposes a semantic constraint ensuring that the connected elements are related via a defined reference path in the model. Cross features can be specified for ends of certain connectors, such as connection or interface.
Cross features can be specified for connector definition or usage ends. There are two options for specifying them:
- Declaring cross features in the related types of the connector definition (using cross subsetting).
- Declaring cross features in connector ends (owned cross features), options:
- Notation:
- Full notation
- Shorthand notation (only for connector usages)
- Named or unnamed
- Notation:
Cross feature specification includes cross multiplicity, which constrains the number of connections, rather than end values. Unlike regular multiplicity, cross multiplicity is used only within the context of cross features and is usually specified for the end elements of a connector. For end elements, cross multiplicity is specified after the end keyword, followed by the ordering and/or uniqueness for at least one of the ends.
Please note that cross features is the correct mechanism to specify multiplicities of the connection definitions and usages while connection end multiplicities are fixed to [1] in SysML v2.0. The multiplicities that were specified on the association ends in SysML v1.x models have to be specified on cross features and not on the connection ends when porting models to SysML v2.0.
Specifying cross features for connector ends
Specifying cross features for connector ends via the Textual Editor
Specifying cross features for connector ends via the Textual Editor
- Do one of the following:
- Declare cross features in the related types of the connector usage/definition:
- Specify cross multiplicity and ordering for the related types.
- Specify the connector usage's/definition's end features to subset cross features owned by the related type.
Cross subsetting
- Identify the usage element that you want to be the subsetting one.
- Follow the subsetting element with either one of the following:
- keyword crosses
- textual symbol =>
Follow with a feature chain in which the first feature is the other connection end and the second feature is the cross feature for that end.
- Declare cross features for ends:
- Full notation:
- (Optional) Specify the cross feature name.
- Specify the kind keyword for the ends.
- Specify cross multiplicity, ordering, and/or uniqueness on at least one of the ends. Optionally, specify a cross feature name after the end keyword.
- Shorthand notation (available only for connector usages):
- Declare the connection keyword, specify the element name (optional) and specialization (optional). State the features explicitly (using the connect...to syntax) or in a comma-separated list of related features prefixed with cross multiplicity.
With shorthand notation, cross features in ends do not accept names; ends do not accept ordering.
- Declare the connection keyword, specify the element name (optional) and specialization (optional). State the features explicitly (using the connect...to syntax) or in a comma-separated list of related features prefixed with cross multiplicity.
- Full notation:
- Declare cross features in the related types of the connector usage/definition:
- Click the Synchronize button.
/* ------------ connection definition ------------ */
/* cross features owned by the end type (uses cross subsetting); Step 1.a */
part def Hub {
ref part connectedDevices [1..*] ordered : Device;
}
part def Device {
ref part connectingHub [0..1] : Hub;
}
connection def DeviceConnection {
/* unnamed cross features in ends */
end part hub : Hub => device.connectingHub; // the kind keyword part is optional
end part device : Device => hub.connectedDevices;
}
/* ------------ connection usage ------------ */
part def NetworkConfiguration {
part networkHubs : Hub [*];
part networkDevices : Device [*];
connection networkConnections : DeviceConnection {
/* cross features owned by the end type (uses cross subsetting) */
end hub ::> networkHubs => device.connectingHub;
end device ::> networkDevices => hub.connectedDevices;
}
}
/* ------------ connection definition ------------ */
/* cross features owned by the ends; Step 1.b */
part def Hub;
part def Device;
// named cross features in ends:
connection def DeviceConnection {
end crossHub [0..1] part hub : Hub; // the kind keyword (part) is mandatory
end crossDevice [1..*] ordered part device : Device;
}
// unnamed cross features in ends:
connection def DeviceConnection {
end [0..1] part hub : Hub; // the kind keyword (part) is mandatory
end [1..*] ordered part device : Device;
}
/* ------------ connection usage ------------ */
// named cross features owned by ends (full notation):
part def NetworkConfiguration {
part networkHubs : Hub [*];
part networkDevices : Device [*];
connection networkConnections : DeviceConnection {
/* cross features owned by ends; cross features named in ends (full notation) */
end crossHub [1] part hub ::> networkHubs; // the kind keyword (part) is mandatory
end crossDevice [0..4] ordered part device ::> networkDevices;
}
}
// unnamed cross features owned by ends (full notation):
part def NetworkConfiguration {
part networkHubs : Hub [*];
part networkDevices : Device [*];
connection networkConnections : DeviceConnection {
/* cross features owned by ends; cross features unnamed in ends (full notation) */
end [1] part hub ::> networkHubs; // the kind keyword (part) is mandatory
end [0..4] ordered part device ::> networkDevices;
}
}
// cross features owned by ends (shorthands):
part def NetworkConfiguration {
part networkHubs : Hub [*];
part networkDevices : Device [*];
/* cross features owned by ends (shorthands) */
connection networkConnections : DeviceConnection connect [1] hub ::> networkHubs to [0..4] device ::> networkDevices;
// OR (equivalent to the above)
connection networkConnections : DeviceConnection connect ([1] hub ::> networkHubs, [0..4] device ::> networkDevices);
}
Moving cross features between end types and ends
Although there are two options for specifying cross features for ends, you can easily refactor connector definition ends from one option to the other.
To move cross features between end types and ends
- Right-click the end of a connector definition and in the shortcut menu, select Refactor, then click one of the following:
- Move Cross Feature to End to move cross features declared in the related types of the connector definition to the connector ends.
- Move Cross Feature to End Type to move cross features declared in the connector ends to the related types of the connector definition.
