Skip to content

Commit 3ff7fef

Browse files
AdminAdmin
authored andcommitted
Add project files.
1 parent 32bc9ba commit 3ff7fef

File tree

75 files changed

+16226
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+16226
-0
lines changed

ConsoleApplication1/App.config

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<configuration>
3+
<startup>
4+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
5+
</startup>
6+
</configuration>
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{AA208FA1-1496-4BBC-97D1-9F628EB4197A}</ProjectGuid>
8+
<OutputType>Exe</OutputType>
9+
<AppDesignerFolder>Properties</AppDesignerFolder>
10+
<RootNamespace>ConsoleApplication1</RootNamespace>
11+
<AssemblyName>ConsoleApplication1</AssemblyName>
12+
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
13+
<FileAlignment>512</FileAlignment>
14+
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
15+
</PropertyGroup>
16+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
17+
<PlatformTarget>AnyCPU</PlatformTarget>
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+
</PropertyGroup>
26+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
27+
<PlatformTarget>AnyCPU</PlatformTarget>
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+
</PropertyGroup>
35+
<ItemGroup>
36+
<Reference Include="System" />
37+
<Reference Include="System.Core" />
38+
<Reference Include="System.Xml.Linq" />
39+
<Reference Include="System.Data.DataSetExtensions" />
40+
<Reference Include="Microsoft.CSharp" />
41+
<Reference Include="System.Data" />
42+
<Reference Include="System.Net.Http" />
43+
<Reference Include="System.Xml" />
44+
</ItemGroup>
45+
<ItemGroup>
46+
<Compile Include="Program.cs" />
47+
<Compile Include="Properties\AssemblyInfo.cs" />
48+
</ItemGroup>
49+
<ItemGroup>
50+
<None Include="App.config" />
51+
</ItemGroup>
52+
<ItemGroup>
53+
<ProjectReference Include="..\EasyModbus\EasyModbus.csproj">
54+
<Project>{7657fc4a-aedf-4f17-b3e9-0d0dfb1ce23b}</Project>
55+
<Name>EasyModbus</Name>
56+
</ProjectReference>
57+
</ItemGroup>
58+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
59+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
60+
Other similar extension points exist, see Microsoft.Common.targets.
61+
<Target Name="BeforeBuild">
62+
</Target>
63+
<Target Name="AfterBuild">
64+
</Target>
65+
-->
66+
</Project>

ConsoleApplication1/Program.cs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace ConsoleApplication1
8+
{
9+
class Program
10+
{
11+
static void Main(string[] args)
12+
{
13+
EasyModbus.ModbusClient modbusClient = new EasyModbus.ModbusClient("COM3");
14+
modbusClient.Connect();
15+
Console.WriteLine("Execute FC5");
16+
modbusClient.WriteSingleCoil(0, true);
17+
Console.WriteLine("Execute FC6");
18+
modbusClient.WriteSingleRegister(0, 1234);
19+
Console.WriteLine("Execute FC15");
20+
modbusClient.WriteMultipleCoils(0, new bool[] { true, false, true, false, true, false, true });
21+
Console.WriteLine("Execute FC16");
22+
modbusClient.WriteMultipleRegisters(5, new int[] { 1, 2, 3, 4, 5, 6, 6 });
23+
Console.WriteLine("Execute FC3");
24+
Console.WriteLine("Value of Holding Register 1000: " + modbusClient.ReadHoldingRegisters(1000, 1)[0]);
25+
Console.ReadKey();
26+
}
27+
}
28+
}
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("ConsoleApplication1")]
9+
[assembly: AssemblyDescription("")]
10+
[assembly: AssemblyConfiguration("")]
11+
[assembly: AssemblyCompany("")]
12+
[assembly: AssemblyProduct("ConsoleApplication1")]
13+
[assembly: AssemblyCopyright("Copyright © 2016")]
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("aa208fa1-1496-4bbc-97d1-9f628eb4197a")]
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")]

EasyModbus.sln

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio 14
4+
VisualStudioVersion = 14.0.25420.1
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EasyModbus", "EasyModbus\EasyModbus.csproj", "{7657FC4A-AEDF-4F17-B3E9-0D0DFB1CE23B}"
7+
EndProject
8+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EasyModbusServerSimulator", "EasyModbusServerSimulator\EasyModbusServerSimulator.csproj", "{871BD4C1-69F0-45B9-8807-1620E6A896A9}"
9+
EndProject
10+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EasyModbusClientExample", "EasyModbusClientExample\EasyModbusClientExample.csproj", "{9412077F-7DFF-45D0-AFF9-7D5303118EA7}"
11+
EndProject
12+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EasyModbusAdvancedClient", "EasyModbusAdvancedClient\EasyModbusAdvancedClient.csproj", "{3398AAF9-F5A5-4F3B-9A02-14A6B2359DC4}"
13+
EndProject
14+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleApplication1", "ConsoleApplication1\ConsoleApplication1.csproj", "{AA208FA1-1496-4BBC-97D1-9F628EB4197A}"
15+
EndProject
16+
Global
17+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
18+
Debug|Any CPU = Debug|Any CPU
19+
Release|Any CPU = Release|Any CPU
20+
EndGlobalSection
21+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
22+
{7657FC4A-AEDF-4F17-B3E9-0D0DFB1CE23B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
23+
{7657FC4A-AEDF-4F17-B3E9-0D0DFB1CE23B}.Debug|Any CPU.Build.0 = Debug|Any CPU
24+
{7657FC4A-AEDF-4F17-B3E9-0D0DFB1CE23B}.Release|Any CPU.ActiveCfg = Release|Any CPU
25+
{7657FC4A-AEDF-4F17-B3E9-0D0DFB1CE23B}.Release|Any CPU.Build.0 = Release|Any CPU
26+
{871BD4C1-69F0-45B9-8807-1620E6A896A9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
27+
{871BD4C1-69F0-45B9-8807-1620E6A896A9}.Debug|Any CPU.Build.0 = Debug|Any CPU
28+
{871BD4C1-69F0-45B9-8807-1620E6A896A9}.Release|Any CPU.ActiveCfg = Release|Any CPU
29+
{871BD4C1-69F0-45B9-8807-1620E6A896A9}.Release|Any CPU.Build.0 = Release|Any CPU
30+
{9412077F-7DFF-45D0-AFF9-7D5303118EA7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
31+
{9412077F-7DFF-45D0-AFF9-7D5303118EA7}.Debug|Any CPU.Build.0 = Debug|Any CPU
32+
{9412077F-7DFF-45D0-AFF9-7D5303118EA7}.Release|Any CPU.ActiveCfg = Release|Any CPU
33+
{9412077F-7DFF-45D0-AFF9-7D5303118EA7}.Release|Any CPU.Build.0 = Release|Any CPU
34+
{3398AAF9-F5A5-4F3B-9A02-14A6B2359DC4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
35+
{3398AAF9-F5A5-4F3B-9A02-14A6B2359DC4}.Debug|Any CPU.Build.0 = Debug|Any CPU
36+
{3398AAF9-F5A5-4F3B-9A02-14A6B2359DC4}.Release|Any CPU.ActiveCfg = Release|Any CPU
37+
{3398AAF9-F5A5-4F3B-9A02-14A6B2359DC4}.Release|Any CPU.Build.0 = Release|Any CPU
38+
{AA208FA1-1496-4BBC-97D1-9F628EB4197A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
39+
{AA208FA1-1496-4BBC-97D1-9F628EB4197A}.Debug|Any CPU.Build.0 = Debug|Any CPU
40+
{AA208FA1-1496-4BBC-97D1-9F628EB4197A}.Release|Any CPU.ActiveCfg = Release|Any CPU
41+
{AA208FA1-1496-4BBC-97D1-9F628EB4197A}.Release|Any CPU.Build.0 = Release|Any CPU
42+
EndGlobalSection
43+
GlobalSection(SolutionProperties) = preSolution
44+
HideSolutionNode = FALSE
45+
EndGlobalSection
46+
GlobalSection(ExtensibilityGlobals) = postSolution
47+
VisualSVNWorkingCopyRoot = .
48+
EndGlobalSection
49+
EndGlobal

EasyModbus/AdvancedModbusClient.cs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
6+
namespace EasyModbus
7+
{
8+
public partial class ModbusClient
9+
{
10+
public enum DataType { Short = 0, UShort = 1, Long = 2, ULong = 3, Float = 4, Double = 5 };
11+
public object[] ReadHoldingRegisters(int startingAddress, int quantity, DataType dataType, RegisterOrder registerOrder)
12+
{
13+
int quantityToRead = quantity;
14+
if (dataType == DataType.Long | dataType == DataType.ULong | dataType == DataType.Float)
15+
quantityToRead = quantity * 2;
16+
if (dataType == DataType.Float)
17+
quantityToRead = quantity * 4;
18+
int[] response = this.ReadHoldingRegisters(startingAddress, quantityToRead);
19+
switch (dataType)
20+
{
21+
case DataType.Short: return response.Cast<object>().ToArray();
22+
break;
23+
default: return response.Cast<object>().ToArray();
24+
break;
25+
26+
}
27+
28+
29+
}
30+
}
31+
}

EasyModbus/EasyModbus.csproj

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build">
3+
<PropertyGroup>
4+
<ProjectGuid>{7657FC4A-AEDF-4F17-B3E9-0D0DFB1CE23B}</ProjectGuid>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<OutputType>Library</OutputType>
8+
<RootNamespace>EasyModbus</RootNamespace>
9+
<AssemblyName>EasyModbus</AssemblyName>
10+
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
11+
<TargetFrameworkProfile>
12+
</TargetFrameworkProfile>
13+
<AppDesignerFolder>Properties</AppDesignerFolder>
14+
<FileUpgradeFlags>
15+
</FileUpgradeFlags>
16+
<UpgradeBackupLocation>
17+
</UpgradeBackupLocation>
18+
<OldToolsVersion>3.5</OldToolsVersion>
19+
</PropertyGroup>
20+
<PropertyGroup Condition=" '$(Platform)' == 'AnyCPU' ">
21+
<PlatformTarget>AnyCPU</PlatformTarget>
22+
</PropertyGroup>
23+
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
24+
<OutputPath>bin\Debug\</OutputPath>
25+
<DebugSymbols>True</DebugSymbols>
26+
<DebugType>Full</DebugType>
27+
<Optimize>False</Optimize>
28+
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
29+
<DefineConstants>DEBUG;TRACE</DefineConstants>
30+
</PropertyGroup>
31+
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
32+
<OutputPath>bin\Release\</OutputPath>
33+
<DebugSymbols>False</DebugSymbols>
34+
<DebugType>None</DebugType>
35+
<Optimize>True</Optimize>
36+
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
37+
<DefineConstants>TRACE</DefineConstants>
38+
</PropertyGroup>
39+
<ItemGroup>
40+
<Reference Include="System" />
41+
<Reference Include="System.Core">
42+
<RequiredTargetFramework>3.5</RequiredTargetFramework>
43+
</Reference>
44+
<Reference Include="System.Xml" />
45+
<Reference Include="System.Xml.Linq">
46+
<RequiredTargetFramework>3.5</RequiredTargetFramework>
47+
</Reference>
48+
</ItemGroup>
49+
<ItemGroup>
50+
<Compile Include="AdvancedModbusClient.cs" />
51+
<Compile Include="Exceptions\Exceptions.cs" />
52+
<Compile Include="ModbusClient.cs" />
53+
<Compile Include="ModbusServer.cs" />
54+
<Compile Include="Properties\AssemblyInfo.cs" />
55+
</ItemGroup>
56+
<ItemGroup />
57+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
58+
</Project>

0 commit comments

Comments
 (0)