(****** QuickLD compiler *******************************)
(****** Copyright Rockwell Automation Canada, Ltd ******)
(****** ST *********************************************)

(*************** Rung **********************************)
(*Communication with ControlLogix in CLogix-3 chassis, slot 0 IP address is 131.151.52.135*)
__STEPPRAGMA
0,1
__ENDSTEPPRAGMA
(*Label :*)(**)
__EDTB1 := TRUE ;
__MO_NOP_1 := __EDTB1 ;

(*************** Code for the end of Rung **************)
__GL __LG0001 ;


(*************** Rung **********************************)
(*Timer to change data in array and real tag*)
__STEPPRAGMA
0,3
__ENDSTEPPRAGMA
(*Label :*)(**)
(* FB call: TON *)
Inc_Tmr(NOT(INC_TMR.Q), T#2S) ;

(*************** Code for the end of Rung **************)
__GL __LG0002 ;


(*************** Rung **********************************)
(*Increment Array2[0], set the last element to Array2[0]+49 and set Real2 to Array2[0]+100. All of these are read by ControlLogix processor*)
__STEPPRAGMA
0,6
__ENDSTEPPRAGMA
(*Label :*)(**)
__EDTB2 := INC_TMR.Q ;
IF __EDTB2 THEN
ARRAY2[0] := (ARRAY2[0] + 1) ;
END_IF ;
__MO_PLUS_1 := __EDTB2 ;
__EDTB3 := __EDTB2 ;
IF __EDTB3 THEN
ARRAY2[49] := (ARRAY2[0] + 49) ;
END_IF ;
__MO_PLUS_2 := __EDTB3 ;
__EDTB4 := __EDTB3 ;
IF __EDTB4 THEN
TEMP_DINT := (ARRAY2[0] + 100) ;
END_IF ;
__MO_PLUS_3 := __EDTB4 ;
__EDTB5 := __EDTB4 ;
IF __EDTB5 THEN
REAL2 := ANY_TO_REAL(TEMP_DINT) ;
END_IF ;
__MO_ANY_TO_REAL_1 := __EDTB5 ;

(*************** Code for the end of Rung **************)
__GL __LG0003 ;


(*************** Rung **********************************)
(*Msg tic for messages*)
__STEPPRAGMA
0,10
__ENDSTEPPRAGMA
(*Label :*)(**)
(* FB call: TON *)
Msg_Tic(NOT(MSG_TIC.Q), T#1S) ;

(*************** Code for the end of Rung **************)
__GL __LG0004 ;


(*************** Rung **********************************)
(*Read of Array1 (DINT[0..49]) from ControlLogix in CLogix-3 chassis, slot 0*)
__STEPPRAGMA
0,13
__ENDSTEPPRAGMA
(*Label :*)(**)
(* FB call: MSG_CIPSYMBOLIC *)
MSG_ClxRd(MSG_ENABLE, CLXRD_CTRLCFG, CLXRD_SYMCFG, CLXRD_TARGETCFG, CLXRD_DATA, 0) ;
CLXRD_STATUS := MSG_ClxRd.Status ;

(*************** Code for the end of Rung **************)
__GL __LG0005 ;


(*************** Rung **********************************)
(*Copy read data bytes into Array1 variable*)
__STEPPRAGMA
0,20
__ENDSTEPPRAGMA
(*Label :*)(**)
(* FB call: COP *)
COP_DintArray(MSG_CLXRD.Q, CLXRD_DATA, 0, ARRAY1, 0, 50, TRUE, , , , ) ;
__MO_COP_1 := MSG_CLXRD.Q ;

(*************** Code for the end of Rung **************)
__GL __LG0006 ;


(*************** Rung **********************************)
(**)
__STEPPRAGMA
0,32
__ENDSTEPPRAGMA
(*Label :*)(**)
ARRAY2[1].0 := ARRAY1[1].0 ;

(*************** Code for the end of Rung **************)
__GL __LG0007 ;


(*************** Rung **********************************)
(*Read of Real1 (REAL) from ControlLogix in CLogix-3 chassis, slot 0*)
__STEPPRAGMA
0,34
__ENDSTEPPRAGMA
(*Label :*)(**)
(* FB call: MSG_CIPSYMBOLIC *)
MSG_ClxRdReal(MSG_TIC.Q, CLXRD_CTRLCFG, CLXRDREAL_SYMCFG, CLXRD_TARGETCFG, CLXRDREAL_DATA, 0) ;
CLXRDREAL_STATUS := MSG_ClxRdReal.Status ;
CLXRDREAL_Q := MSG_ClxRdReal.Q ;

(*************** Code for the end of Rung **************)
__GL __LG0008 ;


(*************** Rung **********************************)
(*Copy read data bytes into Real1 variable*)
__STEPPRAGMA
0,41
__ENDSTEPPRAGMA
(*Label :*)(**)
(* FB call: COP *)
COP_RealRd(CLXRDREAL_Q, CLXRDREAL_DATA, 0, REAL1, 0, 1, TRUE, 0, 0, 0, 0) ;
__MO_COP_2 := CLXRDREAL_Q ;

(*************** Code for the end of Rung **************)
__GL __LG0009 ;


(*************** Rung **********************************)
(*Make up FT101*)
__STEPPRAGMA
0,53
__ENDSTEPPRAGMA
(*Label :*)(**)
__EDTB6 := INC_TMR.Q ;
IF __EDTB6 THEN
TEMP_DINT := (ARRAY2[0] + 300) ;
END_IF ;
__MO_PLUS_4 := __EDTB6 ;
__EDTB7 := __EDTB6 ;
IF __EDTB7 THEN
FT101 := ANY_TO_REAL(TEMP_DINT) ;
END_IF ;
__MO_ANY_TO_REAL_2 := __EDTB7 ;

(*************** Code for the end of Rung **************)
__GL __LG000A ;


(*************** Rung **********************************)
(*Copy FT101 bytes into data array written to ControlLogix*)
__STEPPRAGMA
0,57
__ENDSTEPPRAGMA
(*Label :*)(**)
(* FB call: COP *)
COP_RealWr(MSG_ENABLE, FT101, 0, CLXWRREAL_DATA, 0, 4, TRUE, 0, 0, 0, 0) ;
__MO_COP_3 := MSG_ENABLE ;

(*************** Code for the end of Rung **************)
__GL __LG000B ;


(*************** Rung **********************************)
(*Write of FT101 (REAL) to ControlLogix in CLogix-3 chassis, slot 0*)
__STEPPRAGMA
0,69
__ENDSTEPPRAGMA
(*Label :*)(**)
__EDTB9 := TRUE ;
IF __EDTB9 THEN
(* Operator output on : = with __EDTB8 *)
__EDTB8 := (COP_REALWR.STS = 1) ;
ELSE
__EDTB8 := FALSE ;
END_IF ;
__MO_EQUAL_1 := __EDTB8 ;
(* FB call: MSG_CIPSYMBOLIC *)
MSG_ClxWrReal(__EDTB8, CLXRD_CTRLCFG, CLXWRREAL_SYMCFG, CLXRD_TARGETCFG, CLXWRREAL_DATA, 0) ;
CLXWRREAL_STATUS := MSG_ClxWrReal.Status ;

(*************** Code for the end of Rung **************)
__GL __LG000C ;


(*************** Rung **********************************)
(**)
__STEPPRAGMA
0,76
__ENDSTEPPRAGMA
(*Label :*)(**)

(*************** Code for the end of Rung **************)
__GL __LG000D ;


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



(*************** Local Symbols table *******************)
(* __EDTB1 *)
(* __EDTB2 *)
(* __EDTB3 *)
(* __EDTB4 *)
(* __EDTB5 *)
(* __EDTB6 *)
(* __EDTB7 *)
(* __EDTB8 *)
(* __EDTB9 *)

