Skip to content

Commit adc0db3

Browse files
committed
add EIP Driver
1 parent 3709de4 commit adc0db3

File tree

16 files changed

+985
-3
lines changed

16 files changed

+985
-3
lines changed
51 KB
Binary file not shown.

SCADA/Program/.vs/DataExchange/v15/Server/sqlite3/db.lock

Whitespace-only changes.
Binary file not shown.

SCADA/Program/.vs/DataExchange/v15/sqlite3/db.lock

Whitespace-only changes.
Binary file not shown.

SCADA/Program/ABPLCReader/ABPLCDriver.cs

Lines changed: 518 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
6+
<ProductVersion>8.0.30703</ProductVersion>
7+
<SchemaVersion>2.0</SchemaVersion>
8+
<ProjectGuid>{02EA8F3A-29F0-4E11-B4F6-3BF87242D99F}</ProjectGuid>
9+
<OutputType>Library</OutputType>
10+
<AppDesignerFolder>Properties</AppDesignerFolder>
11+
<RootNamespace>ABPLCReader</RootNamespace>
12+
<AssemblyName>ABPLCReader</AssemblyName>
13+
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
14+
<FileAlignment>512</FileAlignment>
15+
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
16+
</PropertyGroup>
17+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
18+
<DebugSymbols>true</DebugSymbols>
19+
<DebugType>full</DebugType>
20+
<Optimize>false</Optimize>
21+
<OutputPath>bin\Debug\</OutputPath>
22+
<DefineConstants>DEBUG;TRACE</DefineConstants>
23+
<ErrorReport>prompt</ErrorReport>
24+
<WarningLevel>4</WarningLevel>
25+
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
26+
</PropertyGroup>
27+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
28+
<DebugType>pdbonly</DebugType>
29+
<Optimize>true</Optimize>
30+
<OutputPath>bin\Release\</OutputPath>
31+
<DefineConstants>TRACE</DefineConstants>
32+
<ErrorReport>prompt</ErrorReport>
33+
<WarningLevel>4</WarningLevel>
34+
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
35+
</PropertyGroup>
36+
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
37+
<DebugSymbols>true</DebugSymbols>
38+
<OutputPath>bin\x64\Debug\</OutputPath>
39+
<DefineConstants>DEBUG;TRACE</DefineConstants>
40+
<DebugType>full</DebugType>
41+
<PlatformTarget>x64</PlatformTarget>
42+
<CodeAnalysisLogFile>bin\Debug\ABPLCReader.dll.CodeAnalysisLog.xml</CodeAnalysisLogFile>
43+
<CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression>
44+
<CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile>
45+
<ErrorReport>prompt</ErrorReport>
46+
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
47+
<CodeAnalysisRuleSetDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets</CodeAnalysisRuleSetDirectories>
48+
<CodeAnalysisIgnoreBuiltInRuleSets>true</CodeAnalysisIgnoreBuiltInRuleSets>
49+
<CodeAnalysisRuleDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules</CodeAnalysisRuleDirectories>
50+
<CodeAnalysisFailOnMissingRules>false</CodeAnalysisFailOnMissingRules>
51+
</PropertyGroup>
52+
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
53+
<OutputPath>bin\x64\Release\</OutputPath>
54+
<DefineConstants>TRACE</DefineConstants>
55+
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
56+
<Optimize>true</Optimize>
57+
<DebugType>pdbonly</DebugType>
58+
<PlatformTarget>x64</PlatformTarget>
59+
<CodeAnalysisLogFile>bin\Release\ABPLCReader.dll.CodeAnalysisLog.xml</CodeAnalysisLogFile>
60+
<CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression>
61+
<CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile>
62+
<ErrorReport>prompt</ErrorReport>
63+
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
64+
<CodeAnalysisRuleSetDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets</CodeAnalysisRuleSetDirectories>
65+
<CodeAnalysisIgnoreBuiltInRuleSets>true</CodeAnalysisIgnoreBuiltInRuleSets>
66+
<CodeAnalysisRuleDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules</CodeAnalysisRuleDirectories>
67+
<CodeAnalysisFailOnMissingRules>false</CodeAnalysisFailOnMissingRules>
68+
</PropertyGroup>
69+
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|Itanium'">
70+
<DebugSymbols>true</DebugSymbols>
71+
<OutputPath>bin\Itanium\Debug\</OutputPath>
72+
<DefineConstants>DEBUG;TRACE</DefineConstants>
73+
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
74+
<DebugType>full</DebugType>
75+
<PlatformTarget>Itanium</PlatformTarget>
76+
<CodeAnalysisLogFile>bin\Debug\ABPLCReader.dll.CodeAnalysisLog.xml</CodeAnalysisLogFile>
77+
<CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression>
78+
<CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile>
79+
<ErrorReport>prompt</ErrorReport>
80+
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
81+
<CodeAnalysisRuleSetDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets</CodeAnalysisRuleSetDirectories>
82+
<CodeAnalysisIgnoreBuiltInRuleSets>false</CodeAnalysisIgnoreBuiltInRuleSets>
83+
<CodeAnalysisRuleDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules</CodeAnalysisRuleDirectories>
84+
<CodeAnalysisIgnoreBuiltInRules>false</CodeAnalysisIgnoreBuiltInRules>
85+
</PropertyGroup>
86+
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|Itanium'">
87+
<OutputPath>bin\Release\</OutputPath>
88+
<DefineConstants>TRACE</DefineConstants>
89+
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
90+
<Optimize>true</Optimize>
91+
<DebugType>pdbonly</DebugType>
92+
<PlatformTarget>AnyCPU</PlatformTarget>
93+
<CodeAnalysisLogFile>bin\Release\ABPLCReader.dll.CodeAnalysisLog.xml</CodeAnalysisLogFile>
94+
<CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression>
95+
<CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile>
96+
<ErrorReport>prompt</ErrorReport>
97+
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
98+
<CodeAnalysisRuleSetDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets</CodeAnalysisRuleSetDirectories>
99+
<CodeAnalysisIgnoreBuiltInRuleSets>true</CodeAnalysisIgnoreBuiltInRuleSets>
100+
<CodeAnalysisRuleDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules</CodeAnalysisRuleDirectories>
101+
<CodeAnalysisIgnoreBuiltInRules>true</CodeAnalysisIgnoreBuiltInRules>
102+
</PropertyGroup>
103+
<ItemGroup>
104+
<Reference Include="System" />
105+
</ItemGroup>
106+
<ItemGroup>
107+
<Compile Include="ABPLCDriver.cs" />
108+
<Compile Include="Properties\AssemblyInfo.cs" />
109+
<Compile Include="Tuxeip_Class.cs" />
110+
<Compile Include="Tuxeip_Struct.cs" />
111+
</ItemGroup>
112+
<ItemGroup>
113+
<ProjectReference Include="..\DataService\DataService.csproj">
114+
<Project>{8965e389-6466-4b30-bd43-83c909044637}</Project>
115+
<Name>DataService</Name>
116+
</ProjectReference>
117+
</ItemGroup>
118+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
119+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
120+
Other similar extension points exist, see Microsoft.Common.targets.
121+
<Target Name="BeforeBuild">
122+
</Target>
123+
<Target Name="AfterBuild">
124+
</Target>
125+
-->
126+
</Project>
37 KB
Binary file not shown.
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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("ABPLCReader")]
9+
[assembly: AssemblyDescription("")]
10+
[assembly: AssemblyConfiguration("")]
11+
[assembly: AssemblyCompany("")]
12+
[assembly: AssemblyProduct("ABPLCReader")]
13+
[assembly: AssemblyCopyright("Copyright © 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("dced3a2e-feef-4144-bcad-e2ace205c774")]
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")]
Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
using System.Runtime.InteropServices;
2+
3+
namespace Tuxeip
4+
{
5+
public unsafe class Tuxeip_Class
6+
{
7+
public const int MAX_MSG_LEN = 1024; // a verifier
8+
9+
public const int EIP_PORT = 0xAF12;//44818
10+
public const int ENCAP_PROTOCOL = 0x0001;
11+
12+
/* Ethernet IP commands */
13+
public const int EIP_NOP = 0x0000;
14+
public const int EIP_LISTTARGETS = 0x0001; // Reserved for legacy RA
15+
public const int EIP_LISTSERVICES = 0x0004;
16+
public const int EIP_LISTIDENTITY = 0x0063;
17+
public const int EIP_LISTINTERFACES = 0x0064;
18+
public const int EIP_REGISTERSESSION = 0x0065;
19+
public const int EIP_UNREGISTERSESSION = 0x0066;
20+
public const int EIP_SENDRRDATA = 0x006F;
21+
public const int EIP_SENDUNITDATA = 0x0070;
22+
public const int EIP_INDICATESTATUS = 0x0072;
23+
public const int EIP_CANCEL = 0x0073;
24+
25+
// Ethernet IP status code
26+
public const int EIP_SUCCESS = 0x0000;
27+
public const int EIP_INVALID_COMMAND = 0x0001;
28+
public const int EIP_MEMORY = 0x0002;
29+
public const int EIP_INCORRECT_DATA = 0x0003;
30+
public const int EIP_INVALID_SESSION_HANDLE = 0x0064;
31+
public const int EIP_INVALID_LENGTH = 0x0065;
32+
public const int EIP_UNSUPPORTED_PROTOCOL = 0x0069;
33+
34+
// Ethernet IP Services Class
35+
public const int EIP_SC_COMMUNICATION = 0x0100;
36+
public const int EIP_VERSION = 0x01;
37+
public const int CIP_DEFAULT_TIMEOUT = 1000;
38+
39+
private const ushort _OriginatorVendorID = 0xFFFE;
40+
private const uint _OriginatorSerialNumber = 0x12345678;
41+
private const byte _Priority = 0x07;
42+
private const sbyte _TimeOut_Ticks = 0x3f;
43+
private const short _Parameters = 0x43f8, _TO_Parameters = 0x43f8;
44+
private const byte _Transport = 0xa3;
45+
private const sbyte _TimeOutMultiplier = 0x01;
46+
47+
const string PATH = @"tuxeipAB.dll";
48+
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
49+
private static extern Eip_Session* _OpenSession(string serveur, int port, int buffer_len, int timeout);
50+
public static Eip_Session* OpenSession(string serveur)
51+
{
52+
return _OpenSession(serveur, EIP_PORT, MAX_MSG_LEN, CIP_DEFAULT_TIMEOUT);
53+
}
54+
55+
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
56+
public static extern void CloseSession(Eip_Session* session);
57+
58+
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
59+
public static extern int _RegisterSession(Eip_Session* session);
60+
61+
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
62+
public static extern int _UnRegisterSession(Eip_Session* session);
63+
64+
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
65+
private static extern Eip_Connection* _ConnectPLCOverCNET(
66+
Eip_Session* session,
67+
Plc_Type Plc,
68+
byte Priority,
69+
sbyte TimeOut_Ticks,
70+
uint TO_ConnID, //originator's CIP consumed session ID
71+
ushort ConnSerialNumber,// session serial number
72+
ushort OriginatorVendorID,
73+
uint OriginatorSerialNumber,
74+
sbyte TimeOutMultiplier,
75+
uint RPI,// originator to target packet rate in msec
76+
byte Transport,
77+
byte[] path, byte pathsize);
78+
public static Eip_Connection* ConnectPLCOverCNET(Eip_Session* session, Plc_Type Plc, byte[] path)
79+
{
80+
return _ConnectPLCOverCNET(session, Plc, _Priority, _TimeOut_Ticks, 0x12345678, 0x6789,
81+
_OriginatorVendorID, _OriginatorSerialNumber, _TimeOutMultiplier, 5000, _Transport, path, (byte)path.Length);
82+
}
83+
84+
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
85+
public static extern Eip_Connection* _ConnectPLCOverDHP(
86+
Eip_Session* session,
87+
Plc_Type Plc,
88+
byte Priority,
89+
sbyte TimeOut_Ticks,
90+
uint TO_ConnID, //originator's CIP consumed session ID
91+
ushort ConnSerialNumber,// session serial number
92+
ushort OriginatorVendorID,
93+
uint OriginatorSerialNumber,
94+
sbyte TimeOutMultiplier,
95+
uint RPI,// originator to target packet rate in msec
96+
byte Transport,
97+
DHP_Channel channel,
98+
byte[] path, byte pathsize);
99+
public static Eip_Connection* ConnectPLCOverDHP(Eip_Session* session, Plc_Type Plc, DHP_Channel channel, byte[] path)
100+
{
101+
return _ConnectPLCOverDHP(session, Plc, _Priority, _TimeOut_Ticks, 0x12345678, 0x6789,
102+
_OriginatorVendorID, _OriginatorSerialNumber, _TimeOutMultiplier, 5000, _Transport, channel, path, (byte)path.Length);
103+
}
104+
105+
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
106+
public static extern PLC_Read* _ReadPLCData(
107+
Eip_Session* session,
108+
Eip_Connection* connection,
109+
DHP_Header* dhp,
110+
byte* routepath, byte routepathsize,
111+
Plc_Type type, short tns,
112+
string address, short number);
113+
114+
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
115+
public static extern int _WritePLCData(
116+
Eip_Session* session,
117+
Eip_Connection* connection,
118+
DHP_Header* dhp,
119+
byte* routepath, byte routepathsize,
120+
Plc_Type type, short tns,
121+
string address,
122+
PLC_Data_Type datatype,
123+
void* data,
124+
short number);
125+
126+
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
127+
public static extern int _PCCC_GetValueAsBoolean(PLC_Read* reply, int index);
128+
129+
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
130+
public static extern float _PCCC_GetValueAsFloat(PLC_Read* reply, int index);
131+
132+
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
133+
public static extern int _PCCC_GetValueAsInteger(PLC_Read* reply, int index);
134+
135+
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
136+
public static extern int _GetLGXValueAsInteger(LGX_Read* reply, int index);
137+
138+
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
139+
public static extern float _GetLGXValueAsFloat(LGX_Read* reply, int index);
140+
141+
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
142+
public static extern int _Forward_Close(Eip_Connection* connection);
143+
144+
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
145+
public static extern LGX_Read* _ReadLgxData(
146+
Eip_Session* session,
147+
Eip_Connection* connection,
148+
string adress,
149+
ushort number);
150+
151+
[DllImport(PATH, CallingConvention = CallingConvention.Cdecl)]
152+
public static extern int _WriteLgxData(
153+
Eip_Session* session,
154+
Eip_Connection* connection,
155+
string adress,
156+
LGX_Data_Type datatype,
157+
void* data,
158+
//int datasize,
159+
short number);
160+
161+
}
162+
}

0 commit comments

Comments
 (0)