• Proop Builder Macro Wizard

  • All technical documents for Proop...
All technical documents for Proop...
 #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
 #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.
Address $0's value is 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.
"GETONCE" command is used to shift address and read 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("Var1", "Var2");

"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()
		
		loadrecipe("Dough","bread");
		
	endf
	endp
 #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