Systems-Modeling / SysML-v2-Pilot-Implementation

Proof-of-concept pilot implementation of the SysML v2 textual notation and visualization
GNU Lesser General Public License v3.0
128 stars 24 forks source link

ST6RI-573 Added localClock to Occurrence, used as trigger clock default. #382

Closed seidewitz closed 2 years ago

seidewitz commented 2 years ago

This PR updates the model library to allow each occurrence to have a "local clock", which is used as the default clock for triggers within an occurrence. This update allows, for example, the following:

part context {
  // This defines a local clock used by default within the “context” part.
  part :>> localClock = Time::Clock();

  state behavior {
    entry; then S1;

    state S1;

    transition
      first S1
      // The time instant in the trigger is, by default, 
      // relative to context::localClock.
      accept at Iso8601DateTime("22-05-12T00:00:00")
      then S2;

    state S2;
  }
}

Kernel Model Library

  1. Clocks.
    • Rename defaultClock to universalClock.
    • Change the default for the clock parameter of TimeOf and DurationOf from defaultClock to localClock.
  2. Occurrences.
    • Add a localClock feature to Occurrence with Clocks::universalClock as its default.
    • Add a suboccurrences feature to Occurrence to include all composite suboccurrences of an occurrence and pass the localClock of an occurrence down as the default for the localClock of its suboccurrences.
  3. Objects.
    • Make Object::subobjects and Object::ownedPerformances subsets of suboccurrences.
  4. Performances.
    • Make Performance::subperformances a subset of suboccurrences.
  5. SpatialFrames.
    • Change the default for the clock parameter of various functions from defaultClock to frame.localClock.
  6. Triggers.
    • Change the default for the clock parameter of TriggerAt and TriggerWhen to their localClock (which, by default, will be bound to the localClock of some containing "context" of the usages of these functions).

Systems Model Library

  1. Items.
    • Make Item::subitems a subset of subobjects.
    • Make Item::checkedConstraints composite and a subset of ownedPerformances.

Quantities and Units Domain Library

  1. Time.
    • Rename defaultClock to universalClock, defaulting to Clocks::universalClock.
    • Change the default for the clock parameter of TimeOf and DurationOf from defaultClock to localClock.

Geometry Domain Library

  1. SpatialItem.
    • Update the existing declaration of localClock for SpatialItem to redefineOccurrences::localClock and default to Time::universalClock. (Note that this cannot be done in Item, because the Time package is in the Quantities and Units Domain library.)

Implicit Specializations

The following are just the changes to the implicit specialization implementation. Unchanged rules are not included.

  1. FeatureAdapter.
    • A composite feature with a class type and an owning type that is a class or a feature with a class type specializes Occurrence::suboccurrences.
    • A composite feature with a structure type and an owning type that is a structure or a feature with a structure type specializes Object::subobjects.
  2. UsageAdapter.
    • By default, a usage has the same implicit specialization as for a feature. (This only applies for reference usages and bare usages with user-defined keywords.)
  3. OccurrenceUsageAdapter.
    • If an occurrence usage fits the requirements of being a suboccurrence (as generically for a feature), then it specializes Occurrence::suboccurrences.
  4. ItemUsageAdapter.
    • If an item usage is a suboccurrence but not a subitem, then it specializes Occurrence::suboccurrences. (Item::subitems subsets subobjects which already subsets suboccurrences.)
  5. ActionUsageAdapter.
    • If an action usage is a suboccurrence but not a subaction, then it specializes Occurrence::suboccurrences. (Action::subactions subsets subperformances which already subsets suboccurrences.)
  6. ConstraintUsageAdapter.
    • If a constraint usage is composite and its owning type is an item definition or usage, then it specializes Item::checkedConstraints. (This fixes the required specialization for constraints, which was broken.)
conradbock commented 2 years ago

defaultClock->localClock a good idea. In Objects:

The suboccurrences of this Object that are themselves Objects.

would be less geeky as

The suboccurrences of this Object that are also Objects.

seidewitz commented 2 years ago

I don't have any problem sounding geeky! But I don't seem to have used the "that are themselves" wording elsewhere (at least that I can find on a quick look). I can change it.

conradbock commented 2 years ago

My comments in code are showing as Pending again, and Outlook isn't letting me search emails right now to find the one where you figured out the problem. Can you remember?

seidewitz commented 2 years ago

You need to create a review and ask for changes.

conradbock commented 2 years ago

That seems to want me to finish all code comments and submit. Is there a way to do incrementally, like my comment above about Objects?

seidewitz commented 2 years ago

I don't think so.

conradbock commented 2 years ago

Found an option to make a single comment after starting review, then "re-request review" next to my name in the reviewer list.

seidewitz commented 2 years ago

@conradbock Do you have any more comments? I would like to wrap up this PR.

conradbock commented 2 years ago

BTW, Richard was really happy about this one. :)