PROGRAM P2P
VAR_EXTERNAL

END_VAR

VAR_GLOBAL

END_VAR

VAR
int1   :bool;
toncycle            :ton;
cycle               :bool;
NetVarSend_Slave	: NetVarSend;
en_word1 at%m6000.0 : dint;
b_en01   at%m6000.1 : bool;
b_en02   at%m6000.2 : bool;
b_en03   at%m6000.3 : bool;
b_en04   at%m6000.4 : bool;
b_en05   at%m6000.5 : bool;
b_en06   at%m6000.6 : bool;
b_en07   at%m6000.7 : bool;
b_en08   at%m6001.0 : bool;
b_en09   at%m6001.1 : bool;
b_en10   at%m6001.2 : bool;
b_en11   at%m6001.3 : bool;
b_en12   at%m6001.4 : bool;
b_en13   at%m6001.5 : bool;
b_en14   at%m6001.6 : bool;
b_en15   at%m6001.7 : bool;
b_en16   at%m6002.0 : bool;
b_en17   at%m6002.1 : bool;
b_en18   at%m6002.2 : bool;
b_en19   at%m6002.3 : bool;
b_en20   at%m6002.4 : bool;
b_en21   at%m6002.5 : bool;
b_en22   at%m6002.6 : bool;
b_en23   at%m6002.7 : bool;
b_en24   at%m6003.0 : bool;
b_en25   at%m6003.1 : bool;
b_en26   at%m6003.2 : bool;
b_en27   at%m6003.3 : bool;
b_en28   at%m6003.4 : bool;
b_en29   at%m6003.5 : bool;
b_en30   at%m6003.6 : bool;

en_word2 at%m6004.0 : Sint;
b_en31   at%m6004.1 : bool;
b_en32   at%m6004.2 : bool;

temp :bool;
en_enable1 :bool;
en_enable2 :bool;

END_VAR
cycle:=not toncycle.q;
toncycle(IN:=cycle,PT:=t#150ms);

if en_enable1=0 and temp=0 then 
	en_enable1:=1; 
	en_word1:=1;
	en_word2:=1;
	temp:=1; 
end_if;



if en_word1=2#10000000000000000000000000000000 then 
	en_enable1:=0 ;
	en_enable2:=1 ;
	en_word1:=0;
	en_word2:=1;
end_if;
if en_word2=2#10000000 then 
	en_enable1:=1 ;
	en_enable2:=0 ;
	en_word1:=1;
	en_word2:=0;
end_if;

if toncycle.q=1 then 
	if en_enable1=1 then
		en_word1:=en_word1*2;
	end_if;
	if en_enable2=1 then
		en_word2:=en_word2*2;
	end_if;
end_if;	



   NetVarSend_Slave(EN := b_en01, IP1 := 192, IP2 := 168, IP3 := 50, IP4 := 22, ADDR_LOCAL := 5800, ADDR_REMOTE := 4000, NUM :=  4);
   NetVarSend_Slave(EN := b_en01, IP1 := 192, IP2 := 168, IP3 := 50, IP4 := 23, ADDR_LOCAL := 5800, ADDR_REMOTE := 4000, NUM :=  4);
   NetVarSend_Slave(EN := b_en01, IP1 := 192, IP2 := 168, IP3 := 50, IP4 := 25, ADDR_LOCAL := 5800, ADDR_REMOTE := 4000, NUM :=  4);
   
   NetVarSend_Slave(EN := b_en01, IP1 := 192, IP2 := 168, IP3 := 50, IP4 := 22, ADDR_LOCAL := 5600, ADDR_REMOTE := 4200, NUM :=  4);
   NetVarSend_Slave(EN := b_en01, IP1 := 192, IP2 := 168, IP3 := 50, IP4 := 23, ADDR_LOCAL := 5600, ADDR_REMOTE := 4200, NUM :=  4);
   NetVarSend_Slave(EN := b_en01, IP1 := 192, IP2 := 168, IP3 := 50, IP4 := 25, ADDR_LOCAL := 5600, ADDR_REMOTE := 4200, NUM :=  4);
RNIIES05H01_CO2S:=LIES05H01_CO2S    ;

RNLIES04A01_TS:=LIES04A01_TS	;
END_PROGRAM