(*************** QuickLD compiler **********************)
(*************** Copyright ICS Triplex ISaGRAF *********)
(*************** ST ************************************)

(*************** Rung **********************************)
(**)
(*Label :*)(**)
__EDTB2 := TRUE ;
IF __EDTB2 THEN
(* Operator output on : <> with __EDTB1 *)
__EDTB1 := (CONTROL_COMMANDS <> OLD_CONTROL_CMD) ;
ELSE
__EDTB1 := FALSE ;
END_IF ;
__MO_DIFF_1 := __EDTB1 ;
ENABLE_CONTROL_COMMANDS := __EDTB1 ;
__EDTB4 := TRUE ;
IF __EDTB4 THEN
(* Operator output on : <> with __EDTB3 *)
__EDTB3 := (TARGET_VALUE <> OLD_TARGET_VALUE) ;
ELSE
__EDTB3 := FALSE ;
END_IF ;
__MO_DIFF_2 := __EDTB3 ;
ENABLE_TARGET_VALUE := __EDTB3 ;
__EDTB6 := TRUE ;
IF __EDTB6 THEN
(* Operator output on : <> with __EDTB5 *)
__EDTB5 := (COARSE_VALUE <> OLD_COARSE_VALUE) ;
ELSE
__EDTB5 := FALSE ;
END_IF ;
__MO_DIFF_3 := __EDTB5 ;
ENABLE_COARSE_VALUE := __EDTB5 ;
__EDTB8 := TRUE ;
IF __EDTB8 THEN
(* Operator output on : <> with __EDTB7 *)
__EDTB7 := (FINE_VALUE <> OLD_FINE_VALUE) ;
ELSE
__EDTB7 := FALSE ;
END_IF ;
__MO_DIFF_4 := __EDTB7 ;
ENABLE_FINE_VALUE := __EDTB7 ;
__EDTB10 := TRUE ;
IF __EDTB10 THEN
(* Operator output on : <> with __EDTB9 *)
__EDTB9 := (CALIBRATION_COMMANDS <> OLD_CALIBRATION_COMMANDS) ;
ELSE
__EDTB9 := FALSE ;
END_IF ;
__MO_DIFF_5 := __EDTB9 ;
ENABLE_CALIBRATION_COMMANDS := __EDTB9 ;
__EDTB12 := TRUE ;
IF __EDTB12 THEN
(* Operator output on : <> with __EDTB11 *)
__EDTB11 := (SPAN_CALB_VALUE <> OLD_SPAN_CALB_VALUE) ;
ELSE
__EDTB11 := FALSE ;
END_IF ;
__MO_DIFF_6 := __EDTB11 ;
ENABLE_SPAN_CALB_VALUE := __EDTB11 ;
__EDTB14 := TRUE ;
IF __EDTB14 THEN
(* Operator output on : <> with __EDTB13 *)
__EDTB13 := (DIGITAL_OUTPUTS <> OLD_DIGITAL_OUTPUTS) ;
ELSE
__EDTB13 := FALSE ;
END_IF ;
__MO_DIFF_7 := __EDTB13 ;
ENABLE_DIGITAL_OUTPUTS := __EDTB13 ;

(*************** Code for the end of Rung **************)


(*************** Rung **********************************)
(**)
(*Label :*)(**)
__EDTB15 := ENABLE_CONTROL_COMMANDS ;
__EDTB16 := ENABLE_TARGET_VALUE ;
__EDTB17 := ENABLE_COARSE_VALUE ;
__EDTB18 := ENABLE_FINE_VALUE ;
__EDTB19 := ENABLE_CALIBRATION_COMMANDS ;
__EDTB20 := ENABLE_SPAN_CALB_VALUE ;
__EDTB21 := ENABLE_DIGITAL_OUTPUTS ;
__EDTB22 := (__EDTB20 OR __EDTB21) ;
__EDTB23 := (__EDTB19 OR __EDTB22) ;
__EDTB24 := (__EDTB18 OR __EDTB23) ;
__EDTB25 := (__EDTB17 OR __EDTB24) ;
__EDTB26 := (__EDTB16 OR __EDTB25) ;
__EDTB27 := (__EDTB15 OR __EDTB26) ;
IF __EDTB27 THEN
(*Set coil*)
ENABLE := TRUE ;
END_IF ;

(*************** Code for the end of Rung **************)


(*************** Rung **********************************)
(**)
(*Label :*)(**)
__EDTB28 := TRUE ;
IF __EDTB28 THEN
TARGETCFG.NODEADDRESS[0] := ANY_TO_USINT(TARGETIPADRESS[0]) ;
END_IF ;
__MO_ANY_TO_USINT_1 := __EDTB28 ;
__EDTB29 := __EDTB28 ;
__EDTB30 := TRUE ;
IF __EDTB30 THEN
TARGETCFG.NODEADDRESS[1] := ANY_TO_USINT(TARGETIPADRESS[1]) ;
END_IF ;
__MO_ANY_TO_USINT_2 := __EDTB30 ;
__EDTB31 := __EDTB30 ;
__EDTB32 := TRUE ;
IF __EDTB32 THEN
TARGETCFG.NODEADDRESS[2] := ANY_TO_USINT(TARGETIPADRESS[2]) ;
END_IF ;
__MO_ANY_TO_USINT_3 := __EDTB32 ;
__EDTB33 := __EDTB32 ;
__EDTB34 := TRUE ;
IF __EDTB34 THEN
TARGETCFG.NODEADDRESS[3] := ANY_TO_USINT(TARGETIPADRESS[3]) ;
END_IF ;
__MO_ANY_TO_USINT_4 := __EDTB34 ;
__EDTB35 := __EDTB34 ;
__EDTB36 := TRUE ;
IF __EDTB36 THEN
TARGETCFG.UNITID := ANY_TO_USINT(TARGETUNITID) ;
END_IF ;
__MO_ANY_TO_USINT_5 := __EDTB36 ;
__EDTB37 := __EDTB36 ;
__EDTB38 := (__EDTB35 OR __EDTB37) ;
__EDTB39 := (__EDTB33 OR __EDTB38) ;
__EDTB40 := (__EDTB31 OR __EDTB39) ;

(*************** Code for the end of Rung **************)


(*************** Rung **********************************)
(**)
(*Label :*)(**)
__EDTB41 := ENABLE_CONTROL_COMMANDS ;
IF __EDTB41 THEN
LOCALADDR[1] := ANY_TO_WORD(CONTROL_COMMANDS) ;
END_IF ;
__MO_ANY_TO_WORD_1 := __EDTB41 ;

(*************** Code for the end of Rung **************)


(*************** Rung **********************************)
(**)
(*Label :*)(**)
__EDTB42 := ENABLE_TARGET_VALUE ;
IF __EDTB42 THEN
DINT4 := AND_MASK(TARGET_VALUE, 65535) ;
END_IF ;
__MO_AND_MASK_1 := __EDTB42 ;
__EDTB43 := __EDTB42 ;
IF __EDTB43 THEN
LOCALADDR[4] := ANY_TO_WORD(DINT4) ;
END_IF ;
__MO_ANY_TO_WORD_2 := __EDTB43 ;
__EDTB44 := __EDTB43 ;
__EDTB45 := ENABLE_TARGET_VALUE ;
IF __EDTB45 THEN
DINT3 := SHR(TARGET_VALUE, 16) ;
END_IF ;
__MO_SHR_1 := __EDTB45 ;
__EDTB46 := __EDTB45 ;
IF __EDTB46 THEN
LOCALADDR[3] := ANY_TO_WORD(DINT3) ;
END_IF ;
__MO_ANY_TO_WORD_3 := __EDTB46 ;
__EDTB47 := __EDTB46 ;

(*************** Code for the end of Rung **************)


(*************** Rung **********************************)
(**)
(*Label :*)(**)
__EDTB48 := ENABLE_COARSE_VALUE ;
IF __EDTB48 THEN
DINT8 := AND_MASK(COARSE_VALUE, 65535) ;
END_IF ;
__MO_AND_MASK_2 := __EDTB48 ;
__EDTB49 := __EDTB48 ;
IF __EDTB49 THEN
LOCALADDR[8] := ANY_TO_WORD(DINT8) ;
END_IF ;
__MO_ANY_TO_WORD_4 := __EDTB49 ;
__EDTB50 := __EDTB49 ;
__EDTB51 := ENABLE_COARSE_VALUE ;
IF __EDTB51 THEN
DINT7 := SHR(COARSE_VALUE, 16) ;
END_IF ;
__MO_SHR_2 := __EDTB51 ;
__EDTB52 := __EDTB51 ;
IF __EDTB52 THEN
LOCALADDR[7] := ANY_TO_WORD(DINT7) ;
END_IF ;
__MO_ANY_TO_WORD_5 := __EDTB52 ;
__EDTB53 := __EDTB52 ;

(*************** Code for the end of Rung **************)


(*************** Rung **********************************)
(**)
(*Label :*)(**)
__EDTB54 := ENABLE_FINE_VALUE ;
IF __EDTB54 THEN
DINT10 := AND_MASK(FINE_VALUE, 65535) ;
END_IF ;
__MO_AND_MASK_3 := __EDTB54 ;
__EDTB55 := __EDTB54 ;
IF __EDTB55 THEN
LOCALADDR[10] := ANY_TO_WORD(DINT10) ;
END_IF ;
__MO_ANY_TO_WORD_6 := __EDTB55 ;
__EDTB56 := __EDTB55 ;
__EDTB57 := ENABLE_FINE_VALUE ;
IF __EDTB57 THEN
DINT9 := SHR(FINE_VALUE, 16) ;
END_IF ;
__MO_SHR_3 := __EDTB57 ;
__EDTB58 := __EDTB57 ;
IF __EDTB58 THEN
LOCALADDR[9] := ANY_TO_WORD(DINT9) ;
END_IF ;
__MO_ANY_TO_WORD_7 := __EDTB58 ;
__EDTB59 := __EDTB58 ;

(*************** Code for the end of Rung **************)


(*************** Rung **********************************)
(**)
(*Label :*)(**)
__EDTB60 := ENABLE_DIGITAL_OUTPUTS ;
IF __EDTB60 THEN
LOCALADDR[19] := ANY_TO_WORD(DIGITAL_OUTPUTS) ;
END_IF ;
__MO_ANY_TO_WORD_8 := __EDTB60 ;

(*************** Code for the end of Rung **************)


(*************** Rung **********************************)
(**)
(*Label :*)(**)
__EDTB61 := ENABLE_CALIBRATION_COMMANDS ;
IF __EDTB61 THEN
LOCALADDR[22] := ANY_TO_WORD(CALIBRATION_COMMANDS) ;
END_IF ;
__MO_ANY_TO_WORD_9 := __EDTB61 ;

(*************** Code for the end of Rung **************)


(*************** Rung **********************************)
(**)
(*Label :*)(**)
__EDTB62 := ENABLE_SPAN_CALB_VALUE ;
IF __EDTB62 THEN
DINT24 := AND_MASK(SPAN_CALB_VALUE, 65535) ;
END_IF ;
__MO_AND_MASK_4 := __EDTB62 ;
__EDTB63 := __EDTB62 ;
IF __EDTB63 THEN
LOCALADDR[24] := ANY_TO_WORD(DINT24) ;
END_IF ;
__MO_ANY_TO_WORD_10 := __EDTB63 ;
__EDTB64 := __EDTB63 ;
__EDTB65 := ENABLE_SPAN_CALB_VALUE ;
IF __EDTB65 THEN
DINT23 := SHR(SPAN_CALB_VALUE, 16) ;
END_IF ;
__MO_SHR_4 := __EDTB65 ;
__EDTB66 := __EDTB65 ;
IF __EDTB66 THEN
LOCALADDR[23] := ANY_TO_WORD(DINT23) ;
END_IF ;
__MO_ANY_TO_WORD_11 := __EDTB66 ;
__EDTB67 := __EDTB66 ;

(*************** Code for the end of Rung **************)


(*************** Rung **********************************)
(**)
(*Label :*)(**)
; (*Pulse detection on : RESETBIT with __MEMO__1__RESETBIT *)
__EDTB68 := (RESETBIT AND NOT(__MEMO__1__RESETBIT)) ;
__EDTB69 := __EDTB68 ;
IF __EDTB69 THEN
OLD_CONTROL_CMD := (  CONTROL_COMMANDS) ;
END_IF ;
__MO_1GAIN_1 := __EDTB69 ;
__EDTB70 := __EDTB69 ;
__EDTB71 := __EDTB68 ;
IF __EDTB71 THEN
OLD_TARGET_VALUE := (  TARGET_VALUE) ;
END_IF ;
__MO_1GAIN_2 := __EDTB71 ;
__EDTB72 := __EDTB71 ;
__EDTB73 := __EDTB68 ;
IF __EDTB73 THEN
OLD_COARSE_VALUE := (  COARSE_VALUE) ;
END_IF ;
__MO_1GAIN_3 := __EDTB73 ;
__EDTB74 := __EDTB73 ;
__EDTB75 := __EDTB68 ;
IF __EDTB75 THEN
OLD_FINE_VALUE := (  FINE_VALUE) ;
END_IF ;
__MO_1GAIN_4 := __EDTB75 ;
__EDTB76 := __EDTB75 ;
__EDTB77 := __EDTB68 ;
IF __EDTB77 THEN
OLD_DIGITAL_OUTPUTS := (  DIGITAL_OUTPUTS) ;
END_IF ;
__MO_1GAIN_5 := __EDTB77 ;
__EDTB78 := __EDTB77 ;
__EDTB79 := (__EDTB76 OR __EDTB78) ;
__EDTB80 := __EDTB68 ;
IF __EDTB80 THEN
OLD_CALIBRATION_COMMANDS := (  CALIBRATION_COMMANDS) ;
END_IF ;
__MO_1GAIN_6 := __EDTB80 ;
__EDTB81 := __EDTB80 ;
__EDTB82 := __EDTB68 ;
IF __EDTB82 THEN
OLD_SPAN_CALB_VALUE := (  SPAN_CALB_VALUE) ;
END_IF ;
__MO_1GAIN_7 := __EDTB82 ;
__EDTB83 := __EDTB82 ;
__EDTB84 := (__EDTB81 OR __EDTB83) ;
__EDTB85 := (__EDTB79 OR __EDTB84) ;
__EDTB86 := (__EDTB74 OR __EDTB85) ;
__EDTB87 := (__EDTB72 OR __EDTB86) ;

(*************** Code for the end of Rung **************)
__MEMO__1__RESETBIT := RESETBIT ; (*Pulse detection on : RESETBIT with __MEMO__1__RESETBIT *)


(*************** Rung **********************************)
(**)
(*Label :*)(**)
(* FB call: MSG_MODBUS2 *)
MSG_MODBUS2_1(ENABLE, false, LOCALCFG, TARGETCFG, LOCALADDR, 0) ;
MODBUSERROR := MSG_MODBUS2_1.Error ;
MODBUSERRORID := MSG_MODBUS2_1.ErrorID ;
__EDTB88 := MSG_MODBUS2_1.Q ;
(* FB call: TON *)
TON_1(ENABLE, t#500ms) ;
RESETBIT := TON_1.Q ;

(*************** Code for the end of Rung **************)


(*************** Rung **********************************)
(**)
(*Label :*)(**)
__EDTB89 := TRUE ;
IF __EDTB89 THEN
(*Reset coil*)
ENABLE := FALSE ;
END_IF ;

(*************** Code for the end of Rung **************)


(*************** Code for the end of File **************)
__GL __LG0000 ;



(*************** Local Symbols table *******************)
(* __EDTB1 *)
(* __EDTB2 *)
(* __EDTB3 *)
(* __EDTB4 *)
(* __EDTB5 *)
(* __EDTB6 *)
(* __EDTB7 *)
(* __EDTB8 *)
(* __EDTB9 *)
(* __EDTB10 *)
(* __EDTB11 *)
(* __EDTB12 *)
(* __EDTB13 *)
(* __EDTB14 *)
(* __EDTB15 *)
(* __EDTB16 *)
(* __EDTB17 *)
(* __EDTB18 *)
(* __EDTB19 *)
(* __EDTB20 *)
(* __EDTB21 *)
(* __EDTB22 *)
(* __EDTB23 *)
(* __EDTB24 *)
(* __EDTB25 *)
(* __EDTB26 *)
(* __EDTB27 *)
(* __EDTB28 *)
(* __EDTB29 *)
(* __EDTB30 *)
(* __EDTB31 *)
(* __EDTB32 *)
(* __EDTB33 *)
(* __EDTB34 *)
(* __EDTB35 *)
(* __EDTB36 *)
(* __EDTB37 *)
(* __EDTB38 *)
(* __EDTB39 *)
(* __EDTB40 *)
(* __EDTB41 *)
(* __EDTB42 *)
(* __EDTB43 *)
(* __EDTB44 *)
(* __EDTB45 *)
(* __EDTB46 *)
(* __EDTB47 *)
(* __EDTB48 *)
(* __EDTB49 *)
(* __EDTB50 *)
(* __EDTB51 *)
(* __EDTB52 *)
(* __EDTB53 *)
(* __EDTB54 *)
(* __EDTB55 *)
(* __EDTB56 *)
(* __EDTB57 *)
(* __EDTB58 *)
(* __EDTB59 *)
(* __EDTB60 *)
(* __EDTB61 *)
(* __EDTB62 *)
(* __EDTB63 *)
(* __EDTB64 *)
(* __EDTB65 *)
(* __EDTB66 *)
(* __EDTB67 *)
(* __MEMO__1__RESETBIT *)
(* __EDTB68 *)
(* __EDTB69 *)
(* __EDTB70 *)
(* __EDTB71 *)
(* __EDTB72 *)
(* __EDTB73 *)
(* __EDTB74 *)
(* __EDTB75 *)
(* __EDTB76 *)
(* __EDTB77 *)
(* __EDTB78 *)
(* __EDTB79 *)
(* __EDTB80 *)
(* __EDTB81 *)
(* __EDTB82 *)
(* __EDTB83 *)
(* __EDTB84 *)
(* __EDTB85 *)
(* __EDTB86 *)
(* __EDTB87 *)
(* __EDTB88 *)
(* __EDTB89 *)

