Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Image Modified

SCCharts Examples

...

Example SCChart  (Graphical)SCChart (Textual SCT)

ABO

 Image Added
Code Block
titleABO.sct
@VHLayout
scchart ABO {
  input output bool A;
  input output bool B;
  output bool O1;
  output bool O2;
  region:
  
  initial state Init
  --> WaitAB immediate with / O1 = false; O2 = false;
  state WaitAB {
    region HandleA:
    initial state WaitA
    --> DoneA  immediate with A / B = true; O1 = true;
    final state DoneA;
    region HandleB:
    initial state WaitB
    --> DoneB with B / O1 = true;
    final state DoneB;
  }
  >-> GotAB with / O1 = false; O2 = true;
  state GotAB;
}

clock

(Referenced SCCharts Example)

To enable the referenced SCCharts feature,

activate the Xtext nature for your project!

 

Code Block
languagesct
titleshifter3.sct
scchart delay {
  input int ticksToWait;
  input bool clock;
  int counter = 0;
  initial state init
  --> done immediate with
    counter >= ticksToWait
  --> init with
    clock / counter = counter + 1;
  final state done;
}
Code Block
languagesct
titleshifter3.sct
scchart emitter {
  input bool clock;
  input bool delay;
  output bool emit = false;
  initial state wait 
  references delay
  bind clock to clock,
  	   ticksToWait to delay
  >-> emit; 
  
  state emit {
    entry / emit = true;
    exit / emit = false;
  }
  --> wait;  
}
Code Block
languagesct
titleshifter3.sct
scchart clock {
  input bool msClock;
  output bool second;
  output bool minute;
  output bool hour;
  const int SEC = 1000;
  const int MIN = 60;
  const int HOUR = 60;
  region seconds:
  initial state seconds
  references emitter
  bind clock to msClock,
       metrum to SEC,
       emit to second
  >-> seconds;

  region minutes:
  initial state minutes
  references emitter
  bind clock to second,
       metrum to MIN,
       emit to minute
  >-> minutes;

  region hours:
  initial state hours
  references emitter
  bind clock to minute,
       metrum to HOUR,
       emit to hour
  >-> hours;
}

...