• Proop Builder Macro Wizard

• All technical documents for Proop...

Proop Builder Macro Wizard

All technical documents for Proop...

Proop Builder Macro Wizard

#189  by Murat
Mon May 28, 2018 8:54 am
Macro Wizard is a help window which lists all macro commands and it has explanatons and examples too. Thanks to this window, macro commands can be prepared in accordance with it’s f ormat and added to macro code window.

Arithmetic Commands:
+ Command
- Command
* Command
/ Command
% Command
SQRT

Comparison Commands:
IF, ELSE, ENDIF

Loop Control:
FOR TO/DOWNTO, ENDFOR
WHILE, ENDW

Variables & Functions:
GLOBAL
LOCAL
FUNC MAIN
FUNC
CALL FUNC

Data Transfer:
= Command
WRITEONCE, GETONCE
WRITEBUF, WRITEBUFSYNC, PUTBUF

Others:
SLEEP
GETSYSTICK
GETSYSTIME
GETSYSTOUCH
RESETCOMM

+, -, *, /, %, SQRT

#190  by Murat
Mon May 28, 2018 8:57 am
Var1 = Var2 + Var3;

"+" command is used to find two variables' sum.

In this example, address \$0's value is equal to address \$1's value 20 plus 10.
\$0 is equal to 30.
Code: Select all
``````Example:
\$1 = 20;
\$0 = \$1 + 10;``````

Var1 = Var2 - Var3;

"-" command subtracts one value from another to find the difference between them.

In this example, address \$0's value is equal to address \$1's value 20 minus 10.
\$0 is equal to 10.
Code: Select all
``````Example:
\$1 = 20;
\$0 = \$1 - 10;``````

Var1 = Var2 * Var3;

"*" command is used for multiplication of two variables.

In this example address \$0 is equal to the result of multiplication address \$1's value 10 and 5.
Code: Select all
``````Example:
\$1 = 10;
\$0 = \$1 * 5;``````

Var1 = Var2 / Var3;

"/" command is used for division of two variables.

In this example address \$0 is equal to the result of division address \$1's value 10 and 5.
Code: Select all
``````Example:
\$1 = 10;
\$0 = \$1 / 5;``````

Var1 = Var2 % Var3;

"%" command finds the remainder after division of one variable by another.

In this example address \$0 is equal to the result of modulo operation of address \$1's value 10 and 3.
Code: Select all
``````Example:
\$1 = 10;
\$0 = \$1 % 3;``````

Var1 = sqrt(Var2);

"sqrt" command is used to find square root of a variable.

In this example, address \$0's value is square root of address \$1's value 81.
Code: Select all
``````Example:
\$1 = 81;
\$0 = sqrt(\$1);``````

IF

#191  by Murat
Mon May 28, 2018 8:58 am
if
/* Execute these statements if TRUE */
else if
/* Execute these statements if FALSE */
else
/* Executed if no other statement is */
endif;

"IF" command allows to make logical comparisons between variables.
"ELSE" command executes when the condition in if statement evaluates to false.
"ELSE IF" command checks the condition when the condition in if statement evaluates to false.
"ENDIF" command is used to terminate a multiple line if command.

Relational Operators:

"==" equal to 5 == 5 is true
"!=" not equal to 5 != 4 is true
"<" less than 5 < 6 is true
"<=" less than or equal 3 <= 4 is true
">" greater than 5 > 4 is true
">=" greater than or equal 5 >= 3 is true

In this example address \$1 is equal to 10 if address \$0's value is equal 1.
If the result is false, it checks address \$0's value is greater than 2 or equal and if it is true then address \$1's value will be 20.
If both comparisons are false then "else" equals address \$1's value to 30.
Code: Select all
``````Example:
func main()
if \$0 == 1
\$1 = 10;
else if \$0 >= 2
\$1 = 20;
else
\$1 = 30;
endif;
endif;
endf
endp``````

FOR, WHILE

#192  by Murat
Mon May 28, 2018 9:02 am
for Var1 = Var2 to/downto Var3 do

/* Execute these statements */

endfor;

"FOR TO" command equals a variable to a value, increments known number of times and executes codes.
"FOR DOWNTO" command equals a variable to a value, decrements known number of times and executes codes.
"ENDFOR" command is used to terminate for loop.

In first example, global a variable's value increases up to 10.
Global b and global a variables are added till global a variable's value is 10.
At the end of loop, b variable's value is 1+2+3+4+5+6+7+8+9+10 = 55.
Code: Select all
``````Example 1:
global a, b;
func main()
for a = 1 to 10 do
b = b + a;
endfor;
endf
endp``````
In second example, global b variable's value is 100 and global a variable's value reduces to 1.
Global a value subtracted from global b till global a variable's value is 1.
At the end of loop, b variable's value is 100-1-2-3-4-5-6-7-8-9-10 = 45.
Code: Select all
``````Example 2:
global a, b;
func main()
b = 100;
for a = 10 downto 1 do
b = b - a;
endfor;
endf
endp``````

while

/* Execute these statements while TRUE */

endw;

"WHILE" command is used to repeat a specific block of code, until a condition is met.
"ENDW" command is used to terminate while loop.

Relational Operators:

"==" equal to 5 == 5 is true
"!=" not equal to 5 != 4 is true
"<" less than 5 < 6 is true
"<=" less than or equal 3 <= 4 is true
">" greater than 5 > 4 is true
">=" greater than or equal 5 >= 3 is true

In this example, global a variable's value is equal to 1 and loop executes codes while global a is not equal to 10.
These codes increment global b 10 and global a 1 in every loop.
At the end of while loop, b is 100.
Code: Select all
``````Example:
global a, b;
func main()
a = 1;
while a != 10
b = b + 10;
a = a + 1;
endw;
endf
endp``````

GLOBAL, LOCAL, FUNC MAIN, FUNC, CALL FUNC

#193  by Murat
Mon May 28, 2018 9:06 am
global Var1;

"GLOBAL" command creates an variable type that is declared outside any function and is accessible for all functions throughout the program.

In this example global a variable can be accessible func_1 function and also main function.
Code: Select all
``````Example:
global a;
func func_1()
a = 1;
endf
func main()
a = 2;
endf
endp``````

local Var1;

"LOCAL" command creates an variable type that is declared inside a function and is accessible just for that function.

In this example local a variable is accessible just for the main function.
Code: Select all
``````Example:
func main()
local a;
a = 2;
endf
endp``````

func main()

"FUNC MAIN" is the main function and script starts this first to execute all codes.

In this example main function's structure is shown.
Code: Select all
``````Example:
func main()

endf
endp``````

func func_name()

"FUNC" is used to define a new function.

In this example func_1 named function is defined and assigns address \$0's value to 1;
Code: Select all
``````Example:
func func_1()
\$0 = 1;
endf``````

call func_name();

"CALL" command calls and executes a function.

In this example func_1 named function equals address \$0's value to 1.
When this function is executed address \$0's value will be 1.
Code: Select all
``````Example:
func func_1()
\$0 = 1;
endf
func main()
call func_1();
endf
endp``````

=, WRITEONCE GETONCE, WRITESYNC, WRITEBUF WRITEBUFSYNC PUTBUF, LOADRECIPE

#194  by Murat
Mon May 28, 2018 9:09 am
Var1 = Var2;

"=" command equals one variable's value to other variable's value.

In this example address \$0's value is equal to address \$1's value 10.
Code: Select all
``````Example:
\$1 = 10;
\$0 = \$1;``````

writeonce(Var1, Var2) = Var3;

Var1 = getonce(Var1, Var2);

"WRITEONCE" command is used to shift address and write value.

In this example, address \$20's value is read with getonce command and written with writeonce command in the first loop.
In the next loops, addresses are shifted as much as i variable's value then read and written.

As result:
\$10 = \$20
\$11 = \$21
\$12 = \$22
Code: Select all
``````Example:
func main()
local i;
for i = 0 to 2 do
writeonce(\$10, i) = getonce(\$20, i);
endfor;
endf
endp``````

Var1 = writesync("Var1", Var2);

"WRITESYNC" command is used to write value synchronously. It can write string value as well.

In this example, two devices are defined being named "modbus1" and "modbus2".
Assume that modbus1 is connected and works, but modbus2 is disconnected.
varMod1's value will be 1.
varMod2's value will be -1.
It means that modbus1's write operation is successful but modbus2's is not.

Code: Select all
``````Example:
func main()
local varMod1;
local varMod2;
varMod1 = writesync("modbus1@40001", 1);
varMod2 = writesync("modbus2@40001", "Hello");
endf
endp``````

Var1 = mw_putbuf("Var2", Var3);

Var4 = mw_writebuf();
Var4 = mw_writebufsync();

"PUTBUF" command puts values to buffer and makes it ready.
"WRITEBUF" command sends buffer and if it is successful it returns 1 if not returns -1.
"WRITEBUFSYNC" command writes buffer and if it is successful it returns 1 if not returns -1.
These commands are used as multi-write function generally.

In this example, two devices are defined being named "modbus1" and "modbus2".
Buffer is made ready for modbus1 and sent with writebuf command. varMod1 variable's value is 1.
Buffer is made ready again for modbus2 and written with writebufsync command. If it is written successfully varMod1 variable's value will be 1 if not will be -1.

Code: Select all
``````Example:
func main()
local varBuf;
local varMod1;
local varMod2;

varBuf = mw_putbuf("modbus1@40001", \$1);
varBuf = mw_putbuf("modbus1@40002", \$2);

varMod1 = mw_writebuf();

varBuf = mw_putbuf("modbus2@40001", \$1);
varBuf = mw_putbuf("modbus2@40002", \$2);

varMod2 = mw_writebufsync();
endf
endp``````

"LOADRECIPE" command is used to call/run prepared recipes.

In this example, an own operation is defined. This operation has "Dough" named recipe and "bread" named recipe data.
Recipe has "Temperature" named entry. It's address and data type is set.
This recipe can be called/run by script easly as shown.

Code: Select all
``````Example:
func main()

endf
endp``````

SLEEP, GETSYSTICK, GETSYSTIME, GETSYSTOUCH, RESETCOMM

#195  by Murat
Mon May 28, 2018 9:15 am
sleep(Var1);

"SLEEP" command is used to suspend the execution of a program for certain time.

In this example sleep command suspends program for 1000 ms (1 second) and then \$0's value will be 1.
Code: Select all
``````Example:
func main()
sleep(1000);
\$0 = 1;
endf
endp``````

Var1 = getsystick();

"GETSYSTICK" command retrieves the number of milliseconds that have elapsed since the system was started.

In this example instant millisecond value is assigned to address \$0.
Code: Select all
``````Example:
func main()
\$0 = getsystick();
endf
endp``````

Var1 = getsystime();

"GETSYSTIME" command retrieves system timing information.

In this example system time is assigned to address \$0.
Code: Select all
``````Example:
func main()
\$0 = getsystime();
endf
endp``````

Var1 = getsystouch();

"GETSYSTOUCH" command is used to get elapsed time since last interaction with screen. This may be used for screen saver option.

In this example, A screen saver project is coded. Screen saver time is assigned as 5000 ms (5 sec).
When project is run main page and if 5 seconds elaps since last touch on screen, screen saver page is activated.
If screen is touched, project returns to main screen.
Code: Select all
``````Example:
global lastPage,
ss_indx, ss_time;

func screenSaver()
ss_indx = 0;			// screensaver page index is 0
ss_time = 5000;			// screensaver time
if getsystouch() > ss_time		// get elapsed time since last touch
if lastPage == 0		// lastPage initial value is 0
lastPage = \$S2;	// get current page index
\$S2 = ss_indx;	// set current page index to screensaver index
endif;
else
if lastPage != 0		// check if screensaver is active
\$S2 = lastPage;	// set the current screen to last active page
lastPage = 0;	// set variable to initial value
endif;
endif;
endf

func main()
call screenSaver();		//call screenSaver function
endf
endp``````

resetcomm("Var1", "Var2");

"RESETCOMM" command is used to reset communications.

In this example, "modbus" named device is defined which has slave id 1.

Code: Select all
``````Example:
func main()

resetcomm("modbus","1");

endf
endp``````

Recent Topics

Macro

by Murat

Tue Feb 05, 2019 12:38 pm

Non Volatile Maximum Limit

by Suleyman

Tue Jul 24, 2018 6:01 pm

Proop Builder Macro Wizard

by Murat

Mon May 28, 2018 9:15 am

by Murat

Wed Dec 20, 2017 3:32 pm

Proop Builder

by Murat

Tue Oct 17, 2017 10:36 am