├── .gitignore ├── ControlLogixNET.sln ├── ControlLogixNET ├── ChangeLog.txt ├── CommonDataServiceReply.cs ├── ControlLogixNET.csproj ├── ConversionHelper.cs ├── Exceptions.cs ├── GetStructAttribsRequest.cs ├── Known Issues.txt ├── LicenseCheck.cs ├── LogixErrors.cs ├── LogixProcessor.cs ├── LogixRead.cs ├── LogixServices.cs ├── LogixTag.cs ├── LogixTagGroup.cs ├── LogixTagInfo.cs ├── LogixTypes.cs ├── MultiServiceRequest.cs ├── NamespaceDoc.cs ├── ProcessorFaultState.cs ├── ProcessorKeySwitch.cs ├── ProcessorResetType.cs ├── ProcessorState.cs ├── Properties │ └── AssemblyInfo.cs ├── ReadDataServiceReply.cs ├── ReadDataServiceRequest.cs ├── ReadTemplateRequest.cs ├── Resources │ ├── ErrorStrings.Designer.cs │ └── ErrorStrings.resx ├── SequenceNumberGenerator.cs ├── TemplateInfo.cs ├── TypeConverter.cs ├── UtilityBelt.cs ├── WriteDataServiceReply.cs └── WriteDataServiceRequest.cs ├── Examples ├── ArrayTags │ ├── ArrayTags.csproj │ ├── Program.cs │ └── Properties │ │ └── AssemblyInfo.cs ├── Processor │ ├── Processor.csproj │ ├── Program.cs │ └── Properties │ │ └── AssemblyInfo.cs ├── SimpleOperations │ ├── Program.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ └── SimpleOperations.csproj ├── StructureTags │ ├── Program.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ └── StructureTags.csproj ├── TagGroups │ ├── Program.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ └── TagGroups.csproj └── UserDefinedType │ ├── Program.cs │ ├── Properties │ └── AssemblyInfo.cs │ └── UserDefinedType.csproj ├── ICommon ├── ICommon.csproj ├── IDevice.cs ├── ITag.cs ├── Properties │ └── AssemblyInfo.cs └── TagQuality.cs ├── LICENSE └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | # Build Folders (you can keep bin if you'd like, to store dlls and pdbs) 2 | [Bb]in/ 3 | [Oo]bj/ 4 | 5 | # mstest test results 6 | TestResults 7 | 8 | ## Ignore Visual Studio temporary files, build results, and 9 | ## files generated by popular Visual Studio add-ons. 10 | 11 | # User-specific files 12 | *.suo 13 | *.user 14 | *.sln.docstates 15 | 16 | # Build results 17 | [Dd]ebug/ 18 | [Rr]elease/ 19 | x64/ 20 | *_i.c 21 | *_p.c 22 | *.ilk 23 | *.meta 24 | *.obj 25 | *.pch 26 | *.pdb 27 | *.pgc 28 | *.pgd 29 | *.rsp 30 | *.sbr 31 | *.tlb 32 | *.tli 33 | *.tlh 34 | *.tmp 35 | *.log 36 | *.vspscc 37 | *.vssscc 38 | .builds 39 | 40 | # Visual C++ cache files 41 | ipch/ 42 | *.aps 43 | *.ncb 44 | *.opensdf 45 | *.sdf 46 | 47 | # Visual Studio profiler 48 | *.psess 49 | *.vsp 50 | *.vspx 51 | 52 | # Guidance Automation Toolkit 53 | *.gpState 54 | 55 | # ReSharper is a .NET coding add-in 56 | _ReSharper* 57 | 58 | # NCrunch 59 | *.ncrunch* 60 | .*crunch*.local.xml 61 | 62 | # Installshield output folder 63 | [Ee]xpress 64 | 65 | # DocProject is a documentation generator add-in 66 | DocProject/buildhelp/ 67 | DocProject/Help/*.HxT 68 | DocProject/Help/*.HxC 69 | DocProject/Help/*.hhc 70 | DocProject/Help/*.hhk 71 | DocProject/Help/*.hhp 72 | DocProject/Help/Html2 73 | DocProject/Help/html 74 | 75 | # Click-Once directory 76 | publish 77 | 78 | # Publish Web Output 79 | *.Publish.xml 80 | 81 | # NuGet Packages Directory 82 | packages 83 | 84 | # Windows Azure Build Output 85 | csx 86 | *.build.csdef 87 | 88 | # Windows Store app package directory 89 | AppPackages/ 90 | 91 | # Others 92 | [Bb]in 93 | [Oo]bj 94 | sql 95 | TestResults 96 | [Tt]est[Rr]esult* 97 | *.Cache 98 | ClientBin 99 | [Ss]tyle[Cc]op.* 100 | ~$* 101 | *.dbmdl 102 | Generated_Code #added for RIA/Silverlight projects 103 | 104 | # Backup & report files from converting an old project file to a newer 105 | # Visual Studio version. Backup files are not needed, because we have git ;-) 106 | _UpgradeReport_Files/ 107 | Backup*/ 108 | UpgradeLog*.XML 109 | -------------------------------------------------------------------------------- /ControlLogixNET.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 11.00 3 | # Visual Studio 2010 4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ControlLogixNET", "ControlLogixNET\ControlLogixNET.csproj", "{9A6CFFE2-0C70-45A7-92FC-88DA9000E591}" 5 | EndProject 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICommon", "ICommon\ICommon.csproj", "{1E726BE8-F9B8-4A9B-B052-E0D9154F3896}" 7 | EndProject 8 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Examples", "Examples", "{3BBB1E40-64FC-46BD-92AA-2D7704C5095E}" 9 | EndProject 10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Processor", "Examples\Processor\Processor.csproj", "{54A5D090-5322-4087-8E92-4A5C5E8E194E}" 11 | EndProject 12 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SimpleOperations", "Examples\SimpleOperations\SimpleOperations.csproj", "{E653D839-E72D-4B45-B6B3-754A8EF98AEE}" 13 | EndProject 14 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TagGroups", "Examples\TagGroups\TagGroups.csproj", "{B8B61369-057F-4893-8C52-366BC8C09EBC}" 15 | EndProject 16 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ArrayTags", "Examples\ArrayTags\ArrayTags.csproj", "{FA46ECC1-6E51-47FA-B025-A38BF75515B8}" 17 | EndProject 18 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UserDefinedType", "Examples\UserDefinedType\UserDefinedType.csproj", "{C11608A6-1EC1-4859-9D42-B4A21FD9D5DD}" 19 | EndProject 20 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StructureTags", "Examples\StructureTags\StructureTags.csproj", "{F9FF55D3-526E-46E7-B703-45E980FABA33}" 21 | EndProject 22 | Global 23 | GlobalSection(TeamFoundationVersionControl) = preSolution 24 | SccNumberOfProjects = 9 25 | SccEnterpriseProvider = {4CA58AB2-18FA-4F8D-95D4-32DDF27D184C} 26 | SccTeamFoundationServer = https://tfs.codeplex.com/tfs/tfs12 27 | SccLocalPath0 = . 28 | SccProjectUniqueName1 = ControlLogixNET\\ControlLogixNET.csproj 29 | SccProjectName1 = ControlLogixNET 30 | SccLocalPath1 = ControlLogixNET 31 | SccProjectUniqueName2 = Examples\\ArrayTags\\ArrayTags.csproj 32 | SccProjectTopLevelParentUniqueName2 = ControlLogixNET.sln 33 | SccProjectName2 = Examples/ArrayTags 34 | SccLocalPath2 = Examples\\ArrayTags 35 | SccProjectUniqueName3 = Examples\\Processor\\Processor.csproj 36 | SccProjectTopLevelParentUniqueName3 = ControlLogixNET.sln 37 | SccProjectName3 = Examples/Processor 38 | SccLocalPath3 = Examples\\Processor 39 | SccProjectUniqueName4 = Examples\\SimpleOperations\\SimpleOperations.csproj 40 | SccProjectTopLevelParentUniqueName4 = ControlLogixNET.sln 41 | SccProjectName4 = Examples/SimpleOperations 42 | SccLocalPath4 = Examples\\SimpleOperations 43 | SccProjectUniqueName5 = Examples\\StructureTags\\StructureTags.csproj 44 | SccProjectTopLevelParentUniqueName5 = ControlLogixNET.sln 45 | SccProjectName5 = Examples/StructureTags 46 | SccLocalPath5 = Examples\\StructureTags 47 | SccProjectUniqueName6 = Examples\\TagGroups\\TagGroups.csproj 48 | SccProjectTopLevelParentUniqueName6 = ControlLogixNET.sln 49 | SccProjectName6 = Examples/TagGroups 50 | SccLocalPath6 = Examples\\TagGroups 51 | SccProjectUniqueName7 = Examples\\UserDefinedType\\UserDefinedType.csproj 52 | SccProjectTopLevelParentUniqueName7 = ControlLogixNET.sln 53 | SccProjectName7 = Examples/UserDefinedType 54 | SccLocalPath7 = Examples\\UserDefinedType 55 | SccProjectUniqueName8 = ICommon\\ICommon.csproj 56 | SccProjectName8 = ICommon 57 | SccLocalPath8 = ICommon 58 | EndGlobalSection 59 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 60 | Debug|Any CPU = Debug|Any CPU 61 | Debug|Mixed Platforms = Debug|Mixed Platforms 62 | Debug|x86 = Debug|x86 63 | Release|Any CPU = Release|Any CPU 64 | Release|Mixed Platforms = Release|Mixed Platforms 65 | Release|x86 = Release|x86 66 | EndGlobalSection 67 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 68 | {9A6CFFE2-0C70-45A7-92FC-88DA9000E591}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 69 | {9A6CFFE2-0C70-45A7-92FC-88DA9000E591}.Debug|Any CPU.Build.0 = Debug|Any CPU 70 | {9A6CFFE2-0C70-45A7-92FC-88DA9000E591}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU 71 | {9A6CFFE2-0C70-45A7-92FC-88DA9000E591}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU 72 | {9A6CFFE2-0C70-45A7-92FC-88DA9000E591}.Debug|x86.ActiveCfg = Debug|Any CPU 73 | {9A6CFFE2-0C70-45A7-92FC-88DA9000E591}.Release|Any CPU.ActiveCfg = Release|Any CPU 74 | {9A6CFFE2-0C70-45A7-92FC-88DA9000E591}.Release|Any CPU.Build.0 = Release|Any CPU 75 | {9A6CFFE2-0C70-45A7-92FC-88DA9000E591}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU 76 | {9A6CFFE2-0C70-45A7-92FC-88DA9000E591}.Release|Mixed Platforms.Build.0 = Release|Any CPU 77 | {9A6CFFE2-0C70-45A7-92FC-88DA9000E591}.Release|x86.ActiveCfg = Release|Any CPU 78 | {1E726BE8-F9B8-4A9B-B052-E0D9154F3896}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 79 | {1E726BE8-F9B8-4A9B-B052-E0D9154F3896}.Debug|Any CPU.Build.0 = Debug|Any CPU 80 | {1E726BE8-F9B8-4A9B-B052-E0D9154F3896}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU 81 | {1E726BE8-F9B8-4A9B-B052-E0D9154F3896}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU 82 | {1E726BE8-F9B8-4A9B-B052-E0D9154F3896}.Debug|x86.ActiveCfg = Debug|Any CPU 83 | {1E726BE8-F9B8-4A9B-B052-E0D9154F3896}.Release|Any CPU.ActiveCfg = Release|Any CPU 84 | {1E726BE8-F9B8-4A9B-B052-E0D9154F3896}.Release|Any CPU.Build.0 = Release|Any CPU 85 | {1E726BE8-F9B8-4A9B-B052-E0D9154F3896}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU 86 | {1E726BE8-F9B8-4A9B-B052-E0D9154F3896}.Release|Mixed Platforms.Build.0 = Release|Any CPU 87 | {1E726BE8-F9B8-4A9B-B052-E0D9154F3896}.Release|x86.ActiveCfg = Release|Any CPU 88 | {54A5D090-5322-4087-8E92-4A5C5E8E194E}.Debug|Any CPU.ActiveCfg = Debug|x86 89 | {54A5D090-5322-4087-8E92-4A5C5E8E194E}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 90 | {54A5D090-5322-4087-8E92-4A5C5E8E194E}.Debug|Mixed Platforms.Build.0 = Debug|x86 91 | {54A5D090-5322-4087-8E92-4A5C5E8E194E}.Debug|x86.ActiveCfg = Debug|x86 92 | {54A5D090-5322-4087-8E92-4A5C5E8E194E}.Debug|x86.Build.0 = Debug|x86 93 | {54A5D090-5322-4087-8E92-4A5C5E8E194E}.Release|Any CPU.ActiveCfg = Release|x86 94 | {54A5D090-5322-4087-8E92-4A5C5E8E194E}.Release|Mixed Platforms.ActiveCfg = Release|x86 95 | {54A5D090-5322-4087-8E92-4A5C5E8E194E}.Release|Mixed Platforms.Build.0 = Release|x86 96 | {54A5D090-5322-4087-8E92-4A5C5E8E194E}.Release|x86.ActiveCfg = Release|x86 97 | {54A5D090-5322-4087-8E92-4A5C5E8E194E}.Release|x86.Build.0 = Release|x86 98 | {E653D839-E72D-4B45-B6B3-754A8EF98AEE}.Debug|Any CPU.ActiveCfg = Debug|x86 99 | {E653D839-E72D-4B45-B6B3-754A8EF98AEE}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 100 | {E653D839-E72D-4B45-B6B3-754A8EF98AEE}.Debug|Mixed Platforms.Build.0 = Debug|x86 101 | {E653D839-E72D-4B45-B6B3-754A8EF98AEE}.Debug|x86.ActiveCfg = Debug|x86 102 | {E653D839-E72D-4B45-B6B3-754A8EF98AEE}.Debug|x86.Build.0 = Debug|x86 103 | {E653D839-E72D-4B45-B6B3-754A8EF98AEE}.Release|Any CPU.ActiveCfg = Release|x86 104 | {E653D839-E72D-4B45-B6B3-754A8EF98AEE}.Release|Mixed Platforms.ActiveCfg = Release|x86 105 | {E653D839-E72D-4B45-B6B3-754A8EF98AEE}.Release|Mixed Platforms.Build.0 = Release|x86 106 | {E653D839-E72D-4B45-B6B3-754A8EF98AEE}.Release|x86.ActiveCfg = Release|x86 107 | {E653D839-E72D-4B45-B6B3-754A8EF98AEE}.Release|x86.Build.0 = Release|x86 108 | {B8B61369-057F-4893-8C52-366BC8C09EBC}.Debug|Any CPU.ActiveCfg = Debug|x86 109 | {B8B61369-057F-4893-8C52-366BC8C09EBC}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 110 | {B8B61369-057F-4893-8C52-366BC8C09EBC}.Debug|Mixed Platforms.Build.0 = Debug|x86 111 | {B8B61369-057F-4893-8C52-366BC8C09EBC}.Debug|x86.ActiveCfg = Debug|x86 112 | {B8B61369-057F-4893-8C52-366BC8C09EBC}.Debug|x86.Build.0 = Debug|x86 113 | {B8B61369-057F-4893-8C52-366BC8C09EBC}.Release|Any CPU.ActiveCfg = Release|x86 114 | {B8B61369-057F-4893-8C52-366BC8C09EBC}.Release|Mixed Platforms.ActiveCfg = Release|x86 115 | {B8B61369-057F-4893-8C52-366BC8C09EBC}.Release|Mixed Platforms.Build.0 = Release|x86 116 | {B8B61369-057F-4893-8C52-366BC8C09EBC}.Release|x86.ActiveCfg = Release|x86 117 | {B8B61369-057F-4893-8C52-366BC8C09EBC}.Release|x86.Build.0 = Release|x86 118 | {FA46ECC1-6E51-47FA-B025-A38BF75515B8}.Debug|Any CPU.ActiveCfg = Debug|x86 119 | {FA46ECC1-6E51-47FA-B025-A38BF75515B8}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 120 | {FA46ECC1-6E51-47FA-B025-A38BF75515B8}.Debug|Mixed Platforms.Build.0 = Debug|x86 121 | {FA46ECC1-6E51-47FA-B025-A38BF75515B8}.Debug|x86.ActiveCfg = Debug|x86 122 | {FA46ECC1-6E51-47FA-B025-A38BF75515B8}.Debug|x86.Build.0 = Debug|x86 123 | {FA46ECC1-6E51-47FA-B025-A38BF75515B8}.Release|Any CPU.ActiveCfg = Release|x86 124 | {FA46ECC1-6E51-47FA-B025-A38BF75515B8}.Release|Mixed Platforms.ActiveCfg = Release|x86 125 | {FA46ECC1-6E51-47FA-B025-A38BF75515B8}.Release|Mixed Platforms.Build.0 = Release|x86 126 | {FA46ECC1-6E51-47FA-B025-A38BF75515B8}.Release|x86.ActiveCfg = Release|x86 127 | {FA46ECC1-6E51-47FA-B025-A38BF75515B8}.Release|x86.Build.0 = Release|x86 128 | {C11608A6-1EC1-4859-9D42-B4A21FD9D5DD}.Debug|Any CPU.ActiveCfg = Debug|x86 129 | {C11608A6-1EC1-4859-9D42-B4A21FD9D5DD}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 130 | {C11608A6-1EC1-4859-9D42-B4A21FD9D5DD}.Debug|Mixed Platforms.Build.0 = Debug|x86 131 | {C11608A6-1EC1-4859-9D42-B4A21FD9D5DD}.Debug|x86.ActiveCfg = Debug|x86 132 | {C11608A6-1EC1-4859-9D42-B4A21FD9D5DD}.Debug|x86.Build.0 = Debug|x86 133 | {C11608A6-1EC1-4859-9D42-B4A21FD9D5DD}.Release|Any CPU.ActiveCfg = Release|x86 134 | {C11608A6-1EC1-4859-9D42-B4A21FD9D5DD}.Release|Mixed Platforms.ActiveCfg = Release|x86 135 | {C11608A6-1EC1-4859-9D42-B4A21FD9D5DD}.Release|Mixed Platforms.Build.0 = Release|x86 136 | {C11608A6-1EC1-4859-9D42-B4A21FD9D5DD}.Release|x86.ActiveCfg = Release|x86 137 | {C11608A6-1EC1-4859-9D42-B4A21FD9D5DD}.Release|x86.Build.0 = Release|x86 138 | {F9FF55D3-526E-46E7-B703-45E980FABA33}.Debug|Any CPU.ActiveCfg = Debug|x86 139 | {F9FF55D3-526E-46E7-B703-45E980FABA33}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 140 | {F9FF55D3-526E-46E7-B703-45E980FABA33}.Debug|Mixed Platforms.Build.0 = Debug|x86 141 | {F9FF55D3-526E-46E7-B703-45E980FABA33}.Debug|x86.ActiveCfg = Debug|x86 142 | {F9FF55D3-526E-46E7-B703-45E980FABA33}.Debug|x86.Build.0 = Debug|x86 143 | {F9FF55D3-526E-46E7-B703-45E980FABA33}.Release|Any CPU.ActiveCfg = Release|x86 144 | {F9FF55D3-526E-46E7-B703-45E980FABA33}.Release|Mixed Platforms.ActiveCfg = Release|x86 145 | {F9FF55D3-526E-46E7-B703-45E980FABA33}.Release|Mixed Platforms.Build.0 = Release|x86 146 | {F9FF55D3-526E-46E7-B703-45E980FABA33}.Release|x86.ActiveCfg = Release|x86 147 | {F9FF55D3-526E-46E7-B703-45E980FABA33}.Release|x86.Build.0 = Release|x86 148 | EndGlobalSection 149 | GlobalSection(SolutionProperties) = preSolution 150 | HideSolutionNode = FALSE 151 | EndGlobalSection 152 | GlobalSection(NestedProjects) = preSolution 153 | {54A5D090-5322-4087-8E92-4A5C5E8E194E} = {3BBB1E40-64FC-46BD-92AA-2D7704C5095E} 154 | {E653D839-E72D-4B45-B6B3-754A8EF98AEE} = {3BBB1E40-64FC-46BD-92AA-2D7704C5095E} 155 | {B8B61369-057F-4893-8C52-366BC8C09EBC} = {3BBB1E40-64FC-46BD-92AA-2D7704C5095E} 156 | {FA46ECC1-6E51-47FA-B025-A38BF75515B8} = {3BBB1E40-64FC-46BD-92AA-2D7704C5095E} 157 | {C11608A6-1EC1-4859-9D42-B4A21FD9D5DD} = {3BBB1E40-64FC-46BD-92AA-2D7704C5095E} 158 | {F9FF55D3-526E-46E7-B703-45E980FABA33} = {3BBB1E40-64FC-46BD-92AA-2D7704C5095E} 159 | EndGlobalSection 160 | GlobalSection(MonoDevelopProperties) = preSolution 161 | StartupItem = EIPNET\EIPNET.csproj 162 | EndGlobalSection 163 | EndGlobal 164 | -------------------------------------------------------------------------------- /ControlLogixNET/ChangeLog.txt: -------------------------------------------------------------------------------- 1 | 1.1 2 | Modified LogixTagGroup so that it sends out tag update notifications as soon as the packet is processed instead of waiting for all packets to be processed. 3 | Added a short version of the IOI string to more quickly update tags. 4 | Added methods on LogixTagGroup to add multiple tags. 5 | Added methods on LogixTagGroup to add tags by LogixTagInfo 6 | Added a LogixTagInfo property on the LogixTag 7 | 8 | 1.0 9 | Initial Release -------------------------------------------------------------------------------- /ControlLogixNET/CommonDataServiceReply.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace ControlLogixNET 7 | { 8 | internal class CommonDataServiceReply 9 | { 10 | public byte Service { get; set; } 11 | public byte Reserved { get; set; } 12 | public ushort Status { get; set; } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /ControlLogixNET/ControlLogixNET.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | AnyCPU 6 | 8.0.30703 7 | 2.0 8 | {9A6CFFE2-0C70-45A7-92FC-88DA9000E591} 9 | Library 10 | Properties 11 | ControlLogixNET 12 | ControlLogixNET 13 | v4.0 14 | 512 15 | SAK 16 | SAK 17 | SAK 18 | SAK 19 | 20 | 21 | true 22 | full 23 | false 24 | bin\Debug\ 25 | DEBUG;TRACE 26 | prompt 27 | 4 28 | bin\Debug\ControlLogixNETDocumentation.XML 29 | 30 | 31 | pdbonly 32 | true 33 | bin\Release\ 34 | TRACE 35 | prompt 36 | 4 37 | 38 | 39 | 40 | False 41 | ..\EIPNET\bin\Debug\EIPNET.dll 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | True 84 | True 85 | ErrorStrings.resx 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | {1E726BE8-F9B8-4A9B-B052-E0D9154F3896} 97 | ICommon 98 | 99 | 100 | 101 | 102 | ResXFileCodeGenerator 103 | ErrorStrings.Designer.cs 104 | 105 | 106 | 107 | 108 | Always 109 | 110 | 111 | 112 | 113 | 114 | 115 | 122 | -------------------------------------------------------------------------------- /ControlLogixNET/ConversionHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using ControlLogixNET.LogixType; 6 | 7 | namespace ControlLogixNET 8 | { 9 | /// 10 | /// Set of utility functions to help convert objects or strings to 11 | /// the correct LogixDataType. 12 | /// 13 | internal class ConversionHelper 14 | { 15 | public object ConvertTo(LogixTypes LogixDataType, object InputValue) 16 | { 17 | switch (LogixDataType) 18 | { 19 | default: 20 | break; 21 | } 22 | return null; 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /ControlLogixNET/Exceptions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace ControlLogixNET 7 | { 8 | /// 9 | /// Raised when an invalid response was detected from the processor 10 | /// 11 | public class InvalidProcessorResponseException : Exception 12 | { 13 | /// 14 | /// Creates a new InvalidProcessorResponseException 15 | /// 16 | /// Description of the exception 17 | internal InvalidProcessorResponseException(string Description) 18 | : base(Description) 19 | { 20 | 21 | } 22 | } 23 | 24 | /// 25 | /// Raised when the dimensions have not been set before accessing a 26 | /// multi-dimensional tag. 27 | /// 28 | public class DimensionsNotSetException : Exception 29 | { 30 | /// 31 | /// Creates a new DimensionsNotSetException 32 | /// 33 | /// Description of the exception 34 | internal DimensionsNotSetException(string Description) 35 | : base(Description) 36 | { 37 | 38 | } 39 | } 40 | 41 | /// 42 | /// Raised when trying to add a group to a that 43 | /// already exists. 44 | /// 45 | public class GroupAlreadyExistsException : Exception 46 | { 47 | internal GroupAlreadyExistsException(string Description) 48 | : base(Description) 49 | { 50 | 51 | } 52 | } 53 | 54 | /// 55 | /// Raised when trying to retrieve a group that doesn't exist on the processor 56 | /// 57 | public class GroupNotFoundException : Exception 58 | { 59 | internal GroupNotFoundException(string Description) 60 | : base(Description) 61 | { 62 | 63 | } 64 | } 65 | 66 | /// 67 | /// Raised when trying to address a field in a UDT that does not exist. 68 | /// 69 | public class UDTMemberNotFoundException : Exception 70 | { 71 | internal UDTMemberNotFoundException(string Description) 72 | : base(Description) 73 | { 74 | 75 | } 76 | } 77 | 78 | /// 79 | /// Raised when the specified type cannot be converted to the correct type. 80 | /// 81 | public class TypeConversionException : Exception 82 | { 83 | internal TypeConversionException(string Description) 84 | : base(Description) 85 | { 86 | 87 | } 88 | } 89 | 90 | /// 91 | /// Raised when an array length is not of the required size 92 | /// 93 | public class ArrayLengthException : Exception 94 | { 95 | internal ArrayLengthException(string Description) 96 | : base(Description) { } 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /ControlLogixNET/GetStructAttribsRequest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace ControlLogixNET 7 | { 8 | internal class GetStructAttribsRequest 9 | { 10 | //Bytes 6 and 7 are the instance number 11 | byte[] request = new byte[] 12 | { 0x03, 0x03, 0x20, 0x6C, 0x25, 0x00, 0x00, 0x00, 0x04, 0x00, 0x04, 0x00, 0x03, 0x00, 13 | 0x02, 0x00, 0x01, 0x00 }; 14 | 15 | public byte RequestSize { get { return (byte)request.Length; } } 16 | 17 | public GetStructAttribsRequest(ushort StructureId) 18 | { 19 | request[7] = (byte)(StructureId & 0x00FF); 20 | request[6] = (byte)((StructureId & 0xFF00) >> 8); 21 | } 22 | 23 | public byte[] Pack() 24 | { 25 | return request; 26 | } 27 | } 28 | 29 | internal class GetStructAttribsReply 30 | { 31 | public uint TemplateSize { get; internal set; } 32 | public ushort MemorySize { get; internal set; } 33 | public ushort MemberCount { get; internal set; } 34 | public ushort Handle { get; internal set; } 35 | 36 | public GetStructAttribsReply(byte[] data) 37 | { 38 | TemplateSize = BitConverter.ToUInt32(data, 6); 39 | MemorySize = BitConverter.ToUInt16(data, 14); 40 | MemberCount = BitConverter.ToUInt16(data, 20); 41 | Handle = BitConverter.ToUInt16(data, 26); 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /ControlLogixNET/Known Issues.txt: -------------------------------------------------------------------------------- 1 | This file contains a list of known issues. These issues will be fixed in an order of priority. 2 | 3 | 1. The "SenderContext" is not being persisted through the requests. (Fixed 9-16-2011 RAB) 4 | 2. LogixProcessor.WriteTag does not support more data than will fit in one packet. Solution may be to create a new WriteOnly group to write the tag. -------------------------------------------------------------------------------- /ControlLogixNET/LicenseCheck.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace ControlLogixNET 7 | { 8 | internal static class LicenseCheck 9 | { 10 | 11 | static LicenseCheck() 12 | { 13 | 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /ControlLogixNET/LogixErrors.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace ControlLogixNET 7 | { 8 | /// 9 | /// Various Logix Errors 10 | /// 11 | public enum LogixErrors 12 | { 13 | /// 14 | /// Session could not be established with the communications link 15 | /// 16 | SessionNotEstablished = -1, 17 | /// 18 | /// Session could not be registered with the communications link 19 | /// 20 | SessionNotRegistered = -2, 21 | /// 22 | /// CIP is not supported on the target device 23 | /// 24 | CIPNotSupported = -3, 25 | /// 26 | /// Processor could not be connected 27 | /// 28 | ProcessorNotConnected = -4, 29 | /// 30 | /// Incorrect Argument Tag Type 31 | /// 32 | IncorrectArgTagType = -5, 33 | /// 34 | /// Tag was not found on the processor 35 | /// 36 | TagNotFound = -6, 37 | /// 38 | /// The data returned by the processor does not match the tag type 39 | /// 40 | TypeMismatch = -7, 41 | /// 42 | /// The group that you are trying to add to the processor already exists 43 | /// 44 | GroupExists = -8, 45 | /// 46 | /// The specified group was not found 47 | /// 48 | GroupNotFound = -9, 49 | /// 50 | /// The processor received an invalid response size 51 | /// 52 | InvalidResponseSize = -10, 53 | /// 54 | /// The specified value could not be converted to the required type 55 | /// 56 | TypeConversionError = -11, 57 | /// 58 | /// The specified User Defined Type member was not found in the structure 59 | /// 60 | UDTMemberNotFound = -12, 61 | /// 62 | /// The IOI path could not be deciphered or the matching item was not found. 63 | /// 64 | MalformedIOI = -13, 65 | /// 66 | /// The item referenced could not be found on the processor 67 | /// 68 | ItemNotFound = -14, 69 | /// 70 | /// An error occurred trying to process one of the attributes 71 | /// 72 | AttributeError = -15, 73 | /// 74 | /// Not enough data was sent to the processor to execute the command 75 | /// 76 | NotEnoughData = -16, 77 | /// 78 | /// An insufficient number of attributes were supplied compared to the attribute count. 79 | /// 80 | InsufficientAttributes = -17, 81 | /// 82 | /// The IOI word length did not match the amount of IOI which was processed 83 | /// 84 | InvalidIOILength = -18, 85 | /// 86 | /// An attempt was made to access data beyond the end of the object 87 | /// 88 | AccessBeyondObject = -19, 89 | /// 90 | /// The abbreviated type does not match the data type of the object 91 | /// 92 | AbbreviatedTypeError = -20, 93 | /// 94 | /// The beginning offset was beyond the end of the template 95 | /// 96 | BeginOffsetError = -21, 97 | /// 98 | /// A socket exception has occurred 99 | /// 100 | SocketError = -22, 101 | /// 102 | /// An unknown error has occurred 103 | /// 104 | Unknown = -100 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /ControlLogixNET/LogixRead.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using EIPNET.CIP; 6 | 7 | namespace ControlLogixNET 8 | { 9 | internal class LogixRead 10 | { 11 | public CIPType DataType { get; set; } 12 | public int VarCount { get; set; } 13 | public int TotalSize { get; set; } 14 | public int ElementSize { get; set; } 15 | public uint Mask { get; set; } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /ControlLogixNET/LogixServices.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using EIPNET.CIP; 6 | using EIPNET; 7 | using EIPNET.EIP; 8 | 9 | namespace ControlLogixNET 10 | { 11 | internal class LogixServices 12 | { 13 | public static ReadDataServiceRequest BuildLogixReadDataRequest(LogixTag tag, ushort number, out int requestSize) 14 | { 15 | if (tag.TagInfo != null && tag.TagInfo.IsStructure == false && tag.TagInfo.Dimensions == 0) 16 | { 17 | //Short version 18 | ushort size = 0; 19 | switch ((CIPType)tag.TagInfo.DataType) 20 | { 21 | case CIPType.BITS: 22 | case CIPType.BOOL: 23 | size = 1; break; 24 | case CIPType.DINT: 25 | size = 4; break; 26 | case CIPType.INT: 27 | size = 2; break; 28 | case CIPType.LINT: 29 | size = 8; break; 30 | case CIPType.REAL: 31 | size = 4; break; 32 | case CIPType.SINT: 33 | size = 1; break; 34 | default: 35 | return BuildLogixReadDataRequest(tag.Address, number, out requestSize); 36 | } 37 | 38 | return BuildShortReadDataRequest(tag.TagInfo.MemoryAddress, number, size, out requestSize); 39 | } 40 | else 41 | { 42 | //Long version 43 | return BuildLogixReadDataRequest(tag.Address, number, out requestSize); 44 | } 45 | } 46 | 47 | public static ReadDataServiceRequest BuildLogixReadDataRequest(string tagAddress, ushort number, out int requestSize) 48 | { 49 | byte[] newIOI = IOI.BuildIOI(tagAddress); 50 | 51 | int pathLen = newIOI.Length;// IOI.BuildIOI(null, tagAddress); 52 | ReadDataServiceRequest request = new ReadDataServiceRequest(); 53 | request.Service = (byte)ControlNetService.CIP_ReadData; 54 | request.PathSize = (byte)(pathLen / 2); 55 | byte[] path = new byte[pathLen]; 56 | Buffer.BlockCopy(newIOI, 0, path, 0, newIOI.Length); 57 | //IOI.BuildIOI(path, tagAddress); 58 | request.Path = path; 59 | request.Elements = number; 60 | 61 | requestSize = request.Size; 62 | 63 | return request; 64 | } 65 | 66 | public static ReadDataServiceRequest BuildShortReadDataRequest(uint tagInstance, ushort number, ushort size, out int requestSize) 67 | { 68 | byte[] newIOI = IOI.BuildIOI(tagInstance); 69 | 70 | int pathLen = newIOI.Length; 71 | ReadDataServiceRequest request = new ReadDataServiceRequest(); 72 | request.Service = 0x4E;// (byte)ControlNetService.CIP_ReadData; 73 | request.PathSize = 0x03; 74 | byte[] path = new byte[] { 0x20, 0xB2, 0x25, 0x00, 0x21, 0x00 }; 75 | request.Path = path; 76 | request.Elements = number; 77 | 78 | byte[] addData = new byte[10 + newIOI.Length]; 79 | addData[0] = 0x02; addData[1] = 0x00; addData[2] = 0x01; addData[3] = 0x01; addData[4] = 0x01; 80 | addData[5] = (byte)(size & 0xFF); addData[6] = (byte)((size & 0xFF00) >> 8); 81 | addData[7] = 0x03; addData[8] = 0x20; addData[9] = 0x6B; 82 | Buffer.BlockCopy(newIOI, 0, addData, 10, newIOI.Length); 83 | request.AddtlData = addData; 84 | 85 | requestSize = request.Size; 86 | 87 | return request; 88 | } 89 | 90 | public static ReadDataServiceRequest BuildFragmentedReadDataRequest(string tagAddress, ushort number, uint offset, out int requestSize) 91 | { 92 | byte[] newIOI = IOI.BuildIOI(tagAddress); 93 | 94 | int pathLen = newIOI.Length;// IOI.BuildIOI(null, tagAddress); 95 | ReadDataServiceRequest request = new ReadDataServiceRequest(); 96 | request.Service = (byte)ControlNetService.CIP_ReadDataFragmented; 97 | request.PathSize = (byte)(pathLen / 2); 98 | request.IsFragmented = true; 99 | request.DataOffset = offset; 100 | byte[] path = new byte[pathLen]; 101 | Buffer.BlockCopy(newIOI, 0, path, 0, newIOI.Length); 102 | //IOI.BuildIOI(path, tagAddress); 103 | request.Path = path; 104 | request.Elements = number; 105 | 106 | requestSize = request.Size; 107 | 108 | return request; 109 | } 110 | 111 | public static ReadDataServiceReply ReadLogixDataFragmented(SessionInfo si, string tagAddress, ushort elementCount, uint byteOffset) 112 | { 113 | int requestSize = 0; 114 | ReadDataServiceRequest request = BuildFragmentedReadDataRequest(tagAddress, elementCount, byteOffset, out requestSize); 115 | 116 | EncapsRRData rrData = new EncapsRRData(); 117 | rrData.CPF = new CommonPacket(); 118 | rrData.CPF.AddressItem = CommonPacketItem.GetConnectedAddressItem(si.ConnectionParameters.O2T_CID); 119 | rrData.CPF.DataItem = CommonPacketItem.GetConnectedDataItem(request.Pack(), SequenceNumberGenerator.SequenceNumber); 120 | rrData.Timeout = 2000; 121 | 122 | EncapsReply reply = si.SendUnitData(rrData.CPF.AddressItem, rrData.CPF.DataItem); 123 | 124 | if (reply == null) 125 | return null; 126 | 127 | if (reply.Status != 0 && reply.Status != 0x06) 128 | { 129 | //si.LastSessionError = (int)reply.Status; 130 | return null; 131 | } 132 | 133 | return new ReadDataServiceReply(reply); 134 | } 135 | 136 | public static ReadDataServiceReply ReadLogixData(SessionInfo si, string tagAddress, ushort elementCount) 137 | { 138 | int requestSize = 0; 139 | ReadDataServiceRequest request = BuildLogixReadDataRequest(tagAddress, elementCount, out requestSize); 140 | 141 | EncapsRRData rrData = new EncapsRRData(); 142 | rrData.CPF = new CommonPacket(); 143 | rrData.CPF.AddressItem = CommonPacketItem.GetConnectedAddressItem(si.ConnectionParameters.O2T_CID); 144 | rrData.CPF.DataItem = CommonPacketItem.GetConnectedDataItem(request.Pack(), SequenceNumberGenerator.SequenceNumber); 145 | rrData.Timeout = 2000; 146 | 147 | EncapsReply reply = si.SendUnitData(rrData.CPF.AddressItem, rrData.CPF.DataItem); 148 | 149 | if (reply == null) 150 | return null; 151 | 152 | if (reply.Status != 0 && reply.Status != 0x06) 153 | { 154 | //si.LastSessionError = (int)reply.Status; 155 | return null; 156 | } 157 | 158 | return new ReadDataServiceReply(reply); 159 | } 160 | 161 | #if MONO 162 | public static WriteDataServiceRequest BuildLogixWriteDataRequest(string tagAddress, ushort dataType, ushort elementCount, byte[] data) 163 | { 164 | return BuildLogixWriteDataRequest(tagAddress, dataType, elementCount, data, 0x0000); 165 | } 166 | #endif 167 | #if MONO 168 | public static WriteDataServiceRequest BuildLogixWriteDataRequest(string tagAddress, ushort dataType, ushort elementCount, byte[] data, ushort structHandle) 169 | #else 170 | public static WriteDataServiceRequest BuildLogixWriteDataRequest(string tagAddress, ushort dataType, ushort elementCount, byte[] data, ushort structHandle = 0x0000) 171 | #endif 172 | { 173 | byte[] newIOI = IOI.BuildIOI(tagAddress); 174 | 175 | int pathLen = newIOI.Length; 176 | WriteDataServiceRequest request = new WriteDataServiceRequest(); 177 | request.Service = (byte)ControlNetService.CIP_WriteData; 178 | request.PathSize = (byte)(pathLen / 2); 179 | byte[] path = new byte[pathLen]; 180 | Buffer.BlockCopy(newIOI, 0, path, 0, newIOI.Length); 181 | request.Path = path; 182 | request.Elements = elementCount; 183 | request.DataType = dataType; 184 | request.StructHandle = structHandle; 185 | request.Data = data; 186 | 187 | return request; 188 | } 189 | 190 | #if MONO 191 | public static WriteDataServiceRequest BuildFragmentedWriteRequest(string tagAddress, ushort dataType, ushort elementCount, uint offset, byte[] data) 192 | { 193 | return BuildFragmentedWriteRequest(tagAddress, dataType, elementCount, offset, data, 0x0000); 194 | } 195 | #endif 196 | #if MONO 197 | public static WriteDataServiceRequest BuildFragmentedWriteRequest(string tagAddress, ushort dataType, ushort elementCount, uint offset, byte[] data, ushort structHandle) 198 | #else 199 | public static WriteDataServiceRequest BuildFragmentedWriteRequest(string tagAddress, ushort dataType, ushort elementCount, uint offset, byte[] data, ushort structHandle = 0x0000) 200 | #endif 201 | { 202 | byte[] newIOI = IOI.BuildIOI(tagAddress); 203 | 204 | int pathLen = newIOI.Length; 205 | WriteDataServiceRequest request = new WriteDataServiceRequest(); 206 | request.Service = (byte)ControlNetService.CIP_WriteDataFragmented; 207 | request.PathSize = (byte)(pathLen / 2); 208 | byte[] path = new byte[pathLen]; 209 | Buffer.BlockCopy(newIOI, 0, path, 0, newIOI.Length); 210 | request.Path = path; 211 | request.Elements = elementCount; 212 | request.DataType = dataType; 213 | request.StructHandle = structHandle; 214 | request.IsFragmented = true; 215 | request.Offset = offset; 216 | request.Data = data; 217 | 218 | return request; 219 | } 220 | 221 | #if MONO 222 | public static WriteDataServiceReply WriteLogixData(SessionInfo si, string tagAddress, ushort dataType, ushort elementCount, byte[] data) 223 | { 224 | return WriteLogixData(si, tagAddress, dataType, elementCount, data, 0x0000); 225 | } 226 | #endif 227 | #if MONO 228 | public static WriteDataServiceReply WriteLogixData(SessionInfo si, string tagAddress, ushort dataType, ushort elementCount, byte[] data, ushort structHandle) 229 | #else 230 | public static WriteDataServiceReply WriteLogixData(SessionInfo si, string tagAddress, ushort dataType, ushort elementCount, byte[] data, ushort structHandle = 0x0000) 231 | #endif 232 | { 233 | WriteDataServiceRequest request = BuildLogixWriteDataRequest(tagAddress, dataType, elementCount, data, structHandle); 234 | 235 | EncapsRRData rrData = new EncapsRRData(); 236 | rrData.CPF = new CommonPacket(); 237 | rrData.CPF.AddressItem = CommonPacketItem.GetConnectedAddressItem(si.ConnectionParameters.O2T_CID); 238 | rrData.CPF.DataItem = CommonPacketItem.GetConnectedDataItem(request.Pack(), SequenceNumberGenerator.SequenceNumber); 239 | rrData.Timeout = 2000; 240 | 241 | EncapsReply reply = si.SendUnitData(rrData.CPF.AddressItem, rrData.CPF.DataItem); 242 | 243 | if (reply == null) 244 | return null; 245 | 246 | if (reply.Status != 0) 247 | { 248 | return null; 249 | } 250 | 251 | return new WriteDataServiceReply(reply); 252 | } 253 | 254 | } 255 | } 256 | -------------------------------------------------------------------------------- /ControlLogixNET/LogixTagInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace ControlLogixNET 7 | { 8 | /// 9 | /// Holds information about a LogixTag in the processor 10 | /// 11 | public class LogixTagInfo 12 | { 13 | /// 14 | /// Gets the memory address of the tag in the LogixProcessor 15 | /// 16 | internal uint MemoryAddress { get; set; } 17 | /// 18 | /// Gets the type information 19 | /// 20 | public ushort FullTypeInfo { get; internal set; } 21 | /// 22 | /// Gets the CIP data type for the tag, or the structure handle 23 | /// 24 | public ushort DataType { get; internal set; } 25 | /// 26 | /// Gets the number of dimensions for array tags 27 | /// 28 | public ushort Dimensions { get; internal set; } 29 | /// 30 | /// Gets true if the tag is a structure, false if it is atomic 31 | /// 32 | public bool IsStructure { get; internal set; } 33 | /// 34 | /// Gets the name of the tag on the 35 | /// 36 | public string TagName { get; internal set; } 37 | /// 38 | /// Gets the first dimension size for array tags. 39 | /// 40 | public uint Dimension1Size { get; internal set; } 41 | /// 42 | /// Gets the second dimension size for array tags. In order for 43 | /// this to be valid, must be greater 44 | /// than zero. 45 | /// 46 | public uint Dimension2Size { get; internal set; } 47 | /// 48 | /// Gets the third dimension size for array tags. In order for 49 | /// this to be valid, must be greater 50 | /// than zero. 51 | /// 52 | public uint Dimension3Size { get; internal set; } 53 | 54 | internal LogixTagInfo() { } 55 | 56 | public override string ToString() 57 | { 58 | StringBuilder sb = new StringBuilder(); 59 | sb.Append(TagName); 60 | 61 | if (Dimensions > 0) 62 | { 63 | sb.Append("["); 64 | sb.Append(Dimension1Size); 65 | if (Dimensions > 1) 66 | { 67 | sb.Append(","); 68 | sb.Append(Dimension2Size); 69 | } 70 | 71 | if (Dimensions > 2) 72 | { 73 | sb.Append(","); 74 | sb.Append(Dimension3Size); 75 | } 76 | sb.Append("]"); 77 | } 78 | 79 | sb.Append((IsStructure ? " (Structure)" : "(Not a Structure)")); 80 | sb.Append(" Memory Address: " + MemoryAddress.ToString("X8")); 81 | 82 | return sb.ToString(); 83 | } 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /ControlLogixNET/MultiServiceRequest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using EIPNET.EIP; 6 | using EIPNET.CIP; 7 | 8 | namespace ControlLogixNET 9 | { 10 | internal class MultiServiceRequest 11 | { 12 | private int _replySize = 0; 13 | 14 | byte[] _header = new byte[] { 0x0A, 0x02, 0x20, 0x02, 0x24, 0x01 }; 15 | public List Services { get; set; } 16 | public int ReplySize 17 | { 18 | get { return _replySize; } 19 | set { _replySize = value; } 20 | } 21 | 22 | public MultiServiceRequest() 23 | { 24 | Services = new List(); 25 | } 26 | 27 | public int Size { 28 | get 29 | { 30 | int retVal = _header.Length + (2 * Services.Count); 31 | 32 | for (int i = 0; i < Services.Count; i++) 33 | retVal += Services[i].Length; 34 | 35 | return retVal + 2; 36 | } 37 | } 38 | 39 | public int AddService(byte[] Service) 40 | { 41 | Services.Add(Service); 42 | return Services.Count - 1; 43 | } 44 | 45 | public byte[] Pack() 46 | { 47 | byte[] retVal = new byte[Size]; 48 | 49 | Buffer.BlockCopy(_header, 0, retVal, 0, _header.Length); 50 | int arrayOffset = _header.Length; 51 | 52 | //Now add 2 bytes for the count 53 | Buffer.BlockCopy(BitConverter.GetBytes((ushort)Services.Count), 0, retVal, arrayOffset, 2); 54 | arrayOffset += 2; 55 | 56 | byte[] offsetArray = new byte[2 * Services.Count]; 57 | int pos = 2 + offsetArray.Length; 58 | for (int i = 0; i < Services.Count; i++) 59 | { 60 | Buffer.BlockCopy(BitConverter.GetBytes((ushort)pos), 0, offsetArray, 2 * i, 2); 61 | pos += Services[i].Length; 62 | } 63 | 64 | List serviceData = new List(); 65 | for (int i = 0; i < Services.Count; i++) 66 | serviceData.AddRange(Services[i]); 67 | 68 | byte[] serviceBytes = serviceData.ToArray(); 69 | Buffer.BlockCopy(offsetArray, 0, retVal, arrayOffset, offsetArray.Length); 70 | arrayOffset += offsetArray.Length; 71 | Buffer.BlockCopy(serviceBytes, 0, retVal, arrayOffset, serviceBytes.Length); 72 | 73 | return retVal; 74 | } 75 | } 76 | 77 | internal class MultiServiceReply 78 | { 79 | public byte ReplyService { get; internal set; } 80 | public byte Reserved { get; internal set; } 81 | public byte GenSTS { get; internal set; } 82 | public byte Reserved2 { get; internal set; } 83 | public ushort Count { get; internal set; } 84 | public List ServiceReplies { get; internal set; } 85 | public bool IsPartial { get; internal set; } 86 | public ushort PartialOffset { get; internal set; } 87 | 88 | public MultiServiceReply() 89 | { 90 | ServiceReplies = new List(); 91 | } 92 | 93 | public MultiServiceReply(EncapsReply reply) 94 | { 95 | EncapsRRData rrData = new EncapsRRData(); 96 | CommonPacket cpf = new CommonPacket(); 97 | 98 | int temp = 0; 99 | rrData.Expand(reply.EncapsData, 0, out temp); 100 | cpf = rrData.CPF; 101 | 102 | MR_Response response = new MR_Response(); 103 | response.Expand(cpf.DataItem.Data, 2, out temp); 104 | 105 | if (response.GeneralStatus == 0x1E) 106 | IsPartial = true; 107 | 108 | ReplyService = response.ReplyService; 109 | GenSTS = response.GeneralStatus; 110 | 111 | ServiceReplies = new List(); 112 | 113 | if (response.ResponseData != null) 114 | Expand(response.ResponseData); 115 | } 116 | 117 | public void Expand(byte[] Data) 118 | { 119 | int offset = 0; 120 | Count = BitConverter.ToUInt16(Data, 0); 121 | offset += 2; 122 | 123 | try 124 | { 125 | for (int i = 0; i < Count; i++) 126 | { 127 | ushort pos = BitConverter.ToUInt16(Data, offset); 128 | offset += 2; 129 | ushort nextPos = BitConverter.ToUInt16(Data, offset); 130 | if (i == (Count - 1)) 131 | nextPos = (ushort)(Data.Length); 132 | ServiceReply svcReply = GetServiceReply(pos, Data, (ushort)(nextPos - pos)); 133 | ServiceReplies.Add(svcReply); 134 | } 135 | } 136 | catch { } 137 | 138 | } 139 | 140 | private ServiceReply GetServiceReply(ushort offset, byte[] data, ushort len) 141 | { 142 | return new ServiceReply(data, offset, len); 143 | } 144 | 145 | } 146 | 147 | internal class ServiceReply 148 | { 149 | public byte Service { get; internal set; } 150 | public byte Status { get; internal set; } 151 | public byte AdditionalStatusSize { get; internal set; } 152 | public byte[] AdditionalStatus { get; internal set; } 153 | public byte[] FullStatus { get; internal set; } 154 | public bool IsPartial { get; internal set; } 155 | public byte[] ServiceData { get; internal set; } 156 | 157 | public ServiceReply(byte[] sourceArray, int start, int len) 158 | { 159 | //First byte is the Service 160 | Service = sourceArray[start]; 161 | Status = sourceArray[start + 2]; 162 | if (sourceArray[start + 2] == 0x06) 163 | IsPartial = true; 164 | 165 | AdditionalStatusSize = sourceArray[start + 3]; 166 | int offset = start + 4; 167 | 168 | if (AdditionalStatusSize > 0) 169 | { 170 | byte[] temp = new byte[AdditionalStatusSize * 2]; 171 | Buffer.BlockCopy(sourceArray, offset, temp, 0, temp.Length); 172 | AdditionalStatus = temp; 173 | } 174 | 175 | FullStatus = new byte[2 + (AdditionalStatusSize * 2)]; 176 | Buffer.BlockCopy(BitConverter.GetBytes((ushort)Status), 0, FullStatus, 0, 2); 177 | if (AdditionalStatusSize > 0) 178 | Buffer.BlockCopy(AdditionalStatus, 0, FullStatus, 2, AdditionalStatus.Length); 179 | 180 | if (len > 4) 181 | { 182 | byte[] temp = new byte[len - 4]; 183 | Buffer.BlockCopy(sourceArray, start + 4, temp, 0, temp.Length); 184 | ServiceData = temp; 185 | } 186 | } 187 | 188 | } 189 | } 190 | -------------------------------------------------------------------------------- /ControlLogixNET/NamespaceDoc.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Runtime.CompilerServices; 6 | 7 | namespace ControlLogixNET 8 | { 9 | /// 10 | /// This namespace contains most of the classes and utilities to interface with a ControlLogix 11 | /// processor. 12 | /// 13 | [CompilerGenerated] 14 | class NamespaceDoc 15 | { 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /ControlLogixNET/ProcessorFaultState.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace ControlLogixNET 7 | { 8 | /// 9 | /// Processor Fault State 10 | /// 11 | public enum ProcessorFaultState 12 | { 13 | /// 14 | /// No Fault 15 | /// 16 | None = 0, 17 | /// 18 | /// Minor Recoverable Fault 19 | /// 20 | MinorRecoverable = 1, 21 | /// 22 | /// Minor Unrecoverable Fault 23 | /// 24 | MinorUnrecoverable = 2, 25 | /// 26 | /// Major Recoverable Fault 27 | /// 28 | MajorRecoverable = 3, 29 | /// 30 | /// Major Unrecoverable Fault 31 | /// 32 | MajorUnrecoverable = 4 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /ControlLogixNET/ProcessorKeySwitch.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace ControlLogixNET 7 | { 8 | /// 9 | /// Position of the Processor Key Switch 10 | /// 11 | public enum ProcessorKeySwitch 12 | { 13 | /// 14 | /// Unknown Position 15 | /// 16 | Unknown = 0, 17 | /// 18 | /// Run Mode 19 | /// 20 | RunMode = 1, 21 | /// 22 | /// Program Mode 23 | /// 24 | ProgramMode = 2, 25 | /// 26 | /// Remote Mode 27 | /// 28 | RemoteMode = 3 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /ControlLogixNET/ProcessorResetType.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace ControlLogixNET 7 | { 8 | /// 9 | /// Used to determine the type of reset to perform 10 | /// 11 | internal enum ProcessorResetType 12 | { 13 | /// 14 | /// Emulate as closely as possible to a power cycle 15 | /// 16 | PowerCycle = 0, 17 | /// 18 | /// Return to the out-of-the-box configuration, then power cycle 19 | /// 20 | FactoryReset = 1 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /ControlLogixNET/ProcessorState.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace ControlLogixNET 7 | { 8 | /// 9 | /// State of the ControlLogix Processor 10 | /// 11 | public enum ProcessorState 12 | { 13 | /// 14 | /// Solid Red (Power-Up) 15 | /// 16 | SolidRed = 0, 17 | /// 18 | /// Firmware Update Mode 19 | /// 20 | FirmwareUpdate = 1, 21 | /// 22 | /// Communication Fault 23 | /// 24 | CommunicationFault = 2, 25 | /// 26 | /// Awaiting Connection 27 | /// 28 | AwaitingConnection = 3, 29 | /// 30 | /// Bad Configuration 31 | /// 32 | ConfigurationBad = 4, 33 | /// 34 | /// Major Fault 35 | /// 36 | MajorFault = 5, 37 | /// 38 | /// Connected 39 | /// 40 | Connected = 6, 41 | /// 42 | /// Program Mode 43 | /// 44 | ProgramMode = 7 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /ControlLogixNET/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("ControlLogixNET")] 9 | [assembly: AssemblyDescription("Library for interfacing to Allen-Bradley ControlLogix Processors")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("Ingenious LLC")] 12 | [assembly: AssemblyProduct("ControlLogixNET")] 13 | [assembly: AssemblyCopyright("Copyright © Ingenious LLC 2012")] 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("d9df3c0d-e310-4292-bada-09529709156a")] 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("1.1.*")] 36 | [assembly: AssemblyFileVersion("1.1.*")] 37 | -------------------------------------------------------------------------------- /ControlLogixNET/ReadDataServiceReply.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using EIPNET.EIP; 6 | using EIPNET.CIP; 7 | 8 | namespace ControlLogixNET 9 | { 10 | internal class ReadDataServiceReply 11 | { 12 | public byte Service { get; internal set; } 13 | public byte Reserved { get; internal set; } 14 | public ushort Status { get; internal set; } 15 | public byte[] ByteStatus { get; internal set; } 16 | public ushort DataType { get; internal set; } 17 | public byte[] Data { get; internal set; } 18 | 19 | public ReadDataServiceReply(EncapsReply reply) 20 | { 21 | //First we have to get the data item... 22 | EncapsRRData rrData = new EncapsRRData(); 23 | 24 | CommonPacket cpf = new CommonPacket(); 25 | int temp = 0; 26 | rrData.Expand(reply.EncapsData, 0, out temp); 27 | cpf = rrData.CPF; 28 | 29 | //The data item contains the information in an MR_Response 30 | MR_Response response = new MR_Response(); 31 | response.Expand(cpf.DataItem.Data, 2, out temp); 32 | 33 | Service = response.ReplyService; 34 | Status = response.GeneralStatus; 35 | 36 | byte[] bbTemp = new byte[4]; 37 | Buffer.BlockCopy(BitConverter.GetBytes(Status), 0, bbTemp, 0, 2); 38 | 39 | if (Status == 0xFF) 40 | { 41 | if (response.AdditionalStatus_Size > 0) 42 | Buffer.BlockCopy(response.AdditionalStatus, 0, bbTemp, 2, 2); 43 | } 44 | 45 | ByteStatus = bbTemp; 46 | 47 | //Now check the response code... 48 | if (response.GeneralStatus != 0 && response.GeneralStatus != 0x06) 49 | return; 50 | 51 | if (response.ResponseData != null) 52 | { 53 | //Now we suck out the data type... 54 | DataType = BitConverter.ToUInt16(response.ResponseData, 0); 55 | byte[] tempB = new byte[response.ResponseData.Length - 2]; 56 | Buffer.BlockCopy(response.ResponseData, 2, tempB, 0, tempB.Length); 57 | Data = tempB; 58 | } 59 | else 60 | { 61 | DataType = 0x0000; 62 | } 63 | 64 | 65 | } 66 | 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /ControlLogixNET/ReadDataServiceRequest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace ControlLogixNET 7 | { 8 | internal class ReadDataServiceRequest 9 | { 10 | public byte Service { get; set; } 11 | public byte PathSize { get; set; } 12 | public byte[] Path { get; set; } 13 | public ushort Elements { get; set; } 14 | public uint DataOffset { get; set; } 15 | public bool IsFragmented { get; set; } 16 | public byte[] AddtlData { get; set; } 17 | 18 | public int Size { get { return 2 + (PathSize * 2) + 2 + (IsFragmented ? 4 : 0) + (AddtlData == null ? 0 : AddtlData.Length); } } 19 | 20 | public byte[] Pack() 21 | { 22 | byte[] retVal = new byte[Size]; 23 | if (AddtlData != null) 24 | retVal = new byte[Size - 2]; 25 | retVal[0] = Service; 26 | retVal[1] = (byte)(PathSize); 27 | Buffer.BlockCopy(Path, 0, retVal, 2, Path.Length); 28 | int offset = 2 + (2 * PathSize); 29 | 30 | if (AddtlData != null) 31 | { 32 | Buffer.BlockCopy(AddtlData, 0, retVal, offset, AddtlData.Length); 33 | offset += AddtlData.Length; 34 | } 35 | else 36 | { 37 | if (IsFragmented) 38 | { 39 | Buffer.BlockCopy(BitConverter.GetBytes(Elements), 0, retVal, offset, 2); 40 | offset += 2; 41 | Buffer.BlockCopy(BitConverter.GetBytes(DataOffset), 0, retVal, offset, 4); 42 | offset += 4; 43 | //Buffer.BlockCopy(BitConverter.GetBytes(Elements), 0, retVal, retVal.Length - 6, 2); 44 | //Buffer.BlockCopy(BitConverter.GetBytes(DataOffset), 0, retVal, retVal.Length - 4, 4); 45 | } 46 | else 47 | { 48 | Buffer.BlockCopy(BitConverter.GetBytes(Elements), 0, retVal, offset, 2); 49 | offset += 2; 50 | //Buffer.BlockCopy(BitConverter.GetBytes(Elements), 0, retVal, retVal.Length - 2, 2); 51 | } 52 | } 53 | 54 | return retVal; 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /ControlLogixNET/ReadTemplateRequest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace ControlLogixNET 7 | { 8 | internal class ReadTemplateRequest 9 | { 10 | 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /ControlLogixNET/Resources/ErrorStrings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.235 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 ControlLogixNET.Resources { 12 | using System; 13 | 14 | 15 | /// 16 | /// A strongly-typed resource class, for looking up localized strings, etc. 17 | /// 18 | // This class was auto-generated by the StronglyTypedResourceBuilder 19 | // class via a tool like ResGen or Visual Studio. 20 | // To add or remove a member, edit your .ResX file then rerun ResGen 21 | // with the /str option, or rebuild your VS project. 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class ErrorStrings { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal ErrorStrings() { 33 | } 34 | 35 | /// 36 | /// Returns the cached ResourceManager instance used by this class. 37 | /// 38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 | internal static global::System.Resources.ResourceManager ResourceManager { 40 | get { 41 | if (object.ReferenceEquals(resourceMan, null)) { 42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ControlLogixNET.Resources.ErrorStrings", typeof(ErrorStrings).Assembly); 43 | resourceMan = temp; 44 | } 45 | return resourceMan; 46 | } 47 | } 48 | 49 | /// 50 | /// Overrides the current thread's CurrentUICulture property for all 51 | /// resource lookups using this strongly typed resource class. 52 | /// 53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 54 | internal static global::System.Globalization.CultureInfo Culture { 55 | get { 56 | return resourceCulture; 57 | } 58 | set { 59 | resourceCulture = value; 60 | } 61 | } 62 | 63 | /// 64 | /// Looks up a localized string similar to The abbreviated type does not match the data type of the data object.. 65 | /// 66 | internal static string AbbreviatedTypeError { 67 | get { 68 | return ResourceManager.GetString("AbbreviatedTypeError", resourceCulture); 69 | } 70 | } 71 | 72 | /// 73 | /// Looks up a localized string similar to Attempted to access beyond the end of the object.. 74 | /// 75 | internal static string AccessBeyondObject { 76 | get { 77 | return ResourceManager.GetString("AccessBeyondObject", resourceCulture); 78 | } 79 | } 80 | 81 | /// 82 | /// Looks up a localized string similar to The specified array length does not match the destination array length.. 83 | /// 84 | internal static string ArrayLengthException { 85 | get { 86 | return ResourceManager.GetString("ArrayLengthException", resourceCulture); 87 | } 88 | } 89 | 90 | /// 91 | /// Looks up a localized string similar to An error occurred trying to process one of the attributes.. 92 | /// 93 | internal static string AttributeError { 94 | get { 95 | return ResourceManager.GetString("AttributeError", resourceCulture); 96 | } 97 | } 98 | 99 | /// 100 | /// Looks up a localized string similar to The beginning offset was beyond the end of the template.. 101 | /// 102 | internal static string BeginOffsetError { 103 | get { 104 | return ResourceManager.GetString("BeginOffsetError", resourceCulture); 105 | } 106 | } 107 | 108 | /// 109 | /// Looks up a localized string similar to Device does not support CIP. 110 | /// 111 | internal static string CIPNotSupported { 112 | get { 113 | return ResourceManager.GetString("CIPNotSupported", resourceCulture); 114 | } 115 | } 116 | 117 | /// 118 | /// Looks up a localized string similar to The dimensions have not been set for this tag. You must set the dimensions before using the multi-dimensional index by using the SetMultipleDimensions function on the tag.. 119 | /// 120 | internal static string DimensionsNotSet { 121 | get { 122 | return ResourceManager.GetString("DimensionsNotSet", resourceCulture); 123 | } 124 | } 125 | 126 | /// 127 | /// Looks up a localized string similar to Specified group already exists on the processor.. 128 | /// 129 | internal static string GroupExists { 130 | get { 131 | return ResourceManager.GetString("GroupExists", resourceCulture); 132 | } 133 | } 134 | 135 | /// 136 | /// Looks up a localized string similar to The specified group was not found on the processor.. 137 | /// 138 | internal static string GroupNotFound { 139 | get { 140 | return ResourceManager.GetString("GroupNotFound", resourceCulture); 141 | } 142 | } 143 | 144 | /// 145 | /// Looks up a localized string similar to Argument must be a "LogixTag".. 146 | /// 147 | internal static string IncorrectArgTagType { 148 | get { 149 | return ResourceManager.GetString("IncorrectArgTagType", resourceCulture); 150 | } 151 | } 152 | 153 | /// 154 | /// Looks up a localized string similar to An insufficient number of attributes were provided compared to the attribute count.. 155 | /// 156 | internal static string InsufficientAttributes { 157 | get { 158 | return ResourceManager.GetString("InsufficientAttributes", resourceCulture); 159 | } 160 | } 161 | 162 | /// 163 | /// Looks up a localized string similar to The IOI word length did not match the amount of IOI which was processed.. 164 | /// 165 | internal static string InvalidIOILength { 166 | get { 167 | return ResourceManager.GetString("InvalidIOILength", resourceCulture); 168 | } 169 | } 170 | 171 | /// 172 | /// Looks up a localized string similar to The processor did not return enough data to complete the data structure.. 173 | /// 174 | internal static string InvalidResponseSize { 175 | get { 176 | return ResourceManager.GetString("InvalidResponseSize", resourceCulture); 177 | } 178 | } 179 | 180 | /// 181 | /// Looks up a localized string similar to The item referenced could not be found on the processor.. 182 | /// 183 | internal static string ItemNotFound { 184 | get { 185 | return ResourceManager.GetString("ItemNotFound", resourceCulture); 186 | } 187 | } 188 | 189 | /// 190 | /// Looks up a localized string similar to The IOI path could not be deciphered by the processor or the matching tag does not exist.. 191 | /// 192 | internal static string MalformedIOI { 193 | get { 194 | return ResourceManager.GetString("MalformedIOI", resourceCulture); 195 | } 196 | } 197 | 198 | /// 199 | /// Looks up a localized string similar to Not enough data was sent to the processor to execute the command.. 200 | /// 201 | internal static string NotEnoughData { 202 | get { 203 | return ResourceManager.GetString("NotEnoughData", resourceCulture); 204 | } 205 | } 206 | 207 | /// 208 | /// Looks up a localized string similar to Could not establish connection with the processor.. 209 | /// 210 | internal static string ProcessorNotConnected { 211 | get { 212 | return ResourceManager.GetString("ProcessorNotConnected", resourceCulture); 213 | } 214 | } 215 | 216 | /// 217 | /// Looks up a localized string similar to Session could not be established.. 218 | /// 219 | internal static string SessionNotEstablished { 220 | get { 221 | return ResourceManager.GetString("SessionNotEstablished", resourceCulture); 222 | } 223 | } 224 | 225 | /// 226 | /// Looks up a localized string similar to Session could not be registered with the processor.. 227 | /// 228 | internal static string SessionNotRegistered { 229 | get { 230 | return ResourceManager.GetString("SessionNotRegistered", resourceCulture); 231 | } 232 | } 233 | 234 | /// 235 | /// Looks up a localized string similar to Session connected and registered.. 236 | /// 237 | internal static string SessionRegistered { 238 | get { 239 | return ResourceManager.GetString("SessionRegistered", resourceCulture); 240 | } 241 | } 242 | 243 | /// 244 | /// Looks up a localized string similar to A socket error has occurred. Check the error code for the socket exception number.. 245 | /// 246 | internal static string SocketError { 247 | get { 248 | return ResourceManager.GetString("SocketError", resourceCulture); 249 | } 250 | } 251 | 252 | /// 253 | /// Looks up a localized string similar to Tag could not be found on the processor.. 254 | /// 255 | internal static string TagNotFound { 256 | get { 257 | return ResourceManager.GetString("TagNotFound", resourceCulture); 258 | } 259 | } 260 | 261 | /// 262 | /// Looks up a localized string similar to The passed in object could not be converted to the required type.. 263 | /// 264 | internal static string TypeConversionError { 265 | get { 266 | return ResourceManager.GetString("TypeConversionError", resourceCulture); 267 | } 268 | } 269 | 270 | /// 271 | /// Looks up a localized string similar to The type returned by the processor does not match the tag type. The processor returned a . 272 | /// 273 | internal static string TypeMismatch { 274 | get { 275 | return ResourceManager.GetString("TypeMismatch", resourceCulture); 276 | } 277 | } 278 | 279 | /// 280 | /// Looks up a localized string similar to The specified field of the UDT does not exist in this structure.. 281 | /// 282 | internal static string UDTMemberNotFound { 283 | get { 284 | return ResourceManager.GetString("UDTMemberNotFound", resourceCulture); 285 | } 286 | } 287 | 288 | /// 289 | /// Looks up a localized string similar to An unknown error has occurred.. 290 | /// 291 | internal static string Unknown { 292 | get { 293 | return ResourceManager.GetString("Unknown", resourceCulture); 294 | } 295 | } 296 | } 297 | } 298 | -------------------------------------------------------------------------------- /ControlLogixNET/Resources/ErrorStrings.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 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | 121 | The abbreviated type does not match the data type of the data object. 122 | 123 | 124 | Attempted to access beyond the end of the object. 125 | 126 | 127 | The specified array length does not match the destination array length. 128 | 129 | 130 | An error occurred trying to process one of the attributes. 131 | 132 | 133 | The beginning offset was beyond the end of the template. 134 | 135 | 136 | Device does not support CIP 137 | 138 | 139 | The dimensions have not been set for this tag. You must set the dimensions before using the multi-dimensional index by using the SetMultipleDimensions function on the tag. 140 | 141 | 142 | Specified group already exists on the processor. 143 | 144 | 145 | The specified group was not found on the processor. 146 | 147 | 148 | Argument must be a "LogixTag". 149 | 150 | 151 | An insufficient number of attributes were provided compared to the attribute count. 152 | 153 | 154 | The IOI word length did not match the amount of IOI which was processed. 155 | 156 | 157 | The processor did not return enough data to complete the data structure. 158 | 159 | 160 | The item referenced could not be found on the processor. 161 | 162 | 163 | The IOI path could not be deciphered by the processor or the matching tag does not exist. 164 | 165 | 166 | Not enough data was sent to the processor to execute the command. 167 | 168 | 169 | Could not establish connection with the processor. 170 | 171 | 172 | Session could not be established. 173 | 174 | 175 | Session could not be registered with the processor. 176 | 177 | 178 | Session connected and registered. 179 | 180 | 181 | A socket error has occurred. Check the error code for the socket exception number. 182 | 183 | 184 | Tag could not be found on the processor. 185 | 186 | 187 | The passed in object could not be converted to the required type. 188 | 189 | 190 | The type returned by the processor does not match the tag type. The processor returned a 191 | 192 | 193 | The specified field of the UDT does not exist in this structure. 194 | 195 | 196 | An unknown error has occurred. 197 | 198 | -------------------------------------------------------------------------------- /ControlLogixNET/SequenceNumberGenerator.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace ControlLogixNET 7 | { 8 | internal static class SequenceNumberGenerator 9 | { 10 | 11 | private static object _lockObject; 12 | private static ushort _sequenceNum; 13 | 14 | 15 | public static ushort SequenceNumber 16 | { 17 | get 18 | { 19 | lock (_lockObject) 20 | { 21 | if (_sequenceNum == ushort.MaxValue) 22 | _sequenceNum = ushort.MinValue; 23 | _sequenceNum++; 24 | return _sequenceNum; 25 | } 26 | } 27 | } 28 | 29 | static SequenceNumberGenerator() 30 | { 31 | _lockObject = new object(); 32 | } 33 | 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /ControlLogixNET/TemplateInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using ControlLogixNET.LogixType; 6 | using EIPNET.CIP; 7 | 8 | namespace ControlLogixNET 9 | { 10 | internal class MemberInfo 11 | { 12 | public ushort MemberType; 13 | public ushort Info; 14 | public int MemberOffset; 15 | public string MemberName; 16 | public int MemberSize; 17 | public LogixTypes LogixType; 18 | } 19 | 20 | internal class TemplateInfo 21 | { 22 | public ushort NumberOfMembers { get; private set; } 23 | public ushort TagSize { get; private set; } 24 | public ushort TemplateHandle { get; private set; } 25 | public string TemplateName { get; private set; } 26 | public List MemberInfo { get; private set; } 27 | 28 | public TemplateInfo(byte[] templateData, GetStructAttribsReply attribs) 29 | { 30 | MemberInfo = new List(); 31 | 32 | //Ok, this is a little confusing, there's supposed to be a header, but 33 | //it seems that the data returned is not in the format specified in the 34 | //1756-RM005 publication. There is no header data (meaning we can't 35 | //know how many elements are in the template), so we kinda have to 36 | //pick through and cheat... Luckily this data is found in the 37 | //GetStructAttribs reply 38 | 39 | //The format of the data returned is: 40 | //[2:Info][2:Type][4:Offset] 41 | //When we reach a byte that is greater than 0x00 42 | int offset = 0; 43 | int lastMember = -1; 44 | int lastOffset = 0; 45 | 46 | for (int i = 0; i < attribs.MemberCount; i++) 47 | { 48 | MemberInfo mi = new MemberInfo(); 49 | mi.Info = BitConverter.ToUInt16(templateData, offset); 50 | offset += 2; 51 | mi.MemberType = BitConverter.ToUInt16(templateData, offset); 52 | offset += 2; 53 | mi.MemberOffset = BitConverter.ToInt32(templateData, offset); 54 | if (lastMember >= 0) 55 | { 56 | //Compute size for the last member... 57 | int size = mi.MemberOffset - lastOffset; 58 | MemberInfo[lastMember].MemberSize = size; 59 | } 60 | lastOffset = mi.MemberOffset; 61 | lastMember++; 62 | offset += 4; 63 | switch ((CIPType)(mi.MemberType & 0x00FF)) 64 | { 65 | case CIPType.BOOL: 66 | mi.LogixType = LogixTypes.Bool; 67 | break; 68 | case CIPType.DINT: 69 | mi.LogixType = LogixTypes.DInt; 70 | break; 71 | case CIPType.INT: 72 | mi.LogixType = LogixTypes.Int; 73 | break; 74 | case CIPType.LINT: 75 | mi.LogixType = LogixTypes.LInt; 76 | break; 77 | case CIPType.REAL: 78 | mi.LogixType = LogixTypes.Real; 79 | break; 80 | case CIPType.SINT: 81 | mi.LogixType = LogixTypes.SInt; 82 | break; 83 | case CIPType.STRUCT: 84 | mi.LogixType = LogixTypes.User_Defined; 85 | break; 86 | default: 87 | mi.LogixType = LogixTypes.Unknown; 88 | break; 89 | } 90 | MemberInfo.Add(mi); 91 | 92 | } 93 | 94 | //Compute the size for the last member 95 | int lastSize = TagSize - lastOffset; 96 | MemberInfo[MemberInfo.Count - 1].MemberSize = lastSize; 97 | 98 | NumberOfMembers = (ushort)MemberInfo.Count; 99 | TemplateHandle = attribs.Handle; 100 | TagSize = attribs.MemorySize; 101 | 102 | //And now we have to go through the rest of the data and pick out 103 | //null terminated strings... 104 | int start = offset; 105 | string currentStr = ""; 106 | int idx = -1; 107 | for (int i = start; i < templateData.Length; i++) 108 | { 109 | if (templateData[i] == 0x00) 110 | { 111 | if (string.IsNullOrEmpty(currentStr)) 112 | continue; 113 | 114 | if (idx == -1) 115 | { 116 | //This is the structure name... 117 | TemplateName = currentStr; 118 | if (TemplateName.Contains(';')) 119 | TemplateName = TemplateName.Substring(0, TemplateName.IndexOf(';')); 120 | } 121 | else 122 | { 123 | MemberInfo[idx].MemberName = currentStr; 124 | } 125 | 126 | currentStr = string.Empty; 127 | idx++; 128 | } 129 | else 130 | { 131 | currentStr += (char)templateData[i]; 132 | } 133 | } 134 | 135 | } 136 | 137 | public override string ToString() 138 | { 139 | StringBuilder sb = new StringBuilder(); 140 | sb.AppendLine(TemplateName); 141 | 142 | for (int i = 0; i < MemberInfo.Count; i++) 143 | { 144 | sb.AppendLine("\t" + MemberInfo[i].MemberName); 145 | } 146 | 147 | return sb.ToString(); 148 | } 149 | } 150 | } 151 | -------------------------------------------------------------------------------- /ControlLogixNET/TypeConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace ControlLogixNET 7 | { 8 | internal static class TypeConverter 9 | { 10 | public static int[] GetInt32Array(byte[] sourceArray, int offset, int length) 11 | { 12 | int skipSize = 4; 13 | List retVals = new List(); 14 | 15 | if (sourceArray.Length < offset + length) 16 | throw new IndexOutOfRangeException("Offset and length must refer to a position in the array"); 17 | 18 | for (int i = offset; i < offset + length; i += skipSize) 19 | { 20 | retVals.Add(BitConverter.ToInt32(sourceArray, i)); 21 | } 22 | 23 | return retVals.ToArray(); 24 | } 25 | 26 | public static long[] GetInt64Array(byte[] sourceArray, int offset, int length) 27 | { 28 | int skipSize = 8; 29 | List retVals = new List(); 30 | 31 | if (sourceArray.Length < offset + length) 32 | throw new IndexOutOfRangeException("Offset and length must refer to a position in the array"); 33 | 34 | for (int i = offset; i < offset + length; i += skipSize) 35 | { 36 | retVals.Add(BitConverter.ToInt64(sourceArray, i)); 37 | } 38 | 39 | return retVals.ToArray(); 40 | } 41 | 42 | public static short[] GetShortArray(byte[] sourceArray, int offset, int length) 43 | { 44 | int skipSize = 2; 45 | List retVals = new List(); 46 | 47 | if (sourceArray.Length < offset + length) 48 | throw new IndexOutOfRangeException("Offset and length must refer to a position in the array"); 49 | 50 | for (int i = offset; i < offset + length; i += skipSize) 51 | { 52 | retVals.Add(BitConverter.ToInt16(sourceArray, i)); 53 | } 54 | 55 | return retVals.ToArray(); 56 | } 57 | 58 | public static float[] GetFloatArray(byte[] sourceArray, int offset, int length) 59 | { 60 | int skipSize = 4; 61 | List retVals = new List(); 62 | 63 | if (sourceArray.Length < offset + length) 64 | throw new IndexOutOfRangeException("Offset and length must refer to a position in the array"); 65 | 66 | for (int i = offset; i < offset + length; i += skipSize) 67 | { 68 | retVals.Add(BitConverter.ToSingle(sourceArray, i)); 69 | } 70 | 71 | return retVals.ToArray(); 72 | } 73 | 74 | public static byte[] GetByteArray(byte[] sourceArray, int offset, int length) 75 | { 76 | byte[] temp = new byte[length]; 77 | Buffer.BlockCopy(sourceArray, (int)offset, temp, 0, length); 78 | return temp; 79 | } 80 | 81 | public static bool[] GetBoolArray(int[] sourceArray) 82 | { 83 | List retVal = new List(); 84 | for (int i = 0; i < sourceArray.Length; i++) 85 | { 86 | for (int b = 0; b < 32; b++) 87 | { 88 | int mask = 1 << b; 89 | if ((sourceArray[i] & mask) == mask) 90 | retVal.Add(true); 91 | else 92 | retVal.Add(false); 93 | } 94 | } 95 | return retVal.ToArray(); 96 | } 97 | 98 | public static int[] GetBoolArray(bool[] sourceArray) 99 | { 100 | List retVal = new List(); 101 | int current = 0; 102 | int bit = 0; 103 | 104 | for (int i = 0; i < sourceArray.Length; i++) 105 | { 106 | if (sourceArray[i]) 107 | { 108 | current &= 0x01 << bit; 109 | } 110 | 111 | bit++; 112 | 113 | if (bit > 31) 114 | { 115 | retVal.Add(current); 116 | current = 0; 117 | bit = 0; 118 | } 119 | } 120 | 121 | return retVal.ToArray(); 122 | } 123 | 124 | #if MONO 125 | public static byte[] GetBytes(int[] intArray) 126 | { 127 | return GetBytes(intArray, 0); 128 | } 129 | #endif 130 | #if MONO 131 | public static byte[] GetBytes(int[] intArray, int sizeInBytes) 132 | #else 133 | public static byte[] GetBytes(int[] intArray, int sizeInBytes = 0) 134 | #endif 135 | { 136 | if (sizeInBytes == 0) 137 | sizeInBytes = intArray.Length * 4; 138 | 139 | List retVal = new List(); 140 | for (int i = 0; i < sizeInBytes; i++) 141 | { 142 | if (i * 4 < intArray.Length) 143 | { 144 | retVal.AddRange(BitConverter.GetBytes(intArray[i / 4])); 145 | i += 3; 146 | } 147 | else 148 | retVal.Add(0); 149 | } 150 | 151 | return retVal.ToArray(); 152 | } 153 | 154 | #if MONO 155 | public static byte[] GetBytes(short[] shortArray) 156 | { 157 | return GetBytes(shortArray, 0); 158 | } 159 | #endif 160 | #if MONO 161 | public static byte[] GetBytes(short[] shortArray, int sizeInBytes) 162 | #else 163 | public static byte[] GetBytes(short[] shortArray, int sizeInBytes = 0) 164 | #endif 165 | { 166 | if (sizeInBytes == 0) 167 | sizeInBytes = shortArray.Length * 2; 168 | 169 | List retVal = new List(); 170 | for (int i = 0; i < sizeInBytes; i++) 171 | { 172 | if (i * 2 < shortArray.Length) 173 | { 174 | retVal.AddRange(BitConverter.GetBytes(shortArray[i / 2])); 175 | i += 1; 176 | } 177 | else 178 | retVal.Add(0); 179 | } 180 | 181 | return retVal.ToArray(); 182 | } 183 | 184 | #if MONO 185 | public static byte[] GetBytes(long[] longArray) 186 | { 187 | return GetBytes(longArray, 0); 188 | } 189 | #endif 190 | #if MONO 191 | public static byte[] GetBytes(long[] longArray, int sizeInBytes) 192 | #else 193 | public static byte[] GetBytes(long[] longArray, int sizeInBytes = 0) 194 | #endif 195 | { 196 | if (sizeInBytes == 0) 197 | sizeInBytes = longArray.Length * 8; 198 | 199 | List retVal = new List(); 200 | for (int i = 0; i < sizeInBytes; i++) 201 | { 202 | if (i * 8 < longArray.Length) 203 | { 204 | retVal.AddRange(BitConverter.GetBytes(longArray[i / 4])); 205 | i += 7; 206 | } 207 | else 208 | retVal.Add(0); 209 | } 210 | 211 | return retVal.ToArray(); 212 | } 213 | 214 | #if MONO 215 | public static byte[] GetBytes(float[] floatArray) 216 | { 217 | return GetBytes(floatArray, 0); 218 | } 219 | #endif 220 | #if MONO 221 | public static byte[] GetBytes(float[] floatArray, int sizeInBytes) 222 | #else 223 | public static byte[] GetBytes(float[] floatArray, int sizeInBytes = 0) 224 | #endif 225 | { 226 | if (sizeInBytes == 0) 227 | sizeInBytes = floatArray.Length * 4; 228 | 229 | List retVal = new List(); 230 | for (int i = 0; i < sizeInBytes; i++) 231 | { 232 | if (i * 4 < floatArray.Length) 233 | { 234 | retVal.AddRange(BitConverter.GetBytes(floatArray[i / 4])); 235 | i += 3; 236 | } 237 | else 238 | retVal.Add(0); 239 | } 240 | 241 | return retVal.ToArray(); 242 | } 243 | } 244 | } 245 | -------------------------------------------------------------------------------- /ControlLogixNET/UtilityBelt.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace ControlLogixNET 7 | { 8 | internal static class UtilityBelt 9 | { 10 | /// 11 | /// Compares 2 arrays. The arrays must be the same size... 12 | /// 13 | /// First array 14 | /// Second array 15 | /// True if they are equal, false if they are not 16 | public static bool CompareArrays(byte[] array1, byte[] array2) 17 | { 18 | if (array1.Length != array2.Length) 19 | return false; 20 | 21 | for (int i = 0; i < array1.Length; i++) 22 | { 23 | if (array1[i] != array2[i]) 24 | return false; 25 | } 26 | 27 | return true; 28 | } 29 | 30 | #if MONO 31 | public static bool CompareArrays(byte[] sourceArray, byte[] compareArray, uint offset) 32 | { 33 | return CompareArrays(sourceArray, compareArray, offset, 0); 34 | } 35 | #endif 36 | 37 | #if MONO 38 | public static bool CompareArrays(byte[] sourceArray, byte[] compareArray, uint offset, uint len) 39 | #else 40 | /// 41 | /// Compares a source array at the specified offset to the compare array 42 | /// 43 | /// Source array 44 | /// Compare array 45 | /// Position to start compare in the source array 46 | /// True if they are equal, false if not 47 | public static bool CompareArrays(byte[] sourceArray, byte[] compareArray, uint offset, uint len = 0) 48 | #endif 49 | { 50 | int compPos = 0; 51 | if (len == 0) 52 | len = (uint)compareArray.Length; 53 | for (uint i = offset; i < len; i++) 54 | { 55 | if (sourceArray[i] != compareArray[compPos]) 56 | return false; 57 | compPos++; 58 | } 59 | return true; 60 | } 61 | 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /ControlLogixNET/WriteDataServiceReply.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using EIPNET.EIP; 6 | using EIPNET.CIP; 7 | 8 | namespace ControlLogixNET 9 | { 10 | internal class WriteDataServiceReply 11 | { 12 | public byte Service { get; internal set; } 13 | public byte Reserved { get; internal set; } 14 | public ushort Status { get; internal set; } 15 | 16 | public WriteDataServiceReply(EncapsReply reply) 17 | { 18 | EncapsRRData rrData = new EncapsRRData(); 19 | 20 | CommonPacket cpf = new CommonPacket(); 21 | int temp = 0; 22 | rrData.Expand(reply.EncapsData, 0, out temp); 23 | cpf = rrData.CPF; 24 | 25 | MR_Response response = new MR_Response(); 26 | response.Expand(cpf.DataItem.Data, 2, out temp); 27 | 28 | if (response.GeneralStatus != 0) 29 | return; 30 | 31 | Service = response.ReplyService; 32 | Status = response.GeneralStatus; 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /ControlLogixNET/WriteDataServiceRequest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace ControlLogixNET 7 | { 8 | internal class WriteDataServiceRequest 9 | { 10 | public byte Service { get; set; } 11 | public byte PathSize { get; set; } 12 | public byte[] Path { get; set; } 13 | public ushort DataType { get; set; } 14 | public ushort StructHandle { get; set; } 15 | public ushort Elements { get; set; } 16 | public byte[] Data { get; set; } 17 | public bool IsFragmented { get; set; } 18 | public uint Offset { get; set; } 19 | 20 | public int Size { get { return 6 + (2 * PathSize) + (Data == null ? 0 : Data.Length) + (IsFragmented ? 4 : 0) + (StructHandle == 0 ? 0 : 2); } } 21 | 22 | public byte[] Pack() 23 | { 24 | byte[] retVal = new byte[Size]; 25 | retVal[0] = Service; 26 | retVal[1] = PathSize; 27 | Buffer.BlockCopy(Path, 0, retVal, 2, Path.Length); 28 | int offset = 2 + (2 * PathSize); 29 | Buffer.BlockCopy(BitConverter.GetBytes(DataType), 0, retVal, offset, 2); 30 | offset += 2; 31 | if (StructHandle != 0) 32 | { 33 | Buffer.BlockCopy(BitConverter.GetBytes(StructHandle), 0, retVal, offset, 2); 34 | offset += 2; 35 | } 36 | Buffer.BlockCopy(BitConverter.GetBytes(Elements), 0, retVal, offset, 2); 37 | offset += 2; 38 | if (IsFragmented) 39 | { 40 | Buffer.BlockCopy(BitConverter.GetBytes(Offset), 0, retVal, offset, 4); 41 | offset += 4; 42 | } 43 | if (Data != null) 44 | Buffer.BlockCopy(Data, 0, retVal, offset, Data.Length); 45 | 46 | return retVal; 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /Examples/ArrayTags/ArrayTags.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | x86 6 | 8.0.30703 7 | 2.0 8 | {FA46ECC1-6E51-47FA-B025-A38BF75515B8} 9 | Exe 10 | Properties 11 | ArrayTags 12 | ArrayTags 13 | v4.0 14 | 512 15 | SAK 16 | SAK 17 | SAK 18 | SAK 19 | 20 | 21 | x86 22 | true 23 | full 24 | false 25 | bin\Debug\ 26 | DEBUG;TRACE 27 | prompt 28 | 4 29 | 30 | 31 | x86 32 | pdbonly 33 | true 34 | bin\Release\ 35 | TRACE 36 | prompt 37 | 4 38 | 39 | 40 | 41 | False 42 | ..\..\ControlLogixNET\bin\Debug\ControlLogixNET_Locked\ControlLogixNET.dll 43 | 44 | 45 | False 46 | ..\..\ControlLogixNET\bin\Debug\EIPNET_Locked\EIPNET.dll 47 | 48 | 49 | False 50 | ..\..\ControlLogixNET\bin\Debug\ICommon_Locked\ICommon.dll 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 79 | -------------------------------------------------------------------------------- /Examples/ArrayTags/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using ControlLogixNET; 6 | using ControlLogixNET.LogixType; 7 | using System.Threading; 8 | 9 | namespace ArrayTags 10 | { 11 | class Program 12 | { 13 | /* 14 | * HOW TO USE THIS SAMPLE 15 | * 16 | * 1. First change the hostNameOrIp to the IP address or host name of your PLC 17 | * 2. Then change the path to be the path to your PLC, see comments below 18 | * 3. Create a 1 dimensional DINT array on the processor called dintArray1[10] 19 | * 4. Create a 2 dimensional DINT array on the processor called dintArray2[10,10] 20 | * 5. Create a 3 dimensional DINT array on the processor called dintArray3[10,10,10] 21 | * 6. Run 22 | * 23 | */ 24 | 25 | static void Main(string[] args) 26 | { 27 | //First we create the processor object. Typically the path is the slot 28 | //number of the processor module in the backplane, but if your communications 29 | //card is not in the same chassis as your processor, this is the path through 30 | //the chassis to get to your processor. You will have to add a 1 for every 31 | //chassis you go through, for example: 32 | //Chassis 1: ENBT card in Slot 1 (slot is irrelavent), ControlNet Card in Slot 2 33 | //Chassis 2: L61 in Slot 4 34 | //Path would be: { 2, 1, 4 } 35 | //Basically it's the target slot, 1 for backplane, target slot, 1 for backplane... 36 | //until you get to the processor. 37 | string hostNameOrIp = "192.168.1.10"; 38 | byte[] path = new byte[] { 1 }; 39 | LogixProcessor processor = new LogixProcessor(hostNameOrIp, path); 40 | 41 | //The processor has to be connected before you add any tags or tag groups. 42 | if (!processor.Connect()) 43 | { 44 | Console.WriteLine("Could not connect to the processor"); 45 | Console.ReadKey(false); 46 | return; 47 | } 48 | 49 | //First create a group. Groups are much more efficient at reading and writing 50 | //large numbers of tags. 51 | LogixTagGroup myGroup = processor.CreateTagGroup("MyGroup"); 52 | 53 | //Now let's create our first array. The number of elements is the TOTAL number 54 | //of elements to read, in all dimensions. 55 | LogixDINT dintArray1 = new LogixDINT("dintArray1", processor, 10); 56 | 57 | //We don't need to set the number of dimensions on the tag here because it 58 | //assumes that it's a single dimension tag. All tags are set up to be arrays 59 | //by default, the .Value or similar member always returns the 0th element 60 | //of the array. With a tag that is not an array, that is where the value is. 61 | 62 | //Let's create the 2 dimensional array 63 | LogixDINT dintArray2 = new LogixDINT("dintArray2", processor, 100); 64 | 65 | //The number of elements are the subscripts multiplied by each other. In this 66 | //case, 10*10 = 100. If you put a lower value here you will only read that 67 | //much of the array. ControlLogix packs it's arrays in row major format, so 68 | //just keep that in mind if reading partial arrays. 69 | 70 | //If you want to set it up to read with a multidimensional accessor, we need 71 | //to tell the tag what the size of the dimensions are. 72 | dintArray2.SetMultipleDimensions(10, 10); 73 | 74 | //We can now access the tag by the tagName[row,column] format. If you didn't 75 | //set the size, you would get an exception when trying to access the tag 76 | //using that format. 77 | 78 | //Let's create the last tag 79 | LogixDINT dintArray3 = new LogixDINT("dintArray3", processor, 1000); 80 | 81 | //Set the dimensions 82 | dintArray3.SetMultipleDimensions(10, 10, 10); 83 | 84 | //Now let's add our tags to the tag group... 85 | myGroup.AddTag(dintArray1); 86 | myGroup.AddTag(dintArray2); 87 | myGroup.AddTag(dintArray3); 88 | 89 | Console.WriteLine("6D Systems LLC\n\n"); 90 | Console.WriteLine("Tags created..."); 91 | 92 | //Now let's pick out some random members and display them... 93 | Console.WriteLine("dintArray1[4] = " + dintArray1[4].ToString()); 94 | Console.WriteLine("dintArray2[5,2] = " + dintArray2[5, 2].ToString()); 95 | Console.WriteLine("dintArray3[4,7,3] = " + dintArray3[4, 7, 3].ToString()); 96 | Console.WriteLine("\nPress any key to write a new value to each of the above tags"); 97 | Console.ReadKey(false); 98 | 99 | //Now let's write some data to those tags... 100 | Random rnd = new Random(); 101 | dintArray1[4] = rnd.Next(int.MinValue, int.MaxValue); 102 | dintArray2[5, 2] = rnd.Next(int.MinValue, int.MaxValue); 103 | dintArray3[4, 7, 3] = rnd.Next(int.MinValue, int.MaxValue); 104 | 105 | //Let's update the tag group 106 | processor.UpdateGroups(); 107 | 108 | //Now print them back out for the user... 109 | Console.WriteLine("\nNew tag values..."); 110 | Console.WriteLine("dintArray1[4] = " + dintArray1[4].ToString()); 111 | Console.WriteLine("dintArray2[5,2] = " + dintArray2[5, 2].ToString()); 112 | Console.WriteLine("dintArray3[4,7,3] = " + dintArray3[4, 7, 3].ToString()); 113 | Console.WriteLine("\nPress any key to quit"); 114 | Console.ReadKey(false); 115 | 116 | //Remember to disconnect from the processor 117 | processor.Disconnect(); 118 | 119 | } 120 | } 121 | } 122 | -------------------------------------------------------------------------------- /Examples/ArrayTags/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("ArrayTags")] 9 | [assembly: AssemblyDescription("Demonstration of using Array tags in a ControlLogix Processor")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("6D Systems LLC")] 12 | [assembly: AssemblyProduct("ArrayTags")] 13 | [assembly: AssemblyCopyright("Copyright © 6D Systems LLC 2011")] 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("578332e3-a9d2-403f-ae85-afda0b1de0cf")] 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("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /Examples/Processor/Processor.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | x86 6 | 8.0.30703 7 | 2.0 8 | {54A5D090-5322-4087-8E92-4A5C5E8E194E} 9 | Exe 10 | Properties 11 | Processor 12 | Processor 13 | v4.0 14 | 512 15 | SAK 16 | SAK 17 | SAK 18 | SAK 19 | 20 | 21 | x86 22 | true 23 | full 24 | false 25 | bin\Debug\ 26 | DEBUG;TRACE 27 | prompt 28 | 4 29 | 30 | 31 | x86 32 | pdbonly 33 | true 34 | bin\Release\ 35 | TRACE 36 | prompt 37 | 4 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | {9A6CFFE2-0C70-45A7-92FC-88DA9000E591} 62 | ControlLogixNET 63 | 64 | 65 | {1E726BE8-F9B8-4A9B-B052-E0D9154F3896} 66 | ICommon 67 | 68 | 69 | 70 | 77 | -------------------------------------------------------------------------------- /Examples/Processor/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using ControlLogixNET; 6 | 7 | namespace Processor 8 | { 9 | class Program 10 | { 11 | /* 12 | * HOW TO USE THIS SAMPLE 13 | * 14 | * 1. First change the hostNameOrIp to the IP address or host name of your PLC 15 | * 2. Then change the path to be the path to your PLC, see comments below 16 | * 3. Run 17 | * 18 | */ 19 | 20 | static void Main(string[] args) 21 | { 22 | //First we create the processor object. Typically the path is the slot 23 | //number of the processor module in the backplane, but if your communications 24 | //card is not in the same chassis as your processor, this is the path through 25 | //the chassis to get to your processor. You will have to add a 1 for every 26 | //chassis you go through, for example: 27 | //Chassis 1: ENBT card in Slot 1 (slot is irrelavent), ControlNet Card in Slot 2 28 | //Chassis 2: L61 in Slot 4 29 | //Path would be: { 2, 1, 4 } 30 | //Basically it's the target slot, 1 for backplane, target slot, 1 for backplane... 31 | //until you get to the processor. 32 | string hostNameOrIp = "192.168.1.10"; 33 | byte[] path = new byte[] { 0 }; 34 | LogixProcessor processor = new LogixProcessor(hostNameOrIp, path); 35 | 36 | //Connect to the PLC, you can create the events before or after the connect function 37 | if (!processor.Connect()) 38 | { 39 | Console.WriteLine("Could not connect to the processor"); 40 | Console.ReadKey(false); 41 | return; 42 | } 43 | 44 | //Create the events, the processor state is updated every second, and if there is 45 | //a change in either the fault state, key switch position, or processor state (RUN, PROGRAM, TEST), 46 | //then one of these events will be fired. 47 | processor.FaultStateChanged += new LogixFaultStateChangedEvent(processor_FaultStateChanged); 48 | processor.KeySwitchChanged += new LogixKeyPositionChangedEvent(processor_KeySwitchChanged); 49 | processor.ProcessorStateChanged += new LogixProcessorStateChangedEvent(processor_ProcessorStateChanged); 50 | 51 | Console.WriteLine("6D Systems LLC"); 52 | Console.WriteLine("Processor State Example: Change the key switch, fault state, or processor\nmode to see a message displayed"); 53 | Console.WriteLine("\nProcessor Information:\n" + processor); 54 | Console.WriteLine("\n\n"); 55 | 56 | //The processor can, through source code, be put in Program mode or Run mode. This is useful 57 | //if you are developing a critical process where you want to be able to shut all the outputs 58 | //off on the PLC at one time. Mode changes only work if the processor key is in Remote 59 | 60 | //The .UserData field can be used to store any data you desire, and it will be persisted 61 | //with the processor object. This is useful, for example, for storing information about 62 | //a processor when it's in a dictionary... 63 | 64 | processor.UserData = "MainPLC_1"; 65 | 66 | bool quitFlag = false; 67 | 68 | while (!quitFlag) 69 | { 70 | Console.WriteLine("\n\n=============================MENU============================="); 71 | Console.WriteLine("Press the 'P' key to put the processor in Program mode"); 72 | Console.WriteLine("Press the 'R' key to put the processor in Run mode"); 73 | Console.WriteLine("Press the 'U' key to display the processor UserData"); 74 | Console.WriteLine("Press the 'T' key to display all the tags on the processor"); 75 | Console.WriteLine("Press the 'Q' key to quit"); 76 | Console.WriteLine("=============================================================="); 77 | 78 | char key = Console.ReadKey(true).KeyChar; 79 | 80 | switch (key) 81 | { 82 | case 'p': 83 | case 'P': 84 | Console.WriteLine("Setting processor to Program mode..."); 85 | processor.SetProgramMode(); 86 | break; 87 | case 'r': 88 | case 'R': 89 | Console.WriteLine("Setting processor to Run mode..."); 90 | processor.SetRunMode(); 91 | break; 92 | case 'u': 93 | case 'U': 94 | Console.WriteLine("UserData: " + (string)processor.UserData); 95 | break; 96 | case 't': 97 | case 'T': 98 | List tagInfo = processor.EnumerateTags(); 99 | if (tagInfo == null) 100 | { 101 | Console.WriteLine("No tags found"); 102 | break; 103 | } 104 | Console.WriteLine("There are " + tagInfo.Count + " tags..."); 105 | foreach (LogixTagInfo info in tagInfo) 106 | { 107 | string name = info.TagName; 108 | if (info.Dimensions > 0) 109 | name += "[" + info.Dimension1Size.ToString(); 110 | if (info.Dimensions > 1) 111 | name += ", " + info.Dimension2Size.ToString(); 112 | if (info.Dimensions > 2) 113 | name += ", " + info.Dimension3Size.ToString(); 114 | if (info.Dimensions > 0) 115 | name += "]"; 116 | Console.WriteLine("\t" + name); 117 | } 118 | break; 119 | case 'q': 120 | case 'Q': 121 | quitFlag = true; 122 | break; 123 | default: 124 | break; 125 | } 126 | } 127 | 128 | //Always remember to disconnect the PLC. If you forget, the PLC won't allow you to reconnect 129 | //until the session times out. This is typically about 45-60 seconds. 130 | processor.Disconnect(); 131 | } 132 | 133 | static void processor_ProcessorStateChanged(LogixProcessor sender, LogixProcessorStateChangedEventArgs e) 134 | { 135 | //This function will be called whenever the processor changes state. The processor state is information 136 | //like what mode it's in, if it has a communications fault, if it's in firmware update mode, etc. 137 | Console.WriteLine("Processor State Changed from " + e.OldState.ToString() + " to " + e.NewState.ToString()); 138 | } 139 | 140 | static void processor_KeySwitchChanged(LogixProcessor sender, LogixKeyChangedEventArgs e) 141 | { 142 | //This function will be called when the key switch changes position. The key switch is on the front of 143 | //the processor and can either be in Run, Program or Remote mode. There is an additional member of the 144 | //ProcessorKeySwitch enumeration called "Unknown" which is used when the value hasn't been read yet or 145 | //can't be obtained. 146 | Console.WriteLine("Processor Key Position Changed from " + e.OldPosition.ToString() + " to " + e.NewPosition.ToString()); 147 | } 148 | 149 | static void processor_FaultStateChanged(LogixProcessor sender, LogixFaultStateChangedEventArgs e) 150 | { 151 | //This function is called when the processor fault state changes. The fault states are None, Minor 152 | //Recoverable, Minor Unrecoverable, Major Recoverable, and Major Unrecoverable. 153 | Console.WriteLine("Processor Fault Mode Changed from " + e.OldState.ToString() + " to " + e.NewState.ToString()); 154 | } 155 | } 156 | } 157 | -------------------------------------------------------------------------------- /Examples/Processor/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("Processor")] 9 | [assembly: AssemblyDescription("Example use of the LogixProcessor class")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("6D Systems LLC")] 12 | [assembly: AssemblyProduct("Processor")] 13 | [assembly: AssemblyCopyright("Copyright © 6D Systems LLC 2011")] 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("547482d2-bd8e-4258-96b9-82b8848fd48d")] 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("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /Examples/SimpleOperations/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using ControlLogixNET; 6 | using ControlLogixNET.LogixType; 7 | 8 | namespace SimpleOperations 9 | { 10 | class Program 11 | { 12 | /* 13 | * HOW TO USE THIS SAMPLE 14 | * 15 | * 1. First change the hostNameOrIp to the IP address or host name of your PLC 16 | * 2. Then change the path to be the path to your PLC, see comments below 17 | * 3. Run 18 | * 19 | */ 20 | 21 | static void Main(string[] args) 22 | { 23 | //First we create the processor object. Typically the path is the slot 24 | //number of the processor module in the backplane, but if your communications 25 | //card is not in the same chassis as your processor, this is the path through 26 | //the chassis to get to your processor. You will have to add a 1 for every 27 | //chassis you go through, for example: 28 | //Chassis 1: ENBT card in Slot 1 (slot is irrelavent), ControlNet Card in Slot 2 29 | //Chassis 2: L61 in Slot 4 30 | //Path would be: { 2, 1, 4 } 31 | //Basically it's the target slot, 1 for backplane, target slot, 1 for backplane... 32 | //until you get to the processor. 33 | string hostNameOrIp = "192.168.1.10"; 34 | byte[] path = new byte[] { 0 }; 35 | LogixProcessor processor = new LogixProcessor(hostNameOrIp, path); 36 | 37 | //The processor has to be connected before you add any tags or tag groups. 38 | if (!processor.Connect()) 39 | { 40 | Console.WriteLine("Could not connect to the processor"); 41 | Console.ReadKey(false); 42 | return; 43 | } 44 | 45 | string menu = "6D Systems LLC\n" 46 | + "-----------------------------------------\n" 47 | + "(1) - Get Information About A Tag\n" 48 | + "(2) - Read a tag\n" 49 | + "(3) - Write a tag\n" 50 | + "(Q) - Quit\n" 51 | + "-----------------------------------------\n" 52 | + "Enter your choice:"; 53 | 54 | bool quitFlag = false; 55 | 56 | while (!quitFlag) 57 | { 58 | Console.Clear(); 59 | Console.Write(menu); 60 | 61 | string key = Console.ReadLine(); 62 | 63 | switch (key) 64 | { 65 | case "1": 66 | TagInformation(processor); 67 | break; 68 | case "2": 69 | ReadTag(processor); 70 | break; 71 | case "3": 72 | WriteTag(processor); 73 | break; 74 | case "q": 75 | case "Q": 76 | quitFlag = true; 77 | continue; 78 | default: 79 | Console.WriteLine("Invalid entry"); 80 | break; 81 | } 82 | 83 | Console.WriteLine("Hit any key to go back to the menu"); 84 | Console.ReadKey(false); 85 | } 86 | 87 | //Remember to disconnect from the processor. If you forget, the processor won't allow you 88 | //to reconnect until the session times out, which is typically 60 seconds. 89 | 90 | processor.Disconnect(); 91 | } 92 | 93 | static void TagInformation(LogixProcessor processor) 94 | { 95 | //Getting detailed tag information is actually an expensive process. Currently 96 | //there is no way to get detailed information about a tag except to request all 97 | //the tag information in the PLC. The GetTagInformation will read all the tags 98 | //in the PLC, then return the one you are looking for. 99 | string address = GetTagAddress(); 100 | 101 | if (string.IsNullOrEmpty(address)) 102 | return; 103 | 104 | LogixTagInfo tagInfo = processor.GetTagInformation(address); 105 | 106 | if (tagInfo == null) 107 | { 108 | Console.WriteLine("The tag '" + address + "' could not be found on the processor"); 109 | Console.ReadKey(false); 110 | return; 111 | } 112 | 113 | Console.WriteLine(tagInfo.ToString()); 114 | } 115 | 116 | static void ReadTag(LogixProcessor processor) 117 | { 118 | //Reading a tag is very easy. First, create a tag... 119 | string address = GetTagAddress(); 120 | 121 | if (string.IsNullOrEmpty(address)) 122 | return; 123 | 124 | //Now we have to create the tag on the processor. The easiest way to 125 | //do this without knowing the underlying type is to use the 126 | //LogixTagFactory class. 127 | LogixTag userTag = LogixTagFactory.CreateTag(address, processor); 128 | 129 | if (userTag == null) 130 | { 131 | Console.WriteLine("Could not create the tag " + address + " on the processor"); 132 | return; 133 | } 134 | 135 | //The tag is automatically read when it is created. The LogixProcessor does this 136 | //to verify the tag exists and to get type information about the tag. From this 137 | //point on you can read/write the tag all you want, either by using tag groups 138 | //or by directly writing it with the LogixProcessor.WriteTag() function. 139 | 140 | //We'll demonstrate a read anyway... 141 | if (!processor.ReadTag(userTag)) 142 | Console.WriteLine("Could not read the tag: " + userTag.LastError); 143 | 144 | //Print the value out with our handy helper function 145 | PrintTagValue(userTag); 146 | 147 | //And go back to the main menu 148 | } 149 | 150 | static void WriteTag(LogixProcessor processor) 151 | { 152 | //Writing a tag is also very easy. First, create a tag... 153 | string address = GetTagAddress(); 154 | 155 | if (string.IsNullOrEmpty(address)) 156 | return; 157 | 158 | //Now we have to create the tag on the processor. The easiest way to 159 | //do this without knowing the underlying type is to use the 160 | //LogixTagFactory class. 161 | LogixTag userTag = LogixTagFactory.CreateTag(address, processor); 162 | 163 | if (userTag == null) 164 | { 165 | Console.WriteLine("Could not create the tag " + address + " on the processor"); 166 | return; 167 | } 168 | 169 | switch (userTag.LogixType) 170 | { 171 | case LogixTypes.Bool: 172 | WriteBool(userTag, processor); 173 | break; 174 | case LogixTypes.DInt: 175 | case LogixTypes.LInt: 176 | case LogixTypes.Real: 177 | case LogixTypes.SInt: 178 | WriteOther(userTag, processor); 179 | break; 180 | case LogixTypes.Control: 181 | case LogixTypes.Counter: 182 | case LogixTypes.Timer: 183 | case LogixTypes.User_Defined: 184 | WriteStructure(userTag, processor); 185 | break; 186 | default: 187 | Console.WriteLine("The LogixType of " + userTag.LogixType.ToString() + " is not supported in this sample"); 188 | return; 189 | } 190 | 191 | PrintTagValue(userTag); 192 | 193 | //And go back to the menu 194 | } 195 | 196 | static void PrintTagValue(LogixTag tag) 197 | { 198 | //Now we'll determine the value of the tag... 199 | switch (tag.LogixType) 200 | { 201 | case LogixTypes.Bool: 202 | Console.WriteLine("BOOL value is: " + ((LogixBOOL)tag).Value.ToString()); 203 | break; 204 | case LogixTypes.Control: 205 | //The control tag is a lot more complicated, there is no way currently to know 206 | //which member was updated, so all you can do is say it was updated, we'll print 207 | //out one of the members though. 208 | Console.WriteLine("Control.POS is: " + ((LogixCONTROL)tag).POS.ToString()); 209 | break; 210 | case LogixTypes.Counter: 211 | //Same as the counter above, we'll just print out the ACC value 212 | Console.WriteLine("Counter.ACC value is: " + ((LogixCOUNTER)tag).ACC.ToString()); 213 | break; 214 | case LogixTypes.DInt: 215 | //Print out the value. DINT's are equivalent to int in .NET 216 | Console.WriteLine("DINT value is: " + ((LogixDINT)tag).Value.ToString()); 217 | break; 218 | case LogixTypes.Int: 219 | //An INT in a logix processor is more like a short in .NET 220 | Console.WriteLine("INT value is: " + ((LogixINT)tag).Value.ToString()); 221 | break; 222 | case LogixTypes.LInt: 223 | //LINT's are equivalent to long in .NET 224 | Console.WriteLine("LINT value is: " + ((LogixLINT)tag).Value.ToString()); 225 | break; 226 | case LogixTypes.Real: 227 | //REALs are single precision floats 228 | Console.WriteLine("REAL value is: " + ((LogixREAL)tag).Value.ToString()); 229 | break; 230 | case LogixTypes.SInt: 231 | //SINTs are signed bytes 232 | Console.WriteLine("SINT value is: " + ((LogixSINT)tag).Value.ToString()); 233 | break; 234 | case LogixTypes.String: 235 | //Strings are just like .NET strings, so notice how we can skip the .StringValue 236 | //member, since the .ToString() will automatically be called, which returns the 237 | //same value as .StringValue 238 | Console.WriteLine("STRING value is: " + ((LogixSTRING)tag)); 239 | break; 240 | case LogixTypes.Timer: 241 | //Timers again are like the CONTROL and COUNTER types 242 | Console.WriteLine("Timer.ACC value is: " + ((LogixTIMER)tag).ACC.ToString()); 243 | break; 244 | case LogixTypes.User_Defined: 245 | //The only way to get the value out of a UDT, PDT, or MDT is to define the 246 | //structure or know the member name you wish to read. We'll just print that 247 | //we know its a UDT, MDT, or PDT that changed. 248 | Console.WriteLine("User defined type"); 249 | break; 250 | default: 251 | break; 252 | } 253 | } 254 | 255 | static string GetTagAddress() 256 | { 257 | Console.Write("\nEnter a Tag Address: "); 258 | 259 | string address = Console.ReadLine(); 260 | 261 | if (string.IsNullOrEmpty(address)) 262 | { 263 | Console.WriteLine("Address can't be a null or empty string"); 264 | return string.Empty; 265 | } 266 | 267 | return address; 268 | } 269 | 270 | static void WriteStructure(LogixTag tag, LogixProcessor processor) 271 | { 272 | Console.Write("The tag is a structure called " + ((LogixUDT)tag).TypeName + ", please enter a member name: "); 273 | string memberName = Console.ReadLine(); 274 | 275 | //First we have to find out if the member exists, if it doesn't we can't write to it... 276 | List memberNames = ((LogixUDT)tag).MemberNames; 277 | 278 | bool hasMember = false; 279 | for (int i = 0; i < memberNames.Count; i++) 280 | { 281 | if (string.Compare(memberNames[i], memberName) == 0) 282 | { 283 | hasMember = true; 284 | break; 285 | } 286 | } 287 | 288 | if (!hasMember) 289 | { 290 | Console.WriteLine("The specified member could not be found in the structure"); 291 | return; 292 | } 293 | 294 | Console.Write("Enter a value: "); 295 | string sValue = Console.ReadLine(); 296 | 297 | //Now we have to convert it to the right type... 298 | try 299 | { 300 | switch (tag.LogixType) 301 | { 302 | case LogixTypes.Bool: 303 | if (sValue == "1") 304 | ((LogixUDT)tag)[memberName] = true; 305 | else 306 | ((LogixUDT)tag)[memberName] = false; 307 | break; 308 | case LogixTypes.DInt: 309 | ((LogixUDT)tag)[memberName] = Convert.ToInt32(sValue); 310 | break; 311 | case LogixTypes.Int: 312 | ((LogixUDT)tag)[memberName] = Convert.ToInt16(sValue); 313 | break; 314 | case LogixTypes.LInt: 315 | ((LogixUDT)tag)[memberName] = Convert.ToInt64(sValue); 316 | break; 317 | case LogixTypes.Real: 318 | ((LogixUDT)tag)[memberName] = Convert.ToSingle(sValue); 319 | break; 320 | case LogixTypes.SInt: 321 | ((LogixUDT)tag)[memberName] = Convert.ToSByte(sValue); 322 | break; 323 | case LogixTypes.User_Defined: 324 | default: 325 | Console.WriteLine("This demo does not support writing to nested structure tags"); 326 | return; 327 | } 328 | 329 | //At this point the tag has not been committed to the processor. The 330 | //tag must be written, then read back for the value to change. The 331 | //easiest way to do this with a single tag is to use the processor 332 | //LogixProcessor.WriteRead() which performs the write, then the 333 | //subsequent read on the tag. 334 | processor.WriteRead(tag); 335 | } 336 | catch (Exception e) 337 | { 338 | Console.WriteLine("Could not convert " + sValue + " to the correct type for " + tag.Address); 339 | } 340 | } 341 | 342 | static void WriteBool(LogixTag tag, LogixProcessor processor) 343 | { 344 | Console.WriteLine("Enter 1 for True, 0 for False: "); 345 | char key = Console.ReadKey().KeyChar; 346 | 347 | if (key == '1') 348 | ((LogixBOOL)tag).Value = true; 349 | else 350 | ((LogixBOOL)tag).Value = false; 351 | 352 | //At this point the tag has not been committed to the processor. The 353 | //tag must be written, then read back for the value to change. The 354 | //easiest way to do this with a single tag is to use the processor 355 | //LogixProcessor.WriteRead() which performs the write, then the 356 | //subsequent read on the tag. 357 | processor.WriteRead(tag); 358 | } 359 | 360 | static void WriteOther(LogixTag tag, LogixProcessor processor) 361 | { 362 | Console.Write("Enter a value: "); 363 | string sValue = Console.ReadLine(); 364 | 365 | //Now we have to convert it to the right type... 366 | try 367 | { 368 | switch (tag.LogixType) 369 | { 370 | case LogixTypes.DInt: 371 | ((LogixDINT)tag).Value = Convert.ToInt32(sValue); 372 | break; 373 | case LogixTypes.Int: 374 | ((LogixINT)tag).Value = Convert.ToInt16(sValue); 375 | break; 376 | case LogixTypes.LInt: 377 | ((LogixLINT)tag).Value = Convert.ToInt64(sValue); 378 | break; 379 | case LogixTypes.Real: 380 | ((LogixREAL)tag).Value = Convert.ToSingle(sValue); 381 | break; 382 | case LogixTypes.SInt: 383 | ((LogixSINT)tag).Value = Convert.ToSByte(sValue); 384 | break; 385 | default: 386 | return; 387 | } 388 | 389 | //At this point the tag has not been committed to the processor. The 390 | //tag must be written, then read back for the value to change. The 391 | //easiest way to do this with a single tag is to use the processor 392 | //LogixProcessor.WriteRead() which performs the write, then the 393 | //subsequent read on the tag. 394 | processor.WriteRead(tag); 395 | } 396 | catch (Exception e) 397 | { 398 | Console.WriteLine("Could not convert " + sValue + " to the correct type for " + tag.Address); 399 | } 400 | 401 | } 402 | 403 | } 404 | } 405 | -------------------------------------------------------------------------------- /Examples/SimpleOperations/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("SimpleOperations")] 9 | [assembly: AssemblyDescription("Demonstration of simple operations on a tag")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("6D Systems LLC")] 12 | [assembly: AssemblyProduct("SimpleOperations")] 13 | [assembly: AssemblyCopyright("Copyright © 6D Systems LLC 2011")] 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("ce3d3091-5157-4a83-bc91-8bd17c106c6f")] 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("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /Examples/SimpleOperations/SimpleOperations.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | x86 6 | 8.0.30703 7 | 2.0 8 | {E653D839-E72D-4B45-B6B3-754A8EF98AEE} 9 | Exe 10 | Properties 11 | SimpleOperations 12 | SimpleOperations 13 | v4.0 14 | 512 15 | SAK 16 | SAK 17 | SAK 18 | SAK 19 | 20 | 21 | x86 22 | true 23 | full 24 | false 25 | bin\Debug\ 26 | DEBUG;TRACE 27 | prompt 28 | 4 29 | 30 | 31 | x86 32 | pdbonly 33 | true 34 | bin\Release\ 35 | TRACE 36 | prompt 37 | 4 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | {9A6CFFE2-0C70-45A7-92FC-88DA9000E591} 62 | ControlLogixNET 63 | 64 | 65 | {1E726BE8-F9B8-4A9B-B052-E0D9154F3896} 66 | ICommon 67 | 68 | 69 | 70 | 77 | -------------------------------------------------------------------------------- /Examples/StructureTags/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using ControlLogixNET; 6 | using ControlLogixNET.LogixType; 7 | 8 | namespace StructureTags 9 | { 10 | class Program 11 | { 12 | /* 13 | * HOW TO USE THIS SAMPLE 14 | * 15 | * 1. First change the hostNameOrIp to the IP address or host name of your PLC 16 | * 2. Then change the path to be the path to your PLC, see comments below 17 | * 3. Create a user defined type tag in your processor called myUDT1 18 | * 4. Create an ALARM tag in your processor called myAlarm1 19 | * 5. Run 20 | * 21 | */ 22 | 23 | static void Main(string[] args) 24 | { 25 | //First we create the processor object. Typically the path is the slot 26 | //number of the processor module in the backplane, but if your communications 27 | //card is not in the same chassis as your processor, this is the path through 28 | //the chassis to get to your processor. You will have to add a 1 for every 29 | //chassis you go through, for example: 30 | //Chassis 1: ENBT card in Slot 1 (slot is irrelavent), ControlNet Card in Slot 2 31 | //Chassis 2: L61 in Slot 4 32 | //Path would be: { 2, 1, 4 } 33 | //Basically it's the target slot, 1 for backplane, target slot, 1 for backplane... 34 | //until you get to the processor. 35 | string hostNameOrIp = "192.168.1.10"; 36 | byte[] path = new byte[] { 1 }; 37 | LogixProcessor processor = new LogixProcessor(hostNameOrIp, path); 38 | 39 | //The processor has to be connected before you add any tags or tag groups. 40 | if (!processor.Connect()) 41 | { 42 | Console.WriteLine("Could not connect to the processor"); 43 | Console.ReadKey(false); 44 | return; 45 | } 46 | 47 | Console.WriteLine("6D Systems LLC\n\n"); 48 | 49 | //First create a group. Groups are much more efficient at reading and writing 50 | //large numbers of tags or complex tags like UDTs. 51 | LogixTagGroup myGroup = processor.CreateTagGroup("MyGroup"); 52 | 53 | //Ok, let's create the first tag which is some random user defined type 54 | LogixTag genericTag = LogixTagFactory.CreateTag("myUDT1", processor); 55 | LogixUDT udtTag = genericTag as LogixUDT; 56 | 57 | if (udtTag == null) 58 | { 59 | Console.WriteLine("The tag 'myUDT1' on the processor is not a structure tag"); 60 | Console.WriteLine("Press any key to quit"); 61 | Console.ReadKey(false); 62 | processor.Disconnect(); 63 | return; 64 | } 65 | 66 | //Let's print out some information about the UDT 67 | PrintStructure(udtTag); 68 | 69 | //The value of any member can also be set with the tagName[memberName] = value syntax 70 | 71 | //Now let's get information about the alarm tag that was created... 72 | LogixTag genericAlarm = LogixTagFactory.CreateTag("myAlarm1", processor); 73 | LogixUDT alarmTag = genericAlarm as LogixUDT; 74 | 75 | if (alarmTag == null) 76 | { 77 | Console.WriteLine("The tag 'myAlarm1' is not a structure tag"); 78 | Console.WriteLine("Press any key to quit"); 79 | Console.ReadKey(false); 80 | processor.Disconnect(); 81 | return; 82 | } 83 | 84 | //Print out information about it... 85 | PrintStructure(alarmTag); 86 | 87 | //Now, let's set up the tags in the group, set the group to auto update, and watch 88 | //for tag update events... 89 | myGroup.AddTag(udtTag); 90 | myGroup.AddTag(alarmTag); 91 | 92 | udtTag.TagValueUpdated += new ICommon.TagValueUpdateEventHandler(TagValueUpdated); 93 | alarmTag.TagValueUpdated += new ICommon.TagValueUpdateEventHandler(TagValueUpdated); 94 | 95 | processor.EnableAutoUpdate(500); 96 | 97 | Console.WriteLine("Press Enter to quit"); 98 | 99 | Console.ReadLine(); 100 | 101 | processor.Disconnect(); 102 | } 103 | 104 | static void TagValueUpdated(ICommon.ITag sender, ICommon.TagValueUpdateEventArgs e) 105 | { 106 | LogixUDT logixUDT = sender as LogixUDT; 107 | 108 | if (logixUDT != null) 109 | PrintStructure(logixUDT); 110 | } 111 | 112 | private static void PrintStructure(LogixUDT structureTag) 113 | { 114 | List memberNames = structureTag.MemberNames; 115 | Console.WriteLine("myUDT1 is a " + structureTag.TypeName + " with members:"); 116 | foreach (string mName in memberNames) 117 | { 118 | LogixTypes memberType = structureTag.GetTypeForMember(mName); 119 | Console.WriteLine("\t" + mName + " : " + memberType.ToString() + " - Value: " + structureTag[mName].ToString()); 120 | } 121 | } 122 | } 123 | } 124 | -------------------------------------------------------------------------------- /Examples/StructureTags/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("StructureTags")] 9 | [assembly: AssemblyDescription("Demonstration of how to use structure tags")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("6D Systems LLC")] 12 | [assembly: AssemblyProduct("StructureTags")] 13 | [assembly: AssemblyCopyright("Copyright © 6D Systems LLC 2011")] 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("315b32c0-075a-46c9-a9f6-cd9e6218d5d6")] 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("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /Examples/StructureTags/StructureTags.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | x86 6 | 8.0.30703 7 | 2.0 8 | {F9FF55D3-526E-46E7-B703-45E980FABA33} 9 | Exe 10 | Properties 11 | StructureTags 12 | StructureTags 13 | v4.0 14 | 512 15 | SAK 16 | SAK 17 | SAK 18 | SAK 19 | 20 | 21 | x86 22 | true 23 | full 24 | false 25 | bin\Debug\ 26 | DEBUG;TRACE 27 | prompt 28 | 4 29 | 30 | 31 | x86 32 | pdbonly 33 | true 34 | bin\Release\ 35 | TRACE 36 | prompt 37 | 4 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | False 56 | ..\..\ControlLogixNET\bin\Debug\ControlLogixNET_Locked\ControlLogixNET.dll 57 | 58 | 59 | False 60 | ..\..\ControlLogixNET\bin\Debug\EIPNET_Locked\EIPNET.dll 61 | 62 | 63 | False 64 | ..\..\ControlLogixNET\bin\Debug\ICommon_Locked\ICommon.dll 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 79 | -------------------------------------------------------------------------------- /Examples/TagGroups/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using ControlLogixNET; 6 | using ControlLogixNET.LogixType; 7 | 8 | namespace TagGroups 9 | { 10 | class Program 11 | { 12 | static void Main(string[] args) 13 | { 14 | //First we create the processor object. Typically the path is the slot 15 | //number of the processor module in the backplane, but if your communications 16 | //card is not in the same chassis as your processor, this is the path through 17 | //the chassis to get to your processor. You will have to add a 1 for every 18 | //chassis you go through, for example: 19 | //Chassis 1: ENBT card in Slot 1 (slot is irrelavent), ControlNet Card in Slot 2 20 | //Chassis 2: L61 in Slot 4 21 | //Path would be: { 2, 1, 4 } 22 | //Basically it's the target slot, 1 for backplane, target slot, 1 for backplane... 23 | //until you get to the processor. 24 | string hostNameOrIp = "192.168.1.10"; 25 | byte[] path = new byte[] { 1 }; 26 | LogixProcessor processor = new LogixProcessor(hostNameOrIp, path); 27 | 28 | //Connect to the PLC, you can create the events before or after the connect function 29 | if (!processor.Connect()) 30 | { 31 | Console.WriteLine("Could not connect to the processor"); 32 | Console.ReadKey(false); 33 | return; 34 | } 35 | 36 | //Tag groups allow you to group tags in a useful manner. For example in an HMI you 37 | //could create tag groups for each page. Disabling a tag group that is not in use 38 | //frees up resources on the processor and the network. 39 | 40 | //You also have to be careful about the two different kinds of Enabled properties. 41 | //There is an enabled property for the tag group, and there is an Enabled property 42 | //for the tag itself. Disabling the tag group stops it from being updated, so no 43 | //tags belonging to that group will be updated (unless they also belong to another 44 | //active tag group). Disabling the tag by setting the LogixTag.Enabled property 45 | //to false means that the tag won't accept new data or pending values, and that 46 | //any tag group that it belongs to won't update it. 47 | 48 | //First, we need to create a LogixTagGroup on the processor. The easiest way to do 49 | //this is to use the LogixProcessor.CreateTagGroup() method. This allows the 50 | //processor to create the tag group, verify it doesn't conflict with another tag 51 | //group, and manage the group. 52 | 53 | LogixTagGroup tg = processor.CreateTagGroup("MyGroup"); 54 | 55 | //Now that we've created a tag group, we can add some tags to it. Adding and removing 56 | //tags from a tag group is an expensive process. The tag group will automatically 57 | //re-optimize all the tags it's responsible for when you add or remove a tag. It's 58 | //recommended that you don't add or remove tags very often, if you don't need a tag 59 | //to be updated anymore just set the LogixTag.Enabled property to false. 60 | 61 | //Here we are going to ask the user (probably you) for some tags. The easiest way to 62 | //create tags without knowing the underlying data type in the processor is to use 63 | //the LogixTagFactory. 64 | 65 | bool quitFlag = false; 66 | LogixDINT dTag = new LogixDINT("tst_Dint", processor); 67 | dTag.TagValueUpdated += new ICommon.TagValueUpdateEventHandler(TagValueUpdated); 68 | tg.AddTag(dTag); 69 | 70 | while (!quitFlag) 71 | { 72 | Console.Write("Please enter a tag name to monitor, enter 'done' when finished: "); 73 | 74 | string tagName = Console.ReadLine(); 75 | 76 | if (tagName.ToLower() == "done") 77 | { 78 | quitFlag = true; 79 | continue; 80 | } 81 | 82 | LogixTag userTag = LogixTagFactory.CreateTag(tagName, processor); 83 | 84 | if (userTag == null) 85 | { 86 | //When the tag factory returns null, the tag was not found or some other 87 | //catastrophic error occurred trying to reference it on the processor. 88 | Console.WriteLine("The tag " + tagName + " could not be created"); 89 | continue; 90 | } 91 | 92 | //If we got here, we were able to successfully create the tag. Let's print 93 | //some information about it... 94 | Console.WriteLine("Created " + tagName + " as a(n) " + userTag.LogixType.ToString()); 95 | 96 | //Let's reference the update functions... 97 | userTag.TagValueUpdated += new ICommon.TagValueUpdateEventHandler(TagValueUpdated); 98 | 99 | //Now let's add it to the tag group... 100 | tg.AddTag(userTag); 101 | } 102 | 103 | //The processor has a feature that allows them to automatically update the tag group. This 104 | //helps to free up your logic and not worry about having to update tag groups that are 105 | //enabled or disabled. The argument for this function is the time between updates in 106 | //milliseconds. The actual time from the start of one update to the start of another is 107 | //dependant on how many tags there are and how much data needs to be transferred. 108 | processor.EnableAutoUpdate(500); 109 | 110 | Console.WriteLine("Press Enter to quit"); 111 | Console.ReadLine(); 112 | 113 | processor.Disconnect(); 114 | 115 | } 116 | 117 | static void TagValueUpdated(ICommon.ITag sender, ICommon.TagValueUpdateEventArgs e) 118 | { 119 | //Here we'll just display the name of the tag and that it was updated. If you 120 | //want to extract the value you'll have to cast it to the correct type. You 121 | //can do this by using a switch as shown below. 122 | Console.WriteLine("Tag " + e.Tag.Address + " Updated"); 123 | 124 | switch (((LogixTag)sender).LogixType) 125 | { 126 | case LogixTypes.Bool: 127 | Console.WriteLine("New value is: " + ((LogixBOOL)sender).Value.ToString()); 128 | break; 129 | case LogixTypes.Control: 130 | //The control tag is a lot more complicated, there is no way currently to know 131 | //which member was updated, so all you can do is say it was updated, we'll print 132 | //out one of the members though. 133 | Console.WriteLine("New value is: " + ((LogixCONTROL)sender).POS.ToString()); 134 | break; 135 | case LogixTypes.Counter: 136 | //Same as the counter above, we'll just print out the ACC value 137 | Console.WriteLine("New ACC value is: " + ((LogixCOUNTER)sender).ACC.ToString()); 138 | break; 139 | case LogixTypes.DInt: 140 | //Print out the value. DINT's are equivalent to int in .NET 141 | Console.WriteLine("New DINT value is: " + ((LogixDINT)sender).Value.ToString()); 142 | break; 143 | case LogixTypes.Int: 144 | //An INT in a logix processor is more like a short in .NET 145 | Console.WriteLine("New INT value is: " + ((LogixINT)sender).Value.ToString()); 146 | break; 147 | case LogixTypes.LInt: 148 | //LINT's are equivalent to long in .NET 149 | Console.WriteLine("New LINT value is: " + ((LogixLINT)sender).Value.ToString()); 150 | break; 151 | case LogixTypes.Real: 152 | //REALs are single precision floats 153 | Console.WriteLine("New REAL value is: " + ((LogixREAL)sender).Value.ToString()); 154 | break; 155 | case LogixTypes.SInt: 156 | //SINTs are signed bytes 157 | Console.WriteLine("New SINT value is: " + ((LogixSINT)sender).Value.ToString()); 158 | break; 159 | case LogixTypes.String: 160 | //Strings are just like .NET strings, so notice how we can skip the .StringValue 161 | //member, since the .ToString() will automatically be called, which returns the 162 | //same value as .StringValue 163 | Console.WriteLine("New STRING value is: " + ((LogixSTRING)sender)); 164 | break; 165 | case LogixTypes.Timer: 166 | //Timers again are like the CONTROL and COUNTER types 167 | Console.WriteLine("New Timer.ACC value is: " + ((LogixTIMER)sender).ACC.ToString()); 168 | break; 169 | case LogixTypes.User_Defined: 170 | //The only way to get the value out of a UDT, PDT, or MDT is to define the 171 | //structure or know the member name you wish to read. We'll just print that 172 | //we know its a UDT, MDT, or PDT that changed. 173 | Console.WriteLine("The user defined type has changed"); 174 | break; 175 | default: 176 | break; 177 | } 178 | } 179 | 180 | } 181 | } 182 | -------------------------------------------------------------------------------- /Examples/TagGroups/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("TagGroups")] 9 | [assembly: AssemblyDescription("Demonstration on how to use tag groups")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("6D Systems LLC")] 12 | [assembly: AssemblyProduct("TagGroups")] 13 | [assembly: AssemblyCopyright("Copyright © 6D Systems LLC 2011")] 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("7fe39fcb-ef66-4c18-8ea4-4a52f169994a")] 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("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /Examples/TagGroups/TagGroups.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | x86 6 | 8.0.30703 7 | 2.0 8 | {B8B61369-057F-4893-8C52-366BC8C09EBC} 9 | Exe 10 | Properties 11 | TagGroups 12 | TagGroups 13 | v4.0 14 | 512 15 | SAK 16 | SAK 17 | SAK 18 | SAK 19 | 20 | 21 | x86 22 | true 23 | full 24 | false 25 | bin\Debug\ 26 | DEBUG;TRACE 27 | prompt 28 | 4 29 | 30 | 31 | x86 32 | pdbonly 33 | true 34 | bin\Release\ 35 | TRACE 36 | prompt 37 | 4 38 | 39 | 40 | 41 | False 42 | ..\..\ControlLogixNET\bin\Debug\ControlLogixNET_Locked\ControlLogixNET.dll 43 | 44 | 45 | False 46 | ..\..\ControlLogixNET\bin\Debug\EIPNET_Locked\EIPNET.dll 47 | 48 | 49 | False 50 | ..\..\ControlLogixNET\bin\Debug\ICommon_Locked\ICommon.dll 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 79 | -------------------------------------------------------------------------------- /Examples/UserDefinedType/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using ControlLogixNET; 6 | using ControlLogixNET.LogixType; 7 | 8 | namespace UserDefinedType 9 | { 10 | class Program 11 | { 12 | /* 13 | * HOW TO USE THIS SAMPLE 14 | * 15 | * 1. First change the hostNameOrIp to the IP address or host name of your PLC 16 | * 2. Then change the path to be the path to your PLC, see comments below 17 | * 3. Create a new User Defined Type on the processor called CustomUDT 18 | * 4. Add the following members to the type: 19 | * 1. Enabled : BOOL 20 | * 2. UpperLimit : DINT 21 | * 3. LowerLimit : DINT 22 | * 4. RunningValue : REAL 23 | * 5. Over : BOOL 24 | * 6. Under : BOOL 25 | * 5. Create a new tag of type CustomUDT called myCustomUDT 26 | * 6. Run 27 | * 28 | */ 29 | static void Main(string[] args) 30 | { 31 | //First we create the processor object. Typically the path is the slot 32 | //number of the processor module in the backplane, but if your communications 33 | //card is not in the same chassis as your processor, this is the path through 34 | //the chassis to get to your processor. You will have to add a 1 for every 35 | //chassis you go through, for example: 36 | //Chassis 1: ENBT card in Slot 1 (slot is irrelavent), ControlNet Card in Slot 2 37 | //Chassis 2: L61 in Slot 4 38 | //Path would be: { 2, 1, 4 } 39 | //Basically it's the target slot, 1 for backplane, target slot, 1 for backplane... 40 | //until you get to the processor. 41 | string hostNameOrIp = "192.168.1.10"; 42 | byte[] path = new byte[] { 1 }; 43 | LogixProcessor processor = new LogixProcessor(hostNameOrIp, path); 44 | 45 | //The processor has to be connected before you add any tags or tag groups. 46 | if (!processor.Connect()) 47 | { 48 | Console.WriteLine("Could not connect to the processor"); 49 | Console.ReadKey(false); 50 | return; 51 | } 52 | 53 | Console.WriteLine("6D Systems LLC\n\n"); 54 | 55 | //First create a group. Groups are much more efficient at reading and writing 56 | //large numbers of tags or complex tags like UDTs. 57 | LogixTagGroup myGroup = processor.CreateTagGroup("MyGroup"); 58 | 59 | CustomUDT myCustomUDT = new CustomUDT("myCustomUDT", processor); 60 | myCustomUDT.TagValueUpdated += new ICommon.TagValueUpdateEventHandler(TagValueUpdated); 61 | 62 | //Add the tag to the group... 63 | myGroup.AddTag(myCustomUDT); 64 | 65 | //Set the group to auto update 66 | processor.EnableAutoUpdate(500); 67 | 68 | //Print out some structure information: 69 | PrintStructure(myCustomUDT); 70 | 71 | //Now wait for updates... 72 | Console.WriteLine("Change some data in the custom type, then hit Enter to quit"); 73 | 74 | Console.ReadLine(); 75 | 76 | processor.Disconnect(); 77 | } 78 | 79 | static void TagValueUpdated(ICommon.ITag sender, ICommon.TagValueUpdateEventArgs e) 80 | { 81 | LogixUDT udtTag = sender as LogixUDT; 82 | 83 | if (udtTag != null) 84 | PrintStructure(udtTag); 85 | } 86 | 87 | private static void PrintStructure(LogixUDT structureTag) 88 | { 89 | List memberNames = structureTag.MemberNames; 90 | Console.WriteLine("myUDT1 is a " + structureTag.TypeName + " with members:"); 91 | foreach (string mName in memberNames) 92 | { 93 | LogixTypes memberType = structureTag.GetTypeForMember(mName); 94 | Console.WriteLine("\t" + mName + " : " + memberType.ToString() + " - Value: " + structureTag[mName].ToString()); 95 | } 96 | } 97 | } 98 | 99 | /// 100 | /// Custom User Defined Type 101 | /// 102 | /// 103 | /// This shows how to create a custom user defined type on the processor. 104 | /// 105 | public class CustomUDT : LogixUDT 106 | { 107 | private LogixUDT _myUDTBase; 108 | 109 | public bool Enabled 110 | { 111 | get { return (bool)this["Enabled"]; } 112 | set { this["Enabled"] = value; } 113 | } 114 | 115 | public int UpperLimit 116 | { 117 | get { return (int)this["UpperLimit"]; } 118 | set { this["UpperLimit"] = value; } 119 | } 120 | 121 | public int LowerLimit 122 | { 123 | get { return (int)this["LowerLimit"]; } 124 | set { this["LowerLimit"] = value; } 125 | } 126 | 127 | public float RunningValue 128 | { 129 | get { return (float)this["RunningValue"]; } 130 | set { this["RunningValue"] = value; } 131 | } 132 | 133 | public bool Over 134 | { 135 | get { return (bool)this["Over"]; } 136 | set { this["Over"] = value; } 137 | } 138 | 139 | public bool Under 140 | { 141 | get { return (bool)this["Under"]; } 142 | set { this["Under"] = value; } 143 | } 144 | 145 | public CustomUDT(string TagAddress, LogixProcessor Processor) 146 | : base(TagAddress, Processor) 147 | { 148 | 149 | } 150 | } 151 | } 152 | -------------------------------------------------------------------------------- /Examples/UserDefinedType/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("UserDefinedType")] 9 | [assembly: AssemblyDescription("How to create interactive User Defined Types")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("6D Systems LLC")] 12 | [assembly: AssemblyProduct("UserDefinedType")] 13 | [assembly: AssemblyCopyright("Copyright © 6D Systems LLC 2011")] 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("f04d1a82-0963-466d-a749-bd6059368097")] 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("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /Examples/UserDefinedType/UserDefinedType.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | x86 6 | 8.0.30703 7 | 2.0 8 | {C11608A6-1EC1-4859-9D42-B4A21FD9D5DD} 9 | Exe 10 | Properties 11 | UserDefinedType 12 | UserDefinedType 13 | v4.0 14 | 512 15 | SAK 16 | SAK 17 | SAK 18 | SAK 19 | 20 | 21 | x86 22 | true 23 | full 24 | false 25 | bin\Debug\ 26 | DEBUG;TRACE 27 | prompt 28 | 4 29 | 30 | 31 | x86 32 | pdbonly 33 | true 34 | bin\Release\ 35 | TRACE 36 | prompt 37 | 4 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | False 56 | ..\..\ControlLogixNET\bin\Debug\ControlLogixNET_Locked\ControlLogixNET.dll 57 | 58 | 59 | False 60 | ..\..\ControlLogixNET\bin\Debug\EIPNET_Locked\EIPNET.dll 61 | 62 | 63 | False 64 | ..\..\ControlLogixNET\bin\Debug\ICommon_Locked\ICommon.dll 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 79 | -------------------------------------------------------------------------------- /ICommon/ICommon.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | AnyCPU 6 | 8.0.30703 7 | 2.0 8 | {1E726BE8-F9B8-4A9B-B052-E0D9154F3896} 9 | Library 10 | Properties 11 | ICommon 12 | ICommon 13 | v4.0 14 | 512 15 | SAK 16 | SAK 17 | SAK 18 | SAK 19 | 20 | 21 | true 22 | full 23 | false 24 | bin\Debug\ 25 | DEBUG;TRACE 26 | prompt 27 | 4 28 | 29 | 30 | pdbonly 31 | true 32 | bin\Release\ 33 | TRACE 34 | prompt 35 | 4 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 67 | -------------------------------------------------------------------------------- /ICommon/IDevice.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace ICommon 7 | { 8 | /// 9 | /// Represents a device which has tag data 10 | /// 11 | public interface IDevice : IDisposable 12 | { 13 | /// 14 | /// Gets the last error code 15 | /// 16 | int ErrorCode { get; } 17 | /// 18 | /// Gets the last error string 19 | /// 20 | string ErrorString { get; } 21 | /// 22 | /// Gets or Sets an object for use by the user 23 | /// 24 | object UserData { get; set; } 25 | /// 26 | /// Gets the version information 27 | /// 28 | Version Version { get; } 29 | 30 | /// 31 | /// Connects to the device 32 | /// 33 | /// True if connected 34 | bool Connect(); 35 | /// 36 | /// Disconnects from the device 37 | /// 38 | /// True if disconnected 39 | bool Disconnect(); 40 | 41 | /// 42 | /// Reads a particular tag from the PLC 43 | /// 44 | /// Tag to read 45 | /// True if the tag was read successfully 46 | bool ReadTag(ITag tag); 47 | /// 48 | /// Writes a particular tag to the PLC 49 | /// 50 | /// Tag to write 51 | /// True if the tag was written successfully 52 | bool WriteTag(ITag tag); 53 | 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /ICommon/ITag.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace ICommon 7 | { 8 | /// 9 | /// Interface for Tag objects 10 | /// 11 | public interface ITag 12 | { 13 | /// 14 | /// Gets or Sets a value determining if the tag is active on the controller 15 | /// 16 | bool Enabled { get; set; } 17 | /// 18 | /// Gets or the device to which this tag belongs 19 | /// 20 | IDevice Device { get; } 21 | /// 22 | /// Gets the DataType code for the tag 23 | /// 24 | ushort DataType { get; } 25 | /// 26 | /// Gets or Sets an object available to the user for any use 27 | /// 28 | object UserData { get; set; } 29 | /// 30 | /// Gets or Sets the address of the tag 31 | /// 32 | string Address { get; } 33 | /// 34 | /// Gets the last error associated with the tag 35 | /// 36 | string LastError { get; } 37 | /// 38 | /// Gets the last error number associated with the tag 39 | /// 40 | int LastErrorNumber { get; } 41 | /// 42 | /// Gets the quality of the tag 43 | /// 44 | TagQuality Quality { get; } 45 | /// 46 | /// Gets the timestamp of the last successful operation on the tag 47 | /// 48 | DateTime TimeStamp { get; } 49 | 50 | /// 51 | /// Raised when the value of the tag is updated 52 | /// 53 | event TagValueUpdateEventHandler TagValueUpdated; 54 | /// 55 | /// Raised when the quality of the tag has changed 56 | /// 57 | event TagQualityChangedEventHandler TagQualityChanged; 58 | } 59 | 60 | //Support Classes 61 | 62 | /// 63 | /// Event delegate for the TagValueUpdateEvent 64 | /// 65 | /// ITag raising the update 66 | /// Event arguments 67 | public delegate void TagValueUpdateEventHandler(ITag sender, TagValueUpdateEventArgs e); 68 | /// 69 | /// Event arguments for 70 | /// 71 | public class TagValueUpdateEventArgs : EventArgs 72 | { 73 | /// 74 | /// Gets the Tag associated with the Update event 75 | /// 76 | public ITag Tag { get; internal set; } 77 | 78 | /// 79 | /// Creates a new TagValueUpdateEventArgs class 80 | /// 81 | /// Tag associated with the update 82 | public TagValueUpdateEventArgs(ITag tag) 83 | { 84 | Tag = tag; 85 | } 86 | } 87 | 88 | /// 89 | /// Event delegate for the TagQualityChanged 90 | /// 91 | /// ITag raising the event 92 | /// Event arguments 93 | public delegate void TagQualityChangedEventHandler(ITag sender, TagQualityChangedEventArgs e); 94 | /// 95 | /// Event arguments for 96 | /// 97 | public class TagQualityChangedEventArgs : EventArgs 98 | { 99 | /// 100 | /// Gets the Tag associated with the Update event 101 | /// 102 | public ITag Tag { get; internal set; } 103 | 104 | /// 105 | /// Creates a new TagValueUpdateEventArgs class 106 | /// 107 | /// Tag associated with the update 108 | public TagQualityChangedEventArgs(ITag tag) 109 | { 110 | Tag = tag; 111 | } 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /ICommon/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("ICommon")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("6D Systems")] 12 | [assembly: AssemblyProduct("ICommon")] 13 | [assembly: AssemblyCopyright("Copyright © 6D Systems 2011")] 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("595dbc10-887e-4097-b6d0-f0362684751c")] 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("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /ICommon/TagQuality.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace ICommon 7 | { 8 | /// 9 | /// Tag Quality 10 | /// 11 | public enum TagQuality : byte 12 | { 13 | /// 14 | /// Tag quality is bad 15 | /// 16 | Bad = 0xFF, 17 | /// 18 | /// Tag quality is unknown 19 | /// 20 | Unknown = 0, 21 | /// 22 | /// Tag quality is good 23 | /// 24 | Good = 1 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | {description} 294 | Copyright (C) {year} {fullname} 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | {signature of Ty Coon}, 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. 340 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ControlLogixNET 2 | =============== 3 | 4 | Fork of https://controllogixnet.codeplex.com/ 5 | --------------------------------------------------------------------------------