Difference between revisions of "Technical topic: OpenGEODE - SDL Operators: How to work with data"

From TASTE
Jump to: navigation, search
Line 8: Line 8:
 
= INTEGER types =
 
= INTEGER types =
  
```
+
  MyInt ::= INTEGER (0 .. 255)
MyInt ::= INTEGER (0 .. 255)
 
```
 
 
 
  
 
= REAL types =  
 
= REAL types =  
  
```
+
  MyReal ::= REAL (0.0 .. 10.0)
MyReal ::= REAL (0.0 .. 10.0)
 
```
 
  
 
= ENUMERATED types =
 
= ENUMERATED types =
  
```
+
  MyEnum ::= ENUMERATED { foo, bar }
MyEnum ::= ENUMERATED { foo, bar }
 
```
 
  
 +
= CHOICE types =
  
= CHOICE types =
+
  MyChoice ::= CHOICE {
 +
      foo BOOLEAN,
 +
      bar INTEGER (0 .. 255)
 +
  }
  
```
 
MyChoice ::= CHOICE { foo BOOLEAN, bar INTEGER (0 .. 255) }
 
```
 
  
 
= SEQUENCE OF types (arrays) =
 
= SEQUENCE OF types (arrays) =
  
```
+
  MySeqOf ::= SEQUENCE (SIZE (0..10)) OF BOOLEAN
MySeqOf ::= SEQUENCE (SIZE (0..10)) OF BOOLEAN
+
 
```
 
  
 
= SEQUENCE types (records) =
 
= SEQUENCE types (records) =
  
```
+
  MySeq ::= SEQUENCE {
MySeq ::= SEQUENCE {
+
      a BOOLEAN OPTIONAL,
  a BOOLEAN OPTIONAL,
+
      b INTEGER (0 .. 255)
  b INTEGER (0 .. 255)
+
  }
}
 
```
 

Revision as of 09:56, 7 February 2019

Introduction

The SDL language primarily targets the description of a system's behaviour. It is however also possible to manipulate data using a collection of built-in operators. This can be convenient to avoid depending on external, manually-written code to process the parameters of messages during the execution of a state machine transition.

Variables are defined in the ASN.1 language and can express simple types (boolean, numbers and enumerated values) as well as complex data structures (records, arrays, and choices). Each type comes with some dedicated operators which are described in this page.


INTEGER types

  MyInt ::= INTEGER (0 .. 255)

REAL types

  MyReal ::= REAL (0.0 .. 10.0)

ENUMERATED types

  MyEnum ::= ENUMERATED { foo, bar }

CHOICE types

  MyChoice ::= CHOICE {
     foo BOOLEAN,
     bar INTEGER (0 .. 255)
  }


SEQUENCE OF types (arrays)

  MySeqOf ::= SEQUENCE (SIZE (0..10)) OF BOOLEAN


SEQUENCE types (records)

  MySeq ::= SEQUENCE {
     a BOOLEAN OPTIONAL,
     b INTEGER (0 .. 255)
  }