По просьбе наших посетителей, данный материал перенесен с сайта plc4good.org.ua, в связи с полной его потерей. Всё возражения принимаются через форму обратной связи.
plc4good.org.ua/view_post.php?id=303
Функции S7put S7get взяты из PCS 7 Industry Library for S7.
Представляют собой оболочки системных PUT GET SFB14,15 функций, дополненных диагностикой и (предположительно) более удобных в использовании.
Функция читает данные из удаленного контроллера через сконфигурированные соединения.
Name: FB1198
Symbolic Name: S7Get
Symbol Comment: GET Communication
Family: COMM
Version: 1.0
Author: S7LibIL
Last modified: 03/07/2012
Use: SFB14, SFC107, SFC19, SFC6
Size: 1292 bytes
Signature: compiled by SCL compiler version: SCLCOMP K05.03.07.00_01.02.00.01 release
FUNCTION_BLOCK
FB11198
TITLE =‘S7Get
Get Data from remote CPU’
{ S7_alarm_ui := ‘1’;
S7_m_c := ‘true’;
S7_tasklist := ‘OB100’ }
AUTHOR : S7LibIL
FAMILY : COMM
NAME : S7Get
VERSION : ‘1.0’
// reversed by komatic
VAR_INPUT
RESTART { S7_visible := ‘false’;
S7_dynamic := ‘true’; S7_link := ‘false’
}: BOOL ; //1=Manual Restart
START { S7_visible := ‘true’;
S7_dynamic := ‘true’; S7_link := ‘false’
}: BOOL ; //1=Start reading
KOM_ID { S7_dynamic := ‘true’;
S7_link := ‘false’ }: INT
; //ID for connection
DBNO_SRC { S7_dynamic := ‘true’;
S7_link := ‘false’ }: INT
; //No of source data block
ADDR_SRC { S7_dynamic := ‘true’;
S7_link := ‘false’ }: DWORD
; //Start address of source data
DBNO_DST { S7_dynamic := ‘true’;
S7_link := ‘false’ }: INT
; //No of destination data block
ADDR_DST { S7_dynamic := ‘true’;
S7_link := ‘false’ }: DWORD
; //Start address of destination data
LENGTH { S7_dynamic := ‘true’;
S7_link := ‘false’ }: INT
:= 400; //Length
of data in BYTE
L_MSGLCK : BOOL
; //Linkable input for message suppression 1=active
MONITOR { S7_link := ‘false’;
S7_string_0 := ‘Monitoring=Off’;
S7_string_1 := ‘Monitoring=On’
}: BOOL := TRUE;
//1=Monitoring active
TIME_MON { S7_visible := ‘false’;
S7_link := ‘false’;
S7_shortcut := ‘Monitoring time’;
S7_unit := ‘s’ }: REAL
:= 3.000000e+001;
//Monitoring time [s]
LIFE_BIT { S7_dynamic := ‘true’;
S7_visible := ‘true’;
S7_string_0 := ‘Neg’;
S7_string_1 := ‘Pos’ }: BOOL
; //1=Communication failure
EN_LIFE { S7_dynamic := ‘true’;
S7_visible := ‘true’; S7_link := ‘false’
}: BOOL ; //1=Enable LIFE_BIT
SAMPLE_T { S7_visible := ‘false’;
S7_link := ‘false’;
S7_sampletime := ‘true’ }: REAL
:= 1.000000e-001;
//Sample time [s]
SUPPTIME { S7_link := ‘false’
}: REAL := 1.000000e+001;
//Suppression time [s]
MSG_EVID { S7_dynamic := ‘false’;
S7_visible := ‘false’; S7_link := ‘false’;
S7_param := ‘false’; S7_server := ‘alarm_archiv’;
S7_a_type := ‘alarm_s’ }: DWORD
; //Message ID
RUNUPCYC { S7_dynamic := ‘false’;
S7_visible := ‘false’; S7_link := ‘false’
}: INT := 3;
//Lag: Number of Run Up Cycles
CMP_ID : DWORD
:= DW#16#1; //area
code
END_VAR
VAR_OUTPUT
QNDR { S7_dynamic := ‘true’;
S7_string_0 := ‘0’;
S7_string_1 := ‘received’ }: BOOL
; //1=New data received
QERR { S7_dynamic := ‘true’;
S7_m_c := ‘true’;
S7_string_0 := ‘OK’;
S7_string_1 := ‘Error’ }: BOOL
; //1=Group error
QLIFE_BIT { S7_dynamic := ‘true’;
S7_string_0 := ‘OK’;
S7_string_1 := ‘Error’ }: BOOL
; //1=Communication failure
QSTATUS { S7_dynamic := ‘true’
}: DWORD ; //Status display
QMSG_ERR { S7_dynamic := ‘false’;
S7_string_0 := ‘OK’;
S7_string_1 := ‘Message failure’
}: BOOL ; //1=Message failure
QMSGLCK { S7_dynamic := ‘true’;
S7_m_c := ‘true’;
S7_string_0 := ‘Unlocked’;
S7_string_1 := ‘Locked’ }: BOOL
; //1=Message locked
QMSG_SUP { S7_dynamic := ‘false’;
S7_m_c := ‘true’;
S7_string_0 := ‘Unlocked’;
S7_string_1 := ‘Locked’ }: BOOL
; //1=Message suppression active
MSG_STAT { S7_dynamic := ‘false’;
S7_visible := ‘false’ }: WORD
; //Message: STATUS output
MSG_ACK { S7_dynamic := ‘false’;
S7_visible := ‘false’ }: BOOL
; //Message: ACK_STATE output
END_VAR
VAR
siRunUpCounter : INT
; //Hochlaufzдhler
GET_1 : SFB14; //Daten
aus einer remoten CPU lesen
sbMsgLock : BOOL
; //Meldungen sperren
srSampleTime : REAL
; //Abtastzeit
sbLifeBit : BOOL
; //Lebenszeichen
srLifeBitCnt : REAL
; //Lebenszeichen-Zдhler
sbLifeBitPos : BOOL
; //Lebenszeichen positive Flanke
sbLifeBitPosOld : BOOL ;
//Lebenszeichen positive Flanke alter Zustand
sbLifeBitNeg : BOOL ;
//Lebenszeichen positive Flanke
sbLifeBitNegOld : BOOL ;
//Lebenszeichen positive Flanke alter Zustand
sbStoerung : BOOL ;
//Kommunikationsstцrung
sbMonitorError : BOOL ;
//Laufzeit-Fehler
srMonitorErrorCnt : REAL ;
//Laufzeit-Fehler Zдhler
sbMonitorErrorStart : BOOL ;
//Laufzeit-Fehler Zдhler Start
ZEIT : REAL ; //Zeit in sec.
seit letzter Дnderung von I
MSG_EN : BOOL ; //Freigabe
Meldung
sb_Error_Old : BOOL ; //Fehler
alter Zustand
liRetVal : INT ; //Fehler vom
SFC Aufruf
sbState : BOOL ; //Status der
Meldung
Begleitwert : STRUCT
Wert1 : WORD ;
Wert2 : BYTE ;
Wert3 : BYTE ;
END_STRUCT ;
END_VAR
VAR_TEMP
OB_NO : INT
; //aufgerufende Organisationsbaustein
sbERR : INT
; //Fehler vom SFC 6 Aufruf
sbREQ : BOOL
; //aktiviert den Datenaustausch bei steigender Flanke (SFB 14)
sbStatus : INT
; //Verbindungsstatus
prMonitorTime : REAL
; //berechnete Laufzeit
prLifeBitTimer : REAL
; //berechnete Lebenszeichenzeit
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
;
START_UP_SI : STRUCT
EV_CLASS : BYTE
;
EV_NUM : BYTE
;
PRIORITY : BYTE
;
NUM : BYTE
;
TYP2_3 : BYTE
;
TYP1 : BYTE
;
ZI1 : WORD
;
ZI2_3 : DWORD
;
END_STRUCT
;
SRC_ANY : ANY
; //Anyzeiger der Quelle
SRC_ANY_st AT
SRC_ANY : STRUCT
b0 : BYTE;
b1 : BYTE;
w2 : INT;
w3 : INT;
d4 : DWORD;
END_STRUCT;
DST_ANY : ANY
; //Anyzeiger des Ziels
DST_ANY_st AT
DST_ANY : STRUCT
b0 : BYTE;
b1 : BYTE;
w2 : INT;
w3 : INT;
d4 : DWORD;
END_STRUCT;
END_VAR
BEGIN
sbERR:=RD_SINFO(TOP_SI
:=TOP_SI,START_UP_SI :=START_UP_SI
);
OB_NO:=BYTE_TO_INT(TOP_SI.NUM);
IF (OB_NO=100)
OR RESTART THEN
siRunUpCounter:=RUNUPCYC;
END_IF;
IF
siRunUpCounter>0 THEN
siRunUpCounter:=siRunUpCounter–1;
QERR:=FALSE;
QLIFE_BIT:=FALSE;
QNDR:=TRUE;
sbREQ:=FALSE;
sbStoerung:=FALSE;
QMSG_ERR:=FALSE;
sbMonitorError:=FALSE;
sbMonitorErrorStart:=FALSE;
srMonitorErrorCnt:=0.0;
sbLifeBit:=FALSE;
srLifeBitCnt:=0.0;
sb_Error_Old:=FALSE;
ELSE
IF
(MSG_STAT=W#16#15) OR
L_MSGLCK THEN
sbMsgLock:=TRUE;
QMSG_SUP:=TRUE;
ELSE
sbMsgLock:=FALSE;
QMSG_SUP:=FALSE;
END_IF;
Оцените статью!