: PS PCS7

: 2013-10-15

: nelegal34

: SCL



pcs7
PS (FB89) "Power Supply" PCS 7 Basic Library V71



...

FUNCTION_BLOCK "PS_SCL"
TITLE ='Power Supply Function Block'
{ S7_hardware := 'rack'; S7_alarm_ui := '1'; S7_tasklist := 'OB1,OB81,OB83,OB100'; S7_language := '7(1) () 18.02.2005 14:48:11'; S7_tag := 'false' }
AUTHOR:DRIVER71
FAMILY:'@SYSTEM'
NAME:'PS_SCL'
VERSION:'6.0'

VAR_INPUT
SLOT_NO { S7_visible := 'false'; S7_link := 'false' }: BYTE; //Slot Number
EN_MSG { S7_visible := 'false'; S7_link := 'false' }: BOOL := TRUE; //1=Enable Alarm
EV_ID { S7_visible := 'false'; S7_link := 'false'; S7_param := 'false'; S7_server := 'alarm_archiv'; S7_a_type := 'alarm_8p' }: DWORD; //Event ID
MS { S7_link := 'false'; S7_m_c := 'true' }: DWORD; //Maintenance State
END_VAR
VAR_OUTPUT
O_MS { S7_visible := 'false' }: DWORD; //Maintenance State
MSG_STAT { S7_visible := 'false' }: WORD; //Message Failure
END_VAR
VAR_IN_OUT
CPU_DIAG:STRUCT
H_MODE:BOOL; //1= H-System
V1_MODE:BOOL; //1= CPU DP V1 Mode
CPU_ERR0:BOOL; //1=CPU Error in Rack0
CPU_ERR1:BOOL; //1=CPU Error in Rack1
OB1_TIME:DINT; //OB1_TIME_TCK
OB_S:STRUCT
NUM_CNT:INT; //Counter Startinfo OB_NR
NUM_01:BYTE; //Startinfo OB_NO
NUM_02:BYTE; //Startinfo OB_NO
NUM_03:BYTE; //Startinfo OB_NO
NUM_04:BYTE; //Startinfo OB_NO
NUM_05:BYTE; //Startinfo OB_NO
NUM_06:BYTE; //Startinfo OB_NO
NUM_07:BYTE; //Startinfo OB_NO
NUM_08:BYTE; //Startinfo OB_NO
NUM_09:BYTE; //Startinfo OB_NO
NUM_10:BYTE; //Startinfo OB_NO
NUM_11:BYTE; //Startinfo OB_NO
NUM_12:BYTE; //Startinfo OB_NO
NUM_13:BYTE; //Startinfo OB_NO
NUM_14:BYTE; //Startinfo OB_NO
NUM_15:BYTE; //Startinfo OB_NO
NUM_16:BYTE; //Startinfo OB_NO
END_STRUCT;
OB_72:STRUCT
TOP_SI:STRUCT
EV_CLASS:BYTE; //Event class
EV_NUM:BYTE; //Event number
PRIORITY:BYTE; //Priority
NUM:BYTE; //OB-Number
TYP2_3:BYTE; //Reserved
TYP1:BYTE; //Reserved
ZI1:WORD; //Reserved
ZI2_3:DWORD; //Reserved
END_STRUCT;
END_STRUCT;
OB_70:STRUCT
TOP_SI:STRUCT
EV_CLASS:BYTE; //Event class
EV_NUM:BYTE; //Event number
PRIORITY:BYTE; //Priority
NUM:BYTE; //OB-Number
TYP2_3:BYTE; //Reserved
TYP1:BYTE; //Reserved
ZI1:WORD; //Reserved
ZI2_3:DWORD; //Reserved
END_STRUCT;
SUBNET:BYTE; //SUBNET ID
RACK:BYTE; //Rack Number
STATUS:DWORD; //Status SFB 54
END_STRUCT;
OB_82:STRUCT
TOP_SI:STRUCT
EV_CLASS:BYTE; //Event class
EV_NUM:BYTE; //Event number
PRIORITY:BYTE; //Priority
NUM:BYTE; //OB-Number
TYP2_3:BYTE; //Reserved
TYP1:BYTE; //Reserved
ZI1:WORD; //Reserved
ZI2_3:DWORD; //Reserved
END_STRUCT;
SUBNET:BYTE; //SUBNET ID
RACK:BYTE; //Rack Number
SL_TYP:BYTE; //Slave-/Profiltyp
A_INF:BYTE; //Alarm-Info-Type
ET_CR_FL:BYTE; //ET-CR-Flags
ET_ER_FL:BYTE; //ET-ER-Flags
PNO_ID:WORD; //PROFIBUS Ident Number
AINFO:STRUCT
D_LENGTH:BYTE; //Data Length
A_TYP:BYTE; //Alarm Type
SLOT:BYTE; //Slot Number
A_SPEC:BYTE; //Alarm-Specifire
A_0:BYTE; //Alarm Information
A_1:BYTE; //Alarm Information
A_2:BYTE; //Alarm Information
A_3:BYTE; //Alarm Information
A_4:BYTE; //Alarm Information
A_5:BYTE; //Alarm Information
A_6:BYTE; //Alarm Information
A_7:BYTE; //Alarm Information
A_8:BYTE; //Alarm Information
A_9:BYTE; //Alarm Information
A_10:BYTE; //Alarm Information
A_11:BYTE; //Alarm Information
A_12:BYTE; //Alarm Information
A_13:BYTE; //Alarm Information
A_14:BYTE; //Alarm Information
A_15:BYTE; //Alarm Information
A_16:BYTE; //Alarm Information
A_17:BYTE; //Alarm Information
A_18:BYTE; //Alarm Information
A_19:BYTE; //Alarm Information
A_20:BYTE; //Alarm Information
A_21:BYTE; //Alarm Information
A_22:BYTE; //Alarm Information
A_23:BYTE; //Alarm Information
A_24:BYTE; //Alarm Information
A_25:BYTE; //Alarm Information
A_26:BYTE; //Alarm Information
A_27:BYTE; //Alarm Information
A_28:BYTE; //Alarm Information
A_29:BYTE; //Alarm Information
A_30:BYTE; //Alarm Information
A_31:BYTE; //Alarm Information
A_32:BYTE; //Alarm Information
A_33:BYTE; //Alarm Information
A_34:BYTE; //Alarm Information
A_35:BYTE; //Alarm Information
A_36:BYTE; //Alarm Information
A_37:BYTE; //Alarm Information
A_38:BYTE; //Alarm Information
A_39:BYTE; //Alarm Information
A_40:BYTE; //Alarm Information
A_41:BYTE; //Alarm Information
A_42:BYTE; //Alarm Information
A_43:BYTE; //Alarm Information
A_44:BYTE; //Alarm Information
A_45:BYTE; //Alarm Information
A_46:BYTE; //Alarm Information
A_47:BYTE; //Alarm Information
A_48:BYTE; //Alarm Information
A_49:BYTE; //Alarm Information
A_50:BYTE; //Alarm Information
A_51:BYTE; //Alarm Information
A_52:BYTE; //Alarm Information
A_53:BYTE; //Alarm Information
A_54:BYTE; //Alarm Information
A_55:BYTE; //Alarm Information
A_56:BYTE; //Alarm Information
A_57:BYTE; //Alarm Information
A_58:BYTE; //Alarm Information
A_59:BYTE; //Alarm Information
END_STRUCT;
STATUS:DWORD; //Status SFB 54
END_STRUCT;
OB_83:STRUCT
TOP_SI:STRUCT
EV_CLASS:BYTE; //Event class
EV_NUM:BYTE; //Event number
PRIORITY:BYTE; //Priority
NUM:BYTE; //OB-Number
TYP2_3:BYTE; //Reserved
TYP1:BYTE; //Reserved
ZI1:WORD; //Reserved
ZI2_3:DWORD; //Reserved
END_STRUCT;
SUBNET:BYTE; //SUBNET ID
RACK:BYTE; //Rack Number
SLOT:BYTE; //Slot Number
STATUS:DWORD; //Status SFB 54
END_STRUCT;
OB_85:STRUCT
TOP_SI:STRUCT
EV_CLASS:BYTE; //Event class
EV_NUM:BYTE; //Event number
PRIORITY:BYTE; //Priority
NUM:BYTE; //OB-Number
TYP2_3:BYTE; //Reserved
TYP1:BYTE; //Reserved
ZI1:WORD; //Reserved
ZI2_3:DWORD; //Reserved
END_STRUCT;
SUBNET:BYTE; //SUBNET ID
RACK:BYTE; //Rack Number
SLOT:BYTE; //Slot Number
STATUS:DWORD; //Status SFB 54
END_STRUCT;
OB_86:STRUCT
TOP_SI:STRUCT
EV_CLASS:BYTE; //Event class
EV_NUM:BYTE; //Event number
PRIORITY:BYTE; //Priority
NUM:BYTE; //OB-Number
TYP2_3:BYTE; //Reserved
TYP1:BYTE; //Reserved
ZI1:WORD; //Reserved
ZI2_3:DWORD; //Reserved
END_STRUCT;
SUBNET:BYTE; //SUBNET ID
RACK:BYTE; //Rack Number
STATUS:DWORD; //Status SFB 54
END_STRUCT;
OB_81:STRUCT
TOP_SI:STRUCT
EV_CLASS:BYTE; //Event class
EV_NUM:BYTE; //Event number
PRIORITY:BYTE; //Priority
NUM:BYTE; //OB-Number
TYP2_3:BYTE; //Reserved
TYP1:BYTE; //Reserved
ZI1:WORD; //Reserved
ZI2_3:DWORD; //Reserved
END_STRUCT;
END_STRUCT;
END_STRUCT;
RAC_DIAG:STRUCT
SUBN1_ID:BYTE; //ID of Primary Subnet
SUBN2_ID:BYTE; //ID of Redundant Subnet
RACK_NO:BYTE; //Rack Number
SUBN_TYP:BOOL; //1=External DP-Interface
SUBN1ERR:BOOL; //1=Slave 1 Failure
SUBN2ERR:BOOL; //1=Slave 2 Failure
SUBN1ACT:BOOL; //1=Slave 1 Active
SUBN2ACT:BOOL; //1=Slave 2 Active
RACK_ERR:BOOL; //1=Rack Error
V1_MODE:BOOL; //1= DPV1 - Mode
END_STRUCT;
END_VAR
VAR
sdwRESERVE:DWORD; //Reserve fr zuknftige nderungen
sbRESTART:BOOL := TRUE; //Erstlaufmerker
INI_ALRM:BOOL; //ALARM_8P freigabe
ASIG0:BYTE;
_V_ASIG0 AT ASIG0: ARRAY[0..7] OF BOOL;
sbASIG0:BYTE;
bySUBN1_ID:BYTE; //Subnet ID fr Meldebegleitwert 1
byRACK_NO:BYTE; //Racknr fr Meldebegleitwert 2
bySLOT_NO:BYTE; //Slotnr fr Meldebegleitwert 3
DUMMY:DWORD;
ALARM_8P_1:"ALARM_8P"; //Multiinstanzierte _8P
END_VAR
VAR_TEMP
RETURN_CODE:INT; //SZL-Returnwert bzw. Fehlercode und Zhlervariable
OB_START:WORD;
_V_OB_START AT OB_START: ARRAY[0..15] OF BOOL;
EN_ALRM:BOOL; //Freigabe des ALARM_8P
OB1_ALRM:BOOL; //Freigabe Alarm8_p in OB1 (OB100)
SZL_HEADER:STRUCT
LENTHDR:WORD;
N_DR:WORD;
END_STRUCT;
GEO1:STRUCT
SUBNET:BYTE; //SUBNET belegt 1 WORD im Speicher!
RACK:WORD;
SLOT:WORD;
RESERVE:ARRAY [0 .. 3 ] OF WORD;
SLV_STAT:WORD;
END_STRUCT;
GEO:STRUCT
SUBNET:BYTE; //SUBNET belegt 1 WORD im Speicher!
RACK:BYTE;
SLOT:BYTE;
END_STRUCT;
ZI1:WORD;
ZI2_3:DWORD;
STAT_ZUST:ARRAY [0 .. 127 ] OF BOOL;
pbTemp:BYTE; //temp byte logische addresse ermitteln
pbBUSY:BOOL; //szlC91 lesen
piIndexAdr:WORD; //szlC91 lesen
pdwSTAT_ZUST:ARRAY [0 .. 3 ] OF //szlC91 lesen
DWORD; //szlC91 lesen
MS_AS:DWORD; //Maintenance State AS
TOP_SI:STRUCT
EV_CLASS:BYTE;
EV_NUM:BYTE;
PRIORITY:BYTE;
NUM:BYTE;
TYP2_3:BYTE;
TYP1:BYTE;
ZI1:WORD;
ZI2_3:DWORD;
END_STRUCT;
END_VAR
 
BEGIN
OB_START:=W#16#0000;
CASE CPU_DIAG.OB_S.NUM_CNT OF
1: TOP_SI.NUM:=CPU_DIAG.OB_S.NUM_01;
2: TOP_SI.NUM:=CPU_DIAG.OB_S.NUM_02;
3: TOP_SI.NUM:=CPU_DIAG.OB_S.NUM_03;
4: TOP_SI.NUM:=CPU_DIAG.OB_S.NUM_04;
5: TOP_SI.NUM:=CPU_DIAG.OB_S.NUM_05;
6: TOP_SI.NUM:=CPU_DIAG.OB_S.NUM_06;
7: TOP_SI.NUM:=CPU_DIAG.OB_S.NUM_07;
8: TOP_SI.NUM:=CPU_DIAG.OB_S.NUM_08;
9: TOP_SI.NUM:=CPU_DIAG.OB_S.NUM_09;
10: TOP_SI.NUM:=CPU_DIAG.OB_S.NUM_10;
11: TOP_SI.NUM:=CPU_DIAG.OB_S.NUM_11;
12: TOP_SI.NUM:=CPU_DIAG.OB_S.NUM_12;
13: TOP_SI.NUM:=CPU_DIAG.OB_S.NUM_13;
14: TOP_SI.NUM:=CPU_DIAG.OB_S.NUM_14;
15: TOP_SI.NUM:=CPU_DIAG.OB_S.NUM_15;
16: TOP_SI.NUM:=CPU_DIAG.OB_S.NUM_16;
ELSE;
END_CASE;
 
IF TOP_SI.NUM=B#16#01 THEN _V_OB_START[6]:=TRUE;
ELSIF TOP_SI.NUM=B#16#64 THEN _V_OB_START[7]:=TRUE;
ELSIF TOP_SI.NUM=B#16#51 THEN _V_OB_START[8]:=TRUE; TOP_SI.EV_NUM:=CPU_DIAG.OB_81.TOP_SI.EV_NUM; TOP_SI.EV_CLASS:=CPU_DIAG.OB_81.TOP_SI.EV_CLASS;
ELSIF TOP_SI.NUM=B#16#53 THEN _V_OB_START[3]:=TRUE;GEO.SUBNET:=CPU_DIAG.OB_83.SUBNET;
GEO.RACK:=CPU_DIAG.OB_83.RACK; GEO.SLOT:=CPU_DIAG.OB_83.SLOT; TOP_SI.EV_CLASS:=CPU_DIAG.OB_83.TOP_SI.EV_CLASS; TOP_SI.EV_NUM:=CPU_DIAG.OB_83.TOP_SI.EV_NUM;
ELSE ;
END_IF;
 
IF _V_OB_START[6] OR _V_OB_START[7] THEN
IF _V_OB_START[7] OR sbRESTART THEN
INI_ALRM:=EN_MSG; sbRESTART:=FALSE;
IF RAC_DIAG.SUBN1_ID=B#16#FF THEN bySUBN1_ID:=RAC_DIAG.SUBN2_ID; ELSE bySUBN1_ID:=RAC_DIAG.SUBN1_ID; END_IF;
byRACK_NO:=RAC_DIAG.RACK_NO;
bySLOT_NO:=SLOT_NO;
RETURN_CODE:=GADR_LGC(SUBNETID:=bySUBN1_ID, RACK:=byRACK_NO, SLOT:=bySLOT_NO, SUBSLOT:=B#16#0,SUBADDR:=B#16#0, IOID:=pbTemp, LADDR:=piIndexAdr);
IF RETURN_CODE=0 THEN
REPEAT
RETURN_CODE:=RDSYSST (REQ:=TRUE, SZL_ID:=W#16#C91, INDEX:=piIndexAdr, BUSY:=pbBUSY, SZL_HEADER:=SZL_HEADER, DR:=pdwSTAT_ZUST);
UNTIL NOT pbBUSY
END_REPEAT;
IF RETURN_CODE=0 THEN
IF (pdwSTAT_ZUST[3] & DW#16#20000)=DW#16#20000 THEN _V_ASIG0[3]:=FALSE;
ELSE _V_ASIG0[3]:=TRUE;
END_IF;
END_IF;
END_IF;
END_IF;
ELSE
IF _V_OB_START[8] THEN
CASE DWORD_TO_INT(TOP_SI.EV_NUM) OF
33: _V_ASIG0[0]:=TOP_SI.EV_CLASS=B#16#39;
34: _V_ASIG0[1]:=TOP_SI.EV_CLASS=B#16#39;
35: _V_ASIG0[2]:=TOP_SI.EV_CLASS=B#16#39;
37: _V_ASIG0[0]:=TOP_SI.EV_CLASS=B#16#39;
38: _V_ASIG0[1]:=TOP_SI.EV_CLASS=B#16#39;
39: _V_ASIG0[2]:=TOP_SI.EV_CLASS=B#16#39;
49: _V_ASIG0[0]:=TOP_SI.EV_CLASS=B#16#39;
50: _V_ASIG0[1]:=TOP_SI.EV_CLASS=B#16#39;
51: _V_ASIG0[2]:=TOP_SI.EV_CLASS=B#16#39;
END_CASE;
ELSE
IF _V_OB_START[3] THEN
IF (GEO.SUBNET=RAC_DIAG.SUBN1_ID OR GEO.SUBNET=RAC_DIAG.SUBN2_ID) & GEO.RACK=RAC_DIAG.RACK_NO & GEO.SLOT=SLOT_NO THEN
IF TOP_SI.EV_CLASS=B#16#39 THEN
IF TOP_SI.EV_NUM=B#16#61 THEN _V_ASIG0[3]:=TRUE;
ELSIF TOP_SI.EV_NUM=B#16#66 THEN _V_ASIG0[1]:=TRUE;
END_IF;
_V_ASIG0[4]:=FALSE;
ELSE IF TOP_SI.EV_NUM=B#16#63 OR TOP_SI.EV_NUM=B#16#64 OR TOP_SI.EV_NUM=B#16#65 THEN _V_ASIG0[4]:=TRUE; ELSE _V_ASIG0[4]:=FALSE; END_IF;
_V_ASIG0[3]:=FALSE; _V_ASIG0[1]:=FALSE;
END_IF;
END_IF;
END_IF;
END_IF;
END_IF;
 
INI_ALRM:=INI_ALRM OR ASIG0<>sbASIG0;
IF INI_ALRM & EN_MSG THEN
ALARM_8P_1(EN_R:=TRUE, ID:=W#16#EEEE, EV_ID:=EV_ID, SIG_1:=_V_ASIG0[0], SIG_2:=_V_ASIG0[1], SIG_3:=_V_ASIG0[2], SIG_4:=_V_ASIG0[3], SIG_5:=_V_ASIG0[4], SD_1:=bySUBN1_ID, SD_2:=byRACK_NO, SD_3:=bySLOT_NO);
sbASIG0:=ASIG0;
MSG_STAT:=ALARM_8P_1.STATUS;
IF (NOT ALARM_8P_1.DONE) & (NOT ALARM_8P_1.ERROR) & (ALARM_8P_1.STATUS<>W#16#000B) THEN INI_ALRM:=FALSE; END_IF;
END_IF;
MS_AS:=MS & DW#16#FF010000;
IF NOT RAC_DIAG.RACK_ERR & EN_MSG THEN
IF _V_ASIG0[3] OR _V_ASIG0[4] THEN MS_AS:=MS_AS OR DW#16#7;
ELSE IF ASIG0<>B#16#0 THEN MS_AS:=MS_AS OR DW#16#5; END_IF;
END_IF;
ELSE MS_AS:=MS_AS OR DW#16#8;
END_IF;
 
MS:=MS_AS; O_MS:=MS_AS;
END_FUNCTION_BLOCK




pcs7



(2, .pdf)



: mail









: 3626

: Draco Malfoy    : 2015-03-22

!

, - - ? - .

, "END_IF:=MS & DW#16#FF010000;"

, .

!

: komatic    : 2015-03-23

, , , .

:

(4000 max):

: