├── LICENSE ├── README.md ├── plc ├── README.md ├── s7-1200 │ ├── DB_Binary.db │ ├── DB_BitStrings.db │ ├── DB_CharacterStrings.db │ ├── DB_DateAndTime.db │ ├── DB_FloatingPoint.db │ ├── DB_HardwareDataTypes.db │ ├── DB_Integers.db │ ├── DB_SystemDataTypes.db │ ├── DB_Timers.db │ ├── FB_Pointers.scl │ ├── FB_Pointers_DB.db │ ├── FC_TestCallPointers.scl │ └── Main.scl └── s7-1500 │ ├── DB_Binary.db │ ├── DB_BitStrings.db │ ├── DB_CharacterStrings.db │ ├── DB_DateAndTime.db │ ├── DB_FloatingPoint.db │ ├── DB_HardwareDataTypes.db │ ├── DB_Integers.db │ ├── DB_SystemDataTypes.db │ ├── DB_Timers.db │ ├── FB_ParameterTypes.scl │ ├── FB_ParameterTypes_DB.db │ ├── FB_Pointers.scl │ ├── FB_Pointers_DB.db │ ├── FC_TestCallParameterTypes.scl │ ├── FC_TestCallPointers.scl │ └── Main.scl └── src ├── .gitignore ├── DriverTest ├── App.config ├── DriverTest.csproj ├── Program.cs ├── Properties │ └── AssemblyInfo.cs └── TestPlcTag.cs ├── S7CommPlusDriver.sln ├── S7CommPlusDriver ├── Alarming │ ├── AlarmsAlarmTexts.cs │ ├── AlarmsAsCgs.cs │ ├── AlarmsAssociatedValues.cs │ ├── AlarmsDai.cs │ ├── AlarmsHandler.cs │ ├── AlarmsHmiInfo.cs │ ├── AlarmsMultipleStai.cs │ └── BrowseAlarms.cs ├── App.config ├── ClientApi │ ├── Browser.cs │ ├── ItemAddress.cs │ ├── PlcTag.cs │ ├── PlcTagQC.cs │ └── PlcTags.cs ├── Core │ ├── BlobDecompressor.cs │ ├── CommRessources.cs │ ├── CreateObjectRequest.cs │ ├── CreateObjectResponse.cs │ ├── Datatype.cs │ ├── DeleteObjectRequest.cs │ ├── DeleteObjectResponse.cs │ ├── ElementID.cs │ ├── ExploreRequest.cs │ ├── ExploreResponse.cs │ ├── Functioncode.cs │ ├── GetMultiVariablesRequest.cs │ ├── GetMultiVariablesResponse.cs │ ├── GetVarSubstreamedRequest.cs │ ├── GetVarSubstreamedResponse.cs │ ├── IS7pRequest.cs │ ├── IS7pResponse.cs │ ├── IS7pSerialize.cs │ ├── Ids.cs │ ├── InitSslRequest.cs │ ├── InitSslResponse.cs │ ├── Notification.cs │ ├── Opcode.cs │ ├── PObject.cs │ ├── POffsetInfoType.cs │ ├── PValue.cs │ ├── PVarnameList.cs │ ├── PVartypeList.cs │ ├── ProtocolVersion.cs │ ├── S7p.cs │ ├── SetMultiVariablesRequest.cs │ ├── SetMultiVariablesResponse.cs │ ├── SetVariableRequest.cs │ ├── SetVariableResponse.cs │ ├── Softdatatype.cs │ ├── SystemEvent.cs │ └── Utils.cs ├── Legitimation │ ├── AccessLevel.cs │ ├── Legitimation.cs │ ├── LegitimationCrypto.cs │ └── LegitimationType.cs ├── Net │ ├── MsgSocket.cs │ ├── S7Client.cs │ └── S7Consts.cs ├── OpenSSL-dll-x64 │ ├── libcrypto-3-x64.dll │ └── libssl-3-x64.dll ├── OpenSSL-dll-x86 │ ├── libcrypto-3.dll │ └── libssl-3.dll ├── OpenSSL │ ├── Native.cs │ └── OpenSSLConnector.cs ├── Properties │ └── AssemblyInfo.cs ├── S7CommPlusConnection.cs ├── S7CommPlusDriver.csproj └── Subscriptions │ └── Subscription.cs ├── S7CommPlusGUIBrowser ├── App.config ├── Form1.Designer.cs ├── Form1.cs ├── Form1.resx ├── Program.cs ├── Properties │ ├── AssemblyInfo.cs │ ├── Resources.Designer.cs │ ├── Resources.resx │ ├── Settings.Designer.cs │ └── Settings.settings ├── README.md └── S7CommPlusGUIBrowser.csproj └── Zlib.net ├── Adler32.cs ├── AssemblyInfo.cs ├── Deflate.cs ├── InfBlocks.cs ├── InfCodes.cs ├── InfTree.cs ├── Inflate.cs ├── LICENSE ├── README.md ├── StaticTree.cs ├── SupportClass.cs ├── Tree.cs ├── ZInputStream.cs ├── ZOutputStream.cs ├── ZStream.cs ├── ZStreamException.cs ├── Zlib.cs ├── Zlib.net.csproj └── history.txt /plc/README.md: -------------------------------------------------------------------------------- 1 | # S7commPlusDriver 2 | 3 | Kommunikationstreiber für den Datenaustausch mit S7-1200/1500 Steuerungen. 4 | 5 | ## Testprogramme mit allen Datentypen 6 | 7 | Im Unterordner s7-1500 liegen Quelldateien für das TIA-Portal, aus denen sich ein Testprogramm 8 | generieren lässt in dem alle möglichen Datentypen vorhanden sind. 9 | 10 | - .scl = SCL-Quelldateien (Text) 11 | - .db = Datenbaustein Quelldateien (Text) 12 | 13 | Die einfachen Datentypen sind in einzelnen Datenbausteinen gemäß ihrer Kategorie zusammengefasst. 14 | Bei Zahlenwerten ist dabei immer eine Variable mit dem kleinst- und größtmöglichen Wert (Min/Max) vorhanden. 15 | Zudem je nach Bedarf einige Testwerte. 16 | 17 | Um die Parametertypen und Zeiger zu generieren, ist für jeden dieser Typen ein FB mit zugehörigem Instanz-DB vorhanden. 18 | 19 | Zu beachten ist, dass die S7-1200 nicht alle in der S7-1500 möglichen Datentypen unterstützt. 20 | 21 | ## Lizenz 22 | 23 | Soweit nicht anders vermerkt, gilt für alle Quellcodes die GNU Lesser General Public License, 24 | Version 3 oder später. 25 | 26 | ## Authors 27 | 28 | * **Thomas Wiens** - *Initial work* - [thomas-v2](https://github.com/thomas-v2) 29 | -------------------------------------------------------------------------------- /plc/s7-1200/DB_Binary.db: -------------------------------------------------------------------------------- 1 | DATA_BLOCK "DB_Binary" 2 | { S7_Optimized_Access := 'TRUE' } 3 | VERSION : 0.1 4 | NON_RETAIN 5 | VAR 6 | Bool_False : Bool; // Bool: False 7 | Bool_True : Bool; // Bool: True 8 | END_VAR 9 | 10 | 11 | BEGIN 12 | Bool_True := TRUE; 13 | 14 | END_DATA_BLOCK 15 | 16 | -------------------------------------------------------------------------------- /plc/s7-1200/DB_BitStrings.db: -------------------------------------------------------------------------------- 1 | DATA_BLOCK "DB_BitStrings" 2 | { S7_Optimized_Access := 'TRUE' } 3 | VERSION : 0.1 4 | NON_RETAIN 5 | VAR 6 | Byte_Min_0x00 : Byte; // Byte: Min 7 | Byte_Max_0xFF : Byte; // Byte: Max 8 | Byte_0xAB : Byte; // Byte: Testvalue 1 9 | Word_Min_0x0000 : Word; // Word: Min 10 | Word_Max_0xFFFF : Word; // Word: Max 11 | Word_0xCAFE : Word; // Word: Testvalue 1 12 | DWord_Min_0x00000000 : DWord; // DWord: Min 13 | DWord_Max_0xFFFFFFFF : DWord; // DWord: Max 14 | DWord_0xCAFEBABE : DWord; // DWord: Testvalue 1 15 | END_VAR 16 | 17 | 18 | BEGIN 19 | Byte_Max_0xFF := 16#00FF; 20 | Byte_0xAB := 16#00AB; 21 | Word_Max_0xFFFF := 16#FFFF; 22 | Word_0xCAFE := 16#CAFE; 23 | DWord_Max_0xFFFFFFFF := 16#FFFF_FFFF; 24 | DWord_0xCAFEBABE := 16#CAFE_BABE; 25 | 26 | END_DATA_BLOCK 27 | 28 | -------------------------------------------------------------------------------- /plc/s7-1200/DB_CharacterStrings.db: -------------------------------------------------------------------------------- 1 | DATA_BLOCK "DB_CharacterStrings" 2 | { S7_Optimized_Access := 'TRUE' } 3 | VERSION : 0.1 4 | NON_RETAIN 5 | VAR 6 | Char_Space : Char; // Char: Space 7 | Char_A : Char; // Char: Capital A 8 | Char_auml : Char; // Char: Lowecase german a Umlaut 9 | String_Empty : String; // String: Empty 10 | String_Hello_World : String; // String: "Hello World" 11 | String_Moumltoumlrhead : String; // String: "Mötörhead" 12 | String_Len4_Test : String[4]; // String: Fix len[4] "Test" 13 | WChar_Space : WChar; // WChar: Space 14 | WChar_auml : WChar; // WChar: Lowecase german a Umlaut 15 | WChar_X : WChar; // WChar: Capital X 16 | WChar_GreekSigmaBig : WChar; // WChar: Greek capital Sigma 17 | WString_Empty : WString; // WString: Empty 18 | WString_Moumltoumlrhead : WString; // WString: "Mötörhead" 19 | WString_Greek1 : WString; // WString: String with greek chars 20 | WString_Len4_Test : WString[4]; // WString: Fix len[4] "Test" 21 | END_VAR 22 | 23 | 24 | BEGIN 25 | Char_A := 'A'; 26 | Char_auml := 'ä'; 27 | String_Hello_World := 'Hello World'; 28 | String_Moumltoumlrhead := 'Mötörhead'; 29 | String_Len4_Test := 'Test'; 30 | WChar_auml := WCHAR#'ä'; 31 | WChar_X := WCHAR#'X'; 32 | WChar_GreekSigmaBig := WCHAR#'Ʃ'; 33 | WString_Moumltoumlrhead := WSTRING#'Mötörhead'; 34 | WString_Greek1 := WSTRING#'Test Greek ΣΛΔ end.'; 35 | WString_Len4_Test := WSTRING#'Test'; 36 | 37 | END_DATA_BLOCK 38 | 39 | -------------------------------------------------------------------------------- /plc/s7-1200/DB_DateAndTime.db: -------------------------------------------------------------------------------- 1 | DATA_BLOCK "DB_DateAndTime" 2 | { S7_Optimized_Access := 'TRUE' } 3 | VERSION : 0.1 4 | NON_RETAIN 5 | VAR 6 | Date_Min_1990_01_01 : Date; // Date: Min 7 | Date_Max_2169_06_06 : Date; // Date: Max 8 | Date_2023_10_28 : Date; // Date: Testvalue 1 9 | Date_1991_02_03 : Date; // Date: Testvalue 2 10 | Time_Of_Day_Min_00_00_00d000 : Time_Of_Day; // Time_Of_Day: Min 11 | Time_Of_Day_Max_23_59_59d999 : Time_Of_Day; // Time_Of_Day: Min 12 | Time_Of_Day_01_02_03 : Time_Of_Day; // Time_Of_Day: Testvalue 1 13 | Time_Of_Day_23_58_59 : Time_Of_Day; // Time_Of_Day: Testvalue 2 14 | Time_Of_Day_12_13_14d123 : Time_Of_Day; // Time_Of_Day: Testvalue 3 15 | DTL_Min_1970_01_01_00_00_00d000000000 {InstructionName := 'DTL'; LibVersion := '1.0'} : DTL; // DTL: Min 16 | DTL_Max_2262_04_11_23_47_16d854775807 {InstructionName := 'DTL'; LibVersion := '1.0'} : DTL; // DTL: Max 17 | DTL_2008_10_25_08_12_34d567 {InstructionName := 'DTL'; LibVersion := '1.0'} : DTL; // DTL: Testvalue 1 18 | END_VAR 19 | 20 | 21 | BEGIN 22 | Date_Max_2169_06_06 := D#2169-06-06; 23 | Date_2023_10_28 := D#2023-10-28; 24 | Date_1991_02_03 := D#1990-02-03; 25 | Time_Of_Day_Max_23_59_59d999 := TOD#23:59:59.999; 26 | Time_Of_Day_01_02_03 := TOD#01:02:03; 27 | Time_Of_Day_23_58_59 := TOD#23:58:59; 28 | Time_Of_Day_12_13_14d123 := TOD#12:13:14.123; 29 | DTL_Max_2262_04_11_23_47_16d854775807.YEAR := 2262; 30 | DTL_Max_2262_04_11_23_47_16d854775807.MONTH := 4; 31 | DTL_Max_2262_04_11_23_47_16d854775807.DAY := 11; 32 | DTL_Max_2262_04_11_23_47_16d854775807.WEEKDAY := 6; 33 | DTL_Max_2262_04_11_23_47_16d854775807.HOUR := 23; 34 | DTL_Max_2262_04_11_23_47_16d854775807.MINUTE := 47; 35 | DTL_Max_2262_04_11_23_47_16d854775807.SECOND := 16; 36 | DTL_Max_2262_04_11_23_47_16d854775807.NANOSECOND := 854775807; 37 | DTL_Max_2262_04_11_23_47_16d854775807 := DTL#2262-04-11-23:47:16.854775807; 38 | DTL_2008_10_25_08_12_34d567.YEAR := 2008; 39 | DTL_2008_10_25_08_12_34d567.MONTH := 10; 40 | DTL_2008_10_25_08_12_34d567.DAY := 25; 41 | DTL_2008_10_25_08_12_34d567.WEEKDAY := 7; 42 | DTL_2008_10_25_08_12_34d567.HOUR := 8; 43 | DTL_2008_10_25_08_12_34d567.MINUTE := 12; 44 | DTL_2008_10_25_08_12_34d567.SECOND := 34; 45 | DTL_2008_10_25_08_12_34d567.NANOSECOND := 567000000; 46 | DTL_2008_10_25_08_12_34d567 := DTL#2008-10-25-08:12:34.567; 47 | 48 | END_DATA_BLOCK 49 | 50 | -------------------------------------------------------------------------------- /plc/s7-1200/DB_FloatingPoint.db: -------------------------------------------------------------------------------- 1 | DATA_BLOCK "DB_FloatingPoint" 2 | { S7_Optimized_Access := 'TRUE' } 3 | VERSION : 0.1 4 | NON_RETAIN 5 | VAR 6 | Real_MinNeg_n3d402823e38 : Real; // Real: Min negative value 7 | Real_MaxNeg_n1d175495en38 : Real; // Real: Max negative value 8 | Real_MinPos_1d175495en38 : Real; // Real: Min positive value 9 | Real_MaxPos_3d402823e38 : Real; // Real: Max positive value 10 | Real_0d0 : Real; // Real: Zero 11 | Real_987d125 : Real; // Real: Testvalue 1 12 | Real_n123d5 : Real; // Real: Testvalue 2 13 | LReal_MinNeg_n1d7976931348623157e308 : LReal; // LReal: Min negative value 14 | LReal_MaxNeg_n2d2250738585072014en308 : LReal; // LReal: Max negative value 15 | LReal_MinPos_2d2250738585072014en308 : LReal; // LReal: Min positive value 16 | LReal_MaxPos_1d7976931348623157e308 : LReal; // LReal: Max positive value 17 | LReal_0d0 : LReal; // LReal: Zero 18 | LReal_987d125 : LReal; // LReal: Testvalue 1 19 | LReal_n123d5 : LReal; // LReal: Testvalue 2 20 | LReal_1d23456789012346e18 : LReal; // LReal: Testvalue 3 21 | END_VAR 22 | 23 | 24 | BEGIN 25 | Real_MinNeg_n3d402823e38 := -3.402823E+38; 26 | Real_MaxNeg_n1d175495en38 := -1.175495E-38; 27 | Real_MinPos_1d175495en38 := 1.175495E-38; 28 | Real_MaxPos_3d402823e38 := 3.402823E+38; 29 | Real_987d125 := 987.125; 30 | Real_n123d5 := -123.5; 31 | LReal_MinNeg_n1d7976931348623157e308 := -1.7976931348623157E+308; 32 | LReal_MaxNeg_n2d2250738585072014en308 := -2.2250738585072014E-308; 33 | LReal_MinPos_2d2250738585072014en308 := 2.2250738585072014E-308; 34 | LReal_MaxPos_1d7976931348623157e308 := 1.7976931348623157E+308; 35 | LReal_987d125 := 987.125; 36 | LReal_n123d5 := -123.5; 37 | LReal_1d23456789012346e18 := 1.23456789012346E+18; 38 | 39 | END_DATA_BLOCK 40 | 41 | -------------------------------------------------------------------------------- /plc/s7-1200/DB_HardwareDataTypes.db: -------------------------------------------------------------------------------- 1 | DATA_BLOCK "DB_HardwareDataTypes" 2 | { S7_Optimized_Access := 'TRUE' } 3 | VERSION : 0.1 4 | NON_RETAIN 5 | VAR 6 | AOM_IDENT_0x1 : AOM_IDENT; // AOM_IDENT: Testvalue 1 7 | CONN_ANY_0x2 : CONN_ANY; // CONN_ANY: Testvalue 1 8 | CONN_OUC_0x3 : CONN_OUC; // CONN_OUC: Testvalue 1 9 | CONN_PRG_0x4 : CONN_PRG; // CONN_PRG: Testvalue 1 10 | DB_ANY_1001 : DB_ANY; // DB_ANY: Testvalue 1 11 | DB_DYN_1002 : DB_DYN; // DB_DYN: Testvalue 1 12 | DB_WWW_1003 : DB_WWW; // DB_WWW: Testvalue 1 13 | EVENT_ANY_0x6 : EVENT_ANY; // EVENT_ANY: Testvalue 1 14 | EVENT_ATT_0x7 : EVENT_ATT; // EVENT_ATT: Testvalue 1 15 | EVENT_HWINT_0x8 : EVENT_HWINT; // EVENT_HWINT: Testvalue 1 16 | HW_ANY_1004 : HW_ANY; // HW_ANY: Testvalue 1 17 | HW_DEVICE_1005 : HW_DEVICE; // HW_DEVICE: Testvalue 1 18 | HW_DPSLAVE_1007 : HW_DPSLAVE; // HW_DPSLAVE: Testvalue 1 19 | HW_HSC_1008 : HW_HSC; // HW_HSC: Testvalue 1 20 | HW_IEPORT_1009 : HW_IEPORT; // HW_IEPORT: Testvalue 1 21 | HW_INTERFACE_1010 : HW_INTERFACE; // HW_INTERFACE: Testvalue 1 22 | HW_IO_1011 : HW_IO; // HW_IO: Testvalue 1 23 | HW_IOSYSTEM_1012 : HW_IOSYSTEM; // HW_IOSYSTEM: Testvalue 1 24 | HW_PTO_1014 : HW_PTO; // HW_PTO: Testvalue 1 25 | HW_PWM_1015 : HW_PWM; // HW_PWM: Testvalue 1 26 | HW_SUBMODULE_1016 : HW_SUBMODULE; // HW_SUBMODULE: Testvalue 1 27 | OB_ANY_1017 : OB_ANY; // OB_ANY: Testvalue 1 28 | OB_ATT_1018 : OB_ATT; // OB_ATT: Testvalue 1 29 | OB_CYCLIC_1019 : OB_CYCLIC; // OB_CYCLIC: Testvalue 1 30 | OB_DELAY_1020 : OB_DELAY; // OB_DELAY: Testvalue 1 31 | OB_DIAG_1021 : OB_DIAG; // OB_DIAG: Testvalue 1 32 | OB_HWINT_1022 : OB_HWINT; // OB_HWINT: Testvalue 1 33 | OB_PCYCLE_1023 : OB_PCYCLE; // OB_PCYCLE: Testvalue 1 34 | OB_STARTUP_1024 : OB_STARTUP; // OB_STARTUP: Testvalue 1 35 | OB_TIMEERROR_1025 : OB_TIMEERROR; // OB_TIMEERROR: Testvalue 1 36 | OB_TOD_1026 : OB_TOD; // OB_TOD: Testvalue 1 37 | PIP_1027 : PIP; // PIP: Testvalue 1 38 | PORT_1028 : PORT; // PORT: Testvalue 1 39 | RTM_1029 : RTM; // RTM: Testvalue 1 40 | END_VAR 41 | 42 | 43 | BEGIN 44 | AOM_IDENT_0x1 := 16#0001; 45 | CONN_ANY_0x2 := 16#0002; 46 | CONN_OUC_0x3 := 16#0003; 47 | CONN_PRG_0x4 := 16#0004; 48 | DB_ANY_1001 := 1001; 49 | DB_DYN_1002 := 1002; 50 | DB_WWW_1003 := 1003; 51 | EVENT_ANY_0x6 := 16#0006; 52 | EVENT_ATT_0x7 := 16#0007; 53 | EVENT_HWINT_0x8 := 16#0008; 54 | HW_ANY_1004 := 1004; 55 | HW_DEVICE_1005 := 1005; 56 | HW_DPSLAVE_1007 := 1007; 57 | HW_HSC_1008 := 1008; 58 | HW_IEPORT_1009 := 1009; 59 | HW_INTERFACE_1010 := 1010; 60 | HW_IO_1011 := 1011; 61 | HW_IOSYSTEM_1012 := 1012; 62 | HW_PTO_1014 := 1014; 63 | HW_PWM_1015 := 1015; 64 | HW_SUBMODULE_1016 := 1016; 65 | OB_ANY_1017 := 1017; 66 | OB_ATT_1018 := 1018; 67 | OB_CYCLIC_1019 := 1019; 68 | OB_DELAY_1020 := 1020; 69 | OB_DIAG_1021 := 1021; 70 | OB_HWINT_1022 := 1022; 71 | OB_PCYCLE_1023 := 1023; 72 | OB_STARTUP_1024 := 1024; 73 | OB_TIMEERROR_1025 := 1025; 74 | OB_TOD_1026 := 1026; 75 | PIP_1027 := 1027; 76 | PORT_1028 := 1028; 77 | RTM_1029 := 1029; 78 | 79 | END_DATA_BLOCK 80 | 81 | -------------------------------------------------------------------------------- /plc/s7-1200/DB_Integers.db: -------------------------------------------------------------------------------- 1 | DATA_BLOCK "DB_Integers" 2 | { S7_Optimized_Access := 'TRUE' } 3 | VERSION : 0.1 4 | NON_RETAIN 5 | VAR 6 | Int_Min_n32768 : Int; // Int: Min 7 | Int_Max_32767 : Int; // Int: Max 8 | Int_12345 : Int; // Int: Testvalue 1 9 | Int_n9876 : Int; // Int: Testvalue 2 10 | USint_Min_0 : USInt; // USInt: Min 11 | USInt_Max_255 : USInt; // USInt: Max 12 | USInt_123 : USInt; // USInt: Testvalue 1 13 | UInt_Min_0 : UInt; // UInt: Min 14 | UInt_Max_65535 : UInt; // UInt: Max 15 | UInt_12345 : UInt; // UInt: Testvalue 1 16 | UDInt_Min_0 : UDInt; // UDInt: Min 17 | UDInt_Max_4294967295 : UDInt; // UDInt: Max 18 | UDint_1234567890 : UDInt; // UDInt: Testvalue 1 19 | SInt_Min_n128 : SInt; // SInt: Min 20 | SInt_Max_127 : SInt; // SInt: Max 21 | SInt_123 : SInt; // SInt: Testvalue 1 22 | SInt_n123 : SInt; // SInt: Testvalue 2 23 | DInt_Min_n2147483648 : DInt; // DInt: Min 24 | DInt_Max_2147483647 : DInt; // DInt: Max 25 | DInt_1234567890 : DInt; // DInt: Testvalue 1 26 | DInt_n987654321 : DInt; // DInt: Testvalue 2 27 | END_VAR 28 | 29 | 30 | BEGIN 31 | Int_Min_n32768 := -32768; 32 | Int_Max_32767 := 32767; 33 | Int_12345 := 12345; 34 | Int_n9876 := -9876; 35 | USInt_Max_255 := 255; 36 | USInt_123 := 123; 37 | UInt_Max_65535 := 65535; 38 | UInt_12345 := 12345; 39 | UDInt_Max_4294967295 := 4_294_967_295; 40 | UDint_1234567890 := 1_234_567_890; 41 | SInt_Min_n128 := -128; 42 | SInt_Max_127 := 127; 43 | SInt_123 := 123; 44 | SInt_n123 := -123; 45 | DInt_Min_n2147483648 := -2_147_483_648; 46 | DInt_Max_2147483647 := 2_147_483_647; 47 | DInt_1234567890 := 1_234_567_890; 48 | DInt_n987654321 := -987_654_321; 49 | 50 | END_DATA_BLOCK 51 | 52 | -------------------------------------------------------------------------------- /plc/s7-1200/DB_SystemDataTypes.db: -------------------------------------------------------------------------------- 1 | DATA_BLOCK "DB_SystemDataTypes" 2 | { S7_Optimized_Access := 'TRUE' } 3 | VERSION : 0.1 4 | NON_RETAIN 5 | VAR 6 | CREF_1 {InstructionName := 'CREF'; LibVersion := '1.0'} : CREF; // CREF: All values default 7 | ErrorStruct_1 {InstructionName := 'ErrorStruct'; LibVersion := '1.0'} : ErrorStruct; // ErrorStruct: All values default 8 | IEC_COUNTER_1 {InstructionName := 'IEC_COUNTER'; LibVersion := '1.0'} : IEC_COUNTER; // IEC_COUNTER: All values default 9 | IEC_DCOUNTER_1 {InstructionName := 'IEC_DCOUNTER'; LibVersion := '1.0'} : IEC_DCOUNTER; // IEC_DCOUNTER: All values default 10 | IEC_SCOUNTER_1 {InstructionName := 'IEC_SCOUNTER'; LibVersion := '1.0'} : IEC_SCOUNTER; // IEC_SCOUNTER: All values default 11 | IEC_TIMER_1 {InstructionName := 'IEC_TIMER'; LibVersion := '1.0'} : IEC_TIMER; // IEC_TIMER: All values default 12 | IEC_UCOUNTER_1 {InstructionName := 'IEC_UCOUNTER'; LibVersion := '1.0'} : IEC_UCOUNTER; // IEC_UCOUNTER: All values default 13 | IEC_UDCOUNTER_1 {InstructionName := 'IEC_UDCOUNTER'; LibVersion := '1.0'} : IEC_UDCOUNTER; // IEC_UDCOUNTER: All values default 14 | IEC_USCOUNTER_1 {InstructionName := 'IEC_USCOUNTER'; LibVersion := '1.0'} : IEC_USCOUNTER; // IEC_USCOUNTER: All values default 15 | NREF {InstructionName := 'NREF'; LibVersion := '1.0'} : NREF; // NREF: All values default 16 | END_VAR 17 | 18 | 19 | BEGIN 20 | 21 | END_DATA_BLOCK 22 | 23 | -------------------------------------------------------------------------------- /plc/s7-1200/DB_Timers.db: -------------------------------------------------------------------------------- 1 | DATA_BLOCK "DB_Timers" 2 | { S7_Optimized_Access := 'TRUE' } 3 | VERSION : 0.1 4 | NON_RETAIN 5 | VAR 6 | Time_Min_n24D_20H_31M_23S_648MS : Time; // Time: Min 7 | Time_Max_24D_20H_31M_23S_647MS : Time; // Time: Max 8 | Time_12S_345MS : Time; // Time: Testvalue 1 9 | Time_n20M_34S : Time; // Time: Testvalue 2 10 | END_VAR 11 | 12 | 13 | BEGIN 14 | Time_Min_n24D_20H_31M_23S_648MS := T#-24D_20H_31M_23S_648MS; 15 | Time_Max_24D_20H_31M_23S_647MS := T#24D_20H_31M_23S_647MS; 16 | Time_12S_345MS := T#12S_345MS; 17 | Time_n20M_34S := T#-20M_34S; 18 | 19 | END_DATA_BLOCK 20 | 21 | -------------------------------------------------------------------------------- /plc/s7-1200/FB_Pointers.scl: -------------------------------------------------------------------------------- 1 | FUNCTION_BLOCK "FB_Pointers" 2 | { S7_Optimized_Access := 'TRUE' } 3 | VERSION : 0.1 4 | VAR_INPUT 5 | Remote_1 : Remote; // Remote 6 | Variant_1 : Variant; // Variant 7 | END_VAR 8 | 9 | 10 | BEGIN 11 | END_FUNCTION_BLOCK 12 | 13 | -------------------------------------------------------------------------------- /plc/s7-1200/FB_Pointers_DB.db: -------------------------------------------------------------------------------- 1 | DATA_BLOCK "FB_Pointers_DB" 2 | { S7_Optimized_Access := 'TRUE' } 3 | VERSION : 0.1 4 | NON_RETAIN 5 | "FB_Pointers" 6 | 7 | BEGIN 8 | 9 | END_DATA_BLOCK 10 | 11 | -------------------------------------------------------------------------------- /plc/s7-1200/FC_TestCallPointers.scl: -------------------------------------------------------------------------------- 1 | FUNCTION "FC_TestCallPointers" : Void 2 | { S7_Optimized_Access := 'TRUE' } 3 | VERSION : 0.1 4 | 5 | BEGIN 6 | // Call FB for test Pointer datatypes 7 | "FB_Pointers_DB"( Remote_1:=P#DB987.DBX6.5 BYTE 4321, 8 | Variant_1:="DB_Integers".Int_12345); 9 | 10 | END_FUNCTION 11 | 12 | -------------------------------------------------------------------------------- /plc/s7-1200/Main.scl: -------------------------------------------------------------------------------- 1 | ORGANIZATION_BLOCK "Main" 2 | TITLE = "Main Program Sweep (Cycle)" 3 | { S7_Optimized_Access := 'TRUE' } 4 | VERSION : 0.1 5 | 6 | BEGIN 7 | // Call test FC for pointer datatypes 8 | "FC_TestCallPointers"(); 9 | END_ORGANIZATION_BLOCK 10 | 11 | -------------------------------------------------------------------------------- /plc/s7-1500/DB_Binary.db: -------------------------------------------------------------------------------- 1 | DATA_BLOCK "DB_Binary" 2 | { S7_Optimized_Access := 'TRUE' } 3 | VERSION : 0.1 4 | NON_RETAIN 5 | VAR 6 | Bool_False : Bool; // Bool: False 7 | Bool_True : Bool; // Bool: True 8 | END_VAR 9 | 10 | 11 | BEGIN 12 | Bool_True := TRUE; 13 | 14 | END_DATA_BLOCK 15 | 16 | -------------------------------------------------------------------------------- /plc/s7-1500/DB_BitStrings.db: -------------------------------------------------------------------------------- 1 | DATA_BLOCK "DB_BitStrings" 2 | { S7_Optimized_Access := 'TRUE' } 3 | VERSION : 0.1 4 | NON_RETAIN 5 | VAR 6 | Byte_Min_0x00 : Byte; // Byte: Min 7 | Byte_Max_0xFF : Byte; // Byte: Max 8 | Byte_0xAB : Byte; // Byte: Testvalue 1 9 | Word_Min_0x0000 : Word; // Word: Min 10 | Word_Max_0xFFFF : Word; // Word: Max 11 | Word_0xCAFE : Word; // Word: Testvalue 1 12 | DWord_Min_0x00000000 : DWord; // DWord: Min 13 | DWord_Max_0xFFFFFFFF : DWord; // DWord: Max 14 | DWord_0xCAFEBABE : DWord; // DWord: Testvalue 1 15 | LWord_Min_0x0000000000000000 : LWord; // LWord: Min 16 | LWord_Max_0xFFFFFFFFFFFFFFFF : LWord; // LWord: Max 17 | LWord_0x12345678ABCDEFAB : LWord; // LWord: Testvalue 1 18 | END_VAR 19 | 20 | 21 | BEGIN 22 | Byte_Max_0xFF := 16#00FF; 23 | Byte_0xAB := 16#00AB; 24 | Word_Max_0xFFFF := 16#FFFF; 25 | Word_0xCAFE := 16#CAFE; 26 | DWord_Max_0xFFFFFFFF := 16#FFFF_FFFF; 27 | DWord_0xCAFEBABE := 16#CAFE_BABE; 28 | LWord_Max_0xFFFFFFFFFFFFFFFF := 16#FFFF_FFFF_FFFF_FFFF; 29 | LWord_0x12345678ABCDEFAB := 16#1234_5678_ABCD_EFAB; 30 | 31 | END_DATA_BLOCK 32 | 33 | -------------------------------------------------------------------------------- /plc/s7-1500/DB_CharacterStrings.db: -------------------------------------------------------------------------------- 1 | DATA_BLOCK "DB_CharacterStrings" 2 | { S7_Optimized_Access := 'TRUE' } 3 | VERSION : 0.1 4 | NON_RETAIN 5 | VAR 6 | Char_Space : Char; // Char: Space 7 | Char_A : Char; // Char: Capital A 8 | Char_auml : Char; // Char: Lowecase german a Umlaut 9 | String_Empty : String; // String: Empty 10 | String_Hello_World : String; // String: "Hello World" 11 | String_Moumltoumlrhead : String; // String: "Mötörhead" 12 | String_Len4_Test : String[4]; // String: Fix len[4] "Test" 13 | WChar_Space : WChar; // WChar: Space 14 | WChar_auml : WChar; // WChar: Lowecase german a Umlaut 15 | WChar_X : WChar; // WChar: Capital X 16 | WChar_GreekSigmaBig : WChar; // WChar: Greek capital Sigma 17 | WString_Empty : WString; // WString: Empty 18 | WString_Moumltoumlrhead : WString; // WString: "Mötörhead" 19 | WString_Greek1 : WString; // WString: String with greek chars 20 | WString_Len4_Test : WString[4]; // WString: Fix len[4] "Test" 21 | END_VAR 22 | 23 | 24 | BEGIN 25 | Char_A := 'A'; 26 | Char_auml := 'ä'; 27 | String_Hello_World := 'Hello World'; 28 | String_Moumltoumlrhead := 'Mötörhead'; 29 | String_Len4_Test := 'Test'; 30 | WChar_auml := WCHAR#'ä'; 31 | WChar_X := WCHAR#'X'; 32 | WChar_GreekSigmaBig := WCHAR#'Ʃ'; 33 | WString_Moumltoumlrhead := WSTRING#'Mötörhead'; 34 | WString_Greek1 := WSTRING#'Test Greek ΣΛΔ end.'; 35 | WString_Len4_Test := WSTRING#'Test'; 36 | 37 | END_DATA_BLOCK 38 | 39 | -------------------------------------------------------------------------------- /plc/s7-1500/DB_DateAndTime.db: -------------------------------------------------------------------------------- 1 | DATA_BLOCK "DB_DateAndTime" 2 | { S7_Optimized_Access := 'TRUE' } 3 | VERSION : 0.1 4 | NON_RETAIN 5 | VAR 6 | Date_Min_1990_01_01 : Date; // Date: Min 7 | Date_Max_2169_06_06 : Date; // Date: Max 8 | Date_2023_10_28 : Date; // Date: Testvalue 1 9 | Date_1991_02_03 : Date; // Date: Testvalue 2 10 | Time_Of_Day_Min_00_00_00d000 : Time_Of_Day; // Time_Of_Day: Min 11 | Time_Of_Day_Max_23_59_59d999 : Time_Of_Day; // Time_Of_Day: Min 12 | Time_Of_Day_01_02_03 : Time_Of_Day; // Time_Of_Day: Testvalue 1 13 | Time_Of_Day_23_58_59 : Time_Of_Day; // Time_Of_Day: Testvalue 2 14 | Time_Of_Day_12_13_14d123 : Time_Of_Day; // Time_Of_Day: Testvalue 3 15 | Date_And_Time_Min_1990_01_01_00_00_00 : Date_And_Time; // Date_And_Time: Min 16 | Date_And_Time_Max_2089_12_31_23_59_59d999 : Date_And_Time; // Date_And_Time: Max 17 | Date_And_Time_2023_10_28_23_58_59d123 : Date_And_Time; // Date_And_Time: Testvalue 1 18 | LTOD_Min_00_00_00d000000000 : LTime_Of_Day; // LTOD: Min 19 | LTOD_Max_23_59_59d999999999 : LTime_Of_Day; // LTOD: Max 20 | LTOD_10_20_30d400365215 : LTime_Of_Day; // LTOD: Testvalue 1 21 | LDT_Min_1970_01_01_00_00_00d000000000 : LDT; // LDT: Min 22 | LDT_Max_2262_04_11_23_47_16d854775807 : LDT; // LDT: Max 23 | LDT_2008_10_25_08_12_34d567 : LDT; // LDT: Testvalue 1 24 | DTL_Min_1970_01_01_00_00_00d000000000 {InstructionName := 'DTL'; LibVersion := '1.0'} : DTL; // DTL: Min 25 | DTL_Max_2262_04_11_23_47_16d854775807 {InstructionName := 'DTL'; LibVersion := '1.0'} : DTL; // DTL: Max 26 | DTL_2008_10_25_08_12_34d567 {InstructionName := 'DTL'; LibVersion := '1.0'} : DTL; // DTL: Testvalue 1 27 | END_VAR 28 | 29 | 30 | BEGIN 31 | Date_Max_2169_06_06 := D#2169-06-06; 32 | Date_2023_10_28 := D#2023-10-28; 33 | Date_1991_02_03 := D#1990-02-03; 34 | Time_Of_Day_Max_23_59_59d999 := TOD#23:59:59.999; 35 | Time_Of_Day_01_02_03 := TOD#01:02:03; 36 | Time_Of_Day_23_58_59 := TOD#23:58:59; 37 | Time_Of_Day_12_13_14d123 := TOD#12:13:14.123; 38 | Date_And_Time_Max_2089_12_31_23_59_59d999 := DT#2089-12-31-23:59:59.999; 39 | Date_And_Time_2023_10_28_23_58_59d123 := DT#2023-10-28-23:58:59.123; 40 | LTOD_Max_23_59_59d999999999 := LTOD#23:59:59.999999999; 41 | LTOD_10_20_30d400365215 := LTOD#10:20:30.400365215; 42 | LDT_Max_2262_04_11_23_47_16d854775807 := LDT#2262-04-11-23:47:16.854775807; 43 | LDT_2008_10_25_08_12_34d567 := LDT#2008-10-25-08:12:34.567; 44 | DTL_Max_2262_04_11_23_47_16d854775807.YEAR := 2262; 45 | DTL_Max_2262_04_11_23_47_16d854775807.MONTH := 4; 46 | DTL_Max_2262_04_11_23_47_16d854775807.DAY := 11; 47 | DTL_Max_2262_04_11_23_47_16d854775807.WEEKDAY := 6; 48 | DTL_Max_2262_04_11_23_47_16d854775807.HOUR := 23; 49 | DTL_Max_2262_04_11_23_47_16d854775807.MINUTE := 47; 50 | DTL_Max_2262_04_11_23_47_16d854775807.SECOND := 16; 51 | DTL_Max_2262_04_11_23_47_16d854775807.NANOSECOND := 854775807; 52 | DTL_Max_2262_04_11_23_47_16d854775807 := DTL#2262-04-11-23:47:16.854775807; 53 | DTL_2008_10_25_08_12_34d567.YEAR := 2008; 54 | DTL_2008_10_25_08_12_34d567.MONTH := 10; 55 | DTL_2008_10_25_08_12_34d567.DAY := 25; 56 | DTL_2008_10_25_08_12_34d567.WEEKDAY := 7; 57 | DTL_2008_10_25_08_12_34d567.HOUR := 8; 58 | DTL_2008_10_25_08_12_34d567.MINUTE := 12; 59 | DTL_2008_10_25_08_12_34d567.SECOND := 34; 60 | DTL_2008_10_25_08_12_34d567.NANOSECOND := 567000000; 61 | DTL_2008_10_25_08_12_34d567 := DTL#2008-10-25-08:12:34.567; 62 | 63 | END_DATA_BLOCK 64 | 65 | -------------------------------------------------------------------------------- /plc/s7-1500/DB_FloatingPoint.db: -------------------------------------------------------------------------------- 1 | DATA_BLOCK "DB_FloatingPoint" 2 | { S7_Optimized_Access := 'TRUE' } 3 | VERSION : 0.1 4 | NON_RETAIN 5 | VAR 6 | Real_MinNeg_n3d402823e38 : Real; // Real: Min negative value 7 | Real_MaxNeg_n1d175495en38 : Real; // Real: Max negative value 8 | Real_MinPos_1d175495en38 : Real; // Real: Min positive value 9 | Real_MaxPos_3d402823e38 : Real; // Real: Max positive value 10 | Real_0d0 : Real; // Real: Zero 11 | Real_987d125 : Real; // Real: Testvalue 1 12 | Real_n123d5 : Real; // Real: Testvalue 2 13 | LReal_MinNeg_n1d7976931348623157e308 : LReal; // LReal: Min negative value 14 | LReal_MaxNeg_n2d2250738585072014en308 : LReal; // LReal: Max negative value 15 | LReal_MinPos_2d2250738585072014en308 : LReal; // LReal: Min positive value 16 | LReal_MaxPos_1d7976931348623157e308 : LReal; // LReal: Max positive value 17 | LReal_0d0 : LReal; // LReal: Zero 18 | LReal_987d125 : LReal; // LReal: Testvalue 1 19 | LReal_n123d5 : LReal; // LReal: Testvalue 2 20 | LReal_1d23456789012346e18 : LReal; // LReal: Testvalue 3 21 | END_VAR 22 | 23 | 24 | BEGIN 25 | Real_MinNeg_n3d402823e38 := -3.402823E+38; 26 | Real_MaxNeg_n1d175495en38 := -1.175495E-38; 27 | Real_MinPos_1d175495en38 := 1.175495E-38; 28 | Real_MaxPos_3d402823e38 := 3.402823E+38; 29 | Real_987d125 := 987.125; 30 | Real_n123d5 := -123.5; 31 | LReal_MinNeg_n1d7976931348623157e308 := -1.7976931348623157E+308; 32 | LReal_MaxNeg_n2d2250738585072014en308 := -2.2250738585072014E-308; 33 | LReal_MinPos_2d2250738585072014en308 := 2.2250738585072014E-308; 34 | LReal_MaxPos_1d7976931348623157e308 := 1.7976931348623157E+308; 35 | LReal_987d125 := 987.125; 36 | LReal_n123d5 := -123.5; 37 | LReal_1d23456789012346e18 := 1.23456789012346E+18; 38 | 39 | END_DATA_BLOCK 40 | 41 | -------------------------------------------------------------------------------- /plc/s7-1500/DB_HardwareDataTypes.db: -------------------------------------------------------------------------------- 1 | DATA_BLOCK "DB_HardwareDataTypes" 2 | { S7_Optimized_Access := 'TRUE' } 3 | VERSION : 0.1 4 | NON_RETAIN 5 | VAR 6 | AOM_IDENT_0x1 : AOM_IDENT; // AOM_IDENT: Testvalue 1 7 | CONN_ANY_0x2 : CONN_ANY; // CONN_ANY: Testvalue 1 8 | CONN_OUC_0x3 : CONN_OUC; // CONN_OUC: Testvalue 1 9 | CONN_PRG_0x4 : CONN_PRG; // CONN_PRG: Testvalue 1 10 | CONN_R_ID_0x5 : CONN_R_ID; // CONN_R_ID: Testvalue 1 11 | DB_ANY_1001 : DB_ANY; // DB_ANY: Testvalue 1 12 | DB_DYN_1002 : DB_DYN; // DB_DYN: Testvalue 1 13 | DB_WWW_1003 : DB_WWW; // DB_WWW: Testvalue 1 14 | EVENT_ANY_0x6 : EVENT_ANY; // EVENT_ANY: Testvalue 1 15 | EVENT_ATT_0x7 : EVENT_ATT; // EVENT_ATT: Testvalue 1 16 | EVENT_HWINT_0x8 : EVENT_HWINT; // EVENT_HWINT: Testvalue 1 17 | HW_ANY_1004 : HW_ANY; // HW_ANY: Testvalue 1 18 | HW_DEVICE_1005 : HW_DEVICE; // HW_DEVICE: Testvalue 1 19 | HW_DPMASTER_1006 : HW_DPMASTER; // HW_DPMASTER: Testvalue 1 20 | HW_DPSLAVE_1007 : HW_DPSLAVE; // HW_DPSLAVE: Testvalue 1 21 | HW_HSC_1008 : HW_HSC; // HW_HSC: Testvalue 1 22 | HW_IEPORT_1009 : HW_IEPORT; // HW_IEPORT: Testvalue 1 23 | HW_INTERFACE_1010 : HW_INTERFACE; // HW_INTERFACE: Testvalue 1 24 | HW_IO_1011 : HW_IO; // HW_IO: Testvalue 1 25 | HW_IOSYSTEM_1012 : HW_IOSYSTEM; // HW_IOSYSTEM: Testvalue 1 26 | HW_MODULE_1013 : HW_MODULE; // HW_MODULE: Testvalue 1 27 | HW_PTO_1014 : HW_PTO; // HW_PTO: Testvalue 1 28 | HW_PWM_1015 : HW_PWM; // HW_PWM: Testvalue 1 29 | HW_SUBMODULE_1016 : HW_SUBMODULE; // HW_SUBMODULE: Testvalue 1 30 | OB_ANY_1017 : OB_ANY; // OB_ANY: Testvalue 1 31 | OB_ATT_1018 : OB_ATT; // OB_ATT: Testvalue 1 32 | OB_CYCLIC_1019 : OB_CYCLIC; // OB_CYCLIC: Testvalue 1 33 | OB_DELAY_1020 : OB_DELAY; // OB_DELAY: Testvalue 1 34 | OB_DIAG_1021 : OB_DIAG; // OB_DIAG: Testvalue 1 35 | OB_HWINT_1022 : OB_HWINT; // OB_HWINT: Testvalue 1 36 | OB_PCYCLE_1023 : OB_PCYCLE; // OB_PCYCLE: Testvalue 1 37 | OB_STARTUP_1024 : OB_STARTUP; // OB_STARTUP: Testvalue 1 38 | OB_TIMEERROR_1025 : OB_TIMEERROR; // OB_TIMEERROR: Testvalue 1 39 | OB_TOD_1026 : OB_TOD; // OB_TOD: Testvalue 1 40 | PIP_1027 : PIP; // PIP: Testvalue 1 41 | PORT_1028 : PORT; // PORT: Testvalue 1 42 | RTM_1029 : RTM; // RTM: Testvalue 1 43 | END_VAR 44 | 45 | 46 | BEGIN 47 | AOM_IDENT_0x1 := 16#0001; 48 | CONN_ANY_0x2 := 16#0002; 49 | CONN_OUC_0x3 := 16#0003; 50 | CONN_PRG_0x4 := 16#0004; 51 | CONN_R_ID_0x5 := 16#0005; 52 | DB_ANY_1001 := 1001; 53 | DB_DYN_1002 := 1002; 54 | DB_WWW_1003 := 1003; 55 | EVENT_ANY_0x6 := 16#0006; 56 | EVENT_ATT_0x7 := 16#0007; 57 | EVENT_HWINT_0x8 := 16#0008; 58 | HW_ANY_1004 := 1004; 59 | HW_DEVICE_1005 := 1005; 60 | HW_DPMASTER_1006 := 1006; 61 | HW_DPSLAVE_1007 := 1007; 62 | HW_HSC_1008 := 1008; 63 | HW_IEPORT_1009 := 1009; 64 | HW_INTERFACE_1010 := 1010; 65 | HW_IO_1011 := 1011; 66 | HW_IOSYSTEM_1012 := 1012; 67 | HW_MODULE_1013 := 1013; 68 | HW_PTO_1014 := 1014; 69 | HW_PWM_1015 := 1015; 70 | HW_SUBMODULE_1016 := 1016; 71 | OB_ANY_1017 := 1017; 72 | OB_ATT_1018 := 1018; 73 | OB_CYCLIC_1019 := 1019; 74 | OB_DELAY_1020 := 1020; 75 | OB_DIAG_1021 := 1021; 76 | OB_HWINT_1022 := 1022; 77 | OB_PCYCLE_1023 := 1023; 78 | OB_STARTUP_1024 := 1024; 79 | OB_TIMEERROR_1025 := 1025; 80 | OB_TOD_1026 := 1026; 81 | PIP_1027 := 1027; 82 | PORT_1028 := 1028; 83 | RTM_1029 := 1029; 84 | 85 | END_DATA_BLOCK 86 | 87 | -------------------------------------------------------------------------------- /plc/s7-1500/DB_Integers.db: -------------------------------------------------------------------------------- 1 | DATA_BLOCK "DB_Integers" 2 | { S7_Optimized_Access := 'TRUE' } 3 | VERSION : 0.1 4 | NON_RETAIN 5 | VAR 6 | Int_Min_n32768 : Int; // Int: Min 7 | Int_Max_32767 : Int; // Int: Max 8 | Int_12345 : Int; // Int: Testvalue 1 9 | Int_n9876 : Int; // Int: Testvalue 2 10 | ULInt_Min_0 : ULInt; // ULInt: Min 11 | ULInt_Max_18446744073709551615 : ULInt; // ULInt: Max 12 | ULInt_12345678901234567890 : ULInt; // ULInt: Testvalue 1 13 | LInt_Min_n9223372036854775808 : LInt; // LInt: Min 14 | LInt_Max_9223372036854775807 : LInt; // LInt: Max 15 | LInt_1234567890123456789 : LInt; // LInt: Testvalue 1 16 | LInt_n987654321098765432 : LInt; // LInt: Testvalue 2 17 | USint_Min_0 : USInt; // USInt: Min 18 | USInt_Max_255 : USInt; // USInt: Max 19 | USInt_123 : USInt; // USInt: Testvalue 1 20 | UInt_Min_0 : UInt; // UInt: Min 21 | UInt_Max_65535 : UInt; // UInt: Max 22 | UInt_12345 : UInt; // UInt: Testvalue 1 23 | UDInt_Min_0 : UDInt; // UDInt: Min 24 | UDInt_Max_4294967295 : UDInt; // UDInt: Max 25 | UDint_1234567890 : UDInt; // UDInt: Testvalue 1 26 | SInt_Min_n128 : SInt; // SInt: Min 27 | SInt_Max_127 : SInt; // SInt: Max 28 | SInt_123 : SInt; // SInt: Testvalue 1 29 | SInt_n123 : SInt; // SInt: Testvalue 2 30 | DInt_Min_n2147483648 : DInt; // DInt: Min 31 | DInt_Max_2147483647 : DInt; // DInt: Max 32 | DInt_1234567890 : DInt; // DInt: Testvalue 1 33 | DInt_n987654321 : DInt; // DInt: Testvalue 2 34 | END_VAR 35 | 36 | 37 | BEGIN 38 | Int_Min_n32768 := -32768; 39 | Int_Max_32767 := 32767; 40 | Int_12345 := 12345; 41 | Int_n9876 := -9876; 42 | ULInt_Max_18446744073709551615 := 18_446_744_073_709_551_615; 43 | ULInt_12345678901234567890 := 12_345_678_901_234_567_890; 44 | LInt_Min_n9223372036854775808 := -9_223_372_036_854_775_808; 45 | LInt_Max_9223372036854775807 := 9_223_372_036_854_775_807; 46 | LInt_1234567890123456789 := 1_234_567_890_123_456_789; 47 | LInt_n987654321098765432 := -987_654_321_098_765_432; 48 | USInt_Max_255 := 255; 49 | USInt_123 := 123; 50 | UInt_Max_65535 := 65535; 51 | UInt_12345 := 12345; 52 | UDInt_Max_4294967295 := 4_294_967_295; 53 | UDint_1234567890 := 1_234_567_890; 54 | SInt_Min_n128 := -128; 55 | SInt_Max_127 := 127; 56 | SInt_123 := 123; 57 | SInt_n123 := -123; 58 | DInt_Min_n2147483648 := -2_147_483_648; 59 | DInt_Max_2147483647 := 2_147_483_647; 60 | DInt_1234567890 := 1_234_567_890; 61 | DInt_n987654321 := -987_654_321; 62 | 63 | END_DATA_BLOCK 64 | 65 | -------------------------------------------------------------------------------- /plc/s7-1500/DB_SystemDataTypes.db: -------------------------------------------------------------------------------- 1 | DATA_BLOCK "DB_SystemDataTypes" 2 | { S7_Optimized_Access := 'TRUE' } 3 | VERSION : 0.1 4 | NON_RETAIN 5 | VAR 6 | CREF_1 {InstructionName := 'CREF'; LibVersion := '1.0'} : CREF; // CREF: All values default 7 | ErrorStruct_1 {InstructionName := 'ErrorStruct'; LibVersion := '1.0'} : ErrorStruct; // ErrorStruct: All values default 8 | IEC_COUNTER_1 {InstructionName := 'IEC_COUNTER'; LibVersion := '1.0'} : IEC_COUNTER; // IEC_COUNTER: All values default 9 | IEC_DCOUNTER_1 {InstructionName := 'IEC_DCOUNTER'; LibVersion := '1.0'} : IEC_DCOUNTER; // IEC_DCOUNTER: All values default 10 | IEC_LCOUNTER_1 {InstructionName := 'IEC_LCOUNTER'; LibVersion := '1.0'} : IEC_LCOUNTER; // IEC_LCOUNTER: All values default 11 | IEC_LTIMER_1 {InstructionName := 'IEC_LTIMER'; LibVersion := '1.0'} : IEC_LTIMER; // IEC_LTIMER: All values default 12 | IEC_SCOUNTER_1 {InstructionName := 'IEC_SCOUNTER'; LibVersion := '1.0'} : IEC_SCOUNTER; // IEC_SCOUNTER: All values default 13 | IEC_TIMER_1 {InstructionName := 'IEC_TIMER'; LibVersion := '1.0'} : IEC_TIMER; // IEC_TIMER: All values default 14 | IEC_UCOUNTER_1 {InstructionName := 'IEC_UCOUNTER'; LibVersion := '1.0'} : IEC_UCOUNTER; // IEC_UCOUNTER: All values default 15 | IEC_UDCOUNTER_1 {InstructionName := 'IEC_UDCOUNTER'; LibVersion := '1.0'} : IEC_UDCOUNTER; // IEC_UDCOUNTER: All values default 16 | IEC_ULCOUNTER_1 {InstructionName := 'IEC_ULCOUNTER'; LibVersion := '1.0'} : IEC_ULCOUNTER; // IEC_ULCOUNTER: All values default 17 | IEC_USCOUNTER_1 {InstructionName := 'IEC_USCOUNTER'; LibVersion := '1.0'} : IEC_USCOUNTER; // IEC_USCOUNTER: All values default 18 | NREF {InstructionName := 'NREF'; LibVersion := '1.0'} : NREF; // NREF: All values default 19 | END_VAR 20 | 21 | 22 | BEGIN 23 | 24 | END_DATA_BLOCK 25 | 26 | -------------------------------------------------------------------------------- /plc/s7-1500/DB_Timers.db: -------------------------------------------------------------------------------- 1 | DATA_BLOCK "DB_Timers" 2 | { S7_Optimized_Access := 'TRUE' } 3 | VERSION : 0.1 4 | NON_RETAIN 5 | VAR 6 | Time_Min_n24D_20H_31M_23S_648MS : Time; // Time: Min 7 | Time_Max_24D_20H_31M_23S_647MS : Time; // Time: Max 8 | Time_12S_345MS : Time; // Time: Testvalue 1 9 | Time_n20M_34S : Time; // Time: Testvalue 2 10 | S5Time_Min_0MS : S5Time; // S5Time: Min 11 | S5Time_Max_2H46M30S : S5Time; // S5Time: Max 12 | S5Time_120MS : S5Time; // S5Time: Testvalue 1 13 | S5Time_12S300MS : S5Time; // S5Time: Testvalue 2 14 | LTime_Min_n106751D_23H_47M_16S_854MS_775US_808NS : LTime; // LTime: Min 15 | LTime_Max_106751D_23H_47M_16S_854MS_775US_807NS : LTime; // LTime: Max 16 | LTime_12S345NS : LTime; // LTime: Testvalue 1 17 | LTime_n12H_345US : LTime; // LTime: Testvalue 2 18 | LTime_23H_456US : LTime; // LTime: Testvalue 3 19 | END_VAR 20 | 21 | 22 | BEGIN 23 | Time_Min_n24D_20H_31M_23S_648MS := T#-24D_20H_31M_23S_648MS; 24 | Time_Max_24D_20H_31M_23S_647MS := T#24D_20H_31M_23S_647MS; 25 | Time_12S_345MS := T#12S_345MS; 26 | Time_n20M_34S := T#-20M_34S; 27 | S5Time_Max_2H46M30S := S5T#2H_46M_30S; 28 | S5Time_120MS := S5T#120MS; 29 | S5Time_12S300MS := S5T#12S_300MS; 30 | LTime_Min_n106751D_23H_47M_16S_854MS_775US_808NS := LT#-106751D_23H_47M_16S_854MS_775US_808NS; 31 | LTime_Max_106751D_23H_47M_16S_854MS_775US_807NS := LT#106751D_23H_47M_16S_854MS_775US_807NS; 32 | LTime_12S345NS := LT#12S_345NS; 33 | LTime_n12H_345US := LT#-12H_345US; 34 | LTime_23H_456US := LT#23H_456US; 35 | 36 | END_DATA_BLOCK 37 | 38 | -------------------------------------------------------------------------------- /plc/s7-1500/FB_ParameterTypes.scl: -------------------------------------------------------------------------------- 1 | FUNCTION_BLOCK "FB_ParameterTypes" 2 | { S7_Optimized_Access := 'TRUE' } 3 | VERSION : 0.1 4 | VAR_INPUT 5 | Block_FB_1234 : Block_FB := FB 1234; // Block_FB 6 | Block_FC_5678 : Block_FC := FC 5678; // Block_FC 7 | Counter_321 : Counter := 321; // Counter 8 | Timer_654 : Timer := 654; // Timer 9 | END_VAR 10 | 11 | 12 | BEGIN 13 | END_FUNCTION_BLOCK 14 | 15 | -------------------------------------------------------------------------------- /plc/s7-1500/FB_ParameterTypes_DB.db: -------------------------------------------------------------------------------- 1 | DATA_BLOCK "FB_ParameterTypes_DB" 2 | { S7_Optimized_Access := 'TRUE' } 3 | VERSION : 0.1 4 | NON_RETAIN 5 | "FB_ParameterTypes" 6 | 7 | BEGIN 8 | 9 | END_DATA_BLOCK 10 | 11 | -------------------------------------------------------------------------------- /plc/s7-1500/FB_Pointers.scl: -------------------------------------------------------------------------------- 1 | FUNCTION_BLOCK "FB_Pointers" 2 | { S7_Optimized_Access := 'TRUE' } 3 | VERSION : 0.1 4 | VAR_INPUT 5 | Any_1 : Any; // Any 6 | Pointer_1 : Pointer; // Pointer 7 | Remote_1 : Remote; // Remote 8 | Variant_1 : Variant; // Variant 9 | END_VAR 10 | 11 | 12 | BEGIN 13 | END_FUNCTION_BLOCK 14 | 15 | -------------------------------------------------------------------------------- /plc/s7-1500/FB_Pointers_DB.db: -------------------------------------------------------------------------------- 1 | DATA_BLOCK "FB_Pointers_DB" 2 | { S7_Optimized_Access := 'TRUE' } 3 | VERSION : 0.1 4 | NON_RETAIN 5 | "FB_Pointers" 6 | 7 | BEGIN 8 | 9 | END_DATA_BLOCK 10 | 11 | -------------------------------------------------------------------------------- /plc/s7-1500/FC_TestCallParameterTypes.scl: -------------------------------------------------------------------------------- 1 | FUNCTION "FC_TestCallParameterTypes" : Void 2 | { S7_Optimized_Access := 'TRUE' } 3 | VERSION : 0.1 4 | 5 | BEGIN 6 | // Call FB for test parameter datatypes 7 | // Unfortunately you can't write the parameters in SCL, only in FUP/KOP. 8 | // We keep the default values defined in the FB interface. 9 | 10 | "FB_ParameterTypes_DB"(); 11 | 12 | END_FUNCTION 13 | 14 | -------------------------------------------------------------------------------- /plc/s7-1500/FC_TestCallPointers.scl: -------------------------------------------------------------------------------- 1 | FUNCTION "FC_TestCallPointers" : Void 2 | { S7_Optimized_Access := 'TRUE' } 3 | VERSION : 0.1 4 | 5 | BEGIN 6 | // Call FB for test Pointer datatypes 7 | "FB_Pointers_DB"(Any_1:=P#DB123.DBX4.5 BYTE 987, 8 | Pointer_1:=P#M1234.5, 9 | Remote_1:=P#DB987.DBX6.5 BYTE 4321, 10 | Variant_1:="DB_Integers".Int_12345); 11 | 12 | END_FUNCTION 13 | 14 | -------------------------------------------------------------------------------- /plc/s7-1500/Main.scl: -------------------------------------------------------------------------------- 1 | ORGANIZATION_BLOCK "Main" 2 | TITLE = "Main Program Sweep (Cycle)" 3 | { S7_Optimized_Access := 'TRUE' } 4 | VERSION : 0.1 5 | 6 | BEGIN 7 | // Call test FC for parameter and pointer datatypes 8 | "FC_TestCallParameterTypes"(); 9 | "FC_TestCallPointers"(); 10 | END_ORGANIZATION_BLOCK 11 | 12 | -------------------------------------------------------------------------------- /src/.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files and build results 2 | 3 | # User-specific files 4 | *.suo 5 | *.user 6 | .vs/ 7 | .editorconfig 8 | 9 | # Build results 10 | [Dd]ebug/ 11 | [Rr]elease/ 12 | [Bb]in/ 13 | [Oo]bj/ 14 | x64/ 15 | build/ 16 | -------------------------------------------------------------------------------- /src/DriverTest/App.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /src/DriverTest/DriverTest.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {94755B6A-7E0D-40F9-A2ED-48FF0C0FEA2B} 8 | Exe 9 | Properties 10 | DriverTest 11 | DriverTest 12 | v4.7.2 13 | 512 14 | true 15 | 16 | 17 | 18 | true 19 | bin\x64\Debug\ 20 | DEBUG;TRACE 21 | full 22 | x64 23 | 7.3 24 | prompt 25 | true 26 | 27 | 28 | bin\x64\Release\ 29 | TRACE 30 | true 31 | pdbonly 32 | x64 33 | 7.3 34 | prompt 35 | true 36 | 37 | 38 | true 39 | bin\x86\Debug\ 40 | DEBUG;TRACE 41 | full 42 | x86 43 | 7.3 44 | prompt 45 | true 46 | 47 | 48 | bin\x86\Release\ 49 | TRACE 50 | true 51 | pdbonly 52 | x86 53 | 7.3 54 | prompt 55 | true 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | {781951d8-80de-4e2f-92ca-a5fef0059415} 78 | S7CommPlusDriver 79 | 80 | 81 | 82 | 83 | xcopy /y /d "$(SolutionDir)S7CommPlusDriver\OpenSSL-dll-$(PlatformName)\*.dll" "$(ProjectDir)$(OutDir)" 84 | 85 | 92 | -------------------------------------------------------------------------------- /src/DriverTest/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("DriverTest")] 9 | [assembly: AssemblyDescription("S7CommPlusDriver Test")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("DriverTest")] 13 | [assembly: AssemblyCopyright("Copyright © 2023, Thomas Wiens")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("94755b6a-7e0d-40f9-a2ed-48ff0c0fea2b")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("0.1.0.0")] 36 | [assembly: AssemblyFileVersion("0.1.0.0")] 37 | -------------------------------------------------------------------------------- /src/S7CommPlusDriver.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.33328.57 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "S7CommPlusDriver", "S7CommPlusDriver\S7CommPlusDriver.csproj", "{781951D8-80DE-4E2F-92CA-A5FEF0059415}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DriverTest", "DriverTest\DriverTest.csproj", "{94755B6A-7E0D-40F9-A2ED-48FF0C0FEA2B}" 9 | EndProject 10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "S7CommPlusGUIBrowser", "S7CommPlusGUIBrowser\S7CommPlusGUIBrowser.csproj", "{BEB37276-B3B3-4DEE-A1EA-D95EB774223B}" 11 | EndProject 12 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Zlib.net", "Zlib.net\Zlib.net.csproj", "{0C89B7A2-A218-49E4-B545-5B044A45F977}" 13 | EndProject 14 | Global 15 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 16 | Debug|Any CPU = Debug|Any CPU 17 | Debug|x64 = Debug|x64 18 | Debug|x86 = Debug|x86 19 | Release|Any CPU = Release|Any CPU 20 | Release|x64 = Release|x64 21 | Release|x86 = Release|x86 22 | EndGlobalSection 23 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 24 | {781951D8-80DE-4E2F-92CA-A5FEF0059415}.Debug|Any CPU.ActiveCfg = Debug|x86 25 | {781951D8-80DE-4E2F-92CA-A5FEF0059415}.Debug|x64.ActiveCfg = Debug|x64 26 | {781951D8-80DE-4E2F-92CA-A5FEF0059415}.Debug|x64.Build.0 = Debug|x64 27 | {781951D8-80DE-4E2F-92CA-A5FEF0059415}.Debug|x86.ActiveCfg = Debug|x86 28 | {781951D8-80DE-4E2F-92CA-A5FEF0059415}.Debug|x86.Build.0 = Debug|x86 29 | {781951D8-80DE-4E2F-92CA-A5FEF0059415}.Release|Any CPU.ActiveCfg = Release|x86 30 | {781951D8-80DE-4E2F-92CA-A5FEF0059415}.Release|x64.ActiveCfg = Release|x64 31 | {781951D8-80DE-4E2F-92CA-A5FEF0059415}.Release|x64.Build.0 = Release|x64 32 | {781951D8-80DE-4E2F-92CA-A5FEF0059415}.Release|x86.ActiveCfg = Release|x86 33 | {781951D8-80DE-4E2F-92CA-A5FEF0059415}.Release|x86.Build.0 = Release|x86 34 | {94755B6A-7E0D-40F9-A2ED-48FF0C0FEA2B}.Debug|Any CPU.ActiveCfg = Debug|x86 35 | {94755B6A-7E0D-40F9-A2ED-48FF0C0FEA2B}.Debug|x64.ActiveCfg = Debug|x64 36 | {94755B6A-7E0D-40F9-A2ED-48FF0C0FEA2B}.Debug|x64.Build.0 = Debug|x64 37 | {94755B6A-7E0D-40F9-A2ED-48FF0C0FEA2B}.Debug|x86.ActiveCfg = Debug|x86 38 | {94755B6A-7E0D-40F9-A2ED-48FF0C0FEA2B}.Debug|x86.Build.0 = Debug|x86 39 | {94755B6A-7E0D-40F9-A2ED-48FF0C0FEA2B}.Release|Any CPU.ActiveCfg = Release|x86 40 | {94755B6A-7E0D-40F9-A2ED-48FF0C0FEA2B}.Release|x64.ActiveCfg = Release|x64 41 | {94755B6A-7E0D-40F9-A2ED-48FF0C0FEA2B}.Release|x64.Build.0 = Release|x64 42 | {94755B6A-7E0D-40F9-A2ED-48FF0C0FEA2B}.Release|x86.ActiveCfg = Release|x86 43 | {94755B6A-7E0D-40F9-A2ED-48FF0C0FEA2B}.Release|x86.Build.0 = Release|x86 44 | {BEB37276-B3B3-4DEE-A1EA-D95EB774223B}.Debug|Any CPU.ActiveCfg = Debug|x86 45 | {BEB37276-B3B3-4DEE-A1EA-D95EB774223B}.Debug|x64.ActiveCfg = Debug|x64 46 | {BEB37276-B3B3-4DEE-A1EA-D95EB774223B}.Debug|x64.Build.0 = Debug|x64 47 | {BEB37276-B3B3-4DEE-A1EA-D95EB774223B}.Debug|x86.ActiveCfg = Debug|x86 48 | {BEB37276-B3B3-4DEE-A1EA-D95EB774223B}.Debug|x86.Build.0 = Debug|x86 49 | {BEB37276-B3B3-4DEE-A1EA-D95EB774223B}.Release|Any CPU.ActiveCfg = Release|x86 50 | {BEB37276-B3B3-4DEE-A1EA-D95EB774223B}.Release|x64.ActiveCfg = Release|x64 51 | {BEB37276-B3B3-4DEE-A1EA-D95EB774223B}.Release|x64.Build.0 = Release|x64 52 | {BEB37276-B3B3-4DEE-A1EA-D95EB774223B}.Release|x86.ActiveCfg = Release|x86 53 | {BEB37276-B3B3-4DEE-A1EA-D95EB774223B}.Release|x86.Build.0 = Release|x86 54 | {0C89B7A2-A218-49E4-B545-5B044A45F977}.Debug|Any CPU.ActiveCfg = Debug|x86 55 | {0C89B7A2-A218-49E4-B545-5B044A45F977}.Debug|x64.ActiveCfg = Debug|x64 56 | {0C89B7A2-A218-49E4-B545-5B044A45F977}.Debug|x64.Build.0 = Debug|x64 57 | {0C89B7A2-A218-49E4-B545-5B044A45F977}.Debug|x86.ActiveCfg = Debug|x86 58 | {0C89B7A2-A218-49E4-B545-5B044A45F977}.Debug|x86.Build.0 = Debug|x86 59 | {0C89B7A2-A218-49E4-B545-5B044A45F977}.Release|Any CPU.ActiveCfg = Release|x86 60 | {0C89B7A2-A218-49E4-B545-5B044A45F977}.Release|x64.ActiveCfg = Release|x64 61 | {0C89B7A2-A218-49E4-B545-5B044A45F977}.Release|x64.Build.0 = Release|x64 62 | {0C89B7A2-A218-49E4-B545-5B044A45F977}.Release|x86.ActiveCfg = Release|x86 63 | {0C89B7A2-A218-49E4-B545-5B044A45F977}.Release|x86.Build.0 = Release|x86 64 | EndGlobalSection 65 | GlobalSection(SolutionProperties) = preSolution 66 | HideSolutionNode = FALSE 67 | EndGlobalSection 68 | GlobalSection(ExtensibilityGlobals) = postSolution 69 | SolutionGuid = {641BA78D-D608-4377-9F99-E4C1029EFA0B} 70 | EndGlobalSection 71 | EndGlobal 72 | -------------------------------------------------------------------------------- /src/S7CommPlusDriver/Alarming/AlarmsAlarmTexts.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | /****************************************************************************** 3 | * S7CommPlusDriver 4 | * 5 | * Copyright (C) 2023 Thomas Wiens, th.wiens@gmx.de 6 | * 7 | * This file is part of S7CommPlusDriver. 8 | * 9 | * S7CommPlusDriver is free software: you can redistribute it and/or modify 10 | * it under the terms of the GNU Lesser General Public License as 11 | * published by the Free Software Foundation, either version 3 of the 12 | * License, or (at your option) any later version. 13 | /****************************************************************************/ 14 | #endregion 15 | 16 | using System; 17 | using System.Collections.Generic; 18 | 19 | namespace S7CommPlusDriver.Alarming 20 | { 21 | public class AlarmsAlarmTexts 22 | { 23 | public int LanguageId; 24 | public string Infotext = String.Empty; 25 | public string AlarmText = String.Empty; 26 | public string AdditionalText1 = String.Empty; 27 | public string AdditionalText2 = String.Empty; 28 | public string AdditionalText3 = String.Empty; 29 | public string AdditionalText4 = String.Empty; 30 | public string AdditionalText5 = String.Empty; 31 | public string AdditionalText6 = String.Empty; 32 | public string AdditionalText7 = String.Empty; 33 | public string AdditionalText8 = String.Empty; 34 | public string AdditionalText9 = String.Empty; 35 | 36 | // These two values we get in addition when browsing for the alarmtexts 37 | // Don't know if they are useful for something. 38 | public ushort UnknownValue1; 39 | public ushort UnknownValue2; 40 | 41 | public static AlarmsAlarmTexts FromNotificationBlob(ValueBlobSparseArray blob, int languageId) 42 | { 43 | var at = new AlarmsAlarmTexts(); 44 | string s; 45 | int lcid; 46 | int textid; 47 | at.LanguageId = languageId; 48 | foreach (var v in blob.Value) 49 | { 50 | s = Utils.GetUtfString(v.Value.value, 0, (uint)v.Value.value.Length); 51 | // Values in older CPUs, from: 0xa09c8001..0xa09c800b (2694610945..2694610955) 52 | // Current CPUs use: 0x04070001..0x0407000b ( 67567617.. 67567627) 53 | // Where the left word is the language ID, 0x0407 = 1031, and the right word is the text id. 54 | // The blob may contain several languages. If you need them all, you need to call this multiple times. 55 | lcid = (int)(v.Key >> 16); 56 | textid = (int)(v.Key & 0xffff); 57 | if (lcid == languageId) 58 | { 59 | switch (textid) 60 | { 61 | case 1: 62 | at.Infotext = s; 63 | break; 64 | case 2: 65 | at.AlarmText = s; 66 | break; 67 | case 3: 68 | at.AdditionalText1 = s; 69 | break; 70 | case 4: 71 | at.AdditionalText2 = s; 72 | break; 73 | case 5: 74 | at.AdditionalText3 = s; 75 | break; 76 | case 6: 77 | at.AdditionalText4 = s; 78 | break; 79 | case 7: 80 | at.AdditionalText5 = s; 81 | break; 82 | case 8: 83 | at.AdditionalText6 = s; 84 | break; 85 | case 9: 86 | at.AdditionalText7 = s; 87 | break; 88 | case 10: 89 | at.AdditionalText8 = s; 90 | break; 91 | case 11: 92 | at.AdditionalText9 = s; 93 | break; 94 | } 95 | } 96 | } 97 | return at; 98 | } 99 | 100 | public override string ToString() 101 | { 102 | string s = "" + Environment.NewLine; 103 | s += "" + Infotext.ToString() + "" + Environment.NewLine; 104 | s += "" + AlarmText.ToString() + "" + Environment.NewLine; 105 | s += "" + AdditionalText1.ToString() + "" + Environment.NewLine; 106 | s += "" + AdditionalText2.ToString() + "" + Environment.NewLine; 107 | s += "" + AdditionalText3.ToString() + "" + Environment.NewLine; 108 | s += "" + AdditionalText4.ToString() + "" + Environment.NewLine; 109 | s += "" + AdditionalText5.ToString() + "" + Environment.NewLine; 110 | s += "" + AdditionalText6.ToString() + "" + Environment.NewLine; 111 | s += "" + AdditionalText7.ToString() + "" + Environment.NewLine; 112 | s += "" + AdditionalText8.ToString() + "" + Environment.NewLine; 113 | s += "" + AdditionalText9.ToString() + "" + Environment.NewLine; 114 | s += "" + Environment.NewLine; 115 | return s; 116 | } 117 | } 118 | } 119 | -------------------------------------------------------------------------------- /src/S7CommPlusDriver/Alarming/AlarmsAsCgs.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | /****************************************************************************** 3 | * S7CommPlusDriver 4 | * 5 | * Copyright (C) 2023 Thomas Wiens, th.wiens@gmx.de 6 | * 7 | * This file is part of S7CommPlusDriver. 8 | * 9 | * S7CommPlusDriver is free software: you can redistribute it and/or modify 10 | * it under the terms of the GNU Lesser General Public License as 11 | * published by the Free Software Foundation, either version 3 of the 12 | * License, or (at your option) any later version. 13 | /****************************************************************************/ 14 | #endregion 15 | 16 | using System; 17 | 18 | namespace S7CommPlusDriver.Alarming 19 | { 20 | public class AlarmsAsCgs 21 | { 22 | public enum SubtypeIds 23 | { 24 | Coming = Ids.DAI_Coming, 25 | Going = Ids.DAI_Going 26 | } 27 | public uint SubtypeId; // This is not part of the class, but is neccessary to store the information: 2673 = DAI.Coming, 2677 = DAI.Going 28 | 29 | public byte AllStatesInfo; 30 | public DateTime Timestamp; 31 | public AlarmsAssociatedValues AssociatedValues; 32 | public DateTime AckTimestamp; 33 | 34 | public override string ToString() 35 | { 36 | string s = "" + Environment.NewLine; 37 | s += "" + SubtypeId.ToString() + "" + Environment.NewLine; 38 | s += "" + ((SubtypeIds)SubtypeId).ToString() + "" + Environment.NewLine; 39 | s += "" + AllStatesInfo.ToString() + "" + Environment.NewLine; 40 | s += "" + Environment.NewLine + AssociatedValues.ToString() + "" + Environment.NewLine; 41 | s += "" + Timestamp.ToString() + "" + Environment.NewLine; 42 | s += "" + AckTimestamp.ToString() + "" + Environment.NewLine; 43 | s += "" + Environment.NewLine; 44 | return s; 45 | } 46 | 47 | public static AlarmsAsCgs FromValueStruct(ValueStruct str) 48 | { 49 | var asCgs = new AlarmsAsCgs(); 50 | asCgs.AllStatesInfo = ((ValueUSInt)str.GetStructElement(Ids.AS_CGS_AllStatesInfo)).GetValue(); 51 | asCgs.Timestamp = Utils.DtFromValueTimestamp(((ValueTimestamp)str.GetStructElement(Ids.AS_CGS_Timestamp)).GetValue()); 52 | asCgs.AssociatedValues = AlarmsAssociatedValues.FromValueBlob(((ValueBlobArray)str.GetStructElement(Ids.AS_CGS_AssociatedValues))); 53 | asCgs.AckTimestamp = Utils.DtFromValueTimestamp(((ValueTimestamp)str.GetStructElement(Ids.AS_CGS_AckTimestamp)).GetValue()); 54 | return asCgs; 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/S7CommPlusDriver/Alarming/AlarmsDai.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | /****************************************************************************** 3 | * S7CommPlusDriver 4 | * 5 | * Copyright (C) 2023 Thomas Wiens, th.wiens@gmx.de 6 | * 7 | * This file is part of S7CommPlusDriver. 8 | * 9 | * S7CommPlusDriver is free software: you can redistribute it and/or modify 10 | * it under the terms of the GNU Lesser General Public License as 11 | * published by the Free Software Foundation, either version 3 of the 12 | * License, or (at your option) any later version. 13 | /****************************************************************************/ 14 | #endregion 15 | 16 | using System; 17 | 18 | namespace S7CommPlusDriver.Alarming 19 | { 20 | public class AlarmsDai 21 | { 22 | public string ObjectVariableTypeName; 23 | 24 | public ulong CpuAlarmId; 25 | public byte AllStatesInfo; 26 | public ushort AlarmDomain; 27 | public int MessageType; 28 | public uint SequenceCounter; 29 | public AlarmsAlarmTexts AlarmTexts; 30 | public AlarmsHmiInfo HmiInfo; 31 | public AlarmsAsCgs AsCgs; 32 | 33 | public override string ToString() 34 | { 35 | string s = "" + Environment.NewLine; 36 | s += "" + ObjectVariableTypeName.ToString() + "" + Environment.NewLine; 37 | s += "" + CpuAlarmId.ToString() + "" + Environment.NewLine; 38 | s += "" + AllStatesInfo.ToString() + "" + Environment.NewLine; 39 | s += "" + AlarmDomain.ToString() + "" + Environment.NewLine; 40 | s += "" + MessageType.ToString() + "" + Environment.NewLine; 41 | s += "" + Environment.NewLine + HmiInfo.ToString() + "" + Environment.NewLine; 42 | s += "" + Environment.NewLine + AsCgs.ToString() + "" + Environment.NewLine; 43 | s += "" + SequenceCounter.ToString() + "" + Environment.NewLine; 44 | if (AlarmTexts != null) 45 | { 46 | s += "" + Environment.NewLine + AlarmTexts.ToString() + "" + Environment.NewLine; 47 | } 48 | else 49 | { 50 | s += "" + Environment.NewLine; 51 | } 52 | s += "" + Environment.NewLine; 53 | return s; 54 | } 55 | 56 | public static AlarmsDai FromNotificationObject(PObject pobj, int alarmtextsLanguageId) 57 | { 58 | var dai = new AlarmsDai(); 59 | dai.ObjectVariableTypeName = ((ValueWString)pobj.GetAttribute(Ids.ObjectVariableTypeName)).GetValue(); 60 | dai.CpuAlarmId = ((ValueLWord)pobj.GetAttribute(Ids.DAI_CPUAlarmID)).GetValue(); 61 | dai.AllStatesInfo = ((ValueUSInt)pobj.GetAttribute(Ids.DAI_AllStatesInfo)).GetValue(); 62 | dai.AlarmDomain = ((ValueUInt)pobj.GetAttribute(Ids.DAI_AlarmDomain)).GetValue(); 63 | dai.MessageType = ((ValueDInt)pobj.GetAttribute(Ids.DAI_MessageType)).GetValue(); 64 | dai.HmiInfo = AlarmsHmiInfo.FromValueBlob(((ValueBlob)pobj.GetAttribute(Ids.DAI_HmiInfo))); 65 | // TODO: Blob for additional values 66 | dai.SequenceCounter = ((ValueUDInt)pobj.GetAttribute(Ids.DAI_SequenceCounter)).GetValue(); 67 | ValueStruct str = null; 68 | uint dai_id = 0; 69 | if (pobj.Attributes.ContainsKey(Ids.DAI_Coming)) 70 | { 71 | str = (ValueStruct)pobj.GetAttribute(Ids.DAI_Coming); 72 | dai_id = Ids.DAI_Coming; 73 | } 74 | else if (pobj.Attributes.ContainsKey(Ids.DAI_Going)) 75 | { 76 | str = (ValueStruct)pobj.GetAttribute(Ids.DAI_Going); 77 | dai_id = Ids.DAI_Going; 78 | } 79 | if (dai_id == 0) 80 | { 81 | return null; 82 | } 83 | dai.AsCgs = AlarmsAsCgs.FromValueStruct(str); 84 | dai.AsCgs.SubtypeId = dai_id; 85 | dai.AlarmTexts = AlarmsAlarmTexts.FromNotificationBlob(((ValueBlobSparseArray)pobj.GetAttribute(Ids.DAI_AlarmTexts_Rid)), alarmtextsLanguageId); 86 | return dai; 87 | } 88 | } 89 | } -------------------------------------------------------------------------------- /src/S7CommPlusDriver/Alarming/AlarmsHmiInfo.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | /****************************************************************************** 3 | * S7CommPlusDriver 4 | * 5 | * Copyright (C) 2023 Thomas Wiens, th.wiens@gmx.de 6 | * 7 | * This file is part of S7CommPlusDriver. 8 | * 9 | * S7CommPlusDriver is free software: you can redistribute it and/or modify 10 | * it under the terms of the GNU Lesser General Public License as 11 | * published by the Free Software Foundation, either version 3 of the 12 | * License, or (at your option) any later version. 13 | /****************************************************************************/ 14 | #endregion 15 | 16 | using System; 17 | using System.IO; 18 | 19 | namespace S7CommPlusDriver.Alarming 20 | { 21 | // 7813 = DAI.HmiInfo 22 | public class AlarmsHmiInfo 23 | { 24 | public ushort SyntaxId; 25 | public ushort Version; 26 | public uint ClientAlarmId; 27 | public byte Priority; 28 | public byte Reserved1; 29 | public byte Reserved2; 30 | public byte Reserved3; 31 | public ushort AlarmClass; 32 | public byte Producer; 33 | public byte GroupId; 34 | public byte Flags; 35 | 36 | public override string ToString() 37 | { 38 | string s = "" + Environment.NewLine; 39 | s += "" + SyntaxId.ToString() + "" + Environment.NewLine; 40 | s += "" + Version.ToString() + "" + Environment.NewLine; 41 | s += "" + ClientAlarmId.ToString() + "" + Environment.NewLine; 42 | s += "" + Priority.ToString() + "" + Environment.NewLine; 43 | if (SyntaxId >= 257) 44 | { 45 | s += "" + Reserved1.ToString() + "" + Environment.NewLine; 46 | s += "" + Reserved2.ToString() + "" + Environment.NewLine; 47 | s += "" + Reserved3.ToString() + "" + Environment.NewLine; 48 | if (SyntaxId >= 258) 49 | { 50 | s += "" + AlarmClass.ToString() + "" + Environment.NewLine; 51 | s += "" + Producer.ToString() + "" + Environment.NewLine; 52 | s += "" + GroupId.ToString() + "" + Environment.NewLine; 53 | s += "" + Flags.ToString() + "" + Environment.NewLine; 54 | } 55 | } 56 | s += "" + Environment.NewLine; 57 | return s; 58 | } 59 | 60 | public int Deserialize(Stream buffer) 61 | { 62 | int ret = 0; 63 | ret += S7p.DecodeUInt16(buffer, out SyntaxId); 64 | ret += S7p.DecodeUInt16(buffer, out Version); 65 | ret += S7p.DecodeUInt32(buffer, out ClientAlarmId); 66 | ret += S7p.DecodeByte(buffer, out Priority); 67 | if (SyntaxId >= 257) 68 | { 69 | ret += S7p.DecodeByte(buffer, out Reserved1); 70 | ret += S7p.DecodeByte(buffer, out Reserved2); 71 | ret += S7p.DecodeByte(buffer, out Reserved3); 72 | if (SyntaxId >= 258) 73 | { 74 | ret += S7p.DecodeUInt16(buffer, out AlarmClass); 75 | ret += S7p.DecodeByte(buffer, out Producer); 76 | ret += S7p.DecodeByte(buffer, out GroupId); 77 | ret += S7p.DecodeByte(buffer, out Flags); 78 | } 79 | } 80 | return ret; 81 | } 82 | 83 | public static AlarmsHmiInfo FromValueBlob(ValueBlob blob) 84 | { 85 | var hmiinfo = new AlarmsHmiInfo(); 86 | var barr = blob.GetValue(); 87 | uint pos = 0; 88 | hmiinfo.SyntaxId = Utils.GetUInt16(barr, pos); 89 | pos += 2; 90 | hmiinfo.Version = Utils.GetUInt16(barr, pos); 91 | pos += 2; 92 | hmiinfo.ClientAlarmId = Utils.GetUInt32(barr, pos); 93 | pos += 4; 94 | hmiinfo.Priority = Utils.GetUInt8(barr, pos); 95 | pos += 1; 96 | if (hmiinfo.SyntaxId >= 257) 97 | { 98 | hmiinfo.Reserved1 = Utils.GetUInt8(barr, pos); 99 | pos += 1; 100 | hmiinfo.Reserved2 = Utils.GetUInt8(barr, pos); 101 | pos += 1; 102 | hmiinfo.Reserved3 = Utils.GetUInt8(barr, pos); 103 | pos += 1; 104 | if (hmiinfo.SyntaxId >= 258) 105 | { 106 | hmiinfo.AlarmClass = Utils.GetUInt16(barr, pos); 107 | pos += 2; 108 | hmiinfo.Producer = Utils.GetUInt8(barr, pos); 109 | pos += 1; 110 | hmiinfo.GroupId = Utils.GetUInt8(barr, pos); 111 | pos += 1; 112 | hmiinfo.Flags = Utils.GetUInt8(barr, pos); 113 | pos += 1; 114 | } 115 | } 116 | return hmiinfo; 117 | } 118 | } 119 | } 120 | -------------------------------------------------------------------------------- /src/S7CommPlusDriver/Alarming/AlarmsMultipleStai.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | /****************************************************************************** 3 | * S7CommPlusDriver 4 | * 5 | * Copyright (C) 2023 Thomas Wiens, th.wiens@gmx.de 6 | * 7 | * This file is part of S7CommPlusDriver. 8 | * 9 | * S7CommPlusDriver is free software: you can redistribute it and/or modify 10 | * it under the terms of the GNU Lesser General Public License as 11 | * published by the Free Software Foundation, either version 3 of the 12 | * License, or (at your option) any later version. 13 | /****************************************************************************/ 14 | #endregion 15 | 16 | using System; 17 | using System.IO; 18 | 19 | namespace S7CommPlusDriver.Alarming 20 | { 21 | public class AlarmsMultipleStai 22 | { 23 | public ushort Alid; 24 | public ushort AlarmDomain; // 1=Systemdiagnose, 2=Security, 256..272 = UserClass_0..UserClass_16 25 | public ushort MessageType; // 1=Alarm AP, 2=Notify AP, 3=Info Report AP, 4=Event Ack AP 26 | public byte AlarmEnabled; //0=No, 1=Yes 27 | 28 | public ushort HmiInfoLength; 29 | public AlarmsHmiInfo HmiInfo; 30 | public ushort LidCount; 31 | public uint[] Lids; 32 | 33 | public override string ToString() 34 | { 35 | string s = ""; 36 | s += "" + Environment.NewLine; 37 | s += "" + Alid.ToString() + "" + Environment.NewLine; 38 | s += "" + AlarmDomain.ToString() + "" + Environment.NewLine; 39 | s += "" + MessageType.ToString() + "" + Environment.NewLine; 40 | s += "" + AlarmEnabled.ToString() + "" + Environment.NewLine; 41 | s += "" + HmiInfoLength.ToString() + "" + Environment.NewLine; 42 | s += "" + Environment.NewLine + HmiInfo.ToString() + "" + Environment.NewLine; 43 | s += "" + LidCount.ToString() + "" + Environment.NewLine; 44 | foreach (var li in Lids) 45 | { 46 | s += "" + li.ToString() + "" + Environment.NewLine; 47 | } 48 | s += "" + Environment.NewLine; 49 | return s; 50 | } 51 | 52 | public int Deserialize(Stream buffer) 53 | { 54 | int ret = 0; 55 | ret += S7p.DecodeUInt16(buffer, out Alid); 56 | ret += S7p.DecodeUInt16(buffer, out AlarmDomain); 57 | ret += S7p.DecodeUInt16(buffer, out MessageType); 58 | ret += S7p.DecodeByte(buffer, out AlarmEnabled); 59 | ret += S7p.DecodeUInt16(buffer, out HmiInfoLength); 60 | HmiInfo = new AlarmsHmiInfo(); 61 | ret += HmiInfo.Deserialize(buffer); 62 | ret += S7p.DecodeUInt16(buffer, out LidCount); 63 | Lids = new uint[LidCount]; 64 | for (int i = 0; i < LidCount; i++) 65 | { 66 | ret += S7p.DecodeUInt32(buffer, out Lids[i]); 67 | } 68 | return ret; 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /src/S7CommPlusDriver/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/S7CommPlusDriver/ClientApi/ItemAddress.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | /****************************************************************************** 3 | * S7CommPlusDriver 4 | * 5 | * Copyright (C) 2023 Thomas Wiens, th.wiens@gmx.de 6 | * 7 | * This file is part of S7CommPlusDriver. 8 | * 9 | * S7CommPlusDriver is free software: you can redistribute it and/or modify 10 | * it under the terms of the GNU Lesser General Public License as 11 | * published by the Free Software Foundation, either version 3 of the 12 | * License, or (at your option) any later version. 13 | /****************************************************************************/ 14 | #endregion 15 | 16 | using System; 17 | using System.Collections.Generic; 18 | using System.IO; 19 | using System.Linq; 20 | 21 | namespace S7CommPlusDriver 22 | { 23 | public class ItemAddress : IS7pSerialize 24 | { 25 | public UInt32 SymbolCrc; 26 | public UInt32 AccessArea; 27 | public UInt32 AccessSubArea; 28 | public List LID = new List(); 29 | 30 | public ItemAddress() : this (0, Ids.DB_ValueActual) 31 | { 32 | } 33 | 34 | public ItemAddress(UInt32 area, UInt32 subArea) 35 | { 36 | SymbolCrc = 0; 37 | AccessArea = area; 38 | AccessSubArea = subArea; 39 | } 40 | 41 | public ItemAddress(string variableAccessString) 42 | { 43 | // Uses a complete access string consisting of hexadecimal strings separated by a dot ("."). 44 | // Returns a list of the extracted IDs, e.g. 8A0E0001.A or 52.A 45 | List ids = new List(); 46 | foreach (string p in variableAccessString.Split('.')) 47 | { 48 | ids.Add(UInt32.Parse(p, System.Globalization.NumberStyles.HexNumber)); 49 | } 50 | // TODO: Check for an error, number of fields should be at least 2 51 | SymbolCrc = 0; 52 | AccessArea = ids[0]; 53 | // Set access area 54 | if (AccessArea >= 0x8A0E0000) // 0x8A0A.... = datablocks 55 | { 56 | AccessSubArea = Ids.DB_ValueActual; 57 | } 58 | else if ((AccessArea == Ids.NativeObjects_theS7Timers_Rid) || 59 | (AccessArea == Ids.NativeObjects_theS7Counters_Rid) || 60 | (AccessArea == Ids.NativeObjects_theIArea_Rid) || 61 | (AccessArea == Ids.NativeObjects_theQArea_Rid) || 62 | (AccessArea == Ids.NativeObjects_theMArea_Rid)) 63 | { 64 | AccessSubArea = Ids.ControllerArea_ValueActual; 65 | } 66 | foreach (var i in ids.Skip(1)) 67 | { 68 | LID.Add(i); 69 | } 70 | } 71 | 72 | public string GetAccessString() 73 | { 74 | // Generate from the given address an Access-String. 75 | // Useful if the user has set the address not via access string, but by the single elements. 76 | string s = String.Format("{0:X}", AccessArea); 77 | foreach(var i in LID) 78 | { 79 | s += String.Format(".{0:X}", i); 80 | } 81 | return s; 82 | } 83 | 84 | public UInt32 GetNumberOfFields() 85 | { 86 | return (UInt32)(4 + LID.Count); 87 | } 88 | 89 | public void SetAccessAreaToDatablock(UInt32 number) 90 | { 91 | AccessArea = (UInt16)number + 0x8a0e0000; 92 | } 93 | 94 | public int Serialize(Stream buffer) 95 | { 96 | int ret = 0; 97 | ret += S7p.EncodeUInt32Vlq(buffer, SymbolCrc); 98 | ret += S7p.EncodeUInt32Vlq(buffer, AccessArea); 99 | ret += S7p.EncodeUInt32Vlq(buffer, (UInt32)LID.Count + 1); 100 | ret += S7p.EncodeUInt32Vlq(buffer, AccessSubArea); 101 | foreach (UInt32 id in LID) 102 | { 103 | ret += S7p.EncodeUInt32Vlq(buffer, id); 104 | } 105 | return ret; 106 | } 107 | 108 | public override string ToString() 109 | { 110 | string s = ""; 111 | s += "" + Environment.NewLine; 112 | s += "" + SymbolCrc.ToString() + "" + Environment.NewLine; 113 | s += "" + AccessArea.ToString() + "" + Environment.NewLine; 114 | s += "" + (LID.Count + 1).ToString() + "" + Environment.NewLine; 115 | s += "" + AccessSubArea.ToString() + "" + Environment.NewLine; 116 | foreach (UInt32 id in LID) 117 | { 118 | s += "" + id.ToString() + "" + Environment.NewLine; 119 | } 120 | s += "" + Environment.NewLine; 121 | return s; 122 | } 123 | } 124 | } 125 | -------------------------------------------------------------------------------- /src/S7CommPlusDriver/ClientApi/PlcTagQC.cs: -------------------------------------------------------------------------------- 1 | namespace S7CommPlusDriver.ClientApi 2 | { 3 | // Tag Quality Codes, based on OPC DA 4 | // Quality and Sub status: QQSSSS 5 | public static class PlcTagQC 6 | { 7 | // Bit masks for Quality, Status and Limits 8 | public const short TAG_QUALITY_MASK = 0xC0; 9 | public const short TAG_STATUS_MASK = 0xFC; 10 | public const short TAG_LIMIT_MASK = 0x03; 11 | 12 | // Values for Quality 13 | public const short TAG_QUALITY_BAD = 0x00; 14 | public const short TAG_QUALITY_UNCERTAIN = 0x40; 15 | public const short TAG_QUALITY_GOOD = 0xC0; 16 | 17 | // Status bits when Quality = BAD 18 | public const short TAG_QUALITY_CONFIG_ERROR = 0x04; 19 | public const short TAG_QUALITY_NOT_CONNECTED = 0x08; 20 | public const short TAG_QUALITY_DEVICE_FAILURE = 0x0c; 21 | public const short TAG_QUALITY_SENSOR_FAILURE = 0x10; 22 | public const short TAG_QUALITY_LAST_KNOWN = 0x14; 23 | public const short TAG_QUALITY_COMM_FAILURE = 0x18; 24 | public const short TAG_QUALITY_OUT_OF_SERVICE = 0x1C; 25 | public const short TAG_QUALITY_WAITING_FOR_INITIAL_DATA = 0x20; 26 | 27 | // Status bits when Quality = UNCERTAIN 28 | public const short TAG_QUALITY_LAST_USABLE = 0x44; 29 | public const short TAG_QUALITY_SENSOR_CAL = 0x50; 30 | public const short TAG_QUALITY_EGU_EXCEEDED = 0x54; 31 | public const short TAG_QUALITY_SUB_NORMAL = 0x58; 32 | 33 | // Status bits when Quality = GOOD 34 | public const short TAG_QUALITY_LOCAL_OVERRIDE = 0xD8; 35 | 36 | // Status bits for Limit Bitfield 37 | public const short TAG_LIMIT_OK = 0x00; 38 | public const short TAG_LIMIT_LOW = 0x01; 39 | public const short TAG_LIMIT_HIGH = 0x02; 40 | public const short TAG_LIMIT_CONST = 0x03; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/S7CommPlusDriver/Core/CreateObjectRequest.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | /****************************************************************************** 3 | * S7CommPlusDriver 4 | * 5 | * Copyright (C) 2023 Thomas Wiens, th.wiens@gmx.de 6 | * 7 | * This file is part of S7CommPlusDriver. 8 | * 9 | * S7CommPlusDriver is free software: you can redistribute it and/or modify 10 | * it under the terms of the GNU Lesser General Public License as 11 | * published by the Free Software Foundation, either version 3 of the 12 | * License, or (at your option) any later version. 13 | /****************************************************************************/ 14 | #endregion 15 | 16 | using System; 17 | using System.IO; 18 | 19 | namespace S7CommPlusDriver 20 | { 21 | public class CreateObjectRequest : IS7pRequest 22 | { 23 | public byte TransportFlags = 0x36; 24 | public UInt32 RequestId; 25 | public PValue RequestValue; 26 | public PObject RequestObject; 27 | 28 | public uint SessionId { get; set; } 29 | public byte ProtocolVersion { get; set; } 30 | public ushort FunctionCode { get => Functioncode.CreateObject; } 31 | public ushort SequenceNumber { get; set; } 32 | public uint IntegrityId { get; set; } 33 | public bool WithIntegrityId { get; set; } 34 | 35 | public CreateObjectRequest(byte protocolVersion, UInt16 seqNum, bool withIntegrityId) 36 | { 37 | ProtocolVersion = protocolVersion; 38 | SequenceNumber = seqNum; 39 | WithIntegrityId = withIntegrityId; 40 | } 41 | 42 | public void SetRequestIdValue(UInt32 requestId, PValue requestValue) 43 | { 44 | RequestId = requestId; 45 | RequestValue = requestValue; 46 | } 47 | 48 | public void SetRequestObject(PObject requestObject) 49 | { 50 | RequestObject = requestObject; 51 | } 52 | 53 | public void SetNullServerSessionData() 54 | { 55 | // Initializes the data for a Nullserver Session on connection setup. 56 | // SessionId is set automatically to Ids.ObjectNullServerSession when this object is sent, if there's no session Id. 57 | TransportFlags = 0x36; 58 | RequestId = Ids.ObjectServerSessionContainer; 59 | RequestValue = new ValueUDInt(0); 60 | 61 | RequestObject = new PObject(RID: Ids.GetNewRIDOnServer, CLSID: Ids.ClassServerSession, AID: Ids.None); 62 | RequestObject.AddAttribute(Ids.ServerSessionClientRID, new ValueRID(0x80c3c901)); 63 | RequestObject.AddObject(new PObject(RID: Ids.GetNewRIDOnServer, CLSID: Ids.ClassSubscriptions, AID: Ids.None)); 64 | } 65 | 66 | public byte GetProtocolVersion() 67 | { 68 | return ProtocolVersion; 69 | } 70 | 71 | public int Serialize(Stream buffer) 72 | { 73 | int ret = 0; 74 | ret += S7p.EncodeByte(buffer, Opcode.Request); 75 | ret += S7p.EncodeUInt16(buffer, 0); 76 | ret += S7p.EncodeUInt16(buffer, FunctionCode); 77 | ret += S7p.EncodeUInt16(buffer, 0); 78 | ret += S7p.EncodeUInt16(buffer, SequenceNumber); 79 | ret += S7p.EncodeUInt32(buffer, SessionId); 80 | ret += S7p.EncodeByte(buffer, TransportFlags); 81 | 82 | // Request set 83 | ret += S7p.EncodeUInt32(buffer, RequestId); 84 | ret += RequestValue.Serialize(buffer); 85 | ret += S7p.EncodeUInt32(buffer, 0); // Unknown value 1 86 | 87 | if (WithIntegrityId) 88 | { 89 | ret += S7p.EncodeUInt32Vlq(buffer, IntegrityId); 90 | } 91 | 92 | // Object 93 | ret += RequestObject.Serialize(buffer); 94 | 95 | // Fill? 96 | ret += S7p.EncodeUInt32(buffer, 0); 97 | return ret; 98 | } 99 | 100 | public override string ToString() 101 | { 102 | string s = ""; 103 | s += "" + Environment.NewLine; 104 | s += "" + ProtocolVersion.ToString() + "" + Environment.NewLine; 105 | s += "" + SequenceNumber.ToString() + "" + Environment.NewLine; 106 | s += "" + SessionId.ToString() + "" + Environment.NewLine; 107 | s += "" + TransportFlags.ToString() + "" + Environment.NewLine; 108 | s += "" + Environment.NewLine; 109 | s += "" + RequestId.ToString() + "" + Environment.NewLine; 110 | s += "" + RequestValue.ToString() + "" + Environment.NewLine; 111 | s += "" + RequestObject.ToString() + "" + Environment.NewLine; 112 | s += "" + Environment.NewLine; 113 | s += "" + Environment.NewLine; 114 | return s; 115 | } 116 | } 117 | } 118 | -------------------------------------------------------------------------------- /src/S7CommPlusDriver/Core/CreateObjectResponse.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | /****************************************************************************** 3 | * S7CommPlusDriver 4 | * 5 | * Copyright (C) 2023 Thomas Wiens, th.wiens@gmx.de 6 | * 7 | * This file is part of S7CommPlusDriver. 8 | * 9 | * S7CommPlusDriver is free software: you can redistribute it and/or modify 10 | * it under the terms of the GNU Lesser General Public License as 11 | * published by the Free Software Foundation, either version 3 of the 12 | * License, or (at your option) any later version. 13 | /****************************************************************************/ 14 | #endregion 15 | 16 | using System; 17 | using System.Collections.Generic; 18 | using System.IO; 19 | 20 | namespace S7CommPlusDriver 21 | { 22 | public class CreateObjectResponse : IS7pResponse 23 | { 24 | public byte TransportFlags; 25 | public UInt64 ReturnValue; 26 | public byte ObjectIdCount; 27 | public List ObjectIds; 28 | public PObject ResponseObject; 29 | 30 | public byte ProtocolVersion { get; set; } 31 | public ushort FunctionCode { get => Functioncode.CreateObject; } 32 | public ushort SequenceNumber { get; set; } 33 | public uint IntegrityId { get; set; } 34 | public bool WithIntegrityId { get; set; } 35 | 36 | public CreateObjectResponse(byte protocolVersion) 37 | { 38 | ProtocolVersion = protocolVersion; 39 | WithIntegrityId = false; 40 | } 41 | 42 | public int Deserialize(Stream buffer) 43 | { 44 | int ret = 0; 45 | UInt32 object_id = 0; 46 | ret += S7p.DecodeUInt16(buffer, out ushort seqnr); 47 | SequenceNumber = seqnr; 48 | ret += S7p.DecodeByte(buffer, out TransportFlags); 49 | 50 | // Response Set 51 | ret += S7p.DecodeUInt64Vlq(buffer, out ReturnValue); 52 | ret += S7p.DecodeByte(buffer, out ObjectIdCount); 53 | 54 | ObjectIds = new List(ObjectIdCount); 55 | for (int i = 0; i < ObjectIdCount; i++) 56 | { 57 | ret += S7p.DecodeUInt32Vlq(buffer, out object_id); 58 | ObjectIds.Add(object_id); 59 | } 60 | ret += S7p.DecodeObject(buffer, ref ResponseObject); 61 | return ret; 62 | } 63 | 64 | public override string ToString() 65 | { 66 | string s = ""; 67 | s += "" + Environment.NewLine; 68 | s += "" + ProtocolVersion.ToString() + "" + Environment.NewLine; 69 | s += "" + SequenceNumber.ToString() + "" + Environment.NewLine; 70 | s += "" + TransportFlags.ToString() + "" + Environment.NewLine; 71 | s += "" + Environment.NewLine; 72 | s += "" + ReturnValue.ToString() + "" + Environment.NewLine; 73 | s += "" + ObjectIdCount.ToString() + "" + Environment.NewLine; 74 | foreach (UInt32 id in ObjectIds) 75 | { 76 | s += "" + id.ToString() + "" + Environment.NewLine; 77 | } 78 | s += "" + ResponseObject.ToString() + "" + Environment.NewLine; 79 | s += "" + Environment.NewLine; 80 | s += "" + Environment.NewLine; 81 | return s; 82 | } 83 | 84 | public static CreateObjectResponse DeserializeFromPdu(Stream pdu) 85 | { 86 | byte protocolVersion; 87 | byte opcode; 88 | UInt16 function; 89 | UInt16 reserved; 90 | // Special handling of ProtocolVersion, which is written to the stream before 91 | S7p.DecodeByte(pdu, out protocolVersion); 92 | 93 | S7p.DecodeByte(pdu, out opcode); 94 | if (opcode != Opcode.Response) 95 | { 96 | return null; 97 | } 98 | S7p.DecodeUInt16(pdu, out reserved); 99 | S7p.DecodeUInt16(pdu, out function); 100 | S7p.DecodeUInt16(pdu, out reserved); 101 | if (function != Functioncode.CreateObject) 102 | { 103 | return null; 104 | } 105 | CreateObjectResponse resp = new CreateObjectResponse(protocolVersion); 106 | resp.Deserialize(pdu); 107 | return resp; 108 | } 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /src/S7CommPlusDriver/Core/Datatype.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | /****************************************************************************** 3 | * S7CommPlusDriver 4 | * 5 | * Copyright (C) 2023 Thomas Wiens, th.wiens@gmx.de 6 | * 7 | * This file is part of S7CommPlusDriver. 8 | * 9 | * S7CommPlusDriver is free software: you can redistribute it and/or modify 10 | * it under the terms of the GNU Lesser General Public License as 11 | * published by the Free Software Foundation, either version 3 of the 12 | * License, or (at your option) any later version. 13 | /****************************************************************************/ 14 | #endregion 15 | 16 | namespace S7CommPlusDriver 17 | { 18 | public static class Datatype 19 | { 20 | public const byte Null = 0x00; 21 | public const byte Bool = 0x01; 22 | public const byte USInt = 0x02; 23 | public const byte UInt = 0x03; 24 | public const byte UDInt = 0x04; 25 | public const byte ULInt = 0x05; 26 | public const byte SInt = 0x06; 27 | public const byte Int = 0x07; 28 | public const byte DInt = 0x08; 29 | public const byte LInt = 0x09; 30 | public const byte Byte = 0x0a; 31 | public const byte Word = 0x0b; 32 | public const byte DWord = 0x0c; 33 | public const byte LWord = 0x0d; 34 | public const byte Real = 0x0e; 35 | public const byte LReal = 0x0f; 36 | public const byte Timestamp = 0x10; 37 | public const byte Timespan = 0x11; 38 | public const byte RID = 0x12; 39 | public const byte AID = 0x13; 40 | public const byte Blob = 0x14; 41 | public const byte WString = 0x15; 42 | public const byte Variant = 0x16; 43 | public const byte Struct = 0x17; 44 | public const byte S7String = 0x19; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/S7CommPlusDriver/Core/DeleteObjectRequest.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | /****************************************************************************** 3 | * S7CommPlusDriver 4 | * 5 | * Copyright (C) 2023 Thomas Wiens, th.wiens@gmx.de 6 | * 7 | * This file is part of S7CommPlusDriver. 8 | * 9 | * S7CommPlusDriver is free software: you can redistribute it and/or modify 10 | * it under the terms of the GNU Lesser General Public License as 11 | * published by the Free Software Foundation, either version 3 of the 12 | * License, or (at your option) any later version. 13 | /****************************************************************************/ 14 | #endregion 15 | 16 | using System; 17 | using System.IO; 18 | 19 | namespace S7CommPlusDriver 20 | { 21 | public class DeleteObjectRequest : IS7pRequest 22 | { 23 | byte TransportFlags = 0x34; 24 | public UInt32 DeleteObjectId; 25 | 26 | public uint SessionId { get; set; } 27 | public byte ProtocolVersion { get; set; } 28 | public ushort FunctionCode { get => Functioncode.DeleteObject; } 29 | public ushort SequenceNumber { get; set; } 30 | public uint IntegrityId { get; set; } 31 | public bool WithIntegrityId { get; set; } 32 | 33 | public DeleteObjectRequest(byte protocolVersion) 34 | { 35 | ProtocolVersion = protocolVersion; 36 | WithIntegrityId = true; 37 | } 38 | 39 | public byte GetProtocolVersion() 40 | { 41 | return ProtocolVersion; 42 | } 43 | 44 | public int Serialize(Stream buffer) 45 | { 46 | int ret = 0; 47 | ret += S7p.EncodeByte(buffer, Opcode.Request); 48 | ret += S7p.EncodeUInt16(buffer, 0); 49 | ret += S7p.EncodeUInt16(buffer, FunctionCode); 50 | ret += S7p.EncodeUInt16(buffer, 0); 51 | ret += S7p.EncodeUInt16(buffer, SequenceNumber); 52 | ret += S7p.EncodeUInt32(buffer, SessionId); 53 | ret += S7p.EncodeByte(buffer, TransportFlags); 54 | 55 | ret += S7p.EncodeUInt32(buffer, DeleteObjectId); 56 | ret += S7p.EncodeByte(buffer, 0x00); 57 | 58 | ret += S7p.EncodeObjectQualifier(buffer); 59 | 60 | if (WithIntegrityId) 61 | { 62 | ret += S7p.EncodeUInt32Vlq(buffer, IntegrityId); 63 | } 64 | 65 | // Fill? 66 | ret += S7p.EncodeUInt32(buffer, 0); 67 | return ret; 68 | } 69 | 70 | public override string ToString() 71 | { 72 | string s = ""; 73 | s += "" + Environment.NewLine; 74 | s += "" + ProtocolVersion.ToString() + "" + Environment.NewLine; 75 | s += "" + SequenceNumber.ToString() + "" + Environment.NewLine; 76 | s += "" + SessionId.ToString() + "" + Environment.NewLine; 77 | s += "" + TransportFlags.ToString() + "" + Environment.NewLine; 78 | s += "" + Environment.NewLine; 79 | s += "" + DeleteObjectId.ToString() + "" + Environment.NewLine; 80 | s += "" + Environment.NewLine; 81 | s += "" + Environment.NewLine; 82 | return s; 83 | } 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /src/S7CommPlusDriver/Core/DeleteObjectResponse.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | /****************************************************************************** 3 | * S7CommPlusDriver 4 | * 5 | * Copyright (C) 2023 Thomas Wiens, th.wiens@gmx.de 6 | * 7 | * This file is part of S7CommPlusDriver. 8 | * 9 | * S7CommPlusDriver is free software: you can redistribute it and/or modify 10 | * it under the terms of the GNU Lesser General Public License as 11 | * published by the Free Software Foundation, either version 3 of the 12 | * License, or (at your option) any later version. 13 | /****************************************************************************/ 14 | #endregion 15 | 16 | using System; 17 | using System.IO; 18 | 19 | namespace S7CommPlusDriver 20 | { 21 | public class DeleteObjectResponse : IS7pResponse 22 | { 23 | public byte TransportFlags; 24 | public UInt64 ReturnValue; 25 | public UInt32 DeleteObjectId; 26 | 27 | public byte ProtocolVersion { get; set; } 28 | public ushort FunctionCode { get => Functioncode.DeleteObject; } 29 | public ushort SequenceNumber { get; set; } 30 | public uint IntegrityId { get; set; } 31 | public bool WithIntegrityId { get; set; } 32 | 33 | public DeleteObjectResponse(byte protocolVersion, bool withIntegrityId) 34 | { 35 | ProtocolVersion = protocolVersion; 36 | WithIntegrityId = withIntegrityId; // When deleting the Sesssion Object-Id, there's no Integrity-Id! 37 | } 38 | 39 | public int Deserialize(Stream buffer) 40 | { 41 | int ret = 0; 42 | ret += S7p.DecodeUInt16(buffer, out ushort seqnr); 43 | SequenceNumber = seqnr; 44 | ret += S7p.DecodeByte(buffer, out TransportFlags); 45 | 46 | // Response Set 47 | ret += S7p.DecodeUInt64Vlq(buffer, out ReturnValue); 48 | ret += S7p.DecodeUInt32(buffer, out DeleteObjectId); 49 | if ((ReturnValue & 0x4000000000000000) > 0) // Error Extension 50 | { 51 | // Decode the error object, but don't use any informations from it. Must be processed on a higher level. 52 | PObject errorObject = new PObject(); 53 | ret += S7p.DecodeObject(buffer, ref errorObject); 54 | } 55 | if (WithIntegrityId) 56 | { 57 | ret += S7p.DecodeUInt32Vlq(buffer, out uint iid); 58 | IntegrityId = iid; 59 | } 60 | return ret; 61 | } 62 | 63 | public override string ToString() 64 | { 65 | string s = ""; 66 | s += "" + Environment.NewLine; 67 | s += "" + ProtocolVersion.ToString() + "" + Environment.NewLine; 68 | s += "" + SequenceNumber.ToString() + "" + Environment.NewLine; 69 | s += "" + TransportFlags.ToString() + "" + Environment.NewLine; 70 | s += "" + Environment.NewLine; 71 | s += "" + ReturnValue.ToString() + "" + Environment.NewLine; 72 | s += "" + DeleteObjectId.ToString() + "" + Environment.NewLine; 73 | s += "" + Environment.NewLine; 74 | s += "" + WithIntegrityId.ToString() + "" + Environment.NewLine; 75 | s += "" + IntegrityId.ToString() + "" + Environment.NewLine; 76 | s += "" + Environment.NewLine; 77 | return s; 78 | } 79 | 80 | public static DeleteObjectResponse DeserializeFromPdu(Stream pdu, bool withIntegrityId) 81 | { 82 | byte protocolVersion; 83 | byte opcode; 84 | UInt16 function; 85 | UInt16 reserved; 86 | // Special handling of ProtocolVersion, which is written to the stream before 87 | S7p.DecodeByte(pdu, out protocolVersion); 88 | S7p.DecodeByte(pdu, out opcode); 89 | if (opcode != Opcode.Response) 90 | { 91 | return null; 92 | } 93 | S7p.DecodeUInt16(pdu, out reserved); 94 | S7p.DecodeUInt16(pdu, out function); 95 | S7p.DecodeUInt16(pdu, out reserved); 96 | if (function != Functioncode.DeleteObject) 97 | { 98 | return null; 99 | } 100 | DeleteObjectResponse resp = new DeleteObjectResponse(protocolVersion, withIntegrityId); 101 | resp.Deserialize(pdu); 102 | 103 | return resp; 104 | } 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /src/S7CommPlusDriver/Core/ElementID.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | /****************************************************************************** 3 | * S7CommPlusDriver 4 | * 5 | * Copyright (C) 2023 Thomas Wiens, th.wiens@gmx.de 6 | * 7 | * This file is part of S7CommPlusDriver. 8 | * 9 | * S7CommPlusDriver is free software: you can redistribute it and/or modify 10 | * it under the terms of the GNU Lesser General Public License as 11 | * published by the Free Software Foundation, either version 3 of the 12 | * License, or (at your option) any later version. 13 | /****************************************************************************/ 14 | #endregion 15 | 16 | namespace S7CommPlusDriver 17 | { 18 | public static class ElementID 19 | { 20 | public const byte StartOfObject = 0xa1; 21 | public const byte TerminatingObject = 0xa2; 22 | public const byte Attribute = 0xa3; 23 | public const byte Relation = 0xa4; 24 | public const byte StartOfTagDescription = 0xa7; 25 | public const byte TerminatingTagDescription = 0xa8; 26 | public const byte VartypeList = 0xab; 27 | public const byte VarnameList = 0xac; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/S7CommPlusDriver/Core/ExploreRequest.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | /****************************************************************************** 3 | * S7CommPlusDriver 4 | * 5 | * Copyright (C) 2023 Thomas Wiens, th.wiens@gmx.de 6 | * 7 | * This file is part of S7CommPlusDriver. 8 | * 9 | * S7CommPlusDriver is free software: you can redistribute it and/or modify 10 | * it under the terms of the GNU Lesser General Public License as 11 | * published by the Free Software Foundation, either version 3 of the 12 | * License, or (at your option) any later version. 13 | /****************************************************************************/ 14 | #endregion 15 | 16 | using System; 17 | using System.Collections.Generic; 18 | using System.IO; 19 | 20 | namespace S7CommPlusDriver 21 | { 22 | public class ExploreRequest : IS7pRequest 23 | { 24 | byte TransportFlags = 0x34; // or 0x36??? 25 | public UInt32 ExploreId; 26 | public UInt32 ExploreRequestId; 27 | public byte ExploreChildsRecursive; 28 | public byte ExploreParents; 29 | public ValueStruct FilterData; 30 | public List AddressList = new List(); 31 | 32 | public uint SessionId { get; set; } 33 | public byte ProtocolVersion { get; set; } 34 | public ushort FunctionCode { get => Functioncode.Explore; } 35 | public ushort SequenceNumber { get; set; } 36 | public uint IntegrityId { get; set; } 37 | public bool WithIntegrityId { get; set; } 38 | 39 | public ExploreRequest(byte protocolVersion) 40 | { 41 | ProtocolVersion = protocolVersion; 42 | WithIntegrityId = true; 43 | } 44 | 45 | public byte GetProtocolVersion() 46 | { 47 | return ProtocolVersion; 48 | } 49 | 50 | public int Serialize(Stream buffer) 51 | { 52 | int ret = 0; 53 | ret += S7p.EncodeByte(buffer, Opcode.Request); 54 | ret += S7p.EncodeUInt16(buffer, 0); // Reserved 55 | ret += S7p.EncodeUInt16(buffer, FunctionCode); 56 | ret += S7p.EncodeUInt16(buffer, 0); // Reserved 57 | ret += S7p.EncodeUInt16(buffer, SequenceNumber); 58 | ret += S7p.EncodeUInt32(buffer, SessionId); 59 | ret += S7p.EncodeByte(buffer, TransportFlags); 60 | 61 | // Request set 62 | ret += S7p.EncodeUInt32(buffer, ExploreId); 63 | ret += S7p.EncodeUInt32Vlq(buffer, ExploreRequestId); 64 | ret += S7p.EncodeByte(buffer, ExploreChildsRecursive); 65 | ret += S7p.EncodeByte(buffer, 1); // unknown 0 or 1? 66 | ret += S7p.EncodeByte(buffer, ExploreParents); 67 | 68 | if (FilterData != null) 69 | { 70 | ret += S7p.EncodeByte(buffer, 1); // 1 object / value 71 | 72 | // TODO / Experimental: 73 | // Not 100% sure about how this has to be used: 74 | // On a Struct, we don't write the datatypeflags into the stream. 75 | // Maybe the byte before are the flags (which is the way I have it in the Wireshark dissector so far, which may be wrong). 76 | // To get this working, the byte which gas given the number of addresses isn't written to the stream anymore. 77 | // ret += S7p.EncodeByte(buffer, 0); // 0 address 78 | ret += FilterData.Serialize(buffer); 79 | } 80 | 81 | ret += S7p.EncodeByte(buffer, 0); // Number of following Objects / unknown 82 | 83 | ret += S7p.EncodeUInt32Vlq(buffer, (UInt32)AddressList.Count); // in Wireshark Dissector only 1 Byte, but maybe a VLQ 84 | foreach (UInt32 id in AddressList) 85 | { 86 | ret += S7p.EncodeUInt32Vlq(buffer, id); 87 | } 88 | if (WithIntegrityId) 89 | { 90 | ret += S7p.EncodeUInt32Vlq(buffer, IntegrityId); 91 | } 92 | // Fill? 93 | ret += S7p.EncodeUInt32(buffer, 0); 94 | // Plcsim V13 with Integrity Id needs here 5 Bytes, with 4 doesn't work (not responding). 95 | // But with my old 1200er FW2.2 it's still working with 4. 96 | ret += S7p.EncodeByte(buffer, 0); 97 | 98 | return ret; 99 | } 100 | 101 | public override string ToString() 102 | { 103 | string s = ""; 104 | s += "" + Environment.NewLine; 105 | s += "" + ProtocolVersion.ToString() + "" + Environment.NewLine; 106 | s += "" + SequenceNumber.ToString() + "" + Environment.NewLine; 107 | s += "" + SessionId.ToString() + "" + Environment.NewLine; 108 | s += "" + TransportFlags.ToString() + "" + Environment.NewLine; 109 | s += "" + Environment.NewLine; 110 | s += "" + ExploreId.ToString() + "" + Environment.NewLine; 111 | s += "" + ExploreRequestId.ToString() + "" + Environment.NewLine; 112 | s += "" + ExploreChildsRecursive.ToString() + "" + Environment.NewLine; 113 | s += "" + ExploreParents.ToString() + "" + Environment.NewLine; 114 | s += "" + Environment.NewLine; 115 | foreach (UInt32 id in AddressList) 116 | { 117 | s += "" + id.ToString() + ""; 118 | } 119 | s += "" + Environment.NewLine; 120 | s += "" + Environment.NewLine; 121 | s += "" + Environment.NewLine; 122 | return s; 123 | } 124 | } 125 | } 126 | -------------------------------------------------------------------------------- /src/S7CommPlusDriver/Core/ExploreResponse.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | /****************************************************************************** 3 | * S7CommPlusDriver 4 | * 5 | * Copyright (C) 2023 Thomas Wiens, th.wiens@gmx.de 6 | * 7 | * This file is part of S7CommPlusDriver. 8 | * 9 | * S7CommPlusDriver is free software: you can redistribute it and/or modify 10 | * it under the terms of the GNU Lesser General Public License as 11 | * published by the Free Software Foundation, either version 3 of the 12 | * License, or (at your option) any later version. 13 | /****************************************************************************/ 14 | #endregion 15 | 16 | using System; 17 | using System.IO; 18 | using System.Collections.Generic; 19 | 20 | namespace S7CommPlusDriver 21 | { 22 | public class ExploreResponse : IS7pResponse 23 | { 24 | public byte TransportFlags; 25 | public UInt64 ReturnValue; 26 | public UInt32 ExploreId; 27 | public List Objects; 28 | 29 | public byte ProtocolVersion { get; set; } 30 | public ushort FunctionCode { get => Functioncode.Explore; } 31 | public ushort SequenceNumber { get; set; } 32 | public uint IntegrityId { get; set; } 33 | public bool WithIntegrityId { get; set; } 34 | 35 | public ExploreResponse(byte protocolVersion) 36 | { 37 | ProtocolVersion = protocolVersion; 38 | } 39 | 40 | public int Deserialize(Stream buffer) 41 | { 42 | int ret = 0; 43 | 44 | ret += S7p.DecodeUInt16(buffer, out ushort seqnr); 45 | SequenceNumber = seqnr; 46 | ret += S7p.DecodeByte(buffer, out TransportFlags); 47 | 48 | // Response Set 49 | ret += S7p.DecodeUInt64Vlq(buffer, out ReturnValue); 50 | ret += S7p.DecodeUInt32(buffer, out ExploreId); 51 | 52 | if (WithIntegrityId) 53 | { 54 | ret += S7p.DecodeUInt32Vlq(buffer, out uint iid); 55 | IntegrityId = iid; 56 | } 57 | 58 | // This is a List of objects 59 | Objects = new List(); 60 | ret += S7p.DecodeObjectList(buffer, ref Objects); 61 | return ret; 62 | } 63 | 64 | public override string ToString() 65 | { 66 | string s = ""; 67 | s += "" + Environment.NewLine; 68 | s += "" + ProtocolVersion.ToString() + "" + Environment.NewLine; 69 | s += "" + SequenceNumber.ToString() + "" + Environment.NewLine; 70 | s += "" + TransportFlags.ToString() + "" + Environment.NewLine; 71 | s += "" + Environment.NewLine; 72 | s += "" + ReturnValue.ToString() + "" + Environment.NewLine; 73 | s += "" + ExploreId.ToString() + "" + Environment.NewLine; 74 | s += ""; 75 | foreach (var obj in Objects) 76 | { 77 | s += obj.ToString(); 78 | } 79 | s += "" + Environment.NewLine; 80 | s += "" + Environment.NewLine; 81 | s += "" + Environment.NewLine; 82 | return s; 83 | } 84 | 85 | public static ExploreResponse DeserializeFromPdu(Stream pdu, bool withIntegrityId) 86 | { 87 | byte protocolVersion; 88 | byte opcode; 89 | UInt16 function; 90 | UInt16 reserved; 91 | // Special handling of ProtocolVersion, which is written to the stream before 92 | S7p.DecodeByte(pdu, out protocolVersion); 93 | S7p.DecodeByte(pdu, out opcode); 94 | if (opcode != Opcode.Response) 95 | { 96 | return null; 97 | } 98 | S7p.DecodeUInt16(pdu, out reserved); 99 | S7p.DecodeUInt16(pdu, out function); 100 | S7p.DecodeUInt16(pdu, out reserved); 101 | if (function != Functioncode.Explore) 102 | { 103 | return null; 104 | } 105 | ExploreResponse resp = new ExploreResponse(protocolVersion); 106 | resp.WithIntegrityId = withIntegrityId; 107 | resp.Deserialize(pdu); 108 | 109 | return resp; 110 | } 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /src/S7CommPlusDriver/Core/Functioncode.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | /****************************************************************************** 3 | * S7CommPlusDriver 4 | * 5 | * Copyright (C) 2023 Thomas Wiens, th.wiens@gmx.de 6 | * 7 | * This file is part of S7CommPlusDriver. 8 | * 9 | * S7CommPlusDriver is free software: you can redistribute it and/or modify 10 | * it under the terms of the GNU Lesser General Public License as 11 | * published by the Free Software Foundation, either version 3 of the 12 | * License, or (at your option) any later version. 13 | /****************************************************************************/ 14 | #endregion 15 | 16 | namespace S7CommPlusDriver 17 | { 18 | public static class Functioncode 19 | { 20 | public const int Error = 0x04b1; 21 | public const int Explore = 0x04bb; 22 | public const int CreateObject = 0x04ca; 23 | public const int DeleteObject = 0x04d4; 24 | public const int SetVariable = 0x04f2; 25 | public const int GetVariable = 0x04fc; /* only in old 1200 FW? */ 26 | public const int AddLink = 0x0506; 27 | public const int RemoveLink = 0x051a; 28 | public const int GetLink = 0x0524; 29 | public const int SetMultiVariables = 0x0542; 30 | public const int GetMultiVariables = 0x054c; 31 | public const int BeginSequence = 0x0556; 32 | public const int EndSequence = 0x0560; 33 | public const int Invoke = 0x056b; 34 | public const int SetVarSubStreamed = 0x057c; 35 | public const int GetVarSubStreamed = 0x0586; 36 | public const int GetVariablesAddress = 0x0590; 37 | public const int Abort = 0x059a; 38 | public const int Error2 = 0x05a9; 39 | public const int InitSsl = 0x05b3; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/S7CommPlusDriver/Core/GetMultiVariablesRequest.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | /****************************************************************************** 3 | * S7CommPlusDriver 4 | * 5 | * Copyright (C) 2023 Thomas Wiens, th.wiens@gmx.de 6 | * 7 | * This file is part of S7CommPlusDriver. 8 | * 9 | * S7CommPlusDriver is free software: you can redistribute it and/or modify 10 | * it under the terms of the GNU Lesser General Public License as 11 | * published by the Free Software Foundation, either version 3 of the 12 | * License, or (at your option) any later version. 13 | /****************************************************************************/ 14 | #endregion 15 | 16 | using System; 17 | using System.Collections.Generic; 18 | using System.IO; 19 | 20 | namespace S7CommPlusDriver 21 | { 22 | class GetMultiVariablesRequest : IS7pRequest 23 | { 24 | byte TransportFlags = 0x34; 25 | public UInt32 LinkId = 0; // for reading variables, this should be 0 26 | public List AddressList = new List(); 27 | 28 | public uint SessionId { get; set; } 29 | public byte ProtocolVersion { get; set; } 30 | public ushort FunctionCode { get => Functioncode.GetMultiVariables; } 31 | public ushort SequenceNumber { get; set; } 32 | public uint IntegrityId { get; set; } 33 | public bool WithIntegrityId { get; set; } 34 | 35 | public GetMultiVariablesRequest(byte protocolVersion) 36 | { 37 | ProtocolVersion = protocolVersion; 38 | WithIntegrityId = true; 39 | } 40 | 41 | public byte GetProtocolVersion() 42 | { 43 | return ProtocolVersion; 44 | } 45 | 46 | public int Serialize(Stream buffer) 47 | { 48 | int ret = 0; 49 | UInt32 fieldCount = 0; 50 | ret += S7p.EncodeByte(buffer, Opcode.Request); 51 | ret += S7p.EncodeUInt16(buffer, 0); // Reserved 52 | ret += S7p.EncodeUInt16(buffer, FunctionCode); 53 | ret += S7p.EncodeUInt16(buffer, 0); // Reserved 54 | ret += S7p.EncodeUInt16(buffer, SequenceNumber); 55 | ret += S7p.EncodeUInt32(buffer, SessionId); 56 | ret += S7p.EncodeByte(buffer, TransportFlags); 57 | 58 | // Request set 59 | ret += S7p.EncodeUInt32(buffer, LinkId); 60 | ret += S7p.EncodeUInt32Vlq(buffer, (UInt32)AddressList.Count); 61 | foreach (ItemAddress adr in AddressList) 62 | { 63 | fieldCount += adr.GetNumberOfFields(); 64 | } 65 | ret += S7p.EncodeUInt32Vlq(buffer, fieldCount); 66 | 67 | foreach (ItemAddress adr in AddressList) 68 | { 69 | ret += adr.Serialize(buffer); 70 | } 71 | ret += S7p.EncodeObjectQualifier(buffer); 72 | 73 | if (WithIntegrityId) 74 | { 75 | ret += S7p.EncodeUInt32Vlq(buffer, IntegrityId); 76 | } 77 | // Fill? 78 | ret += S7p.EncodeUInt32(buffer, 0); 79 | 80 | return ret; 81 | } 82 | 83 | public override string ToString() 84 | { 85 | string s = ""; 86 | s += "" + Environment.NewLine; 87 | s += "" + ProtocolVersion.ToString() + "" + Environment.NewLine; 88 | s += "" + SequenceNumber.ToString() + "" + Environment.NewLine; 89 | s += "" + SessionId.ToString() + "" + Environment.NewLine; 90 | s += "" + TransportFlags.ToString() + "" + Environment.NewLine; 91 | s += "" + Environment.NewLine; 92 | s += "" + LinkId.ToString() + "" + Environment.NewLine; 93 | s += "" + AddressList.Count.ToString() + "" + Environment.NewLine; 94 | UInt32 fieldCount = 0; 95 | foreach (ItemAddress adr in AddressList) 96 | { 97 | fieldCount += adr.GetNumberOfFields(); 98 | } 99 | s += "" + fieldCount.ToString() + "" + Environment.NewLine; 100 | s += "" + Environment.NewLine; 101 | foreach (ItemAddress adr in AddressList) 102 | { 103 | s += adr.ToString(); 104 | } 105 | s += "" + Environment.NewLine; 106 | s += "" + Environment.NewLine; 107 | s += "" + Environment.NewLine; 108 | return s; 109 | } 110 | } 111 | } 112 | -------------------------------------------------------------------------------- /src/S7CommPlusDriver/Core/GetMultiVariablesResponse.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | /****************************************************************************** 3 | * S7CommPlusDriver 4 | * 5 | * Copyright (C) 2023 Thomas Wiens, th.wiens@gmx.de 6 | * 7 | * This file is part of S7CommPlusDriver. 8 | * 9 | * S7CommPlusDriver is free software: you can redistribute it and/or modify 10 | * it under the terms of the GNU Lesser General Public License as 11 | * published by the Free Software Foundation, either version 3 of the 12 | * License, or (at your option) any later version. 13 | /****************************************************************************/ 14 | #endregion 15 | 16 | using System; 17 | using System.Collections.Generic; 18 | using System.IO; 19 | 20 | namespace S7CommPlusDriver 21 | { 22 | public class GetMultiVariablesResponse : IS7pResponse 23 | { 24 | public byte TransportFlags; 25 | public UInt64 ReturnValue; 26 | public Dictionary Values; // ItemNumber, Value 27 | public Dictionary ErrorValues; // ItemNumber, ReturnValue 28 | 29 | public byte ProtocolVersion { get; set; } 30 | public ushort FunctionCode { get => Functioncode.GetMultiVariables; } 31 | public ushort SequenceNumber { get; set; } 32 | public uint IntegrityId { get; set; } 33 | public bool WithIntegrityId { get; set; } 34 | 35 | public GetMultiVariablesResponse(byte protocolVersion) 36 | { 37 | ProtocolVersion = protocolVersion; 38 | ErrorValues = new Dictionary(); 39 | Values = new Dictionary(); 40 | WithIntegrityId = true; 41 | } 42 | 43 | public int Deserialize(Stream buffer) 44 | { 45 | int ret = 0; 46 | UInt32 itemnr = 0; 47 | UInt64 retval = 0; 48 | 49 | ret += S7p.DecodeUInt16(buffer, out ushort seqnr); 50 | SequenceNumber = seqnr; 51 | ret += S7p.DecodeByte(buffer, out TransportFlags); 52 | 53 | // Response Set 54 | ret += S7p.DecodeUInt64Vlq(buffer, out ReturnValue); 55 | ErrorValues.Clear(); 56 | 57 | // ValueList 58 | ret += S7p.DecodeUInt32Vlq(buffer, out itemnr); 59 | while (itemnr > 0) 60 | { 61 | PValue v = PValue.Deserialize(buffer); 62 | Values.Add(itemnr, v); 63 | ret += S7p.DecodeUInt32Vlq(buffer, out itemnr); 64 | } 65 | 66 | // ErrorvalueList 67 | ret += S7p.DecodeUInt32Vlq(buffer, out itemnr); 68 | while (itemnr > 0) 69 | { 70 | ret += S7p.DecodeUInt64Vlq(buffer, out retval); 71 | ErrorValues.Add(itemnr, retval); 72 | ret += S7p.DecodeUInt32Vlq(buffer, out itemnr); 73 | } 74 | ret += S7p.DecodeUInt32Vlq(buffer, out uint iid); 75 | IntegrityId = iid; 76 | return ret; 77 | } 78 | 79 | public override string ToString() 80 | { 81 | string s = ""; 82 | s += "" + Environment.NewLine; 83 | s += "" + ProtocolVersion.ToString() + "" + Environment.NewLine; 84 | s += "" + SequenceNumber.ToString() + "" + Environment.NewLine; 85 | s += "" + TransportFlags.ToString() + "" + Environment.NewLine; 86 | s += "" + Environment.NewLine; 87 | s += "" + ReturnValue.ToString() + "" + Environment.NewLine; 88 | 89 | s += "" + Environment.NewLine; 90 | foreach (var value in Values) 91 | { 92 | s += "" + Environment.NewLine; 93 | s += "" + value.Key.ToString() + "" + Environment.NewLine; 94 | s += value.Value.ToString(); 95 | s += "" + Environment.NewLine; 96 | } 97 | s += "" + Environment.NewLine; 98 | 99 | s += "" + Environment.NewLine; 100 | foreach (var errval in ErrorValues) 101 | { 102 | s += "" + Environment.NewLine; 103 | s += "" + errval.Key.ToString() + "" + Environment.NewLine; 104 | s += "" + errval.Value.ToString() + "" + Environment.NewLine; 105 | s += "" + Environment.NewLine; 106 | } 107 | s += "" + Environment.NewLine; 108 | s += "" + Environment.NewLine; 109 | s += "" + IntegrityId.ToString() + "" + Environment.NewLine; 110 | s += "" + Environment.NewLine; 111 | return s; 112 | } 113 | 114 | public static GetMultiVariablesResponse DeserializeFromPdu(Stream pdu) 115 | { 116 | byte protocolVersion; 117 | byte opcode; 118 | UInt16 function; 119 | UInt16 reserved; 120 | // Special handling of ProtocolVersion, which is written to the stream before 121 | S7p.DecodeByte(pdu, out protocolVersion); 122 | S7p.DecodeByte(pdu, out opcode); 123 | if (opcode != Opcode.Response) 124 | { 125 | return null; 126 | } 127 | S7p.DecodeUInt16(pdu, out reserved); 128 | S7p.DecodeUInt16(pdu, out function); 129 | S7p.DecodeUInt16(pdu, out reserved); 130 | if (function != Functioncode.GetMultiVariables) 131 | { 132 | return null; 133 | } 134 | GetMultiVariablesResponse resp = new GetMultiVariablesResponse(protocolVersion); 135 | resp.Deserialize(pdu); 136 | 137 | return resp; 138 | } 139 | } 140 | } 141 | -------------------------------------------------------------------------------- /src/S7CommPlusDriver/Core/GetVarSubstreamedRequest.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | /****************************************************************************** 3 | * S7CommPlusDriver 4 | * 5 | * Copyright (C) 2023 Thomas Wiens, th.wiens@gmx.de 6 | * 7 | * This file is part of S7CommPlusDriver. 8 | * 9 | * S7CommPlusDriver is free software: you can redistribute it and/or modify 10 | * it under the terms of the GNU Lesser General Public License as 11 | * published by the Free Software Foundation, either version 3 of the 12 | * License, or (at your option) any later version. 13 | /****************************************************************************/ 14 | #endregion 15 | 16 | using System; 17 | using System.IO; 18 | 19 | namespace S7CommPlusDriver 20 | { 21 | public class GetVarSubstreamedRequest : IS7pRequest 22 | { 23 | public byte TransportFlags = 0x34; 24 | 25 | public UInt32 InObjectId; 26 | 27 | public UInt16 Address; 28 | 29 | public uint SessionId { get; set; } 30 | public byte ProtocolVersion { get; set; } 31 | public ushort FunctionCode { get => Functioncode.GetVarSubStreamed; } 32 | public ushort SequenceNumber { get; set; } 33 | public uint IntegrityId { get; set; } 34 | public bool WithIntegrityId { get; set; } 35 | 36 | public GetVarSubstreamedRequest(byte protocolVersion) 37 | { 38 | ProtocolVersion = protocolVersion; 39 | WithIntegrityId = true; 40 | } 41 | 42 | public byte GetProtocolVersion() 43 | { 44 | return ProtocolVersion; 45 | } 46 | 47 | public int Serialize(Stream buffer) 48 | { 49 | int ret = 0; 50 | ret += S7p.EncodeByte(buffer, Opcode.Request); 51 | ret += S7p.EncodeUInt16(buffer, 0); // Reserved 52 | ret += S7p.EncodeUInt16(buffer, FunctionCode); 53 | ret += S7p.EncodeUInt16(buffer, 0); // Reserved 54 | ret += S7p.EncodeUInt16(buffer, SequenceNumber); 55 | ret += S7p.EncodeUInt32(buffer, SessionId); 56 | ret += S7p.EncodeByte(buffer, TransportFlags); 57 | 58 | // Request set 59 | ret += S7p.EncodeUInt32(buffer, InObjectId); 60 | ret += S7p.EncodeByte(buffer, 0x20); // Addressarray 61 | ret += S7p.EncodeByte(buffer, Datatype.UDInt); 62 | ret += S7p.EncodeByte(buffer, 1); // Array size 63 | ret += S7p.EncodeUInt32Vlq(buffer, Address); 64 | 65 | ret += S7p.EncodeObjectQualifier(buffer); 66 | // 2 Bytes unknown 67 | ret += S7p.EncodeUInt16(buffer, 0x0001); 68 | 69 | if (WithIntegrityId) 70 | { 71 | ret += S7p.EncodeUInt32Vlq(buffer, IntegrityId); 72 | } 73 | 74 | // Fill? 75 | ret += S7p.EncodeUInt32(buffer, 0); 76 | 77 | return ret; 78 | } 79 | 80 | public override string ToString() 81 | { 82 | string s = ""; 83 | s += "" + Environment.NewLine; 84 | s += "" + ProtocolVersion.ToString() + "" + Environment.NewLine; 85 | s += "" + SequenceNumber.ToString() + "" + Environment.NewLine; 86 | s += "" + SessionId.ToString() + "" + Environment.NewLine; 87 | s += "" + TransportFlags.ToString() + "" + Environment.NewLine; 88 | s += "" + Environment.NewLine; 89 | s += "" + InObjectId.ToString() + "" + Environment.NewLine; 90 | s += "" + Environment.NewLine; 91 | s += "" + Address.ToString() + "" + Environment.NewLine; 92 | s += "" + Environment.NewLine; 93 | s += "" + Environment.NewLine; 94 | s += "" + Environment.NewLine; 95 | s += "" + Environment.NewLine; 96 | s += "" + Environment.NewLine; 97 | return s; 98 | } 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /src/S7CommPlusDriver/Core/GetVarSubstreamedResponse.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | /****************************************************************************** 3 | * S7CommPlusDriver 4 | * 5 | * Copyright (C) 2023 Thomas Wiens, th.wiens@gmx.de 6 | * 7 | * This file is part of S7CommPlusDriver. 8 | * 9 | * S7CommPlusDriver is free software: you can redistribute it and/or modify 10 | * it under the terms of the GNU Lesser General Public License as 11 | * published by the Free Software Foundation, either version 3 of the 12 | * License, or (at your option) any later version. 13 | /****************************************************************************/ 14 | #endregion 15 | 16 | using System; 17 | using System.IO; 18 | 19 | namespace S7CommPlusDriver 20 | { 21 | public class GetVarSubstreamedResponse : IS7pResponse 22 | { 23 | public byte TransportFlags; 24 | public UInt64 ReturnValue; 25 | public PValue Value; 26 | 27 | public byte ProtocolVersion { get; set; } 28 | public ushort FunctionCode { get => Functioncode.SetVariable; } 29 | public ushort SequenceNumber { get; set; } 30 | public uint IntegrityId { get; set; } 31 | public bool WithIntegrityId { get; set; } 32 | 33 | public GetVarSubstreamedResponse(byte protocolVersion) 34 | { 35 | ProtocolVersion = protocolVersion; 36 | WithIntegrityId = true; 37 | } 38 | 39 | public int Deserialize(Stream buffer) 40 | { 41 | int ret = 0; 42 | 43 | ret += S7p.DecodeUInt16(buffer, out ushort seqnr); 44 | SequenceNumber = seqnr; 45 | ret += S7p.DecodeByte(buffer, out TransportFlags); 46 | 47 | // Response Set 48 | ret += S7p.DecodeUInt64Vlq(buffer, out ReturnValue); 49 | 50 | byte unknown; 51 | ret += S7p.DecodeByte(buffer, out unknown); 52 | 53 | Value = PValue.Deserialize(buffer); 54 | 55 | ret += S7p.DecodeUInt32Vlq(buffer, out uint iid); 56 | IntegrityId = iid; 57 | return ret; 58 | } 59 | 60 | public override string ToString() 61 | { 62 | string s = ""; 63 | s += "" + Environment.NewLine; 64 | s += "" + ProtocolVersion.ToString() + "" + Environment.NewLine; 65 | s += "" + SequenceNumber.ToString() + "" + Environment.NewLine; 66 | s += "" + TransportFlags.ToString() + "" + Environment.NewLine; 67 | s += "" + Environment.NewLine; 68 | s += "" + ReturnValue.ToString() + "" + Environment.NewLine; 69 | s += "" + Environment.NewLine; 70 | s += "" + IntegrityId.ToString() + "" + Environment.NewLine; 71 | s += "" + Environment.NewLine; 72 | return s; 73 | } 74 | 75 | public static GetVarSubstreamedResponse DeserializeFromPdu(Stream pdu) 76 | { 77 | byte protocolVersion; 78 | byte opcode; 79 | UInt16 function; 80 | UInt16 reserved; 81 | // Special handling of ProtocolVersion, which is written to the stream before 82 | S7p.DecodeByte(pdu, out protocolVersion); 83 | S7p.DecodeByte(pdu, out opcode); 84 | if (opcode != Opcode.Response) 85 | { 86 | return null; 87 | } 88 | S7p.DecodeUInt16(pdu, out reserved); 89 | S7p.DecodeUInt16(pdu, out function); 90 | S7p.DecodeUInt16(pdu, out reserved); 91 | if (function != Functioncode.GetVarSubStreamed) 92 | { 93 | return null; 94 | } 95 | GetVarSubstreamedResponse resp = new GetVarSubstreamedResponse(protocolVersion); 96 | resp.Deserialize(pdu); 97 | 98 | return resp; 99 | } 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /src/S7CommPlusDriver/Core/IS7pRequest.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | /****************************************************************************** 3 | * S7CommPlusDriver 4 | * 5 | * Copyright (C) 2023 Thomas Wiens, th.wiens@gmx.de 6 | * 7 | * This file is part of S7CommPlusDriver. 8 | * 9 | * S7CommPlusDriver is free software: you can redistribute it and/or modify 10 | * it under the terms of the GNU Lesser General Public License as 11 | * published by the Free Software Foundation, either version 3 of the 12 | * License, or (at your option) any later version. 13 | /****************************************************************************/ 14 | #endregion 15 | 16 | namespace S7CommPlusDriver 17 | { 18 | public interface IS7pRequest 19 | { 20 | int Serialize(System.IO.Stream buffer); 21 | 22 | uint SessionId 23 | { 24 | get; 25 | set; 26 | } 27 | 28 | byte ProtocolVersion 29 | { 30 | get; 31 | set; 32 | } 33 | 34 | ushort FunctionCode 35 | { 36 | get; 37 | } 38 | 39 | ushort SequenceNumber 40 | { 41 | get; 42 | set; 43 | } 44 | 45 | uint IntegrityId 46 | { 47 | get; 48 | set; 49 | } 50 | 51 | bool WithIntegrityId 52 | { 53 | get; 54 | set; 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/S7CommPlusDriver/Core/IS7pResponse.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | /****************************************************************************** 3 | * S7CommPlusDriver 4 | * 5 | * Copyright (C) 2023 Thomas Wiens, th.wiens@gmx.de 6 | * 7 | * This file is part of S7CommPlusDriver. 8 | * 9 | * S7CommPlusDriver is free software: you can redistribute it and/or modify 10 | * it under the terms of the GNU Lesser General Public License as 11 | * published by the Free Software Foundation, either version 3 of the 12 | * License, or (at your option) any later version. 13 | /****************************************************************************/ 14 | #endregion 15 | 16 | namespace S7CommPlusDriver 17 | { 18 | public interface IS7pResponse 19 | { 20 | byte ProtocolVersion 21 | { 22 | get; 23 | set; 24 | } 25 | 26 | ushort FunctionCode 27 | { 28 | get; 29 | } 30 | 31 | ushort SequenceNumber 32 | { 33 | get; 34 | set; 35 | } 36 | 37 | uint IntegrityId 38 | { 39 | get; 40 | set; 41 | } 42 | 43 | bool WithIntegrityId 44 | { 45 | get; 46 | set; 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/S7CommPlusDriver/Core/IS7pSerialize.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | /****************************************************************************** 3 | * S7CommPlusDriver 4 | * 5 | * Copyright (C) 2023 Thomas Wiens, th.wiens@gmx.de 6 | * 7 | * This file is part of S7CommPlusDriver. 8 | * 9 | * S7CommPlusDriver is free software: you can redistribute it and/or modify 10 | * it under the terms of the GNU Lesser General Public License as 11 | * published by the Free Software Foundation, either version 3 of the 12 | * License, or (at your option) any later version. 13 | /****************************************************************************/ 14 | #endregion 15 | 16 | namespace S7CommPlusDriver 17 | { 18 | public interface IS7pSerialize 19 | { 20 | int Serialize(System.IO.Stream buffer); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/S7CommPlusDriver/Core/InitSslRequest.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | /****************************************************************************** 3 | * S7CommPlusDriver 4 | * 5 | * Copyright (C) 2023 Thomas Wiens, th.wiens@gmx.de 6 | * 7 | * This file is part of S7CommPlusDriver. 8 | * 9 | * S7CommPlusDriver is free software: you can redistribute it and/or modify 10 | * it under the terms of the GNU Lesser General Public License as 11 | * published by the Free Software Foundation, either version 3 of the 12 | * License, or (at your option) any later version. 13 | /****************************************************************************/ 14 | #endregion 15 | 16 | using System; 17 | using System.IO; 18 | 19 | namespace S7CommPlusDriver 20 | { 21 | class InitSslRequest : IS7pRequest 22 | { 23 | byte TransportFlags = 0x30; 24 | 25 | public uint SessionId { get; set; } 26 | public byte ProtocolVersion { get; set; } 27 | public ushort FunctionCode { get => Functioncode.InitSsl; } 28 | public ushort SequenceNumber { get; set; } 29 | public uint IntegrityId { get; set; } 30 | public bool WithIntegrityId { get; set; } 31 | 32 | public InitSslRequest(byte protocolVersion, UInt16 seqNum, UInt32 sessionId) 33 | { 34 | ProtocolVersion = protocolVersion; 35 | SequenceNumber = seqNum; 36 | SessionId = sessionId; 37 | WithIntegrityId = false; 38 | } 39 | 40 | public byte GetProtocolVersion() 41 | { 42 | return ProtocolVersion; 43 | } 44 | 45 | public int Serialize(Stream buffer) 46 | { 47 | int ret = 0; 48 | ret += S7p.EncodeByte(buffer, Opcode.Request); 49 | ret += S7p.EncodeUInt16(buffer, 0); // Reserved 50 | ret += S7p.EncodeUInt16(buffer, FunctionCode); 51 | ret += S7p.EncodeUInt16(buffer, 0); // Reserved 52 | ret += S7p.EncodeUInt16(buffer, SequenceNumber); 53 | ret += S7p.EncodeUInt32(buffer, SessionId); 54 | ret += S7p.EncodeByte(buffer, TransportFlags); 55 | 56 | // Fill? 57 | ret += S7p.EncodeUInt32(buffer, 0); 58 | 59 | return ret; 60 | } 61 | 62 | public override string ToString() 63 | { 64 | string s = ""; 65 | s += "" + Environment.NewLine; 66 | s += "" + ProtocolVersion.ToString() + "" + Environment.NewLine; 67 | s += "" + SequenceNumber.ToString() + "" + Environment.NewLine; 68 | s += "" + SessionId.ToString() + "" + Environment.NewLine; 69 | s += "" + TransportFlags.ToString() + "" + Environment.NewLine; 70 | s += "" + Environment.NewLine; 71 | return s; 72 | } 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /src/S7CommPlusDriver/Core/InitSslResponse.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | /****************************************************************************** 3 | * S7CommPlusDriver 4 | * 5 | * Copyright (C) 2023 Thomas Wiens, th.wiens@gmx.de 6 | * 7 | * This file is part of S7CommPlusDriver. 8 | * 9 | * S7CommPlusDriver is free software: you can redistribute it and/or modify 10 | * it under the terms of the GNU Lesser General Public License as 11 | * published by the Free Software Foundation, either version 3 of the 12 | * License, or (at your option) any later version. 13 | /****************************************************************************/ 14 | #endregion 15 | 16 | using System; 17 | using System.IO; 18 | 19 | namespace S7CommPlusDriver 20 | { 21 | class InitSslResponse : IS7pResponse 22 | { 23 | public byte TransportFlags; 24 | public UInt64 ReturnValue; 25 | 26 | public byte ProtocolVersion { get; set; } 27 | public ushort FunctionCode { get => Functioncode.InitSsl; } 28 | public ushort SequenceNumber { get; set; } 29 | public uint IntegrityId { get; set; } 30 | public bool WithIntegrityId { get; set; } 31 | 32 | public InitSslResponse(byte protocolVersion) 33 | { 34 | ProtocolVersion = protocolVersion; 35 | WithIntegrityId = false; 36 | } 37 | 38 | public int Deserialize(Stream buffer) 39 | { 40 | int ret = 0; 41 | 42 | ret += S7p.DecodeUInt16(buffer, out ushort seqnr); 43 | SequenceNumber = seqnr; 44 | ret += S7p.DecodeByte(buffer, out TransportFlags); 45 | 46 | // Response Set 47 | ret += S7p.DecodeUInt64Vlq(buffer, out ReturnValue); 48 | if ((ReturnValue & 0x4000000000000000) > 0) // Error Extension 49 | { 50 | // Decode the error object, but don't use any informations from it. Must be processed on a higher level. 51 | PObject errorObject = new PObject(); 52 | ret += S7p.DecodeObject(buffer, ref errorObject); 53 | } 54 | 55 | return ret; 56 | } 57 | 58 | public override string ToString() 59 | { 60 | string s = ""; 61 | s += "" + Environment.NewLine; 62 | s += "" + ProtocolVersion.ToString() + "" + Environment.NewLine; 63 | s += "" + SequenceNumber.ToString() + "" + Environment.NewLine; 64 | s += "" + TransportFlags.ToString() + "" + Environment.NewLine; 65 | s += "" + Environment.NewLine; 66 | s += "" + ReturnValue.ToString() + "" + Environment.NewLine; 67 | s += "" + Environment.NewLine; 68 | s += "" + Environment.NewLine; 69 | return s; 70 | } 71 | 72 | public static InitSslResponse DeserializeFromPdu(Stream pdu) 73 | { 74 | byte protocolVersion; 75 | byte opcode; 76 | UInt16 function; 77 | UInt16 reserved; 78 | // Special handling of ProtocolVersion, which is written to the stream before 79 | S7p.DecodeByte(pdu, out protocolVersion); 80 | S7p.DecodeByte(pdu, out opcode); 81 | if (opcode != Opcode.Response) 82 | { 83 | return null; 84 | } 85 | S7p.DecodeUInt16(pdu, out reserved); 86 | S7p.DecodeUInt16(pdu, out function); 87 | S7p.DecodeUInt16(pdu, out reserved); 88 | if (function != Functioncode.InitSsl) 89 | { 90 | return null; 91 | } 92 | InitSslResponse resp = new InitSslResponse(protocolVersion); 93 | resp.Deserialize(pdu); 94 | 95 | return resp; 96 | } 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /src/S7CommPlusDriver/Core/Opcode.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | /****************************************************************************** 3 | * S7CommPlusDriver 4 | * 5 | * Copyright (C) 2023 Thomas Wiens, th.wiens@gmx.de 6 | * 7 | * This file is part of S7CommPlusDriver. 8 | * 9 | * S7CommPlusDriver is free software: you can redistribute it and/or modify 10 | * it under the terms of the GNU Lesser General Public License as 11 | * published by the Free Software Foundation, either version 3 of the 12 | * License, or (at your option) any later version. 13 | /****************************************************************************/ 14 | #endregion 15 | 16 | namespace S7CommPlusDriver 17 | { 18 | public static class Opcode 19 | { 20 | public static byte Request = 0x31; 21 | public static byte Response = 0x32; 22 | public static byte Notification = 0x33; 23 | public static byte Response2 = 0x02; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/S7CommPlusDriver/Core/PVarnameList.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | /****************************************************************************** 3 | * S7CommPlusDriver 4 | * 5 | * Copyright (C) 2023 Thomas Wiens, th.wiens@gmx.de 6 | * 7 | * This file is part of S7CommPlusDriver. 8 | * 9 | * S7CommPlusDriver is free software: you can redistribute it and/or modify 10 | * it under the terms of the GNU Lesser General Public License as 11 | * published by the Free Software Foundation, either version 3 of the 12 | * License, or (at your option) any later version. 13 | /****************************************************************************/ 14 | #endregion 15 | 16 | using System; 17 | using System.Collections.Generic; 18 | using System.IO; 19 | 20 | namespace S7CommPlusDriver 21 | { 22 | public class PVarnameList 23 | { 24 | public List Names; 25 | 26 | public int Deserialize(Stream buffer) 27 | { 28 | int ret = 0; 29 | int maxret; 30 | byte namelen = 0; 31 | UInt16 blocklen = 0; 32 | string name; 33 | byte unknown2; 34 | 35 | Names = new List(); 36 | 37 | ret += S7p.DecodeUInt16(buffer, out blocklen); 38 | maxret = ret + blocklen; 39 | while (blocklen > 0) 40 | { 41 | do 42 | { 43 | name = String.Empty; 44 | // Length of a name is max. 128 chars 45 | ret += S7p.DecodeByte(buffer, out namelen); 46 | ret += S7p.DecodeWString(buffer, namelen, out name); 47 | Names.Add(name); 48 | // Additional 1 Byte with 0 at the end. Why Null termination when the length is given? I don't know... 49 | ret += S7p.DecodeByte(buffer, out unknown2); 50 | } while (ret < maxret); 51 | ret += S7p.DecodeUInt16(buffer, out blocklen); 52 | maxret = ret + blocklen; 53 | } 54 | return ret; 55 | } 56 | 57 | public override string ToString() 58 | { 59 | string s = ""; 60 | int i = 1; 61 | s += "" + Environment.NewLine; 62 | foreach (var name in Names) 63 | { 64 | s += "" + name.ToString() + "" + Environment.NewLine; 65 | i++; 66 | } 67 | s += "" + Environment.NewLine; 68 | return s; 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /src/S7CommPlusDriver/Core/ProtocolVersion.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | /****************************************************************************** 3 | * S7CommPlusDriver 4 | * 5 | * Copyright (C) 2023 Thomas Wiens, th.wiens@gmx.de 6 | * 7 | * This file is part of S7CommPlusDriver. 8 | * 9 | * S7CommPlusDriver is free software: you can redistribute it and/or modify 10 | * it under the terms of the GNU Lesser General Public License as 11 | * published by the Free Software Foundation, either version 3 of the 12 | * License, or (at your option) any later version. 13 | /****************************************************************************/ 14 | #endregion 15 | 16 | using System; 17 | using System.Collections.Generic; 18 | using System.Linq; 19 | using System.Text; 20 | using System.Threading.Tasks; 21 | 22 | namespace S7CommPlusDriver 23 | { 24 | public static class ProtocolVersion 25 | { 26 | public const byte V1 = 0x01; 27 | public const byte V2 = 0x02; 28 | public const byte V3 = 0x03; 29 | public const byte SystemEvent = 0xfe; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/S7CommPlusDriver/Core/SetMultiVariablesResponse.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | /****************************************************************************** 3 | * S7CommPlusDriver 4 | * 5 | * Copyright (C) 2023 Thomas Wiens, th.wiens@gmx.de 6 | * 7 | * This file is part of S7CommPlusDriver. 8 | * 9 | * S7CommPlusDriver is free software: you can redistribute it and/or modify 10 | * it under the terms of the GNU Lesser General Public License as 11 | * published by the Free Software Foundation, either version 3 of the 12 | * License, or (at your option) any later version. 13 | /****************************************************************************/ 14 | #endregion 15 | 16 | using System; 17 | using System.Collections.Generic; 18 | using System.IO; 19 | 20 | namespace S7CommPlusDriver 21 | { 22 | public class SetMultiVariablesResponse : IS7pResponse 23 | { 24 | public byte TransportFlags; 25 | public UInt64 ReturnValue; 26 | public Dictionary ErrorValues; // ItemNumber, ReturnValue 27 | 28 | public byte ProtocolVersion { get; set; } 29 | public ushort FunctionCode { get => Functioncode.SetMultiVariables; } 30 | public ushort SequenceNumber { get; set; } 31 | public uint IntegrityId { get; set; } 32 | public bool WithIntegrityId { get; set; } 33 | 34 | public SetMultiVariablesResponse(byte protocolVersion) 35 | { 36 | ProtocolVersion = protocolVersion; 37 | ErrorValues = new Dictionary(); 38 | WithIntegrityId = true; 39 | } 40 | 41 | public int Deserialize(Stream buffer) 42 | { 43 | int ret = 0; 44 | UInt32 itemnr = 0; 45 | UInt64 retval = 0; 46 | 47 | ret += S7p.DecodeUInt16(buffer, out ushort seqnr); 48 | SequenceNumber = seqnr; 49 | ret += S7p.DecodeByte(buffer, out TransportFlags); 50 | 51 | // Response Set 52 | ret += S7p.DecodeUInt64Vlq(buffer, out ReturnValue); 53 | ErrorValues.Clear(); 54 | ret += S7p.DecodeUInt32Vlq(buffer, out itemnr); 55 | while (itemnr > 0) 56 | { 57 | ret += S7p.DecodeUInt64Vlq(buffer, out retval); 58 | ErrorValues.Add(itemnr, retval); 59 | ret += S7p.DecodeUInt32Vlq(buffer, out itemnr); /// TODO: Is this correct? 60 | } 61 | ret += S7p.DecodeUInt32Vlq(buffer, out uint iid); 62 | IntegrityId = iid; 63 | return ret; 64 | } 65 | 66 | public override string ToString() 67 | { 68 | string s = ""; 69 | s += "" + Environment.NewLine; 70 | s += "" + ProtocolVersion.ToString() + "" + Environment.NewLine; 71 | s += "" + SequenceNumber.ToString() + "" + Environment.NewLine; 72 | s += "" + TransportFlags.ToString() + "" + Environment.NewLine; 73 | s += "" + Environment.NewLine; 74 | s += "" + ReturnValue.ToString() + "" + Environment.NewLine; 75 | s += "" + Environment.NewLine; 76 | foreach (var errval in ErrorValues) 77 | { 78 | s += "" + Environment.NewLine; 79 | s += "" + errval.Key.ToString() + "" + Environment.NewLine; 80 | s += "" + errval.Value.ToString() + "" + Environment.NewLine; 81 | s += "" + Environment.NewLine; 82 | } 83 | s += "" + Environment.NewLine; 84 | s += "" + Environment.NewLine; 85 | s += "" + IntegrityId.ToString() + "" + Environment.NewLine; 86 | s += "" + Environment.NewLine; 87 | return s; 88 | } 89 | 90 | public static SetMultiVariablesResponse DeserializeFromPdu(Stream pdu) 91 | { 92 | byte protocolVersion; 93 | byte opcode; 94 | UInt16 function; 95 | UInt16 reserved; 96 | // Special handling of ProtocolVersion, which is written to the stream before 97 | S7p.DecodeByte(pdu, out protocolVersion); 98 | S7p.DecodeByte(pdu, out opcode); 99 | if (opcode != Opcode.Response) 100 | { 101 | return null; 102 | } 103 | S7p.DecodeUInt16(pdu, out reserved); 104 | S7p.DecodeUInt16(pdu, out function); 105 | S7p.DecodeUInt16(pdu, out reserved); 106 | if (function != Functioncode.SetMultiVariables) 107 | { 108 | return null; 109 | } 110 | SetMultiVariablesResponse resp = new SetMultiVariablesResponse(protocolVersion); 111 | resp.Deserialize(pdu); 112 | 113 | return resp; 114 | } 115 | } 116 | } 117 | -------------------------------------------------------------------------------- /src/S7CommPlusDriver/Core/SetVariableRequest.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | /****************************************************************************** 3 | * S7CommPlusDriver 4 | * 5 | * Copyright (C) 2023 Thomas Wiens, th.wiens@gmx.de 6 | * 7 | * This file is part of S7CommPlusDriver. 8 | * 9 | * S7CommPlusDriver is free software: you can redistribute it and/or modify 10 | * it under the terms of the GNU Lesser General Public License as 11 | * published by the Free Software Foundation, either version 3 of the 12 | * License, or (at your option) any later version. 13 | /****************************************************************************/ 14 | #endregion 15 | 16 | using System; 17 | using System.IO; 18 | 19 | namespace S7CommPlusDriver 20 | { 21 | public class SetVariableRequest : IS7pRequest 22 | { 23 | public byte TransportFlags = 0x34; 24 | 25 | public UInt32 InObjectId; 26 | 27 | public UInt32 Address; 28 | public PValue Value; 29 | 30 | public uint SessionId { get; set; } 31 | public byte ProtocolVersion { get; set; } 32 | public ushort FunctionCode { get => Functioncode.SetVariable; } 33 | public ushort SequenceNumber { get; set; } 34 | public uint IntegrityId { get; set; } 35 | public bool WithIntegrityId { get; set; } 36 | 37 | public SetVariableRequest(byte protocolVersion) 38 | { 39 | ProtocolVersion = protocolVersion; 40 | WithIntegrityId = true; 41 | } 42 | 43 | public byte GetProtocolVersion() 44 | { 45 | return ProtocolVersion; 46 | } 47 | 48 | public int Serialize(Stream buffer) 49 | { 50 | int ret = 0; 51 | ret += S7p.EncodeByte(buffer, Opcode.Request); 52 | ret += S7p.EncodeUInt16(buffer, 0); // Reserved 53 | ret += S7p.EncodeUInt16(buffer, FunctionCode); 54 | ret += S7p.EncodeUInt16(buffer, 0); // Reserved 55 | ret += S7p.EncodeUInt16(buffer, SequenceNumber); 56 | ret += S7p.EncodeUInt32(buffer, SessionId); 57 | ret += S7p.EncodeByte(buffer, TransportFlags); 58 | 59 | // Request set 60 | ret += S7p.EncodeUInt32(buffer, InObjectId); 61 | ret += S7p.EncodeUInt32Vlq(buffer, 1); // Always 1 (?) 62 | ret += S7p.EncodeUInt32Vlq(buffer, Address); 63 | ret += Value.Serialize(buffer); 64 | 65 | ret += S7p.EncodeObjectQualifier(buffer); 66 | // 1 Byte unknown 67 | ret += S7p.EncodeByte(buffer, 0x00); 68 | 69 | if (WithIntegrityId) 70 | { 71 | ret += S7p.EncodeUInt32Vlq(buffer, IntegrityId); 72 | } 73 | 74 | // Fill? 75 | ret += S7p.EncodeUInt32(buffer, 0); 76 | 77 | return ret; 78 | } 79 | 80 | public override string ToString() 81 | { 82 | string s = ""; 83 | s += "" + Environment.NewLine; 84 | s += "" + ProtocolVersion.ToString() + "" + Environment.NewLine; 85 | s += "" + SequenceNumber.ToString() + "" + Environment.NewLine; 86 | s += "" + SessionId.ToString() + "" + Environment.NewLine; 87 | s += "" + TransportFlags.ToString() + "" + Environment.NewLine; 88 | s += "" + Environment.NewLine; 89 | s += "" + InObjectId.ToString() + "" + Environment.NewLine; 90 | s += "" + Environment.NewLine; 91 | s += "" + Address.ToString() + "" + Environment.NewLine; 92 | s += "" + Environment.NewLine; 93 | s += "" + Environment.NewLine; 94 | s += "" + Value.ToString() + "" + Environment.NewLine; 95 | s += "" + Environment.NewLine; 96 | s += "" + Environment.NewLine; 97 | s += "" + Environment.NewLine; 98 | return s; 99 | } 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /src/S7CommPlusDriver/Core/SetVariableResponse.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | /****************************************************************************** 3 | * S7CommPlusDriver 4 | * 5 | * Copyright (C) 2023 Thomas Wiens, th.wiens@gmx.de 6 | * 7 | * This file is part of S7CommPlusDriver. 8 | * 9 | * S7CommPlusDriver is free software: you can redistribute it and/or modify 10 | * it under the terms of the GNU Lesser General Public License as 11 | * published by the Free Software Foundation, either version 3 of the 12 | * License, or (at your option) any later version. 13 | /****************************************************************************/ 14 | #endregion 15 | 16 | using System; 17 | using System.IO; 18 | 19 | namespace S7CommPlusDriver 20 | { 21 | public class SetVariableResponse : IS7pResponse 22 | { 23 | public byte TransportFlags; 24 | public UInt64 ReturnValue; 25 | 26 | public byte ProtocolVersion { get; set; } 27 | public ushort FunctionCode { get => Functioncode.SetVariable; } 28 | public ushort SequenceNumber { get; set; } 29 | public uint IntegrityId { get; set; } 30 | public bool WithIntegrityId { get; set; } 31 | 32 | public SetVariableResponse(byte protocolVersion) 33 | { 34 | ProtocolVersion = protocolVersion; 35 | WithIntegrityId = true; 36 | } 37 | 38 | public int Deserialize(Stream buffer) 39 | { 40 | int ret = 0; 41 | 42 | ret += S7p.DecodeUInt16(buffer, out ushort seqnr); 43 | SequenceNumber = seqnr; 44 | ret += S7p.DecodeByte(buffer, out TransportFlags); 45 | 46 | // Response Set 47 | ret += S7p.DecodeUInt64Vlq(buffer, out ReturnValue); 48 | 49 | ret += S7p.DecodeUInt32Vlq(buffer, out uint iid); 50 | IntegrityId = iid; 51 | return ret; 52 | } 53 | 54 | public override string ToString() 55 | { 56 | string s = ""; 57 | s += "" + Environment.NewLine; 58 | s += "" + ProtocolVersion.ToString() + "" + Environment.NewLine; 59 | s += "" + SequenceNumber.ToString() + "" + Environment.NewLine; 60 | s += "" + TransportFlags.ToString() + "" + Environment.NewLine; 61 | s += "" + Environment.NewLine; 62 | s += "" + ReturnValue.ToString() + "" + Environment.NewLine; 63 | s += "" + Environment.NewLine; 64 | s += "" + IntegrityId.ToString() + "" + Environment.NewLine; 65 | s += "" + Environment.NewLine; 66 | return s; 67 | } 68 | 69 | public static SetVariableResponse DeserializeFromPdu(Stream pdu) 70 | { 71 | byte protocolVersion; 72 | byte opcode; 73 | UInt16 function; 74 | UInt16 reserved; 75 | // Special handling of ProtocolVersion, which is written to the stream before 76 | S7p.DecodeByte(pdu, out protocolVersion); 77 | S7p.DecodeByte(pdu, out opcode); 78 | if (opcode != Opcode.Response) 79 | { 80 | return null; 81 | } 82 | S7p.DecodeUInt16(pdu, out reserved); 83 | S7p.DecodeUInt16(pdu, out function); 84 | S7p.DecodeUInt16(pdu, out reserved); 85 | if (function != Functioncode.SetVariable) 86 | { 87 | return null; 88 | } 89 | SetVariableResponse resp = new SetVariableResponse(protocolVersion); 90 | resp.Deserialize(pdu); 91 | 92 | return resp; 93 | } 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /src/S7CommPlusDriver/Legitimation/AccessLevel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace S7CommPlusDriver.Legitimation 8 | { 9 | public static class AccessLevel 10 | { 11 | public const UInt32 FullAccess = 1; 12 | public const UInt32 ReadAccess = 2; 13 | public const UInt32 HMIAccess = 3; 14 | public const UInt32 NoAccess = 4; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/S7CommPlusDriver/Legitimation/LegitimationCrypto.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Security.Cryptography; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace S7CommPlusDriver.Legitimation 9 | { 10 | static class LegitimationCrypto 11 | { 12 | 13 | /// 14 | /// SHA256 15 | /// 16 | /// Data to hash 17 | /// Hash 18 | public static byte[] sha256(byte[] data) 19 | { 20 | using (SHA256 sha = SHA256.Create()) 21 | { 22 | return sha.ComputeHash(data); 23 | } 24 | } 25 | 26 | /// 27 | /// Encrypt AES256CBC 28 | /// 29 | /// Plain data 30 | /// Encryption key 31 | /// Init vector 32 | /// Encrypted data 33 | public static byte[] EncryptAesCbc(byte[] plainBytes, byte[] key, byte[] iv) 34 | { 35 | byte[] encryptedBytes = null; 36 | 37 | // Set up the encryption objects 38 | using (Aes aes = Aes.Create()) 39 | { 40 | aes.Key = key; 41 | aes.IV = iv; 42 | aes.Mode = CipherMode.CBC; 43 | aes.Padding = PaddingMode.PKCS7; 44 | 45 | // Encrypt the input plaintext using the AES algorithm 46 | using (ICryptoTransform encryptor = aes.CreateEncryptor()) 47 | { 48 | encryptedBytes = encryptor.TransformFinalBlock(plainBytes, 0, plainBytes.Length); 49 | } 50 | } 51 | 52 | return encryptedBytes; 53 | } 54 | 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/S7CommPlusDriver/Legitimation/LegitimationType.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace S7CommPlusDriver.Legitimation 8 | { 9 | public static class LegitimationType 10 | { 11 | public const UInt32 Legacy = 1; 12 | public const UInt32 New = 2; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/S7CommPlusDriver/Net/MsgSocket.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | /****************************************************************************** 3 | * S7CommPlusDriver 4 | * 5 | * Based on Snap7 (Sharp7.cs) by Davide Nardella licensed under LGPL 6 | * 7 | /****************************************************************************/ 8 | #endregion 9 | 10 | using System; 11 | using System.Net.Sockets; 12 | using System.Threading; 13 | 14 | namespace S7CommPlusDriver 15 | { 16 | // 17 | class MsgSocket 18 | { 19 | private Socket TCPSocket; 20 | private int _ReadTimeout = 2000; 21 | private int _WriteTimeout = 2000; 22 | private int _ConnectTimeout = 1000; 23 | public int LastError = 0; 24 | 25 | public MsgSocket() 26 | { 27 | } 28 | 29 | ~MsgSocket() 30 | { 31 | Close(); 32 | } 33 | 34 | public void Close() 35 | { 36 | if (TCPSocket != null) 37 | { 38 | TCPSocket.Dispose(); 39 | TCPSocket = null; 40 | } 41 | } 42 | 43 | private void CreateSocket() 44 | { 45 | TCPSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); 46 | TCPSocket.NoDelay = true; 47 | } 48 | 49 | private void TCPPing(string Host, int Port) 50 | { 51 | // To Ping the PLC an Asynchronous socket is used rather then an ICMP packet. 52 | // This allows the use also across Internet and Firewalls (obviously the port must be opened) 53 | LastError = 0; 54 | Socket PingSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); 55 | try 56 | { 57 | IAsyncResult result = PingSocket.BeginConnect(Host, Port, null, null); 58 | bool success = result.AsyncWaitHandle.WaitOne(_ConnectTimeout, true); 59 | 60 | if (!success) 61 | { 62 | LastError = S7Consts.errTCPConnectionFailed; 63 | } 64 | } 65 | catch 66 | { 67 | LastError = S7Consts.errTCPConnectionFailed; 68 | }; 69 | PingSocket.Close(); 70 | } 71 | 72 | public int Connect(string Host, int Port) 73 | { 74 | LastError = 0; 75 | if (!Connected) 76 | { 77 | // TWI: TCPPing rausgenommen, stört bei Wireshark Analyse 78 | //TCPPing(Host, Port); 79 | if (LastError == 0) 80 | try 81 | { 82 | CreateSocket(); 83 | TCPSocket.Connect(Host, Port); 84 | } 85 | catch 86 | { 87 | LastError = S7Consts.errTCPConnectionFailed; 88 | } 89 | } 90 | return LastError; 91 | } 92 | 93 | private int WaitForData(int Size, int Timeout) 94 | { 95 | bool Expired = false; 96 | int SizeAvail; 97 | int Elapsed = Environment.TickCount; 98 | LastError = 0; 99 | try 100 | { 101 | SizeAvail = TCPSocket.Available; 102 | while ((SizeAvail < Size) && (!Expired)) 103 | { 104 | Thread.Sleep(2); 105 | SizeAvail = TCPSocket.Available; 106 | Expired = Environment.TickCount - Elapsed > Timeout; 107 | // If timeout we clean the buffer 108 | if (Expired && (SizeAvail > 0)) 109 | try 110 | { 111 | byte[] Flush = new byte[SizeAvail]; 112 | TCPSocket.Receive(Flush, 0, SizeAvail, SocketFlags.None); 113 | } 114 | catch { } 115 | } 116 | } 117 | catch 118 | { 119 | LastError = S7Consts.errTCPDataReceive; 120 | } 121 | if (Expired) 122 | { 123 | LastError = S7Consts.errTCPDataReceive; 124 | } 125 | return LastError; 126 | } 127 | 128 | public int Receive(byte[] Buffer, int Start, int Size) 129 | { 130 | 131 | int BytesRead = 0; 132 | LastError = WaitForData(Size, _ReadTimeout); 133 | if (LastError == 0) 134 | { 135 | try 136 | { 137 | BytesRead = TCPSocket.Receive(Buffer, Start, Size, SocketFlags.None); 138 | } 139 | catch 140 | { 141 | LastError = S7Consts.errTCPDataReceive; 142 | } 143 | if (BytesRead == 0) // Connection Reset by the peer 144 | { 145 | LastError = S7Consts.errTCPDataReceive; 146 | Close(); 147 | } 148 | } 149 | return LastError; 150 | } 151 | 152 | public int Send(byte[] Buffer, int Size) 153 | { 154 | LastError = 0; 155 | try 156 | { 157 | int BytesSent = TCPSocket.Send(Buffer, Size, SocketFlags.None); 158 | } 159 | catch 160 | { 161 | LastError = S7Consts.errTCPDataSend; 162 | Close(); 163 | } 164 | return LastError; 165 | } 166 | 167 | public bool Connected 168 | { 169 | get 170 | { 171 | return (TCPSocket != null) && (TCPSocket.Connected); 172 | } 173 | } 174 | 175 | public int ReadTimeout 176 | { 177 | get 178 | { 179 | return _ReadTimeout; 180 | } 181 | set 182 | { 183 | _ReadTimeout = value; 184 | } 185 | } 186 | 187 | public int WriteTimeout 188 | { 189 | get 190 | { 191 | return _WriteTimeout; 192 | } 193 | set 194 | { 195 | _WriteTimeout = value; 196 | } 197 | 198 | } 199 | public int ConnectTimeout 200 | { 201 | get 202 | { 203 | return _ConnectTimeout; 204 | } 205 | set 206 | { 207 | _ConnectTimeout = value; 208 | } 209 | } 210 | } 211 | } 212 | -------------------------------------------------------------------------------- /src/S7CommPlusDriver/Net/S7Consts.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | /****************************************************************************** 3 | * S7CommPlusDriver 4 | * 5 | * Based on Snap7 (Sharp7.cs) by Davide Nardella licensed under LPGP 6 | * 7 | /****************************************************************************/ 8 | #endregion 9 | 10 | using System; 11 | using System.Collections.Generic; 12 | using System.Linq; 13 | using System.Text; 14 | using System.Threading.Tasks; 15 | 16 | namespace S7CommPlusDriver 17 | { 18 | public static class S7Consts 19 | { 20 | #region [Exported Consts] 21 | // Error codes 22 | //------------------------------------------------------------------------------ 23 | // ERRORS 24 | //------------------------------------------------------------------------------ 25 | public const int errTCPSocketCreation = 0x00000001; 26 | public const int errTCPConnectionTimeout = 0x00000002; 27 | public const int errTCPConnectionFailed = 0x00000003; 28 | public const int errTCPReceiveTimeout = 0x00000004; 29 | public const int errTCPDataReceive = 0x00000005; 30 | public const int errTCPSendTimeout = 0x00000006; 31 | public const int errTCPDataSend = 0x00000007; 32 | public const int errTCPConnectionReset = 0x00000008; 33 | public const int errTCPNotConnected = 0x00000009; 34 | public const int errTCPUnreachableHost = 0x00002751; 35 | 36 | public const int errIsoConnect = 0x00010000; // Connection error 37 | public const int errIsoInvalidPDU = 0x00030000; // Bad format 38 | public const int errIsoInvalidDataSize = 0x00040000; // Bad Datasize passed to send/recv : buffer is invalid 39 | 40 | public const int errCliNegotiatingPDU = 0x00100000; 41 | public const int errCliInvalidParams = 0x00200000; 42 | public const int errCliJobPending = 0x00300000; 43 | public const int errCliTooManyItems = 0x00400000; 44 | public const int errCliInvalidWordLen = 0x00500000; 45 | public const int errCliPartialDataWritten = 0x00600000; 46 | public const int errCliSizeOverPDU = 0x00700000; 47 | public const int errCliInvalidPlcAnswer = 0x00800000; 48 | public const int errCliAddressOutOfRange = 0x00900000; 49 | public const int errCliInvalidTransportSize = 0x00A00000; 50 | public const int errCliWriteDataSizeMismatch = 0x00B00000; 51 | public const int errCliItemNotAvailable = 0x00C00000; 52 | public const int errCliInvalidValue = 0x00D00000; 53 | public const int errCliCannotStartPLC = 0x00E00000; 54 | public const int errCliAlreadyRun = 0x00F00000; 55 | public const int errCliCannotStopPLC = 0x01000000; 56 | public const int errCliCannotCopyRamToRom = 0x01100000; 57 | public const int errCliCannotCompress = 0x01200000; 58 | public const int errCliAlreadyStop = 0x01300000; 59 | public const int errCliFunNotAvailable = 0x01400000; 60 | public const int errCliUploadSequenceFailed = 0x01500000; 61 | public const int errCliInvalidDataSizeRecvd = 0x01600000; 62 | public const int errCliInvalidBlockType = 0x01700000; 63 | public const int errCliInvalidBlockNumber = 0x01800000; 64 | public const int errCliInvalidBlockSize = 0x01900000; 65 | public const int errCliNeedPassword = 0x01D00000; 66 | public const int errCliInvalidPassword = 0x01E00000; 67 | public const int errCliAccessDenied = 0x01E10000; 68 | public const int errCliNoPasswordToSetOrClear = 0x01F00000; 69 | public const int errCliJobTimeout = 0x02000000; 70 | public const int errCliPartialDataRead = 0x02100000; 71 | public const int errCliBufferTooSmall = 0x02200000; 72 | public const int errCliFunctionRefused = 0x02300000; 73 | public const int errCliDestroying = 0x02400000; 74 | public const int errCliInvalidParamNumber = 0x02500000; 75 | public const int errCliCannotChangeParam = 0x02600000; 76 | public const int errCliFunctionNotImplemented = 0x02700000; 77 | public const int errCliFirmwareNotSupported = 0x02800000; 78 | public const int errCliDeviceNotSupported = 0x02900000; 79 | 80 | public const int errOpenSSL = 0x03100000; 81 | //------------------------------------------------------------------------------ 82 | // PARAMS LIST FOR COMPATIBILITY WITH Snap7.net.cs 83 | //------------------------------------------------------------------------------ 84 | public const Int32 p_u16_LocalPort = 1; // Not applicable here 85 | public const Int32 p_u16_RemotePort = 2; 86 | public const Int32 p_i32_PingTimeout = 3; 87 | public const Int32 p_i32_SendTimeout = 4; 88 | public const Int32 p_i32_RecvTimeout = 5; 89 | public const Int32 p_i32_WorkInterval = 6; // Not applicable here 90 | public const Int32 p_u16_SrcRef = 7; // Not applicable here 91 | public const Int32 p_u16_DstRef = 8; // Not applicable here 92 | public const Int32 p_u16_SrcTSap = 9; // Not applicable here 93 | public const Int32 p_i32_PDURequest = 10; 94 | public const Int32 p_i32_MaxClients = 11; // Not applicable here 95 | public const Int32 p_i32_BSendTimeout = 12; // Not applicable here 96 | public const Int32 p_i32_BRecvTimeout = 13; // Not applicable here 97 | public const Int32 p_u32_RecoveryTime = 14; // Not applicable here 98 | public const Int32 p_u32_KeepAliveTime = 15; // Not applicable here 99 | 100 | #endregion 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /src/S7CommPlusDriver/OpenSSL-dll-x64/libcrypto-3-x64.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thomas-v2/S7CommPlusDriver/7cf0a6a2b779c46cca811517b93462a7d58a58cd/src/S7CommPlusDriver/OpenSSL-dll-x64/libcrypto-3-x64.dll -------------------------------------------------------------------------------- /src/S7CommPlusDriver/OpenSSL-dll-x64/libssl-3-x64.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thomas-v2/S7CommPlusDriver/7cf0a6a2b779c46cca811517b93462a7d58a58cd/src/S7CommPlusDriver/OpenSSL-dll-x64/libssl-3-x64.dll -------------------------------------------------------------------------------- /src/S7CommPlusDriver/OpenSSL-dll-x86/libcrypto-3.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thomas-v2/S7CommPlusDriver/7cf0a6a2b779c46cca811517b93462a7d58a58cd/src/S7CommPlusDriver/OpenSSL-dll-x86/libcrypto-3.dll -------------------------------------------------------------------------------- /src/S7CommPlusDriver/OpenSSL-dll-x86/libssl-3.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thomas-v2/S7CommPlusDriver/7cf0a6a2b779c46cca811517b93462a7d58a58cd/src/S7CommPlusDriver/OpenSSL-dll-x86/libssl-3.dll -------------------------------------------------------------------------------- /src/S7CommPlusDriver/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // Allgemeine Informationen über eine Assembly werden über die folgenden 6 | // Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern, 7 | // die einer Assembly zugeordnet sind. 8 | [assembly: AssemblyTitle("S7CommPlusDriver")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("S7CommPlusDriver")] 13 | [assembly: AssemblyCopyright("Copyright © 2023, Thomas Wiens")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Durch Festlegen von ComVisible auf FALSE werden die Typen in dieser Assembly 18 | // für COM-Komponenten unsichtbar. Wenn Sie auf einen Typ in dieser Assembly von 19 | // COM aus zugreifen müssen, sollten Sie das ComVisible-Attribut für diesen Typ auf "True" festlegen. 20 | [assembly: ComVisible(false)] 21 | 22 | // Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird 23 | [assembly: Guid("781951d8-80de-4e2f-92ca-a5fef0059415")] 24 | 25 | // Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten: 26 | // 27 | // Hauptversion 28 | // Nebenversion 29 | // Buildnummer 30 | // Revision 31 | // 32 | // Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden, 33 | // indem Sie "*" wie unten gezeigt eingeben: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("0.1.0.0")] 36 | [assembly: AssemblyFileVersion("0.1.0.0")] 37 | -------------------------------------------------------------------------------- /src/S7CommPlusGUIBrowser/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/S7CommPlusGUIBrowser/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows.Forms; 3 | 4 | namespace S7CommPlusGUIBrowser 5 | { 6 | internal static class Program { 7 | /// 8 | /// Der Haupteinstiegspunkt für die Anwendung. 9 | /// 10 | [STAThread] 11 | static void Main() 12 | { 13 | Application.EnableVisualStyles(); 14 | Application.SetCompatibleTextRenderingDefault(false); 15 | Application.Run(new Form1()); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/S7CommPlusGUIBrowser/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // Allgemeine Informationen über eine Assembly werden über die folgenden 6 | // Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern, 7 | // die einer Assembly zugeordnet sind. 8 | [assembly: AssemblyTitle("S7CommPlusGUIBrowser")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("S7CommPlusGUIBrowser")] 13 | [assembly: AssemblyCopyright("Copyright © 2024")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Durch Festlegen von ComVisible auf FALSE werden die Typen in dieser Assembly 18 | // für COM-Komponenten unsichtbar. Wenn Sie auf einen Typ in dieser Assembly von 19 | // COM aus zugreifen müssen, sollten Sie das ComVisible-Attribut für diesen Typ auf "True" festlegen. 20 | [assembly: ComVisible(false)] 21 | 22 | // Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird 23 | [assembly: Guid("beb37276-b3b3-4dee-a1ea-d95eb774223b")] 24 | 25 | // Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten: 26 | // 27 | // Hauptversion 28 | // Nebenversion 29 | // Buildnummer 30 | // Revision 31 | // 32 | // Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden, 33 | // indem Sie "*" wie unten gezeigt eingeben: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /src/S7CommPlusGUIBrowser/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // Dieser Code wurde von einem Tool generiert. 4 | // Laufzeitversion: 4.0.30319.42000 5 | // 6 | // Änderungen an dieser Datei können fehlerhaftes Verhalten verursachen und gehen verloren, wenn 7 | // der Code neu generiert wird. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace S7CommPlusGUIBrowser.Properties { 12 | 13 | 14 | /// 15 | /// Eine stark typisierte Ressourcenklasse zum Suchen von lokalisierten Zeichenfolgen usw. 16 | /// 17 | // Diese Klasse wurde von der StronglyTypedResourceBuilder-Klasse 18 | // über ein Tool wie ResGen oder Visual Studio automatisch generiert. 19 | // Um einen Member hinzuzufügen oder zu entfernen, bearbeiten Sie die .ResX-Datei und führen dann ResGen 20 | // mit der Option /str erneut aus, oder erstellen Sie Ihr VS-Projekt neu. 21 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] 22 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 23 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 24 | internal class Resources { 25 | 26 | private static global::System.Resources.ResourceManager resourceMan; 27 | 28 | private static global::System.Globalization.CultureInfo resourceCulture; 29 | 30 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 31 | internal Resources() { 32 | } 33 | 34 | /// 35 | /// Gibt die zwischengespeicherte ResourceManager-Instanz zurück, die von dieser Klasse verwendet wird. 36 | /// 37 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 38 | internal static global::System.Resources.ResourceManager ResourceManager { 39 | get { 40 | if ((resourceMan == null)) { 41 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("S7CommPlusGUIBrowser.Properties.Resources", typeof(Resources).Assembly); 42 | resourceMan = temp; 43 | } 44 | return resourceMan; 45 | } 46 | } 47 | 48 | /// 49 | /// Überschreibt die CurrentUICulture-Eigenschaft des aktuellen Threads für alle 50 | /// Ressourcenlookups, die diese stark typisierte Ressourcenklasse verwenden. 51 | /// 52 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 53 | internal static global::System.Globalization.CultureInfo Culture { 54 | get { 55 | return resourceCulture; 56 | } 57 | set { 58 | resourceCulture = value; 59 | } 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/S7CommPlusGUIBrowser/Properties/Resources.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | text/microsoft-resx 107 | 108 | 109 | 2.0 110 | 111 | 112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 113 | 114 | 115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | -------------------------------------------------------------------------------- /src/S7CommPlusGUIBrowser/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace S7CommPlusGUIBrowser.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/S7CommPlusGUIBrowser/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/S7CommPlusGUIBrowser/README.md: -------------------------------------------------------------------------------- 1 | # S7commPlusGuiBrowser 2 | 3 | Dieses kleine Programm soll demonstrieren wie die Library dazu genutzt werden kann um dynamisch durch die in der PLC vorhandenen Symbole / Tags zu browsen. 4 | 5 | WICHTIG: Das Programm dient nur als Beispiel und sollte nicht in einer produktiv Umgebung eingesetzt werden! 6 | Um dieses Beispielprogramm möglichst klein und simpel zu halten, erfolgt der Zugriff auf die Library im main Task und blockt daher die GUI. 7 | -------------------------------------------------------------------------------- /src/S7CommPlusGUIBrowser/S7CommPlusGUIBrowser.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {BEB37276-B3B3-4DEE-A1EA-D95EB774223B} 8 | WinExe 9 | S7CommPlusGUIBrowser 10 | S7CommPlusGUIBrowser 11 | v4.7.2 12 | 512 13 | true 14 | true 15 | 16 | 17 | true 18 | bin\x64\Debug\ 19 | DEBUG;TRACE 20 | full 21 | x64 22 | 7.3 23 | prompt 24 | true 25 | 26 | 27 | bin\x64\Release\ 28 | TRACE 29 | true 30 | pdbonly 31 | x64 32 | 7.3 33 | prompt 34 | true 35 | 36 | 37 | true 38 | bin\x86\Debug\ 39 | DEBUG;TRACE 40 | full 41 | x86 42 | 7.3 43 | prompt 44 | true 45 | 46 | 47 | bin\x86\Release\ 48 | TRACE 49 | true 50 | pdbonly 51 | x86 52 | 7.3 53 | prompt 54 | true 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | Form 72 | 73 | 74 | Form1.cs 75 | 76 | 77 | 78 | 79 | Form1.cs 80 | 81 | 82 | ResXFileCodeGenerator 83 | Resources.Designer.cs 84 | Designer 85 | 86 | 87 | True 88 | Resources.resx 89 | 90 | 91 | 92 | SettingsSingleFileGenerator 93 | Settings.Designer.cs 94 | 95 | 96 | True 97 | Settings.settings 98 | True 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | {781951d8-80de-4e2f-92ca-a5fef0059415} 107 | S7CommPlusDriver 108 | 109 | 110 | 111 | 112 | xcopy /y /d "$(SolutionDir)S7CommPlusDriver\OpenSSL-dll-$(PlatformName)\*.dll" "$(ProjectDir)$(OutDir)" 113 | 114 | -------------------------------------------------------------------------------- /src/Zlib.net/Adler32.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2006, ComponentAce 2 | // http://www.componentace.com 3 | // All rights reserved. 4 | 5 | // Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 6 | 7 | // Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | // Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 9 | // Neither the name of ComponentAce nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 10 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 11 | 12 | 13 | 14 | /* 15 | Copyright (c) 2000,2001,2002,2003 ymnk, JCraft,Inc. All rights reserved. 16 | 17 | Redistribution and use in source and binary forms, with or without 18 | modification, are permitted provided that the following conditions are met: 19 | 20 | 1. Redistributions of source code must retain the above copyright notice, 21 | this list of conditions and the following disclaimer. 22 | 23 | 2. Redistributions in binary form must reproduce the above copyright 24 | notice, this list of conditions and the following disclaimer in 25 | the documentation and/or other materials provided with the distribution. 26 | 27 | 3. The names of the authors may not be used to endorse or promote products 28 | derived from this software without specific prior written permission. 29 | 30 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 31 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 32 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, 33 | INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, 34 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 35 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 36 | OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 37 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 38 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 39 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 40 | */ 41 | /* 42 | * This program is based on zlib-1.1.3, so all credit should go authors 43 | * Jean-loup Gailly(jloup@gzip.org) and Mark Adler(madler@alumni.caltech.edu) 44 | * and contributors of zlib. 45 | */ 46 | using System; 47 | namespace ComponentAce.Compression.Libs.zlib 48 | { 49 | 50 | sealed class Adler32 51 | { 52 | 53 | // largest prime smaller than 65536 54 | private const int BASE = 65521; 55 | // NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 56 | private const int NMAX = 5552; 57 | 58 | internal long adler32(long adler, byte[] buf, int index, int len) 59 | { 60 | if (buf == null) 61 | { 62 | return 1L; 63 | } 64 | 65 | long s1 = adler & 0xffff; 66 | long s2 = (adler >> 16) & 0xffff; 67 | int k; 68 | 69 | while (len > 0) 70 | { 71 | k = len < NMAX?len:NMAX; 72 | len -= k; 73 | while (k >= 16) 74 | { 75 | s1 += (buf[index++] & 0xff); s2 += s1; 76 | s1 += (buf[index++] & 0xff); s2 += s1; 77 | s1 += (buf[index++] & 0xff); s2 += s1; 78 | s1 += (buf[index++] & 0xff); s2 += s1; 79 | s1 += (buf[index++] & 0xff); s2 += s1; 80 | s1 += (buf[index++] & 0xff); s2 += s1; 81 | s1 += (buf[index++] & 0xff); s2 += s1; 82 | s1 += (buf[index++] & 0xff); s2 += s1; 83 | s1 += (buf[index++] & 0xff); s2 += s1; 84 | s1 += (buf[index++] & 0xff); s2 += s1; 85 | s1 += (buf[index++] & 0xff); s2 += s1; 86 | s1 += (buf[index++] & 0xff); s2 += s1; 87 | s1 += (buf[index++] & 0xff); s2 += s1; 88 | s1 += (buf[index++] & 0xff); s2 += s1; 89 | s1 += (buf[index++] & 0xff); s2 += s1; 90 | s1 += (buf[index++] & 0xff); s2 += s1; 91 | k -= 16; 92 | } 93 | if (k != 0) 94 | { 95 | do 96 | { 97 | s1 += (buf[index++] & 0xff); s2 += s1; 98 | } 99 | while (--k != 0); 100 | } 101 | s1 %= BASE; 102 | s2 %= BASE; 103 | } 104 | return (s2 << 16) | s1; 105 | } 106 | 107 | } 108 | } -------------------------------------------------------------------------------- /src/Zlib.net/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | 4 | // 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | // 9 | [assembly: AssemblyTitle("ZLIB.NET")] 10 | [assembly: AssemblyDescription("ZLIB.NET")] 11 | [assembly: AssemblyConfiguration("")] 12 | [assembly: AssemblyCompany("ComponentAce")] 13 | [assembly: AssemblyProduct("ZLIB.NET")] 14 | [assembly: AssemblyCopyright("ComponentAce")] 15 | [assembly: AssemblyTrademark("")] 16 | [assembly: AssemblyCulture("")] 17 | 18 | // 19 | // Version information for an assembly consists of the following four values: 20 | // 21 | // Major Version 22 | // Minor Version 23 | // Build Number 24 | // Revision 25 | // 26 | // You can specify all the values or you can default the Revision and Build Numbers 27 | // by using the '*' as shown below: 28 | 29 | [assembly: AssemblyVersion("1.0.3.0")] 30 | 31 | // 32 | // In order to sign your assembly you must specify a key to use. Refer to the 33 | // Microsoft .NET Framework documentation for more information on assembly signing. 34 | // 35 | // Use the attributes below to control which key is used for signing. 36 | // 37 | // Notes: 38 | // (*) If no key is specified, the assembly is not signed. 39 | // (*) KeyName refers to a key that has been installed in the Crypto Service 40 | // Provider (CSP) on your machine. KeyFile refers to a file which contains 41 | // a key. 42 | // (*) If the KeyFile and the KeyName values are both specified, the 43 | // following processing occurs: 44 | // (1) If the KeyName can be found in the CSP, that key is used. 45 | // (2) If the KeyName does not exist and the KeyFile does exist, the key 46 | // in the KeyFile is installed into the CSP and used. 47 | // (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility. 48 | // When specifying the KeyFile, the location of the KeyFile should be 49 | // relative to the project output directory which is 50 | // %Project Directory%\obj\. For example, if your KeyFile is 51 | // located in the project directory, you would specify the AssemblyKeyFile 52 | // attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")] 53 | // (*) Delay Signing is an advanced option - see the Microsoft .NET Framework 54 | // documentation for more information on this. 55 | // 56 | [assembly: AssemblyDelaySign(false)] 57 | [assembly: AssemblyKeyFile("")] 58 | [assembly: AssemblyKeyName("")] 59 | -------------------------------------------------------------------------------- /src/Zlib.net/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2006-2007, ComponentAce 2 | http://www.componentace.com 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 6 | 7 | Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 9 | Neither the name of ComponentAce nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 10 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 11 | -------------------------------------------------------------------------------- /src/Zlib.net/README.md: -------------------------------------------------------------------------------- 1 | ZLIB.NET: README 2 | ================================================== 3 | 4 | Contents 5 | -------- 6 | 7 | Program information 8 | Company information 9 | Description 10 | Specification 11 | Other ComponentAce compression products 12 | 13 | 14 | 15 | Program information 16 | ------------------- 17 | 18 | Program Name: 19 | ZLIB.NET 20 | License Type: freeware 21 | 22 | Program Version: 23 | 1.04 24 | Program Release Date: 25 | 03/28/2007 26 | Program Purpose: 27 | version of ZLIB compression library for .NET framework 28 | Target Environment: 29 | Visual Studio 2003, Visual Studio 2005, Borland Developer Studio 2005, Borland Developer Studio 2006 and other 30 | 31 | 32 | Company information 33 | ------------------- 34 | 35 | Company Name: 36 | ComponentAce 37 | Contact E-mail Address: 38 | support@componentace.com 39 | Contact WWW URL: 40 | http://www.componentace.com 41 | 42 | 43 | Description 44 | ----------- 45 | 46 | 100% managed version of ZLIB compression library. 47 | Based on JZlib library (c) 2000,2001,2002,2003 ymnk, JCraft,Inc. 48 | 49 | The zlib compression library was written by Jean-loup Gailly gzip@prep.ai.mit.edu and Mark Adler madler@alumni.caltech.edu. 50 | 51 | The primary site for the zlib compression library is http://www.zlib.org. 52 | 53 | Copyright and license 54 | --------------------- 55 | 56 | See "LICENSE" file. 57 | 58 | 59 | Warranty and guarantee 60 | ---------------------- 61 | 62 | See "LICENSE" file. 63 | 64 | 65 | Other ComponentAce compression products 66 | --------------------------------------- 67 | 68 | ZipForge.NET 69 | ------------ 70 | 71 | ZipForge.NET is an advanced ZIP compression library for .NET framework. 72 | ZipForge.NET features include streaming support, transaction system, ZIP encryption, repair, 73 | progress indication, Zip64 support, SFX (self-extracting) archives, unicode filenames, spanning support and much more. 74 | 75 | FlexCompress.NET 76 | ---------------- 77 | 78 | FlexCompress.NET is an advanced compression and encryption .NET component designed to provide archive 79 | functionality for your applications. This solution provides flexible compression and strong encryption algorithms that 80 | allows you to integrate archiving or backup features into your programs in a fast and easy way. 81 | FlexCompres.NET uses its own file format which allows to achieve high compression rate. 82 | 83 | For more info visit 84 | http://www.componentace.com/.NET_components -------------------------------------------------------------------------------- /src/Zlib.net/ZStreamException.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2006, ComponentAce 2 | // http://www.componentace.com 3 | // All rights reserved. 4 | 5 | // Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 6 | 7 | // Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | // Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 9 | // Neither the name of ComponentAce nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 10 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 11 | 12 | /* 13 | Copyright (c) 2000,2001,2002,2003 ymnk, JCraft,Inc. All rights reserved. 14 | 15 | Redistribution and use in source and binary forms, with or without 16 | modification, are permitted provided that the following conditions are met: 17 | 18 | 1. Redistributions of source code must retain the above copyright notice, 19 | this list of conditions and the following disclaimer. 20 | 21 | 2. Redistributions in binary form must reproduce the above copyright 22 | notice, this list of conditions and the following disclaimer in 23 | the documentation and/or other materials provided with the distribution. 24 | 25 | 3. The names of the authors may not be used to endorse or promote products 26 | derived from this software without specific prior written permission. 27 | 28 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 29 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 30 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, 31 | INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, 32 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 33 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 34 | OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 35 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 36 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 37 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 38 | */ 39 | /* 40 | * This program is based on zlib-1.1.3, so all credit should go authors 41 | * Jean-loup Gailly(jloup@gzip.org) and Mark Adler(madler@alumni.caltech.edu) 42 | * and contributors of zlib. 43 | */ 44 | using System; 45 | namespace ComponentAce.Compression.Libs.zlib 46 | { 47 | 48 | 49 | public class ZStreamException:System.IO.IOException 50 | { 51 | public ZStreamException():base() 52 | { 53 | } 54 | public ZStreamException(System.String s):base(s) 55 | { 56 | } 57 | } 58 | } -------------------------------------------------------------------------------- /src/Zlib.net/Zlib.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2006, ComponentAce 2 | // http://www.componentace.com 3 | // All rights reserved. 4 | 5 | // Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 6 | 7 | // Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | // Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 9 | // Neither the name of ComponentAce nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 10 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 11 | 12 | /* 13 | Copyright (c) 2000,2001,2002,2003 ymnk, JCraft,Inc. All rights reserved. 14 | 15 | Redistribution and use in source and binary forms, with or without 16 | modification, are permitted provided that the following conditions are met: 17 | 18 | 1. Redistributions of source code must retain the above copyright notice, 19 | this list of conditions and the following disclaimer. 20 | 21 | 2. Redistributions in binary form must reproduce the above copyright 22 | notice, this list of conditions and the following disclaimer in 23 | the documentation and/or other materials provided with the distribution. 24 | 25 | 3. The names of the authors may not be used to endorse or promote products 26 | derived from this software without specific prior written permission. 27 | 28 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 29 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 30 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, 31 | INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, 32 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 33 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 34 | OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 35 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 36 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 37 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 38 | */ 39 | /* 40 | * This program is based on zlib-1.1.3, so all credit should go authors 41 | * Jean-loup Gailly(jloup@gzip.org) and Mark Adler(madler@alumni.caltech.edu) 42 | * and contributors of zlib. 43 | */ 44 | using System; 45 | namespace ComponentAce.Compression.Libs.zlib 46 | { 47 | 48 | sealed public class zlibConst 49 | { 50 | private const System.String version_Renamed_Field = "1.0.2"; 51 | public static System.String version() 52 | { 53 | return version_Renamed_Field; 54 | } 55 | 56 | // compression levels 57 | public const int Z_NO_COMPRESSION = 0; 58 | public const int Z_BEST_SPEED = 1; 59 | public const int Z_BEST_COMPRESSION = 9; 60 | public const int Z_DEFAULT_COMPRESSION = (- 1); 61 | 62 | // compression strategy 63 | public const int Z_FILTERED = 1; 64 | public const int Z_HUFFMAN_ONLY = 2; 65 | public const int Z_DEFAULT_STRATEGY = 0; 66 | 67 | public const int Z_NO_FLUSH = 0; 68 | public const int Z_PARTIAL_FLUSH = 1; 69 | public const int Z_SYNC_FLUSH = 2; 70 | public const int Z_FULL_FLUSH = 3; 71 | public const int Z_FINISH = 4; 72 | 73 | public const int Z_OK = 0; 74 | public const int Z_STREAM_END = 1; 75 | public const int Z_NEED_DICT = 2; 76 | public const int Z_ERRNO = - 1; 77 | public const int Z_STREAM_ERROR = - 2; 78 | public const int Z_DATA_ERROR = - 3; 79 | public const int Z_MEM_ERROR = - 4; 80 | public const int Z_BUF_ERROR = - 5; 81 | public const int Z_VERSION_ERROR = - 6; 82 | } 83 | } -------------------------------------------------------------------------------- /src/Zlib.net/Zlib.net.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Local 5 | 7.10.3077 6 | 2.0 7 | {0C89B7A2-A218-49E4-B545-5B044A45F977} 8 | Debug 9 | AnyCPU 10 | 11 | 12 | zlib.net 13 | 14 | JScript 15 | Grid 16 | IE50 17 | false 18 | Library 19 | zlib 20 | OnBuildSuccess 21 | 22 | 23 | 24 | 25 | 26 | 0.0 27 | v4.7.2 28 | 29 | 30 | 31 | true 32 | bin\x86\Debug\ 33 | DEBUG;TRACE 34 | 285212672 35 | 4096 36 | full 37 | x86 38 | 7.3 39 | prompt 40 | 41 | 42 | bin\x86\Release\ 43 | TRACE 44 | 285212672 45 | true 46 | 4096 47 | x86 48 | 7.3 49 | prompt 50 | 51 | 52 | true 53 | bin\x64\Debug\ 54 | DEBUG;TRACE 55 | 285212672 56 | 4096 57 | full 58 | x64 59 | 7.3 60 | prompt 61 | 62 | 63 | bin\x64\Release\ 64 | TRACE 65 | 285212672 66 | true 67 | 4096 68 | x64 69 | 7.3 70 | prompt 71 | 72 | 73 | 74 | System 75 | 76 | 77 | System.Data 78 | 79 | 80 | System.XML 81 | 82 | 83 | 84 | 85 | Code 86 | 87 | 88 | Code 89 | 90 | 91 | Code 92 | 93 | 94 | Code 95 | 96 | 97 | Code 98 | 99 | 100 | Code 101 | 102 | 103 | Code 104 | 105 | 106 | Code 107 | 108 | 109 | Code 110 | 111 | 112 | Code 113 | 114 | 115 | Code 116 | 117 | 118 | Code 119 | 120 | 121 | Code 122 | 123 | 124 | Code 125 | 126 | 127 | Code 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | -------------------------------------------------------------------------------- /src/Zlib.net/history.txt: -------------------------------------------------------------------------------- 1 | ZLIB.NET: History of changes 2 | ============================= 3 | 4 | version 1.04 (03/28/2007) 5 | 6 | - Problem with decompression some files is solved 7 | 8 | 9 | version 1.03 (03/05/2007) 10 | 11 | - Problem with decomressing some files is solved 12 | 13 | 14 | version 1.02 (01/29/2007) 15 | 16 | - Problem with decompressing large files using ZOutputStream is solved 17 | 18 | 19 | version 1.01 (08/17/2006) 20 | 21 | - Demos are updated 22 | - Some minor bugs are fixed 23 | 24 | 25 | version 1.0 (07/06/2006) 26 | 27 | 28 | 29 | 30 | --------------------------------------------------------------------------------