Skip to content
Snippets Groups Projects
data_dictionary.html 6.9 KiB
Newer Older
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<!--  Documentation of Defining a Data Dictionary. -->

	<link rel="stylesheet" type="text/css" href="../layout/stylesheet.css">
	<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
	<title>Defining a Data Dictionary using AutoFOCUS3 (AF3)</title>
</head>
<body>
<div class="header">
<div class="box">
<div class="navbar">
<!--a href="https://www.fortiss.org/" align="left">
<img src="fortiss-logo.png" width="90px" height="20px" align="left">
</a-->
 <div class="dropdown">
    <button class="btn" id="hamburger">
    <label for="hamburger" class="hamburger">
        <span class="hamburgerLine"></span>
        <span class="hamburgerLine"></span>
        <span class="hamburgerLine"></span>
    </label>
    </button>
    <div class="dropdown-content">  
      <a href="../getting_started.html"> Main Page</a>
      <a href="../ModandSim/model_element_attributes.html">Modeling and Simulation</a>
      <a href="../ta/technical_viewpoint.html">Deployment and Code Generation</a>
      <a href="../dse/dse_perspective.html">Design Space Exploration (DSE)</a>
      <a href="../assuranceCases/creation.html">Assurance Case Modeling</a>
      <a href=".././af3_further_resources.html">Further Resources</a>
    </div>
   </div> 
    <div class="dropdown">
    <button class="dropbtn">Modeling and Simulation <i class="triangle"></i></button>
    <div class="dropdown-content">
	   
	<a href="model_element_attributes.html">Introduction to Graphical Modeling Interface</a>
        <a href="component_architecture.html">Component Architecture Modeling</a>
        <a href="code_specification.html">Behavior Modeling -> Code Specifications</a>
        <a href="state_automaton.html">Behavior Modeling -> State Automata</a>
	<a href="hierarchical_state_automaton.html">Behavior Modeling -> Hierarchical State Automata</a>
	<a href="mode_automaton.html">Behavior Modeling -> Mode Automata</a>
	<a href="simulation_with_af3.html">Simulation -> Simulation</a>
	<a href="operatorpanels.html">Simulation -> Operator Panels</a>
	<a href="operatorpanels_advanced.html">Simulation -> Advanced Operator Panels</a>
	<a href="cosimulation_with_af3.html">Simulation -> Co-Simulation and FMI Support</a>
	<a href="refactoring.html">Refactoring</a>
	<a href="model_markers_view.html">On-the-fly Checks</a>
    </div>
   </div>
<div class="topnav-right">
      <a href="mailto:af_user@lists.fortiss.org?subject=Reporting 'Data_Dictionary.html' Documentation Problem!&body= Dear Af3 team, I am reporting an issue related to 'modelling and simulation'. 
       {Please specify the problem precisely here.}.">Report a Problem?</a>
    </div>
  </div>
</head>
</div>
</div>
<div class="box">
<button onclick="topFunction()" id="upBtn" title="Go to top">Top</button>
<h2>Data Dictionary: Types and functions</h2>
<p>AF3 allows you to define your own datatypes and functions by using a socalled "Data Dictionary". To create such a Data Dictionary, right-click at the root of your project and select "Data Dictionary", as shown below:</p>

<img src="./pictures/DataDictionary.Add.png">

<p>You can then add the following elements to your Data Dictionary:
<ul>
<li>Enumeration</li>
<li>Structure</li>
<li>Array</li>
<li>Function</li>
</ul>
</p>
<p>These can be added by drag-and-drop from the model elements palette or by the context menu (right-click) of the data dictionary itself in the model navigator.</p>
<p>We describe below every of these elements in more details: what they consist of, how to define them, as well as the <i>syntax</i> to use to refer to the data items they define. The latter is particularly
useful, e.g., in Guards and Actions of <a href="state_automaton.html"><i>State Automata</i></a> or in <a href="code_specification.html"><i>Code Specifications</i></a>.</p>
<p> An enumeration is a data type defined as a finite list of values. Variables of this type can only contain a value which belong to this list. This is similar to "unions" in C, or to "sum types" in functional languages. After having created an enumeration, you can add elements to it by drag and dropping "enumeration members" from the
palette or by right-clicking the enumeration in the data dictionary editor.</p>

<p><i>Syntax</i>: an enumeration member can be accessed by writing its name followed by "()" (this allows to distinguish enumeration members from ports).
For instance, referring to the elements of the enumeration defined below is done by writing "Green()", "Red()", "RedYellow()", "Yellow()". </p>

<img src="./pictures/DataDictionary.Enumeration.png">

<h3>Structure</h3>

<p> A structure is a data type which allows to gather various values in one variable, each value being uniquely identified by a structure member <i>name</i>. One can for instance state a value shall always have a member called "x" of type integer and a member called "y" of type boolean.
This is similar to "records" in C, or to "product types" in functional languages. After having created a structure, you can add elements to it by drag and dropping "structure members" from the
palette or by right-clicking the structure in the data dictionary editor. </p>
<p><i>Syntax</i>: a structure member of a variable "v" can be accessed by writing "<tt>v.MEMBER_NAME"</tt>.
For instance, for the example structure mentioned in the previous paragraph, one would access the integer by "<tt>v.x</tt>" and the boolean by "<tt>v.y</tt>".
Creating a structure is done with the syntax "<tt>{member_name_1: value_1, member_name_2: value_2, ...}</tt>". With the same example above: "<tt>{ x: 1, y: true }</tt>".
</p>


<h3>Array</h3>

Arrays are like usual C arrays, but <i>their size is defined in the datatype itself</i>.

<p><i>Syntax</i>: Given a variable "v" whose type is an array, the i-th element can be accessed by the expression
"<tt>v[i]</tt>". The index starts from 0. Assigning a value x to the i-th element is done with the syntax "<tt>v[i] = x</tt>".</p>
<p>Functions denote small functions which can be used in various places in an AF3 project. <i>Note:</i>Functions are not a type but are still defined in the data dictionary.
</p>
<li>name
<li>comment
<li>parameters
<li>a return type
<li>a definition

<i>Note:</i> the definition cannot contain local variables! (this means that practically, most function definitions contain only "if" and "return" statements.)
</ul>
(see next figure for an example). 
</p>

<img src="./pictures/DataDictionary.Definitions.png">
<p>If you want to check your defined functions, AutoFOCUS provides an Evaluator for the Data Dictionary. Simply click onto the Evaluator-Tab and insert commands into the lower field. The upper field shows the results of your inputs. 
As you can see in the following Example, the Function "tRed()" returns 5 as defined. </p>

<img src="./pictures/DataDictionary.Evaluator.png">

</div>

<script src="../layout/jsscript/topBtn.js">
</script>