mirror of
https://github.com/S7NetPlus/s7netplus.git
synced 2026-02-17 14:28:25 +08:00
Minor beautification tweaks and additional README info.
This commit is contained in:
61
README.md
61
README.md
@@ -1,15 +1,48 @@
|
||||
# s7netplus
|
||||
#### A .NET Library for Siemens S7 Connectivity
|
||||
|
||||
## Overview
|
||||
|
||||
S7.Net Plus is a continuation of the work done on the [S7.Net](http://s7net.codeplex.com/) project by [Juergen1969](http://www.codeplex.com/site/users/view/juergen1969).
|
||||
I found the library simple and effective, but the project has languished unchanged since late 2009.
|
||||
|
||||
I was doing some automation work already and saw a few places where the code base could be improved. Because Juergen did not respond
|
||||
to my request for committing code, I decided to pick up where he left off here on GitHub.
|
||||
|
||||
## Requirements
|
||||
|
||||
+ Compatible S7 PLC (S7-200, S7-300, S7-400, S7-1200)
|
||||
# s7netplus
|
||||
#### A .NET Library for Siemens S7 Connectivity
|
||||
|
||||
## Overview
|
||||
|
||||
S7.Net Plus is a continuation of the work done on the [S7.Net](http://s7net.codeplex.com/) project by [Juergen1969](http://www.codeplex.com/site/users/view/juergen1969).
|
||||
I found the library simple and effective, but the project has languished unchanged since late 2009.
|
||||
|
||||
I was doing some automation work already and saw a few places where the code base could be improved. Because Juergen did not respond
|
||||
to my request for committing code, I decided to pick up where he left off here on GitHub.
|
||||
|
||||
## Requirements
|
||||
|
||||
+ Compatible S7 PLC (S7-200, S7-300, S7-400, S7-1200)
|
||||
+ .NET Framework 3.5 or higher
|
||||
|
||||
## Basic Usage
|
||||
|
||||
```C#
|
||||
string deviceIpAddress = "172.25.116.87";
|
||||
int rackNumber = 0;
|
||||
int slotNumber = 2;
|
||||
using (var plc = new PLC(CPU_Type.S7300, deviceIpAddress, rackNumber, slotNumber))
|
||||
{
|
||||
//Ensure IP is responding
|
||||
if (plc.IsAvailable)
|
||||
{
|
||||
ErrorCode connectionResult = plc.Open();
|
||||
|
||||
//Verify that connection was successful
|
||||
if (connectionResult.Equals(ErrorCode.NoError))
|
||||
{
|
||||
//Get data
|
||||
object data = plc.Read("MB59");
|
||||
|
||||
Console.WriteLine("SUCCESS: Read result of MB59 is {0}", data);
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("ERROR: Device is available but connection was unsuccessful!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("ERROR: Device is not available!");
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
@@ -1,49 +1,50 @@
|
||||
namespace S7
|
||||
{
|
||||
public enum CpuType
|
||||
{
|
||||
S7200 = 0,
|
||||
S7300 = 10,
|
||||
S7400 = 20
|
||||
}
|
||||
|
||||
public enum ErrorCode
|
||||
{
|
||||
NoError = 0,
|
||||
WrongCPU_Type = 1,
|
||||
ConnectionError = 2,
|
||||
IPAddressNotAvailable,
|
||||
|
||||
WrongVarFormat = 10,
|
||||
WrongNumberReceivedBytes = 11,
|
||||
|
||||
SendData = 20,
|
||||
ReadData = 30,
|
||||
|
||||
WriteData = 50
|
||||
}
|
||||
|
||||
public enum DataType
|
||||
{
|
||||
Input = 129,
|
||||
Output = 130,
|
||||
Marker = 131,
|
||||
DataBlock = 132,
|
||||
Timer = 29,
|
||||
Counter = 28
|
||||
}
|
||||
|
||||
public enum VarType
|
||||
{
|
||||
Bit,
|
||||
Byte,
|
||||
Word,
|
||||
DWord,
|
||||
Int,
|
||||
DInt,
|
||||
Real,
|
||||
String,
|
||||
Timer,
|
||||
Counter
|
||||
}
|
||||
}
|
||||
namespace S7
|
||||
{
|
||||
public enum CpuType
|
||||
{
|
||||
S7200 = 0,
|
||||
S7300 = 10,
|
||||
S7400 = 20,
|
||||
S71200 = 30,
|
||||
}
|
||||
|
||||
public enum ErrorCode
|
||||
{
|
||||
NoError = 0,
|
||||
WrongCPU_Type = 1,
|
||||
ConnectionError = 2,
|
||||
IPAddressNotAvailable,
|
||||
|
||||
WrongVarFormat = 10,
|
||||
WrongNumberReceivedBytes = 11,
|
||||
|
||||
SendData = 20,
|
||||
ReadData = 30,
|
||||
|
||||
WriteData = 50
|
||||
}
|
||||
|
||||
public enum DataType
|
||||
{
|
||||
Input = 129,
|
||||
Output = 130,
|
||||
Marker = 131,
|
||||
DataBlock = 132,
|
||||
Timer = 29,
|
||||
Counter = 28
|
||||
}
|
||||
|
||||
public enum VarType
|
||||
{
|
||||
Bit,
|
||||
Byte,
|
||||
Word,
|
||||
DWord,
|
||||
Int,
|
||||
DInt,
|
||||
Real,
|
||||
String,
|
||||
Timer,
|
||||
Counter
|
||||
}
|
||||
}
|
||||
|
||||
1456
S7.Net/PLC.cs
1456
S7.Net/PLC.cs
File diff suppressed because it is too large
Load Diff
57
S7.sln
57
S7.sln
@@ -1,26 +1,31 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 2012
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "S7.Net", "S7.Net\S7.Net.csproj", "{BFD484F9-3F04-42A2-BF2A-60A189A25DCF}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "S7.Net.Test", "S7.Net.Test\S7.Net.Test.csproj", "{D34F7AF6-19DA-4AE6-9BB0-6666970F6838}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{BFD484F9-3F04-42A2-BF2A-60A189A25DCF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{BFD484F9-3F04-42A2-BF2A-60A189A25DCF}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{BFD484F9-3F04-42A2-BF2A-60A189A25DCF}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{BFD484F9-3F04-42A2-BF2A-60A189A25DCF}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{D34F7AF6-19DA-4AE6-9BB0-6666970F6838}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{D34F7AF6-19DA-4AE6-9BB0-6666970F6838}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{D34F7AF6-19DA-4AE6-9BB0-6666970F6838}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{D34F7AF6-19DA-4AE6-9BB0-6666970F6838}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 2012
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "S7.Net", "S7.Net\S7.Net.csproj", "{BFD484F9-3F04-42A2-BF2A-60A189A25DCF}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "S7.Net.Test", "S7.Net.Test\S7.Net.Test.csproj", "{D34F7AF6-19DA-4AE6-9BB0-6666970F6838}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{7A8252C3-E6AE-435A-809D-4413C06E0711}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
README.md = README.md
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{BFD484F9-3F04-42A2-BF2A-60A189A25DCF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{BFD484F9-3F04-42A2-BF2A-60A189A25DCF}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{BFD484F9-3F04-42A2-BF2A-60A189A25DCF}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{BFD484F9-3F04-42A2-BF2A-60A189A25DCF}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{D34F7AF6-19DA-4AE6-9BB0-6666970F6838}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{D34F7AF6-19DA-4AE6-9BB0-6666970F6838}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{D34F7AF6-19DA-4AE6-9BB0-6666970F6838}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{D34F7AF6-19DA-4AE6-9BB0-6666970F6838}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
||||
Reference in New Issue
Block a user