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 32 Next »

Version 0.13 RC1

This page is part of the SCCharts Editor 0.13 RC1 documentation. This page is still under construction. We are still in the process of creating the release candidate. Please excuse any missing or incomplete entry. We apologize for any inconvenience.


SCCharts

Each SCChart starts with the keyword scchart followed by an IDA ID can be any alpha-numerical combination, but must start with an alphabetical character or an underscore (a single underscore is prohibited). However, underscores are used to identify auto-generated constructs, so the modeler should not use them as prefix.

Simple States

One of the basic constructs of SCCharts is a simple state. A simple state does not have any inner behavior and can be connected via transitions to other states.

Initial State

To tell the program where to start, a state can be marked as initial. Exactly one state (per concurrent region, see concurrency) must be marked as initial.

Transitions

Experimental Syntax

IMPORTANT: We are testing different syntax variations for transitions in the release candidate. At the moment we prefer the following syntax as default.

[immediate] [if condition] [do effect[; effect]*] (go | abort | join) to targetstate

Please test it. We appreciate it.

However, in the RC1 you can also start with the jump and follow with the if or even use the legacy syntax with the ascii art arrow. Hence, some examples may differ slightly from each other. Feel free to experiment. Please provide us with feedback. We will streamline the syntax before the final release.


Transitions connect states. There are different kinds of Transitions, but we will restrict ourselves to the two basic types for now. (See below for more complex transitions.)

Delayed Transitions

Immediate Transitions

Explicit Delay Behavior

Final State

A state can also be marked as final. A final state marks the end of a thread. If a final state is reached on root level, the program terminates.

scchart Simple {
	
  initial state A
  go to B 
  
  state B
  go to C 
  
  state C
  go to A immediate
}
scchart Simple {
	
  initial state A
  go to B auto
  
  state B
  go to C delayed
  
  final state C
}




Declarations & Variables

Each scope (for now just the SCChart) can have a list of declarations. The SCChart code on the right gives an example. A declaration starts with the type, followed by a list of variable identifier. Each variables can be initialized with a specific value. 

Types

The following native types are supported: bool, int, double, string, signal (see below)

Additionally, you can mark a declaration as extern and give it a string that will be used in the serialization of the final code, e.g., the name of a host type. You can then add variables as before.

Arrays

If you add brackets to a variable and specify cardinalities, you declare an array.

Constants

Declarations can be marked as constant, meaning that each occurrence is then replaced by the initialization because the variable is not allowed to be changed.

scchart Variables {
  input bool second
  output bool beep
  int i, j, k
  int arr[10]
  bool alarm = false
  const bool ON = 1
  extern "rObj" rail  
  
  initial state A
  go to B
  
  state B
}


Tuples

You can assign a whole tuple at once to an array. 

scchart tuples {
  output int arr[5] = {1, 2, 3, 4, 5}

  initial state init {
    entry do arr = {6, 7, 8, 9, 10}
  }
}

To assign only certain values of an array, you can also use the ignore value placeholder. Consult the expression manual for further information.

scchart tuples {
  const int A = 1
  output int arr[3][2] = {{A,0}, {2,0}, {3,0}}

  initial state init
    --> init do arr = {{arr[0] + 1, _}, _, {arr[2] + 1, _}}
}

This would, for example, result in c code assignments as displayed on the right.

void logic(TickData* d) {
  d->_g0 = d->_GO;
  if (d->_g0) {
    d->arr[0][0] = 1;
    d->arr[0][1] = 0;
    d->arr[1][0] = 2;
    d->arr[1][1] = 0;
    d->arr[2][0] = 3;
    d->arr[2][1] = 0;
  }
  d->_g2 = d->_pg1;
  if (d->_g2) {
    d->arr[0][0] = d->arr[0] + 1;
    d->arr[2][0] = d->arr[2] + 1;
  }
  d->_g1 = d->_g0 || d->_g2;
}




Comments

You can simply use JavaDoc-style comments to comment you SCChart. The comments will appear in the synthesized diagram as comment boxes. You can toggle these boxes in your sidebar. 

Additionally, for documentation reason, you can annotate different elements to give them a user-defined style. E.g. colorize a state or comment box for visual effect. Use html-like color codes for different colors. Please read more on annotations in the section below.

/**
 * Getting there!
 */
scchart Root {
  /** Test */
  input bool second 
  output bool speaker 

  /**
    * Main region!
    */
  region main:

  /**	
    * The initial state
    * This is entered as soon as the program starts.
    */    
  @foreground f0f024
  @background ffffcc
  @backgroundTarget fff9ba
  initial state Superstate {
    initial state R1
  } 
  /** Transition */
  /** Transition 2 */
  join to S

  /**
    * The final state!
    * @foreground f00
    * @background a00
    */
  final state S
}



Trigger & Effects

hey can be guarded by a trigger that determines when this transition is enabled and they can have effects that are executed whenever this transition becomes active.



Hierarchy & Concurrency

Superstates

Regions



For Regions

You can automatically duplicate regions and access a region counter variable.

scchart IIIRO {
  input int I
  input bool R
  output bool O

  initial state IIO {
    entry do O = false

    initial state II {
      region main for i : 1 .. 3 {
        initial state IWait
        go to IDone if I == i
	
        final state IDone
      }
    }
    join to Done do O = true
		
    state Done
  }
  go to IIO if R
}

This is also possible for a complete array.

scchart IIIRO {
  input int I
  input bool R
  output bool O
  input bool ACTIVE[10]

  initial state IIO {
    entry do O = false

    initial state II {
      region for i : ACTIVE {
        initial state IWait
        go to IDone if ACTIVE[i]
	
        final state IDone
      }
    }
    join to Done do O = true
	
    state Done
  }
  go to IIO if R
}


Actions

Entry Action

During Action

Exit Action


Complex Transitions

Count Delay

Shallow History

Deep History

Deferred

Signals


References

We will use the beep.sctx as example for referenced SCCharts.

scchart Beep {
	input bool second
	output bool beep = false
	
	initial state A
	if second do beep = true go to B 
	
	state B
	if second do beep = false go to A 
}

If you want to use another SCChart inside your model, you must first include it with an import pragma. For example, if you want to include beep into the comment example "root" from above, you can add #import "beep" and include a state that references beep. We will learn more about pragmas later on.

#import "beep"

/**
 * Getting there!
 */
scchart Root {
	/** Test */
	input bool second 
	output bool speaker 
	
	/**
 	 * Main region!
     */
	region main:
	
	/**	
	 * The initial state
	 * This is entered as soon as the program starts.
	 * @foreground f0f024
	 * @background ffffcc
     * @backgroundTarget fff9ba
	 */    
	initial state R is Beep(second to second, speaker to beep) 
	/** Transition */
	/** Transition 2 */
	join to S
	
	/**
	 * The final state!
	 * @foreground f0f0240
     * @background ffc
     */
	final state S
}

The keyword is indicates that R is a reference. When you are referencing, you have to bind the interface of the referenced SCChart model to variables of the actual on. You must do this in the parentheses after the referenced state. In the example second is bound to second, and the local speaker boolean is bound to the beep from beep's interface. You can read more about variable bindings in the next paragraph. Also, the content assist will help you with your bindings and inform you about missing bindings.

Details about Bindings

There are three different kinds of bindings: explicit bindings, order bindings, and implicit bindings. In the example we used explicit bindings, which are the safest way of bindings.

initial state R is Beep(second to second, speaker to beep) 

They state explicitly which local variable gets bound to which remote. The content assist will help you with errors.

If you now the order of the variables (and/or listen to the content assist), you can also use order bindings and simply state the list of local variables.

initial state R is Beep(second, speaker) 

They will be bound to the interface in the order of declaration in the remote SCChart. However, be aware of the fact that the bindings will change, when the declarations of the referenced SCChart change.

In the example, the names of the local and referenced second variables are identical. Hence, you can also omit the binding completely.

initial state R is Beep(speaker to beep) 

SCCharts will then bind the variable implicitly. However, we also consider this kind of binding unsafe and the editor will warn you about any implicit bindings. They can be handy though when dealing with large interfaces.

Continuation

As any state, referenced states are allowed to own transitions. However, if you are using terminations, you must make sure that the referenced SCChart terminates. Otherwise, the transition will never trigger. The content assist will help you with this issue.

Legacy

You do not need to activate the Xtext nature as in previous versions of SCCharts. In fact, we recommend to deactivate the Xtext nature for SCCharts projects.



Example warnings from the content assist:


Hostcode

Annotations

Pragmas

Expressions


Overview

Here you can see an SCCharts graphical notation overview.



  • No labels