onInit — actuation at module loading (during overwriting the logics or supplying the power).


void onInit() {


Actions specified in braces are performed during module reboot. It is applied for setting initial parameters, conditions, for correct system initialization, initializing it to operate or to operate together with eeEmulRead, eeEmulWrite functions.


<item addr="524:248" addr="524:248" LAMP1="512:8" LAMP2="512:9" name="Test for onInit() function" type="script">

void onInit() 
	setStatus(LAMP1, 1);
	setStatus(LAMP2, 1);
	u32 val = 0;
	eeEmulRead(1, &val);

	if(val > 200) 
		setStatus(2023:32, {1, "unit was restarted more than 200 times!"});
		u8 strForMess[70]; 
		sprintf(strForMess, "% unit was restarted %d times!", 4, val);
		setStatus(2023:32, &strForMess);
		eeEmulWrite(1, val);

		eeEmulWrite(1, 1); 
		setStatus(2023:32, {1, "Countdown has been started!"});


The result of performing the example in the interface:

When clicking the element script and further unit rebooting with the loss of power the elements LAMP1 and LAMP2 will be actuated as well as the messages containing the data on how many times unit was rebooted will be displayed in the interface.


When connecting several scripts containing this function to one unit all the connected functions are executed.