Einleitung
Das Beispiel gilt für S7-1500 und S7-1200.
Um den Programmcode in Ihr Projekt zu übernehmen, gehen Sie folgendermaßen vor:
1.Kopieren Sie den gesamten Programmcode in die Zwischenablage.
2.Öffnen Sie einen Texteditor (z. B. "Editor").
3.Fügen Sie den Inhalt der Zwischenablage in den Texteditor ein mit Strg+V.Speichern
Sie das Dokument als scl‑Datei ab, z. B. SNMP_DEACT.scl.
4.Öffnen Sie Ihr Projekt in STEP 7.
5.Importieren Sie scl‑Datei als externe Quelle.
6.Erzeugen Sie den Anlauf-OB und die Datenbausteine.
7.Rechtsklicken Sie auf die scl-Datei und wählen Sie im Kontextmenü "Baustein aus
Quelle generieren".
Programmbeispiel mit WRREC-Aufruf im OB 100 DATA_BLOCK "Deactivate_SNMP"
{ S7_Optimized_Access := 'TRUE' }
VERSION : 0.1
NON_RETAIN
VAR
snmp_deactivate : Bool;
snmp_record : Struct
BlockID : UInt;
BlockLength : UInt;
"Version" : USInt;
Subversion : USInt;
Reserved : UInt;
SNMPControl : UDInt;
END_STRUCT;
snmp_done : Bool;
snmp_error : Bool;
snmp_Status : DWord;
END_VAR
BEGIN
snmp_deactivate := true;
snmp_record.BlockID := 16#f003;
snmp_record.BlockLength := 8;
snmp_record."Version" := 1;
END_DATA_BLOCK
ORGANIZATION_BLOCK "Startup"
TITLE = "Complete Restart"
{ S7_Optimized_Access := 'TRUE' }
VERSION : 0.1
BEGIN
REPEAT
"WRREC_DB_1"(REQ := "Deactivate_SNMP".snmp_deactivate,
ID := "Local~PROFINET-Schnittstelle_1",
INDEX := 16#b071,
DONE => "Deactivate_SNMP".snmp_done,
ERROR => "Deactivate_SNMP".snmp_error,
STATUS => "Deactivate_SNMP".snmp_Status,
RECORD := "Deactivate_SNMP".snmp_record);
UNTIL "Deactivate_SNMP".snmp_done OR "Deactivate_SNMP".snmp_error END_REPEAT;
END_ORGANIZATION_BLOCK
DATA_BLOCK "WRREC_DB_1"
{OriginalPartName := 'WRREC';
VersionGUID := 'bc169451-58cd-44a3-855b-3f78cc0623c8';
S7_Optimized_Access := 'TRUE' }
AUTHOR : SIMATIC
FAMILY : DP
NAME : WRREC
VERSION : 1.0
NON_RETAIN
WRREC
BEGIN
END_DATA_BLOCK