Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 4 Next »

Related Publications

Towards Object-Oriented Modeling in SCCharts. Alexander Schulz-Rosengarten and Steven Smyth and Michael Mendler. In Proc. Forum on Specification and Design Languages (FDL ’19), Southampton, UK, 2019.


Inheritance

SCCharts support inheritance, similar to the concept of references.

Each root state can extend multiple base states (since the name super states is already used) by listing them after the extends keyword.

Such an state will inherit all declarations, action and regions of the base states. If conflicts arise or a state has a cyclic inheritance hierarchy, a warning will be displayed. If a state is contained multiple times in the inheritance hierarchy its content will inherited only once.

Declarations can have the private keyword to prevent extending SCCharts from accessing these variables.

Root-level regions of base states can be overriden with the override keyword and consequently replace the behavior by the new definition. Anonymous regions (defined without an ID) cannot be overridden.

Regions can also be references similar to states by using the is keyword. If the reference should refer to the implementation in the base state, the super keyword must be used.

scchart MotorWithButton
  extends ButtonBehavior, MotorBehavior {
    
  override region HandleMotor {
    suspend if !buttonPressed
    
    region is super.HandleMotor
  }
}

scchart MotorBehavior {
  output int motorRotation
  
  const int motorRotationMax = 16
  entry do motorRotation = 0
  
  region HandleMotor {
    initial state Increment {
      during do motorRotation++
    } if motorRotation == motorRotationMax
      do motorRotation = 0
      abort to Increment
  }
}

scchart ButtonBehavior {
  input float buttonPosition
  
  bool buttonPressed = false
  private const float threshold = 0.5
  
  region HandleButton {
    initial state Released
      if buttonPosition < threshold
      do buttonPressed = true
      go to Pressed
    
    state Pressed
      if buttonPosition >= threshold
      do buttonPressed = false
      go to Released
  }
}

Classes

TODO

Methods

TODO

Class Modeling

TODO

Generics

COMING SOON

Host Classes

TODO

  • No labels