Functions and Calculations

The EA PLC-Series can process small mathematical functions internally at runtime. In addition, with logical operators and options, they offer the possibility to make decisions, similar to an if-statement. In order to be able to evaluate user inputs or optimize the screen layout, calculation commands are also available that can work with object properties, such as bar graph value, last touch position or object width and position. Most functions are available as both integer and floating-point calculations. Care must be taken to stay in the respective number range, or to convert with the cast operator (float or int).

The module works with little-endian (Intel-format), that means the least significant byte is transferred first.

Attention:

Calculations need to be run inside brackets (...). See command syntax for further details.



signed Integer

(32 Bit)

Float

IEEE 754

(32-Bit)


Mathematical functions

Arithmetical functions

+, -, * , /, ()

Absolute value |x|

abs(x)

Sign of x (-1, 0, 1): x<0, x==0, x>0

sign(x)

Modulo x%y

mod(x,y)

Power x^y

pow(x,y)

Root

sqrt(var)


n-th root (from V1.1)

sqrt(var,n)


Truncate decimal points

trunc(var)


Round decimal points

round(var)


Logarithm (base n) (from V1.1)

log(var,n)



Logarithm (base 10)

log(var)


Natural logarithm (ln, Basis e)

ln(var)


Exponential function base e

exp(var)


Degrees to rad

rad(deg)


Rad to degrees

deg(rad)


Sine

sin(deg)


Cosine

cos(deg)


Tangent

tan(deg)


Arcsine

asin(var)


Arc cosine

acos(var)


Arctangent

atan(var)


Arctangent, right quadrant

atan(y,x)


Minimum

min(a,b,c…)

Maximum

max(a,b,c…)

Average

avg(a,b,c…)

Random value sv <= x <= ev (max 65535)

rand(sv,ev)

Random value 0 <=x <= ev (max 65535)

rand(ev)

Random value 0<= x<=1000

rand()

Register increment / decrement

pre-/post- increment

++Rx, Rx++

pre-/post-  decrement

--Rx, Rx--

Cast Integer Float

Integer calculation, return Float

int(calculation)


Float calculation, return Integer

float(calculation)


Bit Operating

Low Byte

loB(x)


High Byte

hiB(x)


Low Word

loW(x)


High Word

hiW(x)


Low Byte from High Word

hwloB(x)


High Byte from High Word

hwhiB(x)


AND

&


OR

|


NOT

~


XOR

^


Shift left / right

<<, >>


Set bit  (Bit-Nr. 0..31)

bitS(value, Bit-No.)


Clear bit(Bit-Nr. 0..31)

bitC(value, Bit-No.)


Exor bit (Bit-Nr. 0..31)

bitX(value, Bit-No.)


Test bit (Bit-Nr. 0..31) returns true or false

bitT(value, Bit-No.)


Logical Operators

AND

&&

OR

||

NOT

!

Equal, not equal

==, !=

Less, less than or equal

<, <=

Greater,Greater than or equal

>, >=

Decision

If-Then-Else-function

ifte(condition, value true, value false)

Value between L1 and L2 (including limits) (from V1.1)

insideE(value,L1,L2)

Value between L1 and L2 (excluding limits) (from V1.1)

insideU(value;L1,L2)


Object commands

Width (without transform)

objW(id)

Height (without transform)

objH(id)

Width of the child (from V1.3)

objW(id, Child-ID)

Height of the child (from V1.3)

objH(id, Child-ID)

Position X (actual anchor, for groups: relative to parent object)

objX(id)

Position Y (actual anchor, for groups: relative to parent object)

objY(id)

Screen-Position X (given anchor, also for groups: Screen coordinates)

objX(id, anchor)

Screen-Position Y (given anchor, also for groups: Screen coordinates)

objY(id, anchor)

Screen position X of the child (specified anchor, also for groups: screen coordinates) (from V1.3)

objX(id, anchor, Child-ID)

Screen position Y of the child (specified anchor, also for groups: screen coordinates) (from V1.3)

objY(id, anchor, Child-ID)

Scaled width

objSW(id)

Scaled height

objSH(id)

Shear X

objSX(id)

Shear Y

objSY(id)

Rotation

objR(id)

Opacity

objO(id)

Layer

objL(id)

Get Obj-ID by Group-ID or screenwide (id=0) and layer (from V1.2)

objLI(id, layer)

Read actual used style

objC(id)

Read active anchor

objA(id)

Object exists?

objE(id)

Object visible? (from V1.1)

objV(id)

Get Obj-ID from screen-coordinates.

objXY(x,y)

Get Obj-ID from screen-coordinates. If onlyrect is true, then fast calculation is done and only the object's rectangular size is checked (transparencies are ignored) (from V1.4)

objXY(x,y,onlyrect)

Object commands Menu

Get last valid menu item

objML(id)

Get active shown menu item (0=closed)

objMV(id)

Check state of item (1=checked, 0=unchecked)

objMC(id, item)

Get enable state (1=enabled, 0=disabled)

objME(id, item)

Object commands ComboBox

Get last valid item

objCL(id)

Get active shown item (0=closed, -1=no item visible)

objCV(id)

Get enable state (1=enabled, 0=disabled)

objCE(id, item)

Object commands SpinBox

Get last valid items

objBL(id)

Get last valid item of box no in spinbox group

objBL(id, boxnr)

Get active shown items

objBV(id)

Get active shown item of box no in spinbox group

objBV(id, boxnr)

Get enable state (1=enabled, 0=disabled)

objBE(id, item)

Get last valid item (from V1.2)

objPL(id)

Get active shown item (from V1.2)

objPV(id)

Get enable state (1=enabled, 0=disabled) (from V1.2)

objPE(id, item)

Get PictureBox/Animated picture item size (from V1.5)

objPA(id)

Object commands StringBox

Visible lines

objTV(id)

Number of paragraphs (= number of lines without AutoWrap)

objTA(id)

Number of lines (after AutoWrap)

objTN(id)

Number of strings (after AutoWrap)

objTN(id, Absatz nr)

Visible top line

objTL(id)

String line start (after AutoWrap)

objTL(id, Absatz nr)

Paragraph from line number

objTS(id, line nr)

Object properties

Read user value integer (#OUI)

objUI(id)

Read user value float (#OUI)

objUF(id)

Object properties Bargraph/Instrument

Current value

objIV(id)

Value drawn on the screen (not necessarily the same for animations as objIV (id))

objID(id)

EndValue

objIE(id)

StartValue

objIS(id)

Object properties paths

Length

pathL(id)

X-Coordinate of a path with distance

pathX(id,distance)

Y-Coordinate of a path with distance

pathY(id,distance)

Tangent angle of a point on a path

pathR(id,distance)

Touch functions

Touch button/switch state

=1 unpressed

=2 pressed

butS(id)

Radio-group: Active switch (id)

butR(id)

Last used touch button

butI()

Letzter Keyboard code

butC()

Last entered keyboard code)

touchA()

Last touch position X (Down- or Drag-Event)

touchX()

Last touch position Y (Down- or Drag-Event)

touchY()

Touch position X of touch point number no (Down- or Drag-Event))

touchX(nr)

Touch position X of touch point number no (Down- or Drag-Event)

touchY(nr)

Decomposition of input elements (Menu)

Get root from item

menR(item)

Get menu from item

menM(item)

Get sub-menu from item

menS(item)

Make item from root, menu, sub-menu

menRMS(r,m,s)


Decomposition of input elements (SpinBox)

Entry box 1 (8 Bit value)

spin1(item)


Entry box 2 (8 Bit value)

spin2(item)


Entry box 3 (8 Bit value)

spin3(item)


Entry box 4 (8 Bit value)

spin4(item)


Make item from individual spinbox values ((e4<<24) | (e3<<16) | (e2<<8) | e1)

spinE(e1,e2,e3,e4)


Item from decimal number (only for spinbox with numeric entries 0-9) (from V1.3)

spinD(Number, Decimal places)



Diagram (from V1.1)

Chart window changed since last touch event

0=no change

1=shift in x-direction

2=shift in y-direction

3=Zoom in x direction

4=Zoom in y direction

diaWC(id)

Automatic scrolling (0=off, 1=on)

diaWS(id)

x-offset of the diagram (active area)

diaWX(id)

y-offset of the diagram (active area)

diaWY(id)

Total width (active area)

diaWW(id)

Total height (active area)

diaWH(id)

Segment length x-direction

diaPX(id)

Segment length y-direction

diaPY(id)

Shift in x-direction

diaMX(id)

Shift in y-direction

diaMY(id)

Zoom in x-direction

diaZX(id)

Zoom in y-direction

diaZY(id)

Start value of the axis

diaAS(id,axis-No.)

Current start value of the axis

diaAA(id,Achsen-No.)

Current value of the axis from coordinates

diaAV(id, axis-No.,x,y)

Current axis interval

diaAP(id,axis-No.)

1/100 Time value of coordinate (only time format of x-axis)

diaAT(id,axis-No.,x)

Nearest line number

diaLN(id,x,y)

Nearest line number (limited to a maximum distance)

diaLN(id,x,y,max. distance)

Nearest Array Index

diaLI(id,line-Nr.,x,y)

Nearest Array Index (limited to a maximum distance)

diaLI(id,line-Nr.,x,y,max. distance)

First visible array index of the x-axis

diaLF(id,line-No.)

Last visible array index of the x-axis

diaLL(id,line-No.)

x-coordinate of line index (relative to active area)

diaIX(id,line-No.,index)

y-coordinate of line index (relative to active area)

diaIY(id,line-No,index)

x-coordinate of line index (absolute)

diaSX(id,line-No.,index)

y-coordinate of line index (absolute)

diaSY(id,line-No.,index

x-value of line index

diaVX(id,line-No.,index)

y-value of line index

diaVY(id,line-No.,index)

1/100s Time Value of line index (only time format of x-axis)

diaVT(id,line-No.,index)

I/O Ports

Port state (a = port expander 0..15)

port(a)

Port-pin state (a = Pin number 0..127)

bit(a)

Analogue input

Analog value (a=0..3))

analog(a)

RS232 Master interface

Length of received data bytes

mstRA()



Timer

Set timer start value (10 ms Timer)

timer(startvalue)


Read timer (10 ms Timer)

timer()



Time functions/ RTC

Time and date are calculated by the module internally in seconds with epoch = 1.1.2000 at 00:00:00 o'clock with SINT32 (= datetime-value). Thus, the maximum period used by the module is from 1932 - 2067. The base date can be changed with the #WDY command. To calculate time periods, it's always necessary to convert the time/date to seconds first, then carry out the calculation. The result can then be converted back again to minutes, hours, day, month and year.

Convert current date into datetime-value

date()


Convert number of days into seconds

date(D)


Convert day + month + year (1932 - 2067) into datetime-value

date(D,M,Y)


Convert actual time into seconds (starting with 0:00:00)

time()


Convert number of hours into seconds (? h·3600)

time(h)


Convert hours and minutes into seconds (? h·3600 + m·60)

time(h, m)


Hour, minutes and seconds into seconds (? h·3600 + m·60 + s)+ s)

time(h, m, s)


Convert current date and time into datetime-value

datetime()


Hour+min+sec+day+month+year into datetime-value

datetime(h,m,s,D,M,Y)


Actual year

year()


Calculate year from datetime-value

year(a)


Actual month

month()


Calculate month from datetime-value

month(a)


Actual day

day()


Calculate day from datetime-value

day(a)


Actual week day (0-6=Sunday..Saturday)

weekday()


Calculate week day from datetime-value

weekday(a)


Actual hour

hour()


Calculate hour from datetime-value

hour(a)


Actual minute

minute()


Calculate minute from datetime-value

minute(a)


Actual second

second()


Calculate seconds from datetime-value

second(a)


String register functions

Length of string (Register no)

strL(nr)


ASCII-Code from string position

strA(nr, offset)


Unicode-Code from string position

strU(nr, offset)


Convert numerical string to SINT32 or float.

strV(nr)

Comparison of two string registers

=0 both strings are the same

>0  first unequal character in n1 is greater then the one in n2

<0  first unequal character in n1 is smaller then the one in n2

strC(n1, n2)


Compare the first len characters of two strings

strC(n1, n2, len)


Compare len characters of two strings, starting with offset  (from V1.1)

strC(n1, n2, len, offset)


Compare len characters of two strings, starting on different offsets  (from V1.1)

strC(n1, n2, len, offset1, offset2)


Search for code in string from left

=-1 not found

>=0 Offset of the first code found

strFL(nr, code)


Search for code in string from left starting with offset (from V1.1)

strFL(nr, code, offset)


Search for code in string from right

strFR(nr, code)


Search for code in string from right starting with offset (from V1.1)

strFR(nr, code, offset)


Search for string from another register (n2) in string (n1)

strFS(n1, n2)


Search for string from another register (n2) in string (n1) from offset. (from V1.1)

strFS(n1, n2, offset)


Check if code is a character

isAL(code)


Check if code is digit or character ist

isAN(code)


Check if code is a small letter

isLO(code)


Check if code is a big letter

isUP(code)


Check if code is whitespace

isWS(code)


Check if code is a digit

isDD(code)


Check if code is a hexadecimal number

isDH(code)


Check if code is a binary number

isDB(code)


Regular expressions (from V1.2)

For all commands concerning the RegEx the result is also saved in ten special RegExp-Registers with direct access, through X? (all X0,container X1..X9, see command syntax).


Find RegEx in StringRegister; return first index found in string(-1 not found)

strXF(RegExp-ID, String-ID)


Find RegEx in StringRegister begin search from offset

strXF(RegExp, String, offset)


RegEx search from StringRegister n1 to n2; return String-ID first match (-1 not found)

strXS(RegExp, String-ID n1, String-ID n2)


RegEx search from StringRegister n1 to n2 begin search from offset

strXS(RegExp, String-ID n1, String-ID n2, offset)


RegEx in StringArray[index];  return first index found in specified string (-1 not found)

strXI(RegExp, Array-ID, index)


RegEx in StringArray[index] begin search from offset

strXI(RegExp, Array-ID, index, offset)


RegEx search in StringArray from start-index (si) to end of array; return array index (-1 not found)

strXA(RegExp, Array-ID, si)


RegEx search in StringArray from start-index (si) to end-index (ei)

strXA(RegExp, Array-ID, si, ei)


RegEx search in StringArray from start-index (si) to end-index (ei), begin search from offset

strXA(RegExp, Array-ID, si, ei, offset)


Get last RegEx search container string length (0=complete,  container 1..9)

strXL(nr)


Get last RegEx Search container start offset

strXP(nr)


Observed Register functions (from V1.5)

Register change flag: true if observed Register nr has changed

cfoR(nr)


StringRegister change flag: true if observed StringRegister nr has changed

cfoS(nr)


Array change flag: true if observed Array nr has changed

cfoA(nr)


Next changed Register Id: returns Id of next changed Register (-1 if no changed)

cfoRN()


Next changed StringRegister Id: returns Id of next changed StringRegister (-1 if no changed)

cfoSN()


Next changed Array Id: returns Id of next changed Array (-1 if no changed)

cfoAN()


Next changed Register Id: returns Id of next changed Register starting at Id startnr

cfoRN(startnr)


Next changed StringRegister Id: returns Id of next changed StringRegister starting at Id startnr

cfoSN(startnr)


Next changed Array Id: returns Id of next changed Array starting at Id startnr

cfoAN(startnr)


Array functions

Get max. elements for a new array (from V1.4)

arE(-1)

Get max. elements for a new string array with stringlength strlen (from V1.6)

arE(-1, strlen)

Get array element count (0 = not exist) (from V1.4)

arE(id)

Get array value (from V1.4)

arV(id, index)

Get unicode value from string array from offset (from V1.6)

arV(id, index, offset)

Get next array value from read index and increment read index (from V1.4)

arV(id)

Get array read index (from V1.4)

arR(id)

Get array write index (from V1.4)

arW(id)

Highest used write pointer index (from V1.5)

arW(id,1)

First Array Index (for Autowrap, otherwise 0) (from V1.5)

arF(id)

Last array index (for autowrap, otherwise arW(id,1)) (from V1.5)

arL(id)

Number of used array entries (from V1.5)

arU(id)

Minimum of all array elements (from V1.5)

arMIN(id)

Maximum of all array elements (from V1.5)

arMAX(id)

Sum of all array elements (from V1.5)

arSUM(id)

Average value of all array elements (from V1.5)

arAVG(id)

Minimum of all array elements from range (from V1.5)

arMIN(id,Start,Ende)

Maximum aller Array Elemente aus Bereich (ab V1.5)

arMAX(id,Start,Ende)

Sum of all array elements from range (from V1.5)

arSUM(id,Start,Ende)

Average value from range (from V1.5)

arAVG(id,Start,Ende)

Color commands

Get red channel from a 24 bit RGB value

getR(x)


Get green channel from a 24 bit RGB value

getG(x)


Get blue channel from a 24 bit RGB value

getB(x)


Combine 3 single color channels to one 24 bit RGB value

RGB(R, G, B)


Read 24 bit RGB value from a color ramp

rampRGB(nr, offset)


Read opacity value from a color ramp

rampO(nr,offset)


Read 24 bit RGB value from a display-pixel (from V1.4)

tftRGB(x,y)


Read 16 bit RGB (RGB565) value from a display-pixel (from V1.5)

tftRGB(x,y,1)


SD-Card (File and directory commands)

File exists? (<Path/filename> in string register no)

fileE(nr)


File size? (<Path/filename> in string register no))

fileS(nr)


File attribute? (<Path/filename> in string register no)

fileA(nr)


Get fat-time of file (<Path/filename> in string register no))

fileT(nr)


Get fat-date of file (<Path/filename> in string register no)

fileD(nr)


Convert datetime-value to fat-time

fatT(datetime)


Convert datetime-value to fat-date

fatD(datetime)


Convert  fat-time and date to datetime-value

fattime(Fat-Time, Fat-Date)


Calculate file crc, compare with FAT crc (from file in string register no), return true or false (#FFS)

fileC(no)


Get stored file crc (from file in string register no), return CRC16. (#FFS)

fileC(no,1)


Calculate file crc (from file in string register no), return CRC16 (#FFS)

fileC(no,2)


Get actual read-pointer position  (#FRO) (from V1.1)

fposR()


Get actual read-pointer position calculated from file end (=negativ) (from V1.1)

fposR(-1)


Get actual file size of opened read file (from V1.4)

fposR(1)


Get actual write-pointer position (#FWO)  (from V1.1)

fposW()


Get actual write-pointer position calculated from file end (=negativ) (from V1.1)

fposW(-1)


Get actual file size of opened write file (from V1.4)

fposW(1)


Get actual maximum file size (from V1.4)

fposW(2)


Get maximum file size of file from string register no (from V1.4)

fileM(nr)


Get storage total size (from V1.4)

memST()


Get storage free size (from V1.4)

memSF()


Get object RAM total size (from V1.4)

memRT()


Get object RAM free size (from V1.4)

memRF()


Get object RaM max block size(from V1.4)

memRB()


Module commands

Firmware version (n=0: uniTFT; n=1: PLC) (from V1.5)

version(n)


Last frame rate (fps)

fps()

Get touch type (=0 no, =1 resistive, =2 PCAP))

touchT()

Screen width (#XCV)

scrW()

Screen Height (#XCV)

scrH()

Screen width of hardware, not depending on (#XCV)

scrW(1)

Screen height of hardware, not depending on (#XCV)

scrH(1)

Video Width

vidW()

Video Height

vidH()

Number of video objects

vidC()

Get actual backlight brightness

ledB()

Get backlight autostate brightness (state=0..2 ))

ledB(status)

Get backlight autostate status

ledS()

Errorstring available?

error()

Errorstring available? copy Errorstring to Stringregister nr (#VSL)

error(nr)

Errorstring available? copy Errorstring to Stringreg nr and  clear Errorstring

error(nr,1)

PLC

Read PLC IP address (n=0: 32Bit; n=1: 8Bit 1 entry; n=2: 8Bit 2 entry;...; n=4: 8Bit 4 entry) (from V1.8). More information see command #QCA

plcI(n)


Read PLC signal strength (-2=RS485; -1=LAN; 0=no connection; 1...5= WIFI strength) (from V1.8). More information see command #QWC

plcW()


Read PLC connection status (PLC address); For satellites only plcN(0) possible (from V1.8)

plcN(address)


Read PLC RS485 baudrate (from V1.8)

plcB()


Priority list of all operators

12

()

Parentheses / function call (highest priority))

11

++

Register increment


- -

Register decrement


+

Sign


-

Sign


!

Logical NOT


~

Bitwise NOT

10

*

Multiplication


/

Division

9

+

Addition


-

Subtraction

8

<<

Shift left


>>

Shift right

7

<

Less than


<=

Less than or equal


>

Greater than


>=

Greater than or equal

6

==

Equal


!=

Unequal

5

&

Bitwise AND

4

^

Bitwise XOR

3

|

Bitwise OR

2

&&

Logical AND

1

||

Logical OR (lowest priority))