T2A1: Important Thoughts

  1. Write down the difference between Extended SCCharts and Core SCCharts. Use your own words.
    • In Extended SCCharts können erweiterte (doh!) Sprachkonstrukte verwendet werden, die prinnzipiell nur Syntaktischer Zucker sind. Sie bieten zusätzlichen Komfort bei der Implementierung des Systems.
  2. What advantages has the Core SCCharts normalization?
    • Die normalisierten SCCharts bieten eine schmale Basis für die Entwicklung des weiteren Compilers. Somit können zusätzliche Features in den SCCharts implementiert werden, ohne den unterliegenden Compiler ändern zu müssen. Der entstehende SCG besteht nur aus sehr wenigen Konstrukten und kann anschliessend gut für den gewünschten Einsatzbereich genutzt werden.
  3. Describe in own words what a basic block is.
    • Basisblöcke beschreiben eine Einheit von Knoten im SCG, die stets gemeinsam sequentiell in einem Tick ausgeführt werden. Verzweigungen und Tick-Grenzen bilden somit Grenzen von Basisblöcken.
  4. Which constraints influence the ordering of a schedule?
    • Abhängigkeiten auf Variablen, d.h. wenn in parallelen Blöcken einerseits eine Variables gesetzt wird und andererseits auf den Wert geprüft wird, müssen berücksichtigt werden.
    • Joins müssen ihre parallelen Blöcke beenden bevor die Ausführung fortgesetzt werden kann.

T2A2: Tickets

Been there, done that!

T2A3: Modeling with SCCharts

scchart rail {
  input bool second;
  input bool contact0, contact1;
  output int track;
 
  region:
      initial state controller "railway controller" {
        region go:
          initial state init
          --> running immediate with / track = 60;
          state running;
         
        region platform:
            initial state waiting
            --> slowdown immediate with contact0 / track = 20;
           
            state slowdown
            --> stop immediate with contact1 / track = 0;
           
            state stop
            --> waiting with 5 second / track = 60;
      };
}

T2A4: SCCharts Transformations

  • Transform all extended features of the SCChart in T2A3 to core variants. Explain in detail what features are extended features and how the particular transformation worked. Upload an image of the SCChart in Core SCChart form.
    • "During + SyncCharts": Die "5 Second"-Transition wird durch eine separate Region mit Zähler (und Fehler) ersetzt. Die urssprüngliche Transition zählt nicht mehr selber, sondern testet nur noch auf den Wert der Zählervariable. Die Zählregion terminiert sobald die Hauptregion terminiert.
    • "Initialization": Variablen, denen im Rahmen ihrer Deklaration auch schon ein Wert zugewiesen wurde, werden in einer neuen "Entry" Aktion initialisiert.
    • "Entry": Die zuvor eingeführten Entry-Aktionen werden durch neue immediate Transitionen realisiert, die vor der eigentlichen Region ausgefügt werden.
    • core.png
       
  • Normalize your new SCChart. Upload an image of the SCCharts in normalized form.
    • normalized.png
  • Convert the SCChart into its SCG representation. (You may use any valid SCG transformation KIELER offers.) Inspect the SCG and write down and explain all potential problems. Upload an image of the SCG.
    • scg.png
    • Im linken Bereich ist der Zähler umgesetzt (mit Fehler), der in jedem Tick auf das Signal second reagieren kann und dann die Variable inkrementiert.
    • Daneben ist prinzipiell der Initialzustand umgesetzt, in dem track = 60 gesetzt wird und anschliessend nichts mehr passiert.
    • Als nächstes ist der Test auf contact0 und dass reduzieren der Geschwindigkeit auf 20 zu sehen, dieser funktioniert ähnlich wie der Zähler.
    • Nachdem dies passiert ist, wird auf den Wert von contact1 wartet und der Zug angehalten.
    • Als letztes wird auf den Zähler gewartet und der Zug wieder beschleunigt.
    • Probleme:
      • Es treten Konflikte bei den Zuweisungen von track auf. Die erste Zuweisung track = 60 steht im SCG in Konflikt zu den anderen Zuweisungen. Unsere Annahme, dass im initialen Tick der Zug nicht die Kontakte auslöst ist hier nicht realisiert.

T2A5: Code Generation

In order to generate executable code for the station controller, some potential problems need to be fixed. Describe these problems. Create a corrected version of the simple station controller and compile it with KIELER. Upload the fixed controller, the new SCG and the resulting c code. Explain which changes were necessary.

SC-Chart:

tsa3-fixed-sct.png

SCG:

tsa3-fixed-scg.png

C-Code

Resulting Controller

 /*****************************************************************************/
/*                 G E N E R A T E D       C    C O D E                      */
/*****************************************************************************/
/* KIELER - Kiel Integrated Environment for Layout Eclipse RichClient        */
/*                                                                           */
/* http://www.informatik.uni-kiel.de/rtsys/kieler/                           */
/* Copyright 2014 by                                                         */
/* + Christian-Albrechts-University of Kiel                                  */
/*   + Department of Computer Science                                        */
/*     + Real-Time and Embedded Systems Group                                */
/*                                                                           */
/* This code is provided under the terms of the Eclipse Public License (EPL).*/
/*****************************************************************************/

int second ;
int contact0 ;
int contact1 ;
int track ;
int _counter ;
int _term ;
int _GO ;
int guard9_e2 ;
int guard9_e2 ;
int guard14_e1 ;
int guard9_e2 ;
int guard14_e1 ;
int guard23_e1 ;
int guard0 ;
int guard1 ;
int guard2 ;
int guard3 ;
int guard4 ;
int guard5 ;
int guard6 ;
int guard7 ;
int guard8 ;
int guard9 ;
int guard10 ;
  int PRE_guard10 ;
int guard11 ;
int guard11b ;
int guard12 ;
int guard13 ;
int guard14 ;
int guard15 ;
int guard16 ;
  int PRE_guard16 ;
int guard17 ;
int guard18 ;
int guard19 ;
  int PRE_guard19 ;
int guard20 ;
int guard21 ;
  int PRE_guard21 ;
int guard22 ;
int guard23 ;
int guard24 ;

   int reset(){
       _GO = 1;
    }

   int tick(){
       guard0 = _GO;
      Tick: {
                 if (guard1) { track = 60; }
                  guard17 = (PRE_guard16);
                  guard18 = (guard17 && (_counter == 5));
                 if (guard18) { track = 60; }
                  guard2 = (guard1 || guard18);
                  guard22 = (PRE_guard21);
                  guard3 = ((guard2 && contact0) || (guard22 && contact0));
                 if (guard3) { track = 20; }
                  guard20 = (PRE_guard19);
                  guard4 = ((guard3 && contact1) || (guard20 && contact1));
                 if (guard4) { track = 0; }
                  guard5 = guard4;
                 if (guard5) { _counter = 0; _term = 0; }
                  guard6 = guard5;
                 if (guard6) { _term = 1; }
                  guard7 = guard5;
                  guard11 = (PRE_guard10);
                  guard12 = (guard11b && (!(_term)));
                  guard13 = (guard12 && second);
                 if (guard13) { _counter = (1 + _counter); }
                  guard8 = (guard7 || guard13);
                  guard9 = ((guard8 && _term) || (guard11b && _term));
                  guard10 = ((guard8 && (!(_term))) || (guard12 && (!(second))));
                  guard9_e2 = (!(guard10));
                  guard14 = ((guard9_e2 || guard9) && (guard6 || guard9));
                  guard14_e1 = (!(guard10));
                  guard15 = ((guard14_e1 ||guard14) && guard14);
                  guard16 = (guard15 || (guard17 && (!((_counter == 5)))));
                  guard19 = ((guard3 && (!(contact1))) || (guard20 && (!(contact1))));
                  guard21 = ((guard2 && (!(contact0))) || (guard22 && (!(contact0))));
                  guard23 = 0;
                  guard23_e1 = (!((guard21 || (guard19 || (guard10 || guard16)))));
                  guard24 = ((guard23_e1 || guard23) && guard23);
                  }
       _GO = 0
    }

Die Initialisierung war zuvor parallel, wird durch eine Transition in der Hauptregion ersetzt. Damit wird unser "Protokoll" erhalten.

T2A6: Hostcode

Replace the contact and track variable assignments/reads with appropriate host code calls. Compile the SCChart again. Inspect the C code. Write down what changes to the code must be done to use this code in the railway simulation from tutorial 1 and the ModelGUI.

Gemacht, geht aber alles kaputt.

Tags: