BaseSystemLib hinzugefügt

This commit is contained in:
2026-06-29 16:28:48 +02:00
parent a51a0c6fd1
commit 14a1c5172d
168 changed files with 6797 additions and 0 deletions
@@ -0,0 +1,6 @@
LibraryType:
Guid: 1bccc25d-f0e3-41bf-bf8f-556451b48635
LibraryVersion:
VersionNumber: 0.0.1
Author: e.yueksel
IsDefault: true
@@ -0,0 +1,9 @@
DocumentHash:
- FileName: FC_CheckSumTel_MCopy.scl
Hash: zcrADDK8lZALDCIxGb5qBh+pGgaCJUi9wXbHiZvlHdw=
LibraryMetaFileHash: TNziG1GxJT4svgIKOyJQgS92gdrlR+wYUjQB1GtjE54=
LibraryVersion:
Guid: 904645a8-99b5-49ae-958e-8bd0900b6f5c
DependsOn:
- TypeName: FC_LenTel_DigitSingle_MCopy
VersionNumber: 0.0.1
@@ -0,0 +1,77 @@
FUNCTION "FC_CheckSumTel_MCopy" : Void
{ S7_Optimized_Access := 'TRUE' }
VERSION : 0.1
VAR_INPUT
"Byte" : Array[1..10] of Byte;
END_VAR
VAR_OUTPUT
nOutCheckSum : UDInt;
xOutError : Bool;
END_VAR
VAR_TEMP
TempInt : Array[1..10] of UDInt;
TempError : Array[1..10] of Bool;
TempResult : UDInt;
TempErrorIndex : USInt;
TempIntIndex : USInt;
END_VAR
BEGIN
"FC_LenTel_DigitSingle_MCopy"(bIn := #Byte[1],
nOut => #TempInt[1],
xOutError => #TempError[1]);
"FC_LenTel_DigitSingle_MCopy"(bIn := #Byte[2],
nOut => #TempInt[2],
xOutError => #TempError[2]);
"FC_LenTel_DigitSingle_MCopy"(bIn := #Byte[3],
nOut => #TempInt[3],
xOutError => #TempError[3]);
"FC_LenTel_DigitSingle_MCopy"(bIn := #Byte[4],
nOut => #TempInt[4],
xOutError => #TempError[4]);
"FC_LenTel_DigitSingle_MCopy"(bIn := #Byte[5],
nOut => #TempInt[5],
xOutError => #TempError[5]);
"FC_LenTel_DigitSingle_MCopy"(bIn := #Byte[6],
nOut => #TempInt[6],
xOutError => #TempError[6]);
"FC_LenTel_DigitSingle_MCopy"(bIn := #Byte[7],
nOut => #TempInt[7],
xOutError => #TempError[7]);
"FC_LenTel_DigitSingle_MCopy"(bIn := #Byte[8],
nOut => #TempInt[8],
xOutError => #TempError[8]);
"FC_LenTel_DigitSingle_MCopy"(bIn := #Byte[9],
nOut => #TempInt[9],
xOutError => #TempError[9]);
"FC_LenTel_DigitSingle_MCopy"(bIn := #Byte[10],
nOut => #TempInt[10],
xOutError => #TempError[10]);
FOR #TempErrorIndex := 1 TO 10 DO
IF #TempError[#TempErrorIndex] THEN
#nOutCheckSum := 0;
#xOutError := true;
FOR #TempIntIndex := 1 TO 10 DO
#TempInt[#TempIntIndex] := 0;
END_FOR;
EXIT;
END_IF;
#xOutError := false;
END_FOR;
#TempResult := (#TempInt[1] * 1000000000) + (#TempInt[2] * 100000000) + (#TempInt[3] * 10000000) + (#TempInt[4] * 1000000) + (#TempInt[5] * 100000) + (#TempInt[6] * 10000) + (#TempInt[7] * 1000) + (#TempInt[8] * 100) + (#TempInt[9] * 10) + (#TempInt[10] * 1);
IF #TempResult <= 4294967295 AND #TempResult > 0 THEN
#nOutCheckSum := #TempResult;
#xOutError := false;
ELSE
#nOutCheckSum := 0;
#xOutError := TRUE;
END_IF;
END_FUNCTION
@@ -0,0 +1,6 @@
LibraryType:
Guid: be300a29-366c-4af7-86d4-03b57ad189ac
LibraryVersion:
VersionNumber: 0.0.1
Author: e.yueksel
IsDefault: true
@@ -0,0 +1,6 @@
DocumentHash:
- FileName: FC_LenTel_DigitSingle_MCopy.scl
Hash: vMlfZS59FkD9vRhU7J4yRkq5IFleg7ON3Y9Ou2gbBCY=
LibraryMetaFileHash: LM23JFYgY7nJI+beJASWy2jiG1lV0xBvHBKcbXzbl5Q=
LibraryVersion:
Guid: 4649d6fe-3163-4b85-9cac-01dbba1c2535
@@ -0,0 +1,53 @@
FUNCTION "FC_LenTel_DigitSingle_MCopy" : Void
{ S7_Optimized_Access := 'TRUE' }
VERSION : 0.1
VAR_INPUT
bIn : Byte;
END_VAR
VAR_OUTPUT
nOut : UDInt;
xOutError : Bool;
END_VAR
BEGIN
CASE #bIn OF
16#30:
#nOut := 0;
#xOutError := FALSE;
16#31:
#nOut := 1;
#xOutError := FALSE;
16#32:
#nOut := 2;
#xOutError := FALSE;
16#33:
#nOut := 3;
#xOutError := FALSE;
16#34:
#nOut := 4;
#xOutError := FALSE;
16#35:
#nOut := 5;
#xOutError := FALSE;
16#36:
#nOut := 6;
#xOutError := FALSE;
16#37:
#nOut := 7;
#xOutError := FALSE;
16#38:
#nOut := 8;
#xOutError := FALSE;
16#39:
#nOut := 9;
#xOutError := FALSE;
ELSE
#xOutError := TRUE
;
END_CASE;
END_FUNCTION
@@ -0,0 +1,6 @@
LibraryType:
Guid: c2de9ced-3384-4ae5-b061-c56131670178
LibraryVersion:
VersionNumber: 0.0.1
Author: e.yueksel
IsDefault: true
@@ -0,0 +1,9 @@
DocumentHash:
- FileName: FC_LenTel_MCopy.scl
Hash: T4kd83QvV4KwH5zjQ+4AcNWXs+c3obLLTTuar2wzbFQ=
LibraryMetaFileHash: SSQYpgHCkqDK4frap08MmA/MXYZ+UPnlm5mGZAunOks=
LibraryVersion:
Guid: 72381b85-e571-49f5-9b1e-12b557d735ff
DependsOn:
- TypeName: FC_LenTel_DigitSingle_MCopy
VersionNumber: 0.0.1
@@ -0,0 +1,68 @@
FUNCTION "FC_LenTel_MCopy" : Void
{ S7_Optimized_Access := 'TRUE' }
VERSION : 0.1
VAR_INPUT
"Byte" : Array[1..7] of Byte;
END_VAR
VAR_OUTPUT
nOutLen : Int;
xOutError : Bool;
END_VAR
VAR_TEMP
TempInt : Array[1..7] of UDInt;
TempError : Array[1..7] of Bool;
TempResult : UDInt;
TempErrorIndex : USInt;
TempIntIndex : USInt;
END_VAR
BEGIN
"FC_LenTel_DigitSingle_MCopy"(bIn:= #Byte[1],
nOut=> #TempInt[1],
xOutError=> #TempError[1]);
"FC_LenTel_DigitSingle_MCopy"(bIn := #Byte[2],
nOut => #TempInt[2],
xOutError => #TempError[2]);
"FC_LenTel_DigitSingle_MCopy"(bIn := #Byte[3],
nOut => #TempInt[3],
xOutError => #TempError[3]);
"FC_LenTel_DigitSingle_MCopy"(bIn := #Byte[4],
nOut => #TempInt[4],
xOutError => #TempError[4]);
"FC_LenTel_DigitSingle_MCopy"(bIn := #Byte[5],
nOut => #TempInt[5],
xOutError => #TempError[5]);
"FC_LenTel_DigitSingle_MCopy"(bIn := #Byte[6],
nOut => #TempInt[6],
xOutError => #TempError[6]);
"FC_LenTel_DigitSingle_MCopy"(bIn := #Byte[7],
nOut => #TempInt[7],
xOutError => #TempError[7]);
FOR #TempErrorIndex := 1 TO 7 DO
IF #TempError[#TempErrorIndex] THEN
#nOutLen := 0;
#xOutError := true;
FOR #TempIntIndex := 1 TO 7 DO
#TempInt[#TempIntIndex] := 0;
END_FOR;
EXIT;
END_IF;
#xOutError := false;
END_FOR;
#TempResult := (#TempInt[1] * 1000000) + (#TempInt[2] * 100000) + (#TempInt[3] * 10000) + (#TempInt[4] * 1000) + (#TempInt[5] * 100) + (#TempInt[6] * 10) + (#TempInt[7] * 1);
IF #TempResult <= 65535 AND #TempResult > 0 THEN
#nOutLen := UDINT_TO_INT(#TempResult);
#xOutError := false;
ELSE
#nOutLen := 0;
#xOutError := TRUE;
END_IF;
END_FUNCTION
@@ -0,0 +1,6 @@
LibraryType:
Guid: 3d599b5b-0213-46f8-8892-325ed0394c19
LibraryVersion:
VersionNumber: 0.0.1
Author: e.yueksel
IsDefault: true
@@ -0,0 +1,6 @@
DocumentHash:
- FileName: LGF_CalcCRC32Advanced_MCopy.scl
Hash: 1qqS4TkbI0CoSZdszKz6k+3lkVQa0jWbmnNgukz1Iqg=
LibraryMetaFileHash: KkCWyXRn3OXenxTY0Y4Iwgskl07io9/EARfgdrNs/mE=
LibraryVersion:
Guid: 31658ecf-f5da-4a76-a463-cd1e98d4aa4e
@@ -0,0 +1,175 @@
FUNCTION "LGF_CalcCRC32Advanced_MCopy" : DWord
TITLE = LGF_CalcCRC32Advanced
{ S7_Optimized_Access := 'TRUE' }
AUTHOR : Siemens_Industry_Support
FAMILY : LGF
NAME : LGF_CRC32Advanced
//Die CRC-Berechnung wird für die Fehlererkennung bei der Datenübertragung verwendet. Das Ergebnis einer Berechnung liefert einen CRC-Wert über die gesendeten Daten. Der Empfänger erkennt eine fehlerhafte Übertragung aufgrund des ungleichen CRC-Werts. Die Funktion `LGF_CalcCRC32Advanced` verwendet als Generatorpolynom (Maske) 32 Bit sowie die Parameter `finalXorValue`, `reflectInput` und `reflectResult`.
VAR_INPUT
initValue { S7_PredefinedAssignment := '16#00'} : DWord; // Startwert, mit dem die Berechnung durchgeführt wird. Wenn keinen Startwert notwendig ist - 16#00 zuweisen.
mask { S7_PredefinedAssignment := '16#00'} : DWord; // Generatorpolynom, mit dem die Berechnung durchgeführt wird. (Maske / CRC Polynom)
finalXorValue { S7_PredefinedAssignment := '16#00'} : DWord; // Wert, mit dem am Ende eine weitere XOR-Operation durchgeführt wird
nInLowerLimit : Int;
nInUpperLimit : Int;
reflectInput { S7_PredefinedAssignment := 'FALSE'} : Bool; // TRUE: wird die Reihenfolge der Bits innerhalb des Eingangsbytes gespiegelt. Aus der Reihenfolge 0…7 wird 7…0.
reflectResult { S7_PredefinedAssignment := 'FALSE'} : Bool; // TRUE: wird die Reihenfolge der Bits innerhalb des Ergebnisses gespiegelt. Aus der Reihenfolge 0…7 wird 7…0.
END_VAR
VAR_IN_OUT
"array" : Array[*] of Byte; // Datenstrom, für den der CRC-Wert berechnet werden soll.
END_VAR
VAR_TEMP
tempInput : Byte; // Temp aktuelles eingangs Byte
tempCRC : DWord; // Temp CRC Prüfsumme
tempInvCRC : DWord; // Temp invertierte CRC Prüfsumme
tempLowerLimit : DInt; // Temp Untergrenze Eingangs Array
tempUpperLimit : DInt; // Temp Obergrenze Eingangs Array
tempIndexArray : DInt; // Temp Array schleifen Index
tempIndexCRC : DInt; // Temp CRC Schleifen Index
END_VAR
VAR CONSTANT
SHIFT_ONE_BIT : UInt := 1; // Schieben der CRC Berechnung um ein Bit
SHIFT_THREE_BYTE : UInt := 24; // Schieben um drei Byte (= 24 Bit)
ARRAY_FIRST_DIMENSION : UInt := 1; // Erste Dimension im Array
CRC_LOOP_LOWER_LIMIT : DInt := 0; // Untere Grenze für die CRC Berechnungsschleife
CRC_LOOP_UPPER_LIMIT : DInt := 7; // Obere Grenze für die CRC Berechnungsschleife
END_VAR
BEGIN
REGION Block info header
//===============================================================================
// SIEMENS AG / (c)Copyright 2019
//-------------------------------------------------------------------------------
// Title: LGF_CRC32Advanced
// Comment/Function: This function makes a CRC calculation according
// to the CRC-32 algorithm
// advanced because of reflect In/Out and final XOR combination
// Library/Family: LGF (Library General Functions)
// Author: Siemens Digital Industry Support
// Tested with: CPU 1515F-2 PN FW:V2.6
// Engineering: TIA Portal V15.1 Update 2
// Restrictions: ENO disabled - no error handling, no failure possible
// Requirements: PLC (S7-1200 / S7-1500)
//-------------------------------------------------------------------------------
// Change log table:
// Version | Date | Expert in charge | Changes applied
//----------|------------|------------------------|------------------------------
// 01.00.00 03.07.2018 Siemens Industry Online Support
// First released version
// 01.00.01 17.08.2018 Siemens Industry Online Support
// Upgrade: TIA V15 Update 2
// 01.00.02 23.11.2018 Siemens Industry Online Support
// Upgrade: TIA V15.1
// 01.00.03 09.10.2019 Simatic Systems Support
// Code refactoring, comments added
// 03.00.00 23.04.2020 Simatic Systems Support
// Set version to V3.0.0, harmonize the version of the whole library
// 03.00.01 12.11.2020 Simatic Systems Support
// Insert documentation
// Assign default start values to optional inputs - `initValue`, `mask`, `finalXorValue`, `reflectInput`, `reflectResult`
//=============================================================================
END_REGION Block info header
REGION DESCRIPTION
(/*
Die Funktion berechnet aus einem beliebig großen Datenstrom den CRC-Wert. Der Datenstrom setzt sich aus den einzelnen Elementen des Arrays am Ein- / Ausgangsparameter `array` zusammen. Der Startwert `initValue` und das Generatorpolynom `mask` sind frei wählbar.
Über die booleschen Eingangsparameter `reflectInput` und `reflectResult` können Sie optional die Bits der Eingangsdaten bzw. des CRC-Werts spiegeln. Außerdem wird mit dem CRC-Wert am Ende und dem Wert `finalXorValue` eine XOR-Operation durchgeführt.
Hinweis
: Für die Berechnung der CRC-Werte stehen verschiedene Online-Tools zur Verfügung. Die Funktion des Bausteins wurde mit folgendem Online-Tool getestet, da es die Eingangsparameter `mask` (Polynom) und `initValue` (Initial Value) unterstützt:
: http://www.sunshine2k.de/coding/javascript/crc/crc_js.html
*/)
END_REGION DESCRIPTION
REGION Initialization and input data processing
// Input array size calculation
#tempLowerLimit := #nInLowerLimit;//LOWER_BOUND(ARR := #array, DIM := #ARRAY_FIRST_DIMENSION);
#tempUpperLimit := #nInUpperLimit;//UPPER_BOUND(ARR := #array, DIM := #ARRAY_FIRST_DIMENSION);
// Defining initial value for algorithm
#tempCRC := #initValue;
END_REGION
REGION CRC calculation
FOR #tempIndexArray := #tempLowerLimit TO #tempUpperLimit DO
IF #reflectInput THEN
// Reverse bit order in input byte
#tempInput.%X7 := #array[#tempIndexArray].%X0;
#tempInput.%X6 := #array[#tempIndexArray].%X1;
#tempInput.%X5 := #array[#tempIndexArray].%X2;
#tempInput.%X4 := #array[#tempIndexArray].%X3;
#tempInput.%X3 := #array[#tempIndexArray].%X4;
#tempInput.%X2 := #array[#tempIndexArray].%X5;
#tempInput.%X1 := #array[#tempIndexArray].%X6;
#tempInput.%X0 := #array[#tempIndexArray].%X7;
ELSE
#tempInput := #array[#tempIndexArray];
END_IF;
// Perform division using XOR function for appropriate DWord in array (with shift byte into MSB of 32bit CRC)
#tempCRC := #tempCRC XOR SHL(IN := BYTE_TO_DWORD(#tempInput), N := #SHIFT_THREE_BYTE);
FOR #tempIndexCRC := #CRC_LOOP_LOWER_LIMIT TO #CRC_LOOP_UPPER_LIMIT DO
// Check if MSB is set
IF #tempCRC.%X31 THEN
// Shift left and perform division by mask polynomial using XOR function
#tempCRC := SHL(IN := #tempCRC, N := #SHIFT_ONE_BIT) XOR #mask;
ELSE
// Shift left without division
#tempCRC := SHL(IN := #tempCRC, N := #SHIFT_ONE_BIT);
END_IF;
END_FOR;
END_FOR;
END_REGION
REGION Outputs assignment
IF #reflectResult THEN
// Reverse bit order in CRC checksum
#tempInvCRC.%X31 := #tempCRC.%X0;
#tempInvCRC.%X30 := #tempCRC.%X1;
#tempInvCRC.%X29 := #tempCRC.%X2;
#tempInvCRC.%X28 := #tempCRC.%X3;
#tempInvCRC.%X27 := #tempCRC.%X4;
#tempInvCRC.%X26 := #tempCRC.%X5;
#tempInvCRC.%X25 := #tempCRC.%X6;
#tempInvCRC.%X24 := #tempCRC.%X7;
#tempInvCRC.%X23 := #tempCRC.%X8;
#tempInvCRC.%X22 := #tempCRC.%X9;
#tempInvCRC.%X21 := #tempCRC.%X10;
#tempInvCRC.%X20 := #tempCRC.%X11;
#tempInvCRC.%X19 := #tempCRC.%X12;
#tempInvCRC.%X18 := #tempCRC.%X13;
#tempInvCRC.%X17 := #tempCRC.%X14;
#tempInvCRC.%X16 := #tempCRC.%X15;
#tempInvCRC.%X15 := #tempCRC.%X16;
#tempInvCRC.%X14 := #tempCRC.%X17;
#tempInvCRC.%X13 := #tempCRC.%X18;
#tempInvCRC.%X12 := #tempCRC.%X19;
#tempInvCRC.%X11 := #tempCRC.%X20;
#tempInvCRC.%X10 := #tempCRC.%X21;
#tempInvCRC.%X9 := #tempCRC.%X22;
#tempInvCRC.%X8 := #tempCRC.%X23;
#tempInvCRC.%X7 := #tempCRC.%X24;
#tempInvCRC.%X6 := #tempCRC.%X25;
#tempInvCRC.%X5 := #tempCRC.%X26;
#tempInvCRC.%X4 := #tempCRC.%X27;
#tempInvCRC.%X3 := #tempCRC.%X28;
#tempInvCRC.%X2 := #tempCRC.%X29;
#tempInvCRC.%X1 := #tempCRC.%X30;
#tempInvCRC.%X0 := #tempCRC.%X31;
#LGF_CalcCRC32Advanced_MCopy := #tempInvCRC XOR #finalXorValue;
ELSE
#LGF_CalcCRC32Advanced_MCopy := #tempCRC XOR #finalXorValue;
END_IF;
// no error handling needed
ENO := TRUE;
END_REGION
END_FUNCTION