Home
Categories
Dictionary
Download
Project Details
Changes Log
Who We Are
FAQ
License

Data provider equations


    1  Overview
    2  Syntax
       2.1  Expressions types
       2.2  Affectations
       2.3  Code blocks
       2.4  Local variables
       2.5  If-then-else
       2.6  While loops
       2.7  Echo
       2.8  Comments
    3  Functions list
    4  See also

The Embed Client Data provider inputs processing logic are specified using an equation syntax. This article explains this syntax..

Overview

All classic numeric and boolean functions are supported:
  • Adding ("+")
  • Substracting ("-")
  • Multiplication ("*")
  • Division ("/")
  • Modulo ("%")
  • Logical OR ("||")
  • Exclusive Logical OR ("^")
  • Logical AND ("&&")
  • Logical NOT ("!")
  • Numeric comparisons ("<", ">", "<=", ">=", "!=", "==")
  • Parenthesis
Additionally:
  • There is no limit to the level of imbrication of functions
  • Operators priority is not taken into account. For example, you should write "(a * 2) + b, and not "a * 2 + b"

Syntax

Expressions types

Expresions use the following syntax:
  • There are a lot of default functions, such as classic numeric functions (addition, substraction, etc..) and mathematical functions (sin, cols, etc...). For example:
    • The result of "1+2" is 3
    • The result of "sin(2)" is the sinus of 2
  • Expressions can have one or several arguments
  • Expressions can use variables and constants. For example, the result of "a + b" depends on the values of a and b, which can be variables or constants

Affectations

It is possible to use affectations in expressions. For example, for the expression "b=2*a":
  • The result is "2*a"
  • The value of 2*a is affected to b

Code blocks

Code blocks are expressions separated by semi-colons (";") séparées. The result of the block of code if the result of the last expression in the list, but the mprevious expressions will also be evaluated. For example, for the expression "a=2;b=2*a":
  • The result is 4
  • The value of b is 4
  • The value of a is 2
The "return" keyword can be used to clarify expressions. For example, the following expression will have the same effect as the previous one: "a=2;b=2*a; return b". It is also possible in this case to write "a=2; return 2*a" if we don't xant to change the value of b. Note that it is possible to omit the last ";".

Local variables

It is possible to use local variables in expressions. PFor example in the following example b is local to the l‘expression. Note that if a local variable has the same name of a global variable, the value of the global variale will not be modified.

      a=2;
      int b=2*a;
      return b
Type declarations for local variables are:
  • int
  • float
  • bool
  • string
  • int[]
  • float[]
  • bool[]
  • string[]
  • var for variaqbles which have a dynamic type

If-then-else

If-then-else expressions are supported. For example:
      if (c) {return 2} else {return 3};
or
      if (!c) {return 2} 
      else if (b == 2) {return b * 10}
      else {return 3}
If-then-else expressions can also be used inside other expresiosn or code blocks. For example:
      if (!c) {return 2}
      else if (b == 2) {
      if (d == 3) { return 25} 
      else {return 45}
      } else {return 3};

While loops

While loops are supported. For example:
      int c = 0;
      int d = 0;
      while (c < 10) {
      d = d + a; 
      c = c + 1};       

Echo

The "echo" function prints the argument in the console. For example: "echo("a = " + a) will show the value of a in the console.

Comments

It is possible to add comments on a line in expressions. For example:

      if (!c) {return 2}
      /* first if */
      else if (b == 2) {
      if (d == 3) { return 25} 
      else {return 45}
      } else {return 3};

Functions list

Function Syntax Definition
abs abs(a) Absolute value
sin sin(a) Sinus (input in radians)
cos cos(a) Cosinus (input in radians)
tan tan(a) Tangent (input in radians)
asin asin(a) Arc sinus
acos acos(a) Arc cosinus
atan atan(a) Arc tangent
atn2 atn2(a) Arc tangent 2
pow pow(a, b) a power b (for example pow(a, 2) is a * a)
sqrt sqrt(a) Square root
PI PI The PI constant
toDegrees toDegrees(a) Conversion from radians to degrees
toRadians toRadians(a) Conversion from degrees to radians

See also


Categories: client | user

Copyright 2016-2017 Dassault Aviation. All Rights Reserved. Documentation and source under the LGPL v2 licence