2017-03-11 update 1 Add .Net Standard Library.
This commit is contained in:
@@ -1,78 +1,25 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
||||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
<TargetFramework>net45</TargetFramework>
|
||||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
|
||||||
<ProjectGuid>{FDCA72BA-6D06-4DE0-B873-C11C4AC853AD}</ProjectGuid>
|
|
||||||
<OutputType>Library</OutputType>
|
|
||||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
|
||||||
<RootNamespace>Modbus.Net.Modbus</RootNamespace>
|
|
||||||
<AssemblyName>Modbus.Net.Modbus</AssemblyName>
|
<AssemblyName>Modbus.Net.Modbus</AssemblyName>
|
||||||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
<RootNamespace>Modbus.Net.Modbus</RootNamespace>
|
||||||
<FileAlignment>512</FileAlignment>
|
<PackageId>Modbus.Net.Modbus</PackageId>
|
||||||
<TargetFrameworkProfile />
|
<Version>1.3.0</Version>
|
||||||
</PropertyGroup>
|
<Authors>Chris L.(Luo Sheng)</Authors>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
<Company>Hangzhou Delian IoT Science Technology Co.,Ltd.</Company>
|
||||||
<DebugSymbols>true</DebugSymbols>
|
<Product>Modbus.Net.Modbus</Product>
|
||||||
<DebugType>full</DebugType>
|
<Description>Modbus.Net Modbus Implementation</Description>
|
||||||
<Optimize>false</Optimize>
|
<Copyright>Copyright 2017 Hangzhou Delian IoT Science Technology Co.,Ltd.</Copyright>
|
||||||
<OutputPath>bin\Debug\</OutputPath>
|
<PackageLicenseUrl>https://github.com/parallelbgls/Modbus.Net/blob/master/LICENSE.md</PackageLicenseUrl>
|
||||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
<PackageProjectUrl>https://github.com/parallelbgls/Modbus.Net/tree/master/Modbus.Net/Modbus.Net.Modbus</PackageProjectUrl>
|
||||||
<ErrorReport>prompt</ErrorReport>
|
<RepositoryUrl>https://github.com/parallelbgls/Modbus.Net</RepositoryUrl>
|
||||||
<WarningLevel>4</WarningLevel>
|
<RepositoryType>git</RepositoryType>
|
||||||
</PropertyGroup>
|
<PackageTags>hardware communicate protocal modbus Delian</PackageTags>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
|
||||||
<DebugType>pdbonly</DebugType>
|
|
||||||
<Optimize>true</Optimize>
|
|
||||||
<OutputPath>bin\Release\</OutputPath>
|
|
||||||
<DefineConstants>TRACE</DefineConstants>
|
|
||||||
<ErrorReport>prompt</ErrorReport>
|
|
||||||
<WarningLevel>4</WarningLevel>
|
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="System" />
|
<ProjectReference Include="..\ModBus.Net\Modbus.Net.csproj" />
|
||||||
<Reference Include="System.Core" />
|
|
||||||
<Reference Include="System.Xml.Linq" />
|
|
||||||
<Reference Include="System.Data.DataSetExtensions" />
|
|
||||||
<Reference Include="Microsoft.CSharp" />
|
|
||||||
<Reference Include="System.Data" />
|
|
||||||
<Reference Include="System.Net.Http" />
|
|
||||||
<Reference Include="System.Xml" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
|
||||||
<Compile Include="AddressFormaterModbus.cs" />
|
|
||||||
<Compile Include="AddressTranslatorModbus.cs" />
|
|
||||||
<Compile Include="ModbusAsciiProtocal.cs" />
|
|
||||||
<Compile Include="ModbusAsciiProtocalLinker.cs" />
|
|
||||||
<Compile Include="ModbusMachine.cs" />
|
|
||||||
<Compile Include="ModbusProtocal.cs" />
|
|
||||||
<Compile Include="ModbusProtocalLinkerBytesExtend.cs" />
|
|
||||||
<Compile Include="ModbusRtuProtocal.cs" />
|
|
||||||
<Compile Include="ModbusRtuProtocalLinker.cs" />
|
|
||||||
<Compile Include="ModbusTcpProtocal.cs" />
|
|
||||||
<Compile Include="ModbusTcpProtocalLinker.cs" />
|
|
||||||
<Compile Include="ModbusUtility.cs" />
|
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<ProjectReference Include="..\ModBus.Net\Modbus.Net.csproj">
|
|
||||||
<Project>{124ebef2-8960-4447-84cf-1d683b1ef7cc}</Project>
|
|
||||||
<Name>Modbus.Net</Name>
|
|
||||||
</ProjectReference>
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<None Include="Modbus.Net.Modbus.nuspec">
|
|
||||||
<SubType>Designer</SubType>
|
|
||||||
</None>
|
|
||||||
<None Include="README.md" />
|
|
||||||
</ItemGroup>
|
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
|
||||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
|
||||||
Other similar extension points exist, see Microsoft.Common.targets.
|
|
||||||
<Target Name="BeforeBuild">
|
|
||||||
</Target>
|
|
||||||
<Target Name="AfterBuild">
|
|
||||||
</Target>
|
|
||||||
-->
|
|
||||||
</Project>
|
</Project>
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
|
|
||||||
<metadata>
|
|
||||||
<id>Modbus.Net.Modbus</id>
|
|
||||||
<version>1.2.4</version>
|
|
||||||
<title>Modbus.Net.Modbus</title>
|
|
||||||
<authors>Chris L.(Luo Sheng)</authors>
|
|
||||||
<owners>Hangzhou Delian IoT Science Technology Co.,Ltd.</owners>
|
|
||||||
<licenseUrl>https://github.com/parallelbgls/Modbus.Net/blob/master/LICENSE.md</licenseUrl>
|
|
||||||
<projectUrl>https://github.com/parallelbgls/Modbus.Net/tree/master/Modbus.Net/Modbus.Net.Modbus</projectUrl>
|
|
||||||
<requireLicenseAcceptance>false</requireLicenseAcceptance>
|
|
||||||
<description>Modbus.Net Modbus Implementation</description>
|
|
||||||
<copyright>Copyright 2017 Hangzhou Delian IoT Science Technology Co.,Ltd.</copyright>
|
|
||||||
<tags>hardware communicate protocal modbus Delian</tags>
|
|
||||||
<dependencies>
|
|
||||||
<dependency id="Modbus.Net" version="1.2.4" />
|
|
||||||
</dependencies>
|
|
||||||
</metadata>
|
|
||||||
<files>
|
|
||||||
<file src="bin\Release\Modbus.Net.Modbus.dll" target="lib\net45\Modbus.Net.Modbus.dll" />
|
|
||||||
</files>
|
|
||||||
</package>
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
using System.Reflection;
|
|
||||||
using System.Runtime.CompilerServices;
|
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
|
|
||||||
// 有关程序集的一般信息由以下
|
|
||||||
// 控制。更改这些特性值可修改
|
|
||||||
// 与程序集关联的信息。
|
|
||||||
[assembly: AssemblyTitle("Modbus.Net.Modbus")]
|
|
||||||
[assembly: AssemblyDescription("")]
|
|
||||||
[assembly: AssemblyConfiguration("")]
|
|
||||||
[assembly: AssemblyCompany("杭州德联物联网科技有限公司")]
|
|
||||||
[assembly: AssemblyProduct("Modbus.Net.Modbus")]
|
|
||||||
[assembly: AssemblyCopyright("Copyright © Chris L. 2017 HangZhou Delian IoT Science Technology Co.,Ltd.")]
|
|
||||||
[assembly: AssemblyTrademark("")]
|
|
||||||
[assembly: AssemblyCulture("")]
|
|
||||||
|
|
||||||
//将 ComVisible 设置为 false 将使此程序集中的类型
|
|
||||||
//对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型,
|
|
||||||
//请将此类型的 ComVisible 特性设置为 true。
|
|
||||||
[assembly: ComVisible(false)]
|
|
||||||
|
|
||||||
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
|
|
||||||
[assembly: Guid("fdca72ba-6d06-4de0-b873-c11c4ac853ad")]
|
|
||||||
|
|
||||||
// 程序集的版本信息由下列四个值组成:
|
|
||||||
//
|
|
||||||
// 主版本
|
|
||||||
// 次版本
|
|
||||||
// 生成号
|
|
||||||
// 修订号
|
|
||||||
//
|
|
||||||
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
|
|
||||||
// 方法是按如下所示使用“*”: :
|
|
||||||
// [assembly: AssemblyVersion("1.0.*")]
|
|
||||||
[assembly: AssemblyVersion("1.2.4")]
|
|
||||||
[assembly: AssemblyFileVersion("1.2.4")]
|
|
||||||
@@ -1,104 +1,28 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
||||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
<TargetFramework>net45</TargetFramework>
|
||||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
|
||||||
<ProjectGuid>{97F5A329-357A-4813-BAAE-58E71CC6FA87}</ProjectGuid>
|
|
||||||
<OutputType>Library</OutputType>
|
|
||||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
|
||||||
<RootNamespace>Modbus.Net.OPC</RootNamespace>
|
|
||||||
<AssemblyName>Modbus.Net.OPC</AssemblyName>
|
<AssemblyName>Modbus.Net.OPC</AssemblyName>
|
||||||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
<RootNamespace>Modbus.Net.OPC</RootNamespace>
|
||||||
<FileAlignment>512</FileAlignment>
|
<PackageId>Modbus.Net.OPC</PackageId>
|
||||||
<TargetFrameworkProfile />
|
<Version>1.3.0</Version>
|
||||||
</PropertyGroup>
|
<Authors>Chris L.(Luo Sheng)</Authors>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
<Company>Hangzhou Delian IoT Science Technology Co.,Ltd.</Company>
|
||||||
<DebugSymbols>true</DebugSymbols>
|
<Description>Modbus.Net OPC Implementation</Description>
|
||||||
<DebugType>full</DebugType>
|
<Copyright>Copyright 2017 Hangzhou Delian IoT Science Technology Co.,Ltd.</Copyright>
|
||||||
<Optimize>false</Optimize>
|
<PackageProjectUrl>https://github.com/parallelbgls/Modbus.Net/tree/master/Modbus.Net/Modbus.Net.OPC</PackageProjectUrl>
|
||||||
<OutputPath>bin\Debug\</OutputPath>
|
<PackageLicenseUrl>https://github.com/parallelbgls/Modbus.Net/blob/master/LICENSE.md</PackageLicenseUrl>
|
||||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
<RepositoryUrl>https://github.com/parallelbgls/Modbus.Net</RepositoryUrl>
|
||||||
<ErrorReport>prompt</ErrorReport>
|
<RepositoryType>git</RepositoryType>
|
||||||
<WarningLevel>4</WarningLevel>
|
<PackageTags>hardware communicate protocal OPC DA Delian</PackageTags>
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
|
||||||
<DebugType>pdbonly</DebugType>
|
|
||||||
<Optimize>true</Optimize>
|
|
||||||
<OutputPath>bin\Release\</OutputPath>
|
|
||||||
<DefineConstants>TRACE</DefineConstants>
|
|
||||||
<ErrorReport>prompt</ErrorReport>
|
|
||||||
<WarningLevel>4</WarningLevel>
|
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="h-opc, Version=0.8.1.0, Culture=neutral, processorArchitecture=MSIL">
|
<PackageReference Include="H.Opc" Version="0.8.1" />
|
||||||
<HintPath>..\packages\H.Opc.0.8.1\lib\h-opc.dll</HintPath>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="Opc.Ua.Client, Version=1.2.334.4, Culture=neutral, processorArchitecture=MSIL">
|
|
||||||
<HintPath>..\packages\H.Opc.0.8.1\lib\Opc.Ua.Client.dll</HintPath>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="Opc.Ua.Configuration, Version=1.2.334.4, Culture=neutral, processorArchitecture=MSIL">
|
|
||||||
<HintPath>..\packages\H.Opc.0.8.1\lib\Opc.Ua.Configuration.dll</HintPath>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="Opc.Ua.Core, Version=1.2.334.4, Culture=neutral, processorArchitecture=MSIL">
|
|
||||||
<HintPath>..\packages\H.Opc.0.8.1\lib\Opc.Ua.Core.dll</HintPath>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="OpcComRcw, Version=2.0.105.1, Culture=neutral, PublicKeyToken=9a40e993cbface53, processorArchitecture=MSIL">
|
|
||||||
<HintPath>..\packages\H.Opc.0.8.1\lib\OpcComRcw.dll</HintPath>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="OpcNetApi, Version=2.1.105.1, Culture=neutral, PublicKeyToken=9a40e993cbface53, processorArchitecture=MSIL">
|
|
||||||
<HintPath>..\packages\H.Opc.0.8.1\lib\OpcNetApi.dll</HintPath>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="OpcNetApi.Com, Version=2.1.105.1, Culture=neutral, PublicKeyToken=9a40e993cbface53, processorArchitecture=MSIL">
|
|
||||||
<HintPath>..\packages\H.Opc.0.8.1\lib\OpcNetApi.Com.dll</HintPath>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="System" />
|
|
||||||
<Reference Include="System.Core" />
|
|
||||||
<Reference Include="System.Xml.Linq" />
|
|
||||||
<Reference Include="System.Data.DataSetExtensions" />
|
|
||||||
<Reference Include="Microsoft.CSharp" />
|
|
||||||
<Reference Include="System.Data" />
|
|
||||||
<Reference Include="System.Net.Http" />
|
|
||||||
<Reference Include="System.Xml" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="AddressFormaterOpc.cs" />
|
<ProjectReference Include="..\ModBus.Net\Modbus.Net.csproj" />
|
||||||
<Compile Include="AddressTranslatorOpc.cs" />
|
|
||||||
<Compile Include="ClientExtend.cs" />
|
|
||||||
<Compile Include="FBox\FBoxOpcDaManchine.cs" />
|
|
||||||
<Compile Include="OpcConnector.cs" />
|
|
||||||
<Compile Include="OpcDaConnector.cs" />
|
|
||||||
<Compile Include="OpcDaMachine.cs" />
|
|
||||||
<Compile Include="OpcDaProtocal.cs" />
|
|
||||||
<Compile Include="OpcDaProtocalLinker.cs" />
|
|
||||||
<Compile Include="OpcDaUtility.cs" />
|
|
||||||
<Compile Include="OpcMachine.cs" />
|
|
||||||
<Compile Include="OpcProtocal.cs" />
|
|
||||||
<Compile Include="OpcUaConnector.cs" />
|
|
||||||
<Compile Include="OpcUaMachine.cs" />
|
|
||||||
<Compile Include="OpcUaProtocal.cs" />
|
|
||||||
<Compile Include="OpcUaProtocalLinker.cs" />
|
|
||||||
<Compile Include="OpcUaUtility.cs" />
|
|
||||||
<Compile Include="OpcUtility.cs" />
|
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
|
||||||
<ProjectReference Include="..\ModBus.Net\Modbus.Net.csproj">
|
|
||||||
<Project>{124ebef2-8960-4447-84cf-1d683b1ef7cc}</Project>
|
|
||||||
<Name>Modbus.Net</Name>
|
|
||||||
</ProjectReference>
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<None Include="Modbus.Net.OPC.nuspec" />
|
|
||||||
<None Include="packages.config" />
|
|
||||||
<None Include="README.md" />
|
|
||||||
</ItemGroup>
|
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
|
||||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
|
||||||
Other similar extension points exist, see Microsoft.Common.targets.
|
|
||||||
<Target Name="BeforeBuild">
|
|
||||||
</Target>
|
|
||||||
<Target Name="AfterBuild">
|
|
||||||
</Target>
|
|
||||||
-->
|
|
||||||
</Project>
|
</Project>
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
|
|
||||||
<metadata>
|
|
||||||
<id>Modbus.Net.OPC</id>
|
|
||||||
<version>1.2.4</version>
|
|
||||||
<title>Modbus.Net.OPC</title>
|
|
||||||
<authors>Chris L.(Luo Sheng)</authors>
|
|
||||||
<owners>Hangzhou Delian IoT Science Technology Co.,Ltd.</owners>
|
|
||||||
<licenseUrl>https://github.com/parallelbgls/Modbus.Net/blob/master/LICENSE.md</licenseUrl>
|
|
||||||
<projectUrl>https://github.com/parallelbgls/Modbus.Net/tree/master/Modbus.Net/Modbus.Net.OPC</projectUrl>
|
|
||||||
<requireLicenseAcceptance>false</requireLicenseAcceptance>
|
|
||||||
<description>Modbus.Net OPC Implementation</description>
|
|
||||||
<copyright>Copyright 2017 Hangzhou Delian IoT Science Technology Co.,Ltd.</copyright>
|
|
||||||
<tags>hardware communicate protocal OPC DA Delian</tags>
|
|
||||||
<dependencies>
|
|
||||||
<dependency id="Modbus.Net" version="1.2.4" />
|
|
||||||
<dependency id="H.Opc" version="0.8.1" />
|
|
||||||
</dependencies>
|
|
||||||
</metadata>
|
|
||||||
<files>
|
|
||||||
<file src="bin\Release\Modbus.Net.OPC.dll" target="lib\net45\Modbus.Net.OPC.dll" />
|
|
||||||
</files>
|
|
||||||
</package>
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
using System.Reflection;
|
|
||||||
using System.Runtime.CompilerServices;
|
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
|
|
||||||
// 有关程序集的一般信息由以下
|
|
||||||
// 控制。更改这些特性值可修改
|
|
||||||
// 与程序集关联的信息。
|
|
||||||
[assembly: AssemblyTitle("Modbus.Net.OPC")]
|
|
||||||
[assembly: AssemblyDescription("")]
|
|
||||||
[assembly: AssemblyConfiguration("")]
|
|
||||||
[assembly: AssemblyCompany("杭州德联物联网科技有限公司")]
|
|
||||||
[assembly: AssemblyProduct("Modbus.Net.OPC")]
|
|
||||||
[assembly: AssemblyCopyright("Copyright © Chris L. 2017 HangZhou Delian IoT Science Technology Co.,Ltd.")]
|
|
||||||
[assembly: AssemblyTrademark("")]
|
|
||||||
[assembly: AssemblyCulture("")]
|
|
||||||
|
|
||||||
//将 ComVisible 设置为 false 将使此程序集中的类型
|
|
||||||
//对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型,
|
|
||||||
//请将此类型的 ComVisible 特性设置为 true。
|
|
||||||
[assembly: ComVisible(false)]
|
|
||||||
|
|
||||||
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
|
|
||||||
[assembly: Guid("97f5a329-357a-4813-baae-58e71cc6fa87")]
|
|
||||||
|
|
||||||
// 程序集的版本信息由下列四个值组成:
|
|
||||||
//
|
|
||||||
// 主版本
|
|
||||||
// 次版本
|
|
||||||
// 生成号
|
|
||||||
// 修订号
|
|
||||||
//
|
|
||||||
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
|
|
||||||
// 方法是按如下所示使用“*”: :
|
|
||||||
// [assembly: AssemblyVersion("1.0.*")]
|
|
||||||
[assembly: AssemblyVersion("1.2.4")]
|
|
||||||
[assembly: AssemblyFileVersion("1.2.4")]
|
|
||||||
@@ -1,77 +1,24 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
||||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
<TargetFramework>net45</TargetFramework>
|
||||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
|
||||||
<ProjectGuid>{6258F9D9-0DF4-497F-9F3B-6D2F6F752A21}</ProjectGuid>
|
|
||||||
<OutputType>Library</OutputType>
|
|
||||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
|
||||||
<RootNamespace>Modbus.Net.Siemens</RootNamespace>
|
|
||||||
<AssemblyName>Modbus.Net.Siemens</AssemblyName>
|
<AssemblyName>Modbus.Net.Siemens</AssemblyName>
|
||||||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
<RootNamespace>Modbus.Net.Siemens</RootNamespace>
|
||||||
<FileAlignment>512</FileAlignment>
|
<PackageId>Modbus.Net.Siemens</PackageId>
|
||||||
<TargetFrameworkProfile />
|
<Version>1.3.0</Version>
|
||||||
</PropertyGroup>
|
<Authors>Chris L.(Luo Sheng)</Authors>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
<Company>Hangzhou Delian IoT Science Technology Co.,Ltd.</Company>
|
||||||
<DebugSymbols>true</DebugSymbols>
|
<Description>Modbus.Net Siemens Profinet Implementation</Description>
|
||||||
<DebugType>full</DebugType>
|
<Copyright>Copyright 2017 Hangzhou Delian IoT Science Technology Co.,Ltd.</Copyright>
|
||||||
<Optimize>false</Optimize>
|
<PackageLicenseUrl>https://github.com/parallelbgls/Modbus.Net/blob/master/LICENSE.md</PackageLicenseUrl>
|
||||||
<OutputPath>bin\Debug\</OutputPath>
|
<PackageProjectUrl>https://github.com/parallelbgls/Modbus.Net/tree/master/Modbus.Net/Modbus.Net.Siemens</PackageProjectUrl>
|
||||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
<RepositoryUrl>https://github.com/parallelbgls/Modbus.Net</RepositoryUrl>
|
||||||
<ErrorReport>prompt</ErrorReport>
|
<RepositoryType>git</RepositoryType>
|
||||||
<WarningLevel>4</WarningLevel>
|
<PackageTags>hardware communicate protocal Siemens profinet Delian</PackageTags>
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
|
||||||
<DebugType>pdbonly</DebugType>
|
|
||||||
<Optimize>true</Optimize>
|
|
||||||
<OutputPath>bin\Release\</OutputPath>
|
|
||||||
<DefineConstants>TRACE</DefineConstants>
|
|
||||||
<ErrorReport>prompt</ErrorReport>
|
|
||||||
<WarningLevel>4</WarningLevel>
|
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="System" />
|
<ProjectReference Include="..\ModBus.Net\Modbus.Net.csproj" />
|
||||||
<Reference Include="System.Core" />
|
|
||||||
<Reference Include="System.Xml.Linq" />
|
|
||||||
<Reference Include="System.Data.DataSetExtensions" />
|
|
||||||
<Reference Include="Microsoft.CSharp" />
|
|
||||||
<Reference Include="System.Data" />
|
|
||||||
<Reference Include="System.Net.Http" />
|
|
||||||
<Reference Include="System.Xml" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
|
||||||
<Compile Include="AddressFormaterSiemens.cs" />
|
|
||||||
<Compile Include="AddressTranslatorSiemens.cs" />
|
|
||||||
<Compile Include="SiemensMachine.cs" />
|
|
||||||
<Compile Include="SiemensPpiProtocal.cs" />
|
|
||||||
<Compile Include="SiemensPpiProtocalLinker.cs" />
|
|
||||||
<Compile Include="SiemensProtocal.cs" />
|
|
||||||
<Compile Include="SiemensProtocalLinkerBytesExtend.cs" />
|
|
||||||
<Compile Include="SiemensStructDefinition.cs" />
|
|
||||||
<Compile Include="SiemensTcpProtocal.cs" />
|
|
||||||
<Compile Include="SiemensTcpProtocalLinker.cs" />
|
|
||||||
<Compile Include="SiemensUtility.cs" />
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<ProjectReference Include="..\ModBus.Net\Modbus.Net.csproj">
|
|
||||||
<Project>{124ebef2-8960-4447-84cf-1d683b1ef7cc}</Project>
|
|
||||||
<Name>Modbus.Net</Name>
|
|
||||||
</ProjectReference>
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<None Include="Modbus.Net.Siemens.nuspec">
|
|
||||||
<SubType>Designer</SubType>
|
|
||||||
</None>
|
|
||||||
<None Include="README.md" />
|
|
||||||
</ItemGroup>
|
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
|
||||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
|
||||||
Other similar extension points exist, see Microsoft.Common.targets.
|
|
||||||
<Target Name="BeforeBuild">
|
|
||||||
</Target>
|
|
||||||
<Target Name="AfterBuild">
|
|
||||||
</Target>
|
|
||||||
-->
|
|
||||||
</Project>
|
</Project>
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
|
|
||||||
<metadata>
|
|
||||||
<id>Modbus.Net.Siemens</id>
|
|
||||||
<version>1.2.4</version>
|
|
||||||
<title>Modbus.Net.Siemens</title>
|
|
||||||
<authors>Chris L.(Luo Sheng)</authors>
|
|
||||||
<owners>Hangzhou Delian IoT Science Technology Co.,Ltd.</owners>
|
|
||||||
<licenseUrl>https://github.com/parallelbgls/Modbus.Net/blob/master/LICENSE.md</licenseUrl>
|
|
||||||
<projectUrl>https://github.com/parallelbgls/Modbus.Net/tree/master/Modbus.Net/Modbus.Net.Siemens</projectUrl>
|
|
||||||
<requireLicenseAcceptance>false</requireLicenseAcceptance>
|
|
||||||
<description>Modbus.Net Siemens Profinet Implementation</description>
|
|
||||||
<copyright>Copyright 2017 Hangzhou Delian IoT Science Technology Co.,Ltd.</copyright>
|
|
||||||
<tags>hardware communicate protocal Siemens profinet Delian</tags>
|
|
||||||
<dependencies>
|
|
||||||
<dependency id="Modbus.Net" version="1.2.4" />
|
|
||||||
</dependencies>
|
|
||||||
</metadata>
|
|
||||||
<files>
|
|
||||||
<file src="bin\Release\Modbus.Net.Siemens.dll" target="lib\net45\Modbus.Net.Siemens.dll" />
|
|
||||||
</files>
|
|
||||||
</package>
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
using System.Reflection;
|
|
||||||
using System.Runtime.CompilerServices;
|
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
|
|
||||||
// 有关程序集的一般信息由以下
|
|
||||||
// 控制。更改这些特性值可修改
|
|
||||||
// 与程序集关联的信息。
|
|
||||||
[assembly: AssemblyTitle("Modbus.Net.Siemens")]
|
|
||||||
[assembly: AssemblyDescription("")]
|
|
||||||
[assembly: AssemblyConfiguration("")]
|
|
||||||
[assembly: AssemblyCompany("杭州德联物联网科技有限公司")]
|
|
||||||
[assembly: AssemblyProduct("Modbus.Net.Siemens")]
|
|
||||||
[assembly: AssemblyCopyright("Copyright © Chris L. 2017 HangZhou Delian IoT Science Technology Co.,Ltd.")]
|
|
||||||
[assembly: AssemblyTrademark("")]
|
|
||||||
[assembly: AssemblyCulture("")]
|
|
||||||
|
|
||||||
//将 ComVisible 设置为 false 将使此程序集中的类型
|
|
||||||
//对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型,
|
|
||||||
//请将此类型的 ComVisible 特性设置为 true。
|
|
||||||
[assembly: ComVisible(false)]
|
|
||||||
|
|
||||||
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
|
|
||||||
[assembly: Guid("6258f9d9-0df4-497f-9f3b-6d2f6f752a21")]
|
|
||||||
|
|
||||||
// 程序集的版本信息由下列四个值组成:
|
|
||||||
//
|
|
||||||
// 主版本
|
|
||||||
// 次版本
|
|
||||||
// 生成号
|
|
||||||
// 修订号
|
|
||||||
//
|
|
||||||
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
|
|
||||||
// 方法是按如下所示使用“*”: :
|
|
||||||
// [assembly: AssemblyVersion("1.0.*")]
|
|
||||||
[assembly: AssemblyVersion("1.2.4")]
|
|
||||||
[assembly: AssemblyFileVersion("1.2.4")]
|
|
||||||
65
Modbus.Net/Modbus.Net.Standard/Modbus.Net.Standard.csproj
Normal file
65
Modbus.Net/Modbus.Net.Standard/Modbus.Net.Standard.csproj
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>netstandard1.5</TargetFramework>
|
||||||
|
<AssemblyName>Modbus.Net</AssemblyName>
|
||||||
|
<RootNamespace>Modbus.Net</RootNamespace>
|
||||||
|
<PackageId>Modbus.Net</PackageId>
|
||||||
|
<Version>1.3.0</Version>
|
||||||
|
<Product>Modbus.Net</Product>
|
||||||
|
<Authors>Chris L.(Luo Sheng)</Authors>
|
||||||
|
<Company>Hangzhou Delian IoT Science Technology Co.,Ltd.</Company>
|
||||||
|
<PackageLicenseUrl>https://github.com/parallelbgls/Modbus.Net/blob/master/LICENSE.md</PackageLicenseUrl>
|
||||||
|
<PackageProjectUrl>https://github.com/parallelbgls/Modbus.Net/tree/master/Modbus.Net</PackageProjectUrl>
|
||||||
|
<RepositoryUrl>https://github.com/parallelbgls/Modbus.Net/</RepositoryUrl>
|
||||||
|
<Description>High extensible hardware communication implementation platform.</Description>
|
||||||
|
<Copyright>Copyright 2017 Hangzhou Delian IoT Science Technology Co.,Ltd.</Copyright>
|
||||||
|
<PackageTags>hardware communicate protocal Delian</PackageTags>
|
||||||
|
<RepositoryType>git</RepositoryType>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="..\src\Base.Common\AddressCombiner.cs" Link="AddressCombiner.cs" />
|
||||||
|
<Compile Include="..\src\Base.Common\AddressFormater.cs" Link="AddressFormater.cs" />
|
||||||
|
<Compile Include="..\src\Base.Common\AddressHelper.cs" Link="AddressHelper.cs" />
|
||||||
|
<Compile Include="..\src\Base.Common\AddressTranslator.cs" Link="AddressTranslator.cs" />
|
||||||
|
<Compile Include="..\src\Base.Common\AsyncHelper.cs" Link="AsyncHelper.cs" />
|
||||||
|
<Compile Include="..\src\Base.Common\BaseConnector.cs" Link="BaseConnector.cs" />
|
||||||
|
<Compile Include="..\src\Base.Common\BaseMachine.cs" Link="BaseMachine.cs" />
|
||||||
|
<Compile Include="..\src\Base.Common\BaseMachineExtend.cs" Link="BaseMachineExtend.cs" />
|
||||||
|
<Compile Include="..\src\Base.Common\BaseProtocal.cs" Link="BaseProtocal.cs" />
|
||||||
|
<Compile Include="..\src\Base.Common\BaseUtility.cs" Link="BaseUtility.cs" />
|
||||||
|
<Compile Include="..\src\Base.Common\CRC16.cs" Link="CRC16.cs" />
|
||||||
|
<Compile Include="..\src\Base.Common\IProtocal.cs" Link="IProtocal.cs" />
|
||||||
|
<Compile Include="..\src\Base.Common\IProtocalFormatting.cs" Link="IProtocalFormatting.cs" />
|
||||||
|
<Compile Include="..\src\Base.Common\IProtocalLinker.cs" Link="IProtocalLinker.cs" />
|
||||||
|
<Compile Include="..\src\Base.Common\IProtocalLinkerBytesExtend.cs" Link="IProtocalLinkerBytesExtend.cs" />
|
||||||
|
<Compile Include="..\src\Base.Common\ProtocalLinker.cs" Link="ProtocalLinker.cs" />
|
||||||
|
<Compile Include="..\src\Base.Common\ProtocalUnit.cs" Link="ProtocalUnit.cs" />
|
||||||
|
<Compile Include="..\src\Base.Common\TaskManager.cs" Link="TaskManager.cs" />
|
||||||
|
<Compile Include="..\src\Base.Common\TcpConnector.cs" Link="TcpConnector.cs" />
|
||||||
|
<Compile Include="..\src\Base.Common\TcpProtocalLinker.cs" Link="TcpProtocalLinker.cs" />
|
||||||
|
<Compile Include="..\src\Base.Common\ValueHelper.cs" Link="ValueHelper.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="System.Collections.NonGeneric" Version="4.3.0" />
|
||||||
|
<PackageReference Include="System.Threading.ThreadPool" Version="4.3.0" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="..\src\Base.Common\ConfigurationManager.Designer.cs" Link="ConfigurationManager.Designer.cs">
|
||||||
|
<DesignTime>True</DesignTime>
|
||||||
|
<AutoGen>True</AutoGen>
|
||||||
|
<DependentUpon>ConfigurationManager.resx</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<EmbeddedResource Include="..\src\Base.Common\ConfigurationManager.resx" Link="ConfigurationManager.resx">
|
||||||
|
<Generator>ResXFileCodeGenerator</Generator>
|
||||||
|
<LastGenOutput>ConfigurationManager.Designer.cs</LastGenOutput>
|
||||||
|
</EmbeddedResource>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
# Visual Studio 14
|
# Visual Studio 15
|
||||||
VisualStudioVersion = 14.0.25420.1
|
VisualStudioVersion = 15.0.26228.4
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Modbus.Net", "ModBus.Net\Modbus.Net.csproj", "{124EBEF2-8960-4447-84CF-1D683B1EF7CC}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Modbus.Net", "ModBus.Net\Modbus.Net.csproj", "{124EBEF2-8960-4447-84CF-1D683B1EF7CC}"
|
||||||
EndProject
|
EndProject
|
||||||
@@ -31,6 +31,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CrossLamp", "..\Samples\Cro
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AnyType", "..\Samples\AnyType\AnyType.csproj", "{25FABD48-D82E-4E08-91A4-46F7057EC954}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AnyType", "..\Samples\AnyType\AnyType.csproj", "{25FABD48-D82E-4E08-91A4-46F7057EC954}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Modbus.Net.Standard", "Modbus.Net.Standard\Modbus.Net.Standard.csproj", "{BBC091FC-A995-4C06-96F1-F91ECD70FA7E}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
@@ -73,6 +75,10 @@ Global
|
|||||||
{25FABD48-D82E-4E08-91A4-46F7057EC954}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{25FABD48-D82E-4E08-91A4-46F7057EC954}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{25FABD48-D82E-4E08-91A4-46F7057EC954}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{25FABD48-D82E-4E08-91A4-46F7057EC954}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{25FABD48-D82E-4E08-91A4-46F7057EC954}.Release|Any CPU.Build.0 = Release|Any CPU
|
{25FABD48-D82E-4E08-91A4-46F7057EC954}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{BBC091FC-A995-4C06-96F1-F91ECD70FA7E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{BBC091FC-A995-4C06-96F1-F91ECD70FA7E}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{BBC091FC-A995-4C06-96F1-F91ECD70FA7E}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{BBC091FC-A995-4C06-96F1-F91ECD70FA7E}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
|||||||
@@ -1,105 +1,60 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
||||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
<TargetFramework>net45</TargetFramework>
|
||||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
|
||||||
<ProjectGuid>{124EBEF2-8960-4447-84CF-1D683B1EF7CC}</ProjectGuid>
|
|
||||||
<OutputType>Library</OutputType>
|
|
||||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
|
||||||
<RootNamespace>Modbus.Net</RootNamespace>
|
|
||||||
<AssemblyName>Modbus.Net</AssemblyName>
|
<AssemblyName>Modbus.Net</AssemblyName>
|
||||||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
<RootNamespace>Modbus.Net</RootNamespace>
|
||||||
<FileAlignment>512</FileAlignment>
|
<PackageId>Modbus.Net</PackageId>
|
||||||
<TargetFrameworkProfile />
|
<Version>1.3.0</Version>
|
||||||
</PropertyGroup>
|
<Product>Modbus.Net</Product>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
<Authors>Chris L.(Luo Sheng)</Authors>
|
||||||
<DebugSymbols>true</DebugSymbols>
|
<Company>Hangzhou Delian IoT Science Technology Co.,Ltd.</Company>
|
||||||
<DebugType>full</DebugType>
|
<PackageLicenseUrl>https://github.com/parallelbgls/Modbus.Net/blob/master/LICENSE.md</PackageLicenseUrl>
|
||||||
<Optimize>false</Optimize>
|
<PackageProjectUrl>https://github.com/parallelbgls/Modbus.Net/tree/master/Modbus.Net</PackageProjectUrl>
|
||||||
<OutputPath>bin\Debug\</OutputPath>
|
<RepositoryUrl>https://github.com/parallelbgls/Modbus.Net/</RepositoryUrl>
|
||||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
<Description>High extensible hardware communication implementation platform.</Description>
|
||||||
<ErrorReport>prompt</ErrorReport>
|
<Copyright>Copyright 2017 Hangzhou Delian IoT Science Technology Co.,Ltd.</Copyright>
|
||||||
<WarningLevel>4</WarningLevel>
|
<PackageTags>hardware communicate protocal Delian</PackageTags>
|
||||||
<AllowUnsafeBlocks>false</AllowUnsafeBlocks>
|
<RepositoryType>git</RepositoryType>
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
|
||||||
<DebugType>pdbonly</DebugType>
|
|
||||||
<Optimize>true</Optimize>
|
|
||||||
<OutputPath>bin\Release\</OutputPath>
|
|
||||||
<DefineConstants>TRACE</DefineConstants>
|
|
||||||
<ErrorReport>prompt</ErrorReport>
|
|
||||||
<WarningLevel>4</WarningLevel>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup>
|
|
||||||
<SignAssembly>false</SignAssembly>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup>
|
|
||||||
<AssemblyOriginatorKeyFile>
|
|
||||||
</AssemblyOriginatorKeyFile>
|
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="System" />
|
<Compile Include="..\src\Base.Common\AddressCombiner.cs" Link="AddressCombiner.cs" />
|
||||||
<Reference Include="System.Core" />
|
<Compile Include="..\src\Base.Common\AddressFormater.cs" Link="AddressFormater.cs" />
|
||||||
<Reference Include="System.Net.Http" />
|
<Compile Include="..\src\Base.Common\AddressHelper.cs" Link="AddressHelper.cs" />
|
||||||
<Reference Include="System.Windows.Forms" />
|
<Compile Include="..\src\Base.Common\AddressTranslator.cs" Link="AddressTranslator.cs" />
|
||||||
<Reference Include="System.Xml.Linq" />
|
<Compile Include="..\src\Base.Common\AsyncHelper.cs" Link="AsyncHelper.cs" />
|
||||||
<Reference Include="System.Data.DataSetExtensions" />
|
<Compile Include="..\src\Base.Common\BaseConnector.cs" Link="BaseConnector.cs" />
|
||||||
<Reference Include="Microsoft.CSharp" />
|
<Compile Include="..\src\Base.Common\BaseMachine.cs" Link="BaseMachine.cs" />
|
||||||
<Reference Include="System.Data" />
|
<Compile Include="..\src\Base.Common\BaseMachineExtend.cs" Link="BaseMachineExtend.cs" />
|
||||||
<Reference Include="System.Xml" />
|
<Compile Include="..\src\Base.Common\BaseProtocal.cs" Link="BaseProtocal.cs" />
|
||||||
|
<Compile Include="..\src\Base.Common\BaseUtility.cs" Link="BaseUtility.cs" />
|
||||||
|
<Compile Include="..\src\Base.Common\CRC16.cs" Link="CRC16.cs" />
|
||||||
|
<Compile Include="..\src\Base.Common\IProtocal.cs" Link="IProtocal.cs" />
|
||||||
|
<Compile Include="..\src\Base.Common\IProtocalFormatting.cs" Link="IProtocalFormatting.cs" />
|
||||||
|
<Compile Include="..\src\Base.Common\IProtocalLinker.cs" Link="IProtocalLinker.cs" />
|
||||||
|
<Compile Include="..\src\Base.Common\IProtocalLinkerBytesExtend.cs" Link="IProtocalLinkerBytesExtend.cs" />
|
||||||
|
<Compile Include="..\src\Base.Common\ProtocalLinker.cs" Link="ProtocalLinker.cs" />
|
||||||
|
<Compile Include="..\src\Base.Common\ProtocalUnit.cs" Link="ProtocalUnit.cs" />
|
||||||
|
<Compile Include="..\src\Base.Common\TaskManager.cs" Link="TaskManager.cs" />
|
||||||
|
<Compile Include="..\src\Base.Common\TcpConnector.cs" Link="TcpConnector.cs" />
|
||||||
|
<Compile Include="..\src\Base.Common\TcpProtocalLinker.cs" Link="TcpProtocalLinker.cs" />
|
||||||
|
<Compile Include="..\src\Base.Common\ValueHelper.cs" Link="ValueHelper.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="AddressCombiner.cs" />
|
<Compile Include="..\src\Base.Common\ConfigurationManager.Designer.cs" Link="ConfigurationManager.Designer.cs">
|
||||||
<Compile Include="AddressFormater.cs" />
|
|
||||||
<Compile Include="AddressTranslator.cs" />
|
|
||||||
<Compile Include="AddressHelper.cs" />
|
|
||||||
<Compile Include="AsyncHelper.cs" />
|
|
||||||
<Compile Include="BaseMachineExtend.cs" />
|
|
||||||
<Compile Include="BaseProtocal.cs" />
|
|
||||||
<Compile Include="BaseUtility.cs" />
|
|
||||||
<Compile Include="BaseMachine.cs" />
|
|
||||||
<Compile Include="ComConnector.cs" />
|
|
||||||
<Compile Include="ComProtocalLinker.cs" />
|
|
||||||
<Compile Include="ConfigurationManager.Designer.cs">
|
|
||||||
<AutoGen>True</AutoGen>
|
|
||||||
<DesignTime>True</DesignTime>
|
<DesignTime>True</DesignTime>
|
||||||
|
<AutoGen>True</AutoGen>
|
||||||
<DependentUpon>ConfigurationManager.resx</DependentUpon>
|
<DependentUpon>ConfigurationManager.resx</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="BaseConnector.cs" />
|
|
||||||
<Compile Include="CRC16.cs" />
|
|
||||||
<Compile Include="IProtocal.cs" />
|
|
||||||
<Compile Include="IProtocalFormatting.cs" />
|
|
||||||
<Compile Include="IProtocalLinker.cs" />
|
|
||||||
<Compile Include="ProtocalLinker.cs" />
|
|
||||||
<Compile Include="IProtocalLinkerBytesExtend.cs" />
|
|
||||||
<Compile Include="ProtocalUnit.cs" />
|
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
|
||||||
<Compile Include="TaskManager.cs" />
|
|
||||||
<Compile Include="TcpConnector.cs">
|
|
||||||
<SubType>Code</SubType>
|
|
||||||
</Compile>
|
|
||||||
<Compile Include="TcpProtocalLinker.cs" />
|
|
||||||
<Compile Include="ValueHelper.cs" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<EmbeddedResource Include="ConfigurationManager.resx">
|
<EmbeddedResource Include="..\src\Base.Common\ConfigurationManager.resx" Link="ConfigurationManager.resx">
|
||||||
<Generator>PublicResXFileCodeGenerator</Generator>
|
<Generator>ResXFileCodeGenerator</Generator>
|
||||||
<LastGenOutput>ConfigurationManager.Designer.cs</LastGenOutput>
|
<LastGenOutput>ConfigurationManager.Designer.cs</LastGenOutput>
|
||||||
</EmbeddedResource>
|
</EmbeddedResource>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
|
||||||
<None Include="ModBus.Net.nuspec">
|
|
||||||
<SubType>Designer</SubType>
|
|
||||||
</None>
|
|
||||||
<None Include="README.md" />
|
|
||||||
</ItemGroup>
|
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
|
||||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
|
||||||
Other similar extension points exist, see Microsoft.Common.targets.
|
|
||||||
<Target Name="BeforeBuild">
|
|
||||||
</Target>
|
|
||||||
<Target Name="AfterBuild">
|
|
||||||
</Target>
|
|
||||||
-->
|
|
||||||
</Project>
|
</Project>
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
using System.Reflection;
|
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
|
|
||||||
// 有关程序集的常规信息通过以下
|
|
||||||
// 特性集控制。更改这些特性值可修改
|
|
||||||
// 与程序集关联的信息。
|
|
||||||
|
|
||||||
[assembly: AssemblyTitle("Modbus.Net")]
|
|
||||||
[assembly: AssemblyDescription("")]
|
|
||||||
[assembly: AssemblyConfiguration("")]
|
|
||||||
[assembly: AssemblyCompany("杭州德联物联网科技有限公司")]
|
|
||||||
[assembly: AssemblyProduct("Modbus.Net")]
|
|
||||||
[assembly: AssemblyCopyright("Copyright © Chris L. 2017 HangZhou Delian IoT Science Technology Co.,Ltd.")]
|
|
||||||
[assembly: AssemblyTrademark("")]
|
|
||||||
[assembly: AssemblyCulture("")]
|
|
||||||
|
|
||||||
// 将 ComVisible 设置为 false 使此程序集中的类型
|
|
||||||
// 对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型,
|
|
||||||
// 则将该类型上的 ComVisible 特性设置为 true。
|
|
||||||
|
|
||||||
[assembly: ComVisible(false)]
|
|
||||||
|
|
||||||
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
|
|
||||||
|
|
||||||
[assembly: Guid("5e21fad9-c4ec-442e-bc0c-050e7a52b418")]
|
|
||||||
|
|
||||||
// 程序集的版本信息由下面四个值组成:
|
|
||||||
//
|
|
||||||
// 主版本
|
|
||||||
// 次版本
|
|
||||||
// 生成号
|
|
||||||
// 修订号
|
|
||||||
//
|
|
||||||
// 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
|
|
||||||
// 方法是按如下所示使用“*”:
|
|
||||||
// [assembly: AssemblyVersion("1.0.*")]
|
|
||||||
|
|
||||||
[assembly: AssemblyVersion("1.2.4")]
|
|
||||||
[assembly: AssemblyFileVersion("1.2.4")]
|
|
||||||
@@ -47,7 +47,7 @@ namespace Modbus.Net
|
|||||||
}
|
}
|
||||||
//自动寻找存在的协议并将其加载
|
//自动寻找存在的协议并将其加载
|
||||||
var protocalUnit =
|
var protocalUnit =
|
||||||
Assembly.Load(type.Assembly.FullName).CreateInstance(protocalName) as ProtocalUnit;
|
Assembly.Load(type.GetTypeInfo().Assembly.GetName()).CreateInstance(protocalName) as ProtocalUnit;
|
||||||
if (protocalUnit == null) throw new InvalidCastException("没有相应的协议内容");
|
if (protocalUnit == null) throw new InvalidCastException("没有相应的协议内容");
|
||||||
protocalUnit.Endian = Endian;
|
protocalUnit.Endian = Endian;
|
||||||
Register(protocalUnit);
|
Register(protocalUnit);
|
||||||
@@ -96,7 +96,7 @@ namespace Modbus.Net
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public bool LrcEfficacy(string message)
|
public bool LrcEfficacy(string message)
|
||||||
{
|
{
|
||||||
var index = message.IndexOf(Environment.NewLine, StringComparison.InvariantCulture);
|
var index = message.IndexOf(Environment.NewLine, StringComparison.Ordinal);
|
||||||
var writeUncheck = message.Substring(1, index - 2);
|
var writeUncheck = message.Substring(1, index - 2);
|
||||||
var checkString = message.Substring(index - 2, 2);
|
var checkString = message.Substring(index - 2, 2);
|
||||||
var hexArray = new char[writeUncheck.Length];
|
var hexArray = new char[writeUncheck.Length];
|
||||||
@@ -8,6 +8,8 @@
|
|||||||
// </auto-generated>
|
// </auto-generated>
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
using System.Reflection;
|
||||||
|
|
||||||
namespace Modbus.Net {
|
namespace Modbus.Net {
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
@@ -39,7 +41,7 @@ namespace Modbus.Net {
|
|||||||
public static global::System.Resources.ResourceManager ResourceManager {
|
public static global::System.Resources.ResourceManager ResourceManager {
|
||||||
get {
|
get {
|
||||||
if (object.ReferenceEquals(resourceMan, null)) {
|
if (object.ReferenceEquals(resourceMan, null)) {
|
||||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Modbus.Net.ConfigurationManager", typeof(ConfigurationManager).Assembly);
|
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Modbus.Net.ConfigurationManager", typeof(ConfigurationManager).GetTypeInfo().Assembly);
|
||||||
resourceMan = temp;
|
resourceMan = temp;
|
||||||
}
|
}
|
||||||
return resourceMan;
|
return resourceMan;
|
||||||
105
Modbus.Net/src/Base.Common/Modbus.Net.csproj
Normal file
105
Modbus.Net/src/Base.Common/Modbus.Net.csproj
Normal file
@@ -0,0 +1,105 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
|
<ProjectGuid>{124EBEF2-8960-4447-84CF-1D683B1EF7CC}</ProjectGuid>
|
||||||
|
<OutputType>Library</OutputType>
|
||||||
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
|
<RootNamespace>Modbus.Net</RootNamespace>
|
||||||
|
<AssemblyName>Modbus.Net</AssemblyName>
|
||||||
|
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||||
|
<FileAlignment>512</FileAlignment>
|
||||||
|
<TargetFrameworkProfile />
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<Optimize>false</Optimize>
|
||||||
|
<OutputPath>bin\Debug\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
<AllowUnsafeBlocks>false</AllowUnsafeBlocks>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<OutputPath>bin\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup>
|
||||||
|
<SignAssembly>false</SignAssembly>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup>
|
||||||
|
<AssemblyOriginatorKeyFile>
|
||||||
|
</AssemblyOriginatorKeyFile>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="System" />
|
||||||
|
<Reference Include="System.Core" />
|
||||||
|
<Reference Include="System.Net.Http" />
|
||||||
|
<Reference Include="System.Windows.Forms" />
|
||||||
|
<Reference Include="System.Xml.Linq" />
|
||||||
|
<Reference Include="System.Data.DataSetExtensions" />
|
||||||
|
<Reference Include="Microsoft.CSharp" />
|
||||||
|
<Reference Include="System.Data" />
|
||||||
|
<Reference Include="System.Xml" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="AddressCombiner.cs" />
|
||||||
|
<Compile Include="AddressFormater.cs" />
|
||||||
|
<Compile Include="AddressTranslator.cs" />
|
||||||
|
<Compile Include="AddressHelper.cs" />
|
||||||
|
<Compile Include="AsyncHelper.cs" />
|
||||||
|
<Compile Include="BaseMachineExtend.cs" />
|
||||||
|
<Compile Include="BaseProtocal.cs" />
|
||||||
|
<Compile Include="BaseUtility.cs" />
|
||||||
|
<Compile Include="BaseMachine.cs" />
|
||||||
|
<Compile Include="ComConnector.cs" />
|
||||||
|
<Compile Include="ComProtocalLinker.cs" />
|
||||||
|
<Compile Include="ConfigurationManager.Designer.cs">
|
||||||
|
<AutoGen>True</AutoGen>
|
||||||
|
<DesignTime>True</DesignTime>
|
||||||
|
<DependentUpon>ConfigurationManager.resx</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="BaseConnector.cs" />
|
||||||
|
<Compile Include="CRC16.cs" />
|
||||||
|
<Compile Include="IProtocal.cs" />
|
||||||
|
<Compile Include="IProtocalFormatting.cs" />
|
||||||
|
<Compile Include="IProtocalLinker.cs" />
|
||||||
|
<Compile Include="ProtocalLinker.cs" />
|
||||||
|
<Compile Include="IProtocalLinkerBytesExtend.cs" />
|
||||||
|
<Compile Include="ProtocalUnit.cs" />
|
||||||
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
<Compile Include="TaskManager.cs" />
|
||||||
|
<Compile Include="TcpConnector.cs">
|
||||||
|
<SubType>Code</SubType>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="TcpProtocalLinker.cs" />
|
||||||
|
<Compile Include="ValueHelper.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<EmbeddedResource Include="ConfigurationManager.resx">
|
||||||
|
<Generator>PublicResXFileCodeGenerator</Generator>
|
||||||
|
<LastGenOutput>ConfigurationManager.Designer.cs</LastGenOutput>
|
||||||
|
</EmbeddedResource>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="ModBus.Net.nuspec">
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
</None>
|
||||||
|
<None Include="README.md" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
|
<Target Name="BeforeBuild">
|
||||||
|
</Target>
|
||||||
|
<Target Name="AfterBuild">
|
||||||
|
</Target>
|
||||||
|
-->
|
||||||
|
</Project>
|
||||||
@@ -112,7 +112,7 @@ namespace Modbus.Net
|
|||||||
{
|
{
|
||||||
//自动查找相应的协议放缩类,命令规则为——当前的实际类名(注意是继承后的)+"BytesExtend"。
|
//自动查找相应的协议放缩类,命令规则为——当前的实际类名(注意是继承后的)+"BytesExtend"。
|
||||||
var bytesExtend =
|
var bytesExtend =
|
||||||
Assembly.Load(GetType().Assembly.FullName).CreateInstance(GetType().FullName + "BytesExtend") as
|
Assembly.Load(GetType().GetTypeInfo().Assembly.GetName()).CreateInstance(GetType().FullName + "BytesExtend") as
|
||||||
IProtocalLinkerBytesExtend;
|
IProtocalLinkerBytesExtend;
|
||||||
return bytesExtend?.BytesExtend(content);
|
return bytesExtend?.BytesExtend(content);
|
||||||
}
|
}
|
||||||
@@ -126,7 +126,7 @@ namespace Modbus.Net
|
|||||||
{
|
{
|
||||||
//自动查找相应的协议放缩类,命令规则为——当前的实际类名(注意是继承后的)+"BytesExtend"。
|
//自动查找相应的协议放缩类,命令规则为——当前的实际类名(注意是继承后的)+"BytesExtend"。
|
||||||
var bytesExtend =
|
var bytesExtend =
|
||||||
Assembly.Load(GetType().Assembly.GetName().Name).CreateInstance(GetType().FullName + "BytesExtend") as
|
Assembly.Load(GetType().GetTypeInfo().Assembly.GetName()).CreateInstance(GetType().FullName + "BytesExtend") as
|
||||||
IProtocalLinkerBytesExtend;
|
IProtocalLinkerBytesExtend;
|
||||||
return bytesExtend?.BytesDecact(content);
|
return bytesExtend?.BytesDecact(content);
|
||||||
}
|
}
|
||||||
546
Modbus.Net/src/Base.Common/README.md
Normal file
546
Modbus.Net/src/Base.Common/README.md
Normal file
@@ -0,0 +1,546 @@
|
|||||||
|
Modbus.Net
|
||||||
|
===================
|
||||||
|
[](https://www.nuget.org/packages/Modbus.Net/)
|
||||||
|
|
||||||
|
An hardware communication Library written by C#.
|
||||||
|
|
||||||
|
Table of Content:
|
||||||
|
* [Features](#features)
|
||||||
|
* [Usage](#usage)
|
||||||
|
* [Architecture](#architecture)
|
||||||
|
* [Quick Start](#quick_start)
|
||||||
|
* [Tutorial](#tutorial)
|
||||||
|
* [Implement](#implement)
|
||||||
|
* [Addition](#addition)
|
||||||
|
|
||||||
|
##<a name="features"></a> Features
|
||||||
|
* A open platform that you can easy to extend a industrial communication protocal.
|
||||||
|
* Modbus Tcp protocal.
|
||||||
|
* Siemens Tcp protocal (acturally it is the same as Profinet)
|
||||||
|
* OPC DA protocal.
|
||||||
|
* All communications could be asynchronized.
|
||||||
|
* A task manager that you can easily manage multiple connections.
|
||||||
|
* .NET Framework 4.5 and Visual Studio 2015 support.
|
||||||
|
|
||||||
|
##<a name="usage"></a> Usage
|
||||||
|
|
||||||
|
###Samples:
|
||||||
|
|
||||||
|
There are four samples in the project. All sample project recommand running in Siemens 200 PLC.
|
||||||
|
PLC Program could be opened by Siemens Portal V13 (Step 7 V13).
|
||||||
|
|
||||||
|
Modbus TCP connection and Siemens Ethenet Connection are supported at the same time.
|
||||||
|
|
||||||
|
* TripleAdd -- Add three numbers in PLC.
|
||||||
|
* TaskManager -- Sample usage of TaskManager.
|
||||||
|
* AnyType -- Get any type in registers.
|
||||||
|
* CrossLamp -- A sample singal lamp controller.
|
||||||
|
|
||||||
|
##<a name="architecture"></a> Architecture
|
||||||
|
|
||||||
|
###Connector
|
||||||
|
|
||||||
|
Connector implements the basic connecting methods, like Socket, Com and SignalR.
|
||||||
|
|
||||||
|
###ProtocalLinker
|
||||||
|
|
||||||
|
ProtocalLinker implements the link, send, and send recevice actions.
|
||||||
|
|
||||||
|
###ProtocalLinkerBytesExtend
|
||||||
|
|
||||||
|
Some Protocal has the same head or tail in the same connection way, but different in different connection way, so bytes extend can extend sending message when they are sended in different type of connection.
|
||||||
|
|
||||||
|
###ProtocalUnit
|
||||||
|
|
||||||
|
Format and deformat the protocal message between the structual class and bytes array.
|
||||||
|
|
||||||
|
###ValueHelper
|
||||||
|
|
||||||
|
Help change the value between number and bytes, or number array to bytes array.
|
||||||
|
|
||||||
|
###Protocal
|
||||||
|
|
||||||
|
Manage all protocals and implement a lazy loading method.
|
||||||
|
|
||||||
|
###Utility
|
||||||
|
|
||||||
|
Manage several types of Protocal to a same calling interface.
|
||||||
|
|
||||||
|
###Machine
|
||||||
|
|
||||||
|
Shows the Hardware PLC or other types of machine and implement a high level send and receive api.
|
||||||
|
|
||||||
|
###AddressFormater
|
||||||
|
|
||||||
|
Format address from definite address to string.
|
||||||
|
|
||||||
|
###AddressTranslator
|
||||||
|
|
||||||
|
Translate address from string to definite address.
|
||||||
|
|
||||||
|
###AddressCombiner
|
||||||
|
|
||||||
|
Combine duplicated addresses to organized addresses, each organized addresses communicate once to a device.
|
||||||
|
|
||||||
|
###TaskManager
|
||||||
|
|
||||||
|
The highest api that you can manage many PLC links and all links are async so there are no block in all connections.
|
||||||
|
|
||||||
|
##<a name="quick_start"></a> Quick Start.
|
||||||
|
|
||||||
|
The fastest way you can write is to use TaskManager. TaskManager Project is a good example.
|
||||||
|
|
||||||
|
|
||||||
|
```C#
|
||||||
|
List<AddressUnit> addressUnits = new List<AddressUnit>
|
||||||
|
{
|
||||||
|
new AddressUnit() {Id = "0", Area = "V", Address = 1, CommunicationTag = "D1", DataType = typeof (ushort), Zoom = 1},
|
||||||
|
new AddressUnit() {Id = "1", Area = "V", Address = 3, CommunicationTag = "D2", DataType = typeof (float), Zoom = 1}
|
||||||
|
};
|
||||||
|
TaskManager task = new TaskManager(10, 300, true);
|
||||||
|
task.AddMachine(new SiemensMachine(SiemensType.Tcp, "192.168.3.11", SiemensMachineModel.S7_300, addressUnits,
|
||||||
|
true, 2, 0));
|
||||||
|
task.ReturnValues += (returnValues) =>
|
||||||
|
{
|
||||||
|
value = new List<string>();
|
||||||
|
if (returnValues.ReturnValues != null)
|
||||||
|
{
|
||||||
|
value = from val in returnValues.ReturnValues select val.Key + " " + val.Value.PlcValue;
|
||||||
|
siemensItems.Dispatcher.Invoke(() => siemensItems.ItemsSource = value);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Console.WriteLine($"ip {returnValues.MachineId} not return value");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
task.TaskStart();
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
Here are the details to use the TaskManager.
|
||||||
|
|
||||||
|
1. Initialize the task manager.
|
||||||
|
Three arguments are: the max tasks you can run in a same time; How long did the next send message call happens(milliseconds); and you should keep the connection when a single message called complete.
|
||||||
|
|
||||||
|
2. Add the addresses that you want to communicate to PLC. Area are defined in AddressTranslator in each type of communiction.
|
||||||
|
Basically you can write only Id, Area, Address, CommunicationTag, DataType and Zoom, and it should work. And there are other fields that you can use.
|
||||||
|
More important, you can extend and implement your own field in UnitExtend in every AddressUnit, and it will return in return event.
|
||||||
|
|
||||||
|
3. Add a machine to TaskManager.
|
||||||
|
Add a machine like siemens machine to the task manager.
|
||||||
|
|
||||||
|
4. Implement ReturnValues event.
|
||||||
|
The argument return values is a key value pair. The architechture is:
|
||||||
|
|
||||||
|
* Key : the link address of machine (in sample is the second parameter).
|
||||||
|
* Value : Dictionary.
|
||||||
|
* Key : CommunicationTag/Address(string) in AddressUnit.
|
||||||
|
* Value : ReturnUnit.
|
||||||
|
* PlcValue : The return data, all in double type.
|
||||||
|
* UnitExtend : UnitExtend in AddressUnit. You should cast this class to your own class extends by UnitExtend.
|
||||||
|
|
||||||
|
##<a name="tutorial"></a> Tutorial
|
||||||
|
This platform has three level APIs that you could use: Low level API called "BaseUtility"; Middle level API called "BaseMachine"; High level API called "TaskManager".
|
||||||
|
|
||||||
|
###BaseUtility
|
||||||
|
BaseUtility is a low level api, in this level you can get or set data only by byte array or object array. Here is an example.
|
||||||
|
|
||||||
|
```C#
|
||||||
|
string ip = "192.168.0.10";
|
||||||
|
BaseUtility utility = new ModbusUtility(ModbusType.Tcp, ip, 0x02, 0x00);
|
||||||
|
object[] getNum = utility.GetDatas("4X 1", new KeyValuePair<Type, int>(typeof(ushort), 4));
|
||||||
|
```
|
||||||
|
|
||||||
|
BaseUtility is an abstract class. You can check all apis in BaseUtility.cs in Modbus.Net project.
|
||||||
|
|
||||||
|
To use BaseUtility, follow these steps.
|
||||||
|
|
||||||
|
1.New a BaseUtility instance, but remember BaseUtility is an abstract class, you should new class inherit from it.
|
||||||
|
```C#
|
||||||
|
BaseUtility utility = new ModbusUtility(ModbusType.Tcp, ip, 0x02, 0x00);
|
||||||
|
```
|
||||||
|
|
||||||
|
2.Use GetData and SetData Api in BaseUtility, like
|
||||||
|
```C#
|
||||||
|
object[] getNum = utility.GetDatas("4X 1", new KeyValuePair<Type, int>(typeof(ushort), 4));
|
||||||
|
|
||||||
|
utility.SetDatas("4X 1", new object[] { (ushort)1, (ushort)2, (ushort)3 });
|
||||||
|
```
|
||||||
|
Remember force set type of numbers because GetData and SetData Apis are type sensitive.
|
||||||
|
|
||||||
|
You can also use async functions like
|
||||||
|
```C#
|
||||||
|
object[] getNum = await utility.GetDatasAsync("4X 1", new KeyValuePair<Type, int>(typeof(ushort), 4));
|
||||||
|
```
|
||||||
|
|
||||||
|
###BaseMachine
|
||||||
|
BaseMachine is a middle level api, in this level you could get and set datas in a managable data structure for a single machine.
|
||||||
|
To understand this class, you have to see the AddressUnit first.
|
||||||
|
```C#
|
||||||
|
public class AddressUnit
|
||||||
|
{
|
||||||
|
public string Id { get; set; }
|
||||||
|
public string Area { get; set; }
|
||||||
|
public int Address { get; set; }
|
||||||
|
public int SubAddress { get; set; } = 0;
|
||||||
|
public Type DataType { get; set; }
|
||||||
|
public double Zoom { get; set; }
|
||||||
|
public int DecimalPos { get; set; }
|
||||||
|
public string CommunicationTag { get; set; }
|
||||||
|
public string Name { get; set; }
|
||||||
|
public string Unit { get; set; }
|
||||||
|
public bool CanWrite { get; set; } = true;
|
||||||
|
public UnitExtend UnitExtend { get; set; }
|
||||||
|
}
|
||||||
|
```
|
||||||
|
For some reasons, AddressUnit has two keys: Id and CommunicationTag, one is integer and the other is string.
|
||||||
|
|
||||||
|
* Details
|
||||||
|
* Area: Address Area description. For example the area code of modbus address "4X 1" is "4X".
|
||||||
|
* Address: Address number description. For example the address of modbus address "4X 1" is "1".
|
||||||
|
* DataType: The DataType of value.
|
||||||
|
* Zoom : Scale the return value. For example if zoom is 0.1 then return value 150 will change to 15.
|
||||||
|
* DecimalPos : Keep to the places after decimal. For example if DecimalPos is 2 then 150.353 will change to 150.35.
|
||||||
|
* Name : Name of the Address.
|
||||||
|
* Unit : Unit of the Address. For example "¡æ".
|
||||||
|
* UnitExtend : If you want to get something else when value returns, extend the class and give it to here.
|
||||||
|
|
||||||
|
Then using BaseMachine like this.
|
||||||
|
```C#
|
||||||
|
BaseMachine machine = new ModbusMachine(ModbusType.Tcp, "192.168.3.12", new List<AddressUnit>()
|
||||||
|
{
|
||||||
|
machine = new ModbusMachine(ModbusType.Rtu, "COM3", new List<AddressUnit>()
|
||||||
|
{
|
||||||
|
new AddressUnit() {Id = "1", Area = "4X", Address = 1, CommunicationTag = "Add1", DataType = typeof(ushort), Zoom = 1, DecimalPos = 0},
|
||||||
|
new AddressUnit() {Id = "2", Area = "4X", Address = 2, CommunicationTag = "Add2", DataType = typeof(ushort), Zoom = 1, DecimalPos = 0},
|
||||||
|
new AddressUnit() {Id = "3", Area = "4X", Address = 3, CommunicationTag = "Add3", DataType = typeof(ushort), Zoom = 1, DecimalPos = 0},
|
||||||
|
new AddressUnit() {Id = "4", Area = "4X", Address = 4, CommunicationTag = "Ans", DataType = typeof(ushort), Zoom = 1, DecimalPos = 0},
|
||||||
|
}, 2, 0);
|
||||||
|
machine.AddressCombiner = new AddressCombinerContinus(machine.AddressTranslator);
|
||||||
|
machine.AddressCombinerSet = new AddressCombinerContinus(machine.AddressTranslator);
|
||||||
|
machine.AddressCombiner = new AddressCombinerPercentageJump(20.0);
|
||||||
|
var result = machine.GetDatas(MachineGetDataType.CommunicationTag);
|
||||||
|
var add1 = result["Add1"].PlcValue;
|
||||||
|
var resultFormat = result.MapGetValuesToSetValues();
|
||||||
|
machine.SetDatas(MachineSetDataType.CommunicationTag, resultFormat);
|
||||||
|
```
|
||||||
|
|
||||||
|
To use BaseMachine, follow these steps.
|
||||||
|
|
||||||
|
1.New a BaseMachine instance. Remeber BaseMachine is an abstract class.
|
||||||
|
|
||||||
|
```C#
|
||||||
|
machine = new ModbusMachine(ModbusType.Rtu, "COM3", new List<AddressUnit>()
|
||||||
|
{
|
||||||
|
new AddressUnit() {Id = "1", Area = "4X", Address = 1, CommunicationTag = "Add1", DataType = typeof(ushort), Zoom = 1, DecimalPos = 0},
|
||||||
|
new AddressUnit() {Id = "2", Area = "4X", Address = 2, CommunicationTag = "Add2", DataType = typeof(ushort), Zoom = 1, DecimalPos = 0},
|
||||||
|
new AddressUnit() {Id = "3", Area = "4X", Address = 3, CommunicationTag = "Add3", DataType = typeof(ushort), Zoom = 1, DecimalPos = 0},
|
||||||
|
new AddressUnit() {Id = "4", Area = "4X", Address = 4, CommunicationTag = "Ans", DataType = typeof(ushort), Zoom = 1, DecimalPos = 0},
|
||||||
|
}, 2, 0);
|
||||||
|
```
|
||||||
|
If you want to change address, you can set machine.GetAddresses.
|
||||||
|
|
||||||
|
2.You can set AddressFormater, AddressTranslator and AddressCombiner to your own implementation.
|
||||||
|
|
||||||
|
```C#
|
||||||
|
machine.AddressFormater = new AddressFormaterNA200H();
|
||||||
|
machine.AddressTranslator = new AddressTranslatorNA200H();
|
||||||
|
machine.AddressCombiner = new AddressCombinerPercentageJump(20.0);
|
||||||
|
```
|
||||||
|
AddressFormater can format Area and Address to a string.
|
||||||
|
AdressTranslator can translate this string to two codes.
|
||||||
|
AddressCombiner can combiner addresses to groups, one group should send one message to hardware.
|
||||||
|
There are 4 AddressCombiners implemented in the platform.
|
||||||
|
|
||||||
|
1. AddressCombinerSingle: Each address group themself.
|
||||||
|
2. AddressCombinerContinus: Continually addresses pack to one group. This is the default.
|
||||||
|
3. AddressCombinerNumericJump: Add some addresses to pack more address in the group, and when the value returns, all added address are ignored.
|
||||||
|
4. AddressCombinerPercentageJump: Same as AddressCombinerNumericJump, and the added count is calculated by the percentage of all get addresses.
|
||||||
|
|
||||||
|
3.Use GetDatas Api.
|
||||||
|
```C#
|
||||||
|
var result = machine.GetDatas(MachineGetDataType.CommunicationTag);
|
||||||
|
//var result = await machine.GetDatasAsync(MachineGetDataType.CommunicationTag);
|
||||||
|
```
|
||||||
|
|
||||||
|
4.Retrive data from result.
|
||||||
|
```C#
|
||||||
|
var add1 = result["Add1"].PlcValue;
|
||||||
|
```
|
||||||
|
|
||||||
|
5.Format result to SetData parameter.
|
||||||
|
```C#
|
||||||
|
var resultFormat = result.MapGetValuesToSetValues();
|
||||||
|
```
|
||||||
|
|
||||||
|
6.SetData to machine or another machine.
|
||||||
|
```C#
|
||||||
|
machine.SetDatas(MachineSetDataType.CommunicationTag, resultFormat);
|
||||||
|
```
|
||||||
|
There is also a SetDatasAsync Api.
|
||||||
|
machine.SetDatas has two types. It is referenced as the first parameter.
|
||||||
|
|
||||||
|
1. MachineSetDataType.Address: the key of the dictionary of the second parameter is address.
|
||||||
|
2. MachineSetDataType.CommunicationTag: the key of the dictionary of the second parameter is communication tag.
|
||||||
|
|
||||||
|
###TaskManager
|
||||||
|
TaskManager is a high level api that you can manage and control many machines together. Remenber if you want to use this class, all communications must be asyncronized.
|
||||||
|
Sample of TaskManager calls like this.
|
||||||
|
```C#
|
||||||
|
TaskManager task = new TaskManager(10, 2000, true);
|
||||||
|
List<AddressUnit> addressUnits = new List<AddressUnit>
|
||||||
|
{
|
||||||
|
new AddressUnit() {Id = 0, Area = "V", Address = 1, CommunicationTag = "D1", DataType = typeof (ushort), Zoom = 1},
|
||||||
|
new AddressUnit() {Id = 1, Area = "V", Address = 3, CommunicationTag = "D2", DataType = typeof (float), Zoom = 1}
|
||||||
|
};
|
||||||
|
task.AddMachine(new SiemensMachine(SiemensType.Tcp, "192.168.3.11",SiemensMachineModel.S7_300, addressUnits, true));
|
||||||
|
task.ReturnValues += (returnValues) =>
|
||||||
|
{
|
||||||
|
value = new List<string>();
|
||||||
|
if (returnValues.Value != null)
|
||||||
|
{
|
||||||
|
value = from val in returnValues.Value select val.Key + " " + val.Value.PlcValue;
|
||||||
|
siemensItems.Dispatcher.Invoke(() => siemensItems.ItemsSource = value);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Console.WriteLine($"ip {returnValues.Key} not return value");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
task.TaskStart();
|
||||||
|
```
|
||||||
|
|
||||||
|
To use the TaskManager, use following steps.
|
||||||
|
|
||||||
|
1.New A TaskManager instance.
|
||||||
|
```C#
|
||||||
|
TaskManager task = new TaskManager(10, 2000, true);
|
||||||
|
```
|
||||||
|
|
||||||
|
2.Add a machine to TaskManager.
|
||||||
|
```C#
|
||||||
|
List<AddressUnit> addressUnits = new List<AddressUnit>
|
||||||
|
{
|
||||||
|
new AddressUnit() {Id = 0, Area = "V", Address = 1, CommunicationTag = "D1", DataType = typeof (ushort), Zoom = 1},
|
||||||
|
new AddressUnit() {Id = 1, Area = "V", Address = 3, CommunicationTag = "D2", DataType = typeof (float), Zoom = 1}
|
||||||
|
};
|
||||||
|
task.AddMachine(new SiemensMachine(SiemensType.Tcp, "192.168.3.11", SiemensMachineModel.S7_300, addressUnits, true));
|
||||||
|
```
|
||||||
|
|
||||||
|
3.Register the ReturnValue Event.
|
||||||
|
```C#
|
||||||
|
task.ReturnValues += (returnValues) =>
|
||||||
|
{
|
||||||
|
value = new List<string>();
|
||||||
|
if (returnValues.Value != null)
|
||||||
|
{
|
||||||
|
value = from val in returnValues.Value select val.Key + " " + val.Value.PlcValue;
|
||||||
|
siemensItems.Dispatcher.Invoke(() => siemensItems.ItemsSource = value);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Console.WriteLine($"ip {returnValues.Key} not return value");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
```
|
||||||
|
The ReturnValues' key is the machineToken, this sample is "192.168.3.11".
|
||||||
|
And the value is the same as the machine.GetDatas returns.
|
||||||
|
|
||||||
|
4.Start the TaskManager.
|
||||||
|
```C#
|
||||||
|
task.TaskStart();
|
||||||
|
```
|
||||||
|
|
||||||
|
5.And don't forget that there is also a SetDatasAsync Api in the TaskManager.
|
||||||
|
```C#
|
||||||
|
public async Task<bool> SetDatasAsync(string connectionToken, MachineSetDataType setDataType, Dictionary<string, double> values)
|
||||||
|
```
|
||||||
|
|
||||||
|
##<a name="implement"></a> Implementing Your Own Protocal
|
||||||
|
The main target of Modbus.Net is building a high extensable hardware communication protocal, so we allow everyone to extend the protocal.
|
||||||
|
|
||||||
|
To extend Modbus.Net, first of all ValueHelper.cs in Modbus.Net is a really powerful tool that you can use to modify values in byte array.There are two ValueHelpers: ValueHelper(Little Endian) and BigEndianValueHelper(Big Endian). Remember using the correct one.
|
||||||
|
|
||||||
|
In this tutorial I will use Modbus.Net.Modbus to tell you how to implement your own protocal.
|
||||||
|
|
||||||
|
You should follow the following steps to implement your own protocal.
|
||||||
|
|
||||||
|
1.Implement Protocal. (ModbusProtocal.cs, ModbusTcpProtocal.cs)
|
||||||
|
First: Extend BaseProtocal to ModbusProtocal.
|
||||||
|
```C#
|
||||||
|
public abstract class ModbusProtocal : BaseProtocal
|
||||||
|
public class ModbusTcpProtocal : ModbusProtocal
|
||||||
|
```
|
||||||
|
"abstract" keyword is optional because if user can use this protocal don't write abstract.
|
||||||
|
|
||||||
|
Second: Extend ProtocalUnit, IInputStruct and IOutputStruct.
|
||||||
|
```C#
|
||||||
|
public class ReadDataModbusProtocal : ProtocalUnit
|
||||||
|
{
|
||||||
|
public override byte[] Format(IInputStruct message)
|
||||||
|
{
|
||||||
|
var r_message = (ReadDataModbusInputStruct)message;
|
||||||
|
return Format(r_message.SlaveAddress, r_message.FunctionCode, r_message.StartAddress, r_message.GetCount);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override IOutputStruct Unformat(byte[] messageBytes, ref int pos)
|
||||||
|
{
|
||||||
|
byte slaveAddress = BigEndianValueHelper.Instance.GetByte(messageBytes, ref pos);
|
||||||
|
byte functionCode = BigEndianValueHelper.Instance.GetByte(messageBytes, ref pos);
|
||||||
|
byte dataCount = BigEndianValueHelper.Instance.GetByte(messageBytes, ref pos);
|
||||||
|
byte[] dataValue = new byte[dataCount];
|
||||||
|
Array.Copy(messageBytes, 3, dataValue, 0, dataCount);
|
||||||
|
return new ReadDataModbusOutputStruct(slaveAddress, functionCode, dataCount, dataValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
There is another interface called ISpecialProtocalUnit.
|
||||||
|
If you add ISpecialProtocalUnit to ProtocalUnit, then the protocal will not run BytesExtend and BytesDecact.
|
||||||
|
```C#
|
||||||
|
internal class CreateReferenceSiemensProtocal : ProtocalUnit, ISpecialProtocalUnit
|
||||||
|
{
|
||||||
|
...
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
2.Implement Protocal based ProtocalLinker. (ModbusTcpProtocalLinker)
|
||||||
|
ProtocalLinker connect the Protocal to the BaseConnector, so that byte array can be sended using some specific way like Ethenet.
|
||||||
|
```C#
|
||||||
|
public class ModbusTcpProtocalLinker : TcpProtocalLinker
|
||||||
|
{
|
||||||
|
public override bool CheckRight(byte[] content)
|
||||||
|
```
|
||||||
|
CheckRight is the return check function, if you got the wrong bytes answer, you can return false or throw exceptions.
|
||||||
|
|
||||||
|
3.Implement Connector based ProtocalLinker and BaseConnector. (TcpProtocalLinker.cs, TcpConnector.cs) (Optional)
|
||||||
|
If you want to connect to hardware using another way, please implement your own ProtocalLinker and BaseConnector. And please remember that if you want to connector hardware using serial line, please don't use ComConnector in Modbus.Net and implement your own ComConnector.
|
||||||
|
You should implement all of these functions in BaseConnector.
|
||||||
|
```C#
|
||||||
|
public abstract string ConnectionToken { get; }
|
||||||
|
public abstract bool IsConnected { get; }
|
||||||
|
public abstract bool Connect();
|
||||||
|
public abstract Task<bool> ConnectAsync();
|
||||||
|
public abstract bool Disconnect();
|
||||||
|
public abstract bool SendMsgWithoutReturn(byte[] message);
|
||||||
|
public abstract Task<bool> SendMsgWithoutReturnAsync(byte[] message);
|
||||||
|
public abstract byte[] SendMsg(byte[] message);
|
||||||
|
public abstract Task<byte[]> SendMsgAsync(byte[] message);
|
||||||
|
```
|
||||||
|
|
||||||
|
4.Implement ProtocalLinkerBytesExtend (ModbusProtocalLinkerBytesExtend.cs)
|
||||||
|
If you want to use extend bytes when you send your bytes array to the hardware, you can set ProtocalLinkerBytesExtend.
|
||||||
|
The name of ProtocalLinkerBytesExtend is ProtocalLinker name + BytesExtend, like ModbusTcpProtocalLinkerBytesExtend.
|
||||||
|
```C#
|
||||||
|
public class ModbusTcpProtocalLinkerBytesExtend : ProtocalLinkerBytesExtend
|
||||||
|
{
|
||||||
|
public override byte[] BytesExtend(byte[] content)
|
||||||
|
{
|
||||||
|
byte[] newFormat = new byte[6 + content.Length];
|
||||||
|
int tag = 0;
|
||||||
|
ushort leng = (ushort)content.Length;
|
||||||
|
Array.Copy(BigEndianValueHelper.Instance.GetBytes(tag), 0, newFormat, 0, 4);
|
||||||
|
Array.Copy(BigEndianValueHelper.Instance.GetBytes(leng), 0, newFormat, 4, 2);
|
||||||
|
Array.Copy(content, 0, newFormat, 6, content.Length);
|
||||||
|
return newFormat;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override byte[] BytesDecact(byte[] content)
|
||||||
|
{
|
||||||
|
byte[] newContent = new byte[content.Length - 6];
|
||||||
|
Array.Copy(content, 6, newContent, 0, newContent.Length);
|
||||||
|
return newContent;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
For example modbus tcp has a 6 bytes head: 4 bytes 0 and 2 bytes length. And when you get the bytes, please remove the head to fit the ModbusProtocal Unformat function.
|
||||||
|
|
||||||
|
5.Implement BaseUtility.cs (ModbusUtility.cs)
|
||||||
|
Implement low level api for Modbus.
|
||||||
|
You need to implement three functions.
|
||||||
|
```C#
|
||||||
|
public override void SetConnectionType(int connectionType)
|
||||||
|
protected override async Task<byte[]> GetDatasAsync(byte slaveAddress, byte masterAddress, string startAddress, int getByteCount)
|
||||||
|
public override async Task<bool> SetDatasAsync(byte slaveAddress, byte masterAddress, string startAddress, object[] setContents)
|
||||||
|
public override bool GetLittleEndian
|
||||||
|
public override bool SetLittleEndian
|
||||||
|
```
|
||||||
|
And don't remember set default AddressTranslator, slaveAddress, masterAddress and Protocal.
|
||||||
|
```C#
|
||||||
|
public ModbusUtility(int connectionType, byte slaveAddress, byte masterAddress) : base(slaveAddress, masterAddress)
|
||||||
|
{
|
||||||
|
ConnectionString = null;
|
||||||
|
ModbusType = (ModbusType)connectionType;
|
||||||
|
AddressTranslator = new AddressTranslatorModbus();
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
6.Implement BaseMachine.cs (ModbusMachine.cs)
|
||||||
|
Implement middle level api for Modbus.
|
||||||
|
```C#
|
||||||
|
public ModbusMachine(ModbusType connectionType, string connectionString,
|
||||||
|
IEnumerable<AddressUnit> getAddresses, bool keepConnect, byte slaveAddress, byte masterAddress)
|
||||||
|
: base(getAddresses, keepConnect, slaveAddress, masterAddress)
|
||||||
|
{
|
||||||
|
BaseUtility = new ModbusUtility(connectionType, connectionString, slaveAddress, masterAddress);
|
||||||
|
AddressFormater = new AddressFormaterModbus();
|
||||||
|
AddressCombiner = new AddressCombinerContinus(AddressTranslator);
|
||||||
|
AddressCombinerSet = new AddressCombinerContinus(AddressTranslator);
|
||||||
|
}
|
||||||
|
```
|
||||||
|
Set BaseUtility, default AddressFormater, AddressCombiner and AddressCombinerSet.
|
||||||
|
|
||||||
|
7.Implement your own AddressFormater, AddressTranslator and AddressCombiner. (AddressFormaterModbus.cs, AddressTranslatorModbus.cs) (Optional)
|
||||||
|
If some devices have its own address rule, you should implement your own address formating system.
|
||||||
|
```C#
|
||||||
|
public class AddressFormaterModbus : AddressFormater
|
||||||
|
{
|
||||||
|
public override string FormatAddress(string area, int address)
|
||||||
|
{
|
||||||
|
return area + " " + address;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override string FormatAddress(string area, int address, int subAddress)
|
||||||
|
{
|
||||||
|
return area + " " + address + "." + subAddress;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
##<a name="addition"></a> Addition
|
||||||
|
|
||||||
|
###For Subpos System
|
||||||
|
Subpos system is implemented for reading and writing of bits.
|
||||||
|
```C#
|
||||||
|
public class AddressUnit
|
||||||
|
{
|
||||||
|
public int SubAddress { get; set; } = 0;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
First of all, there are two types of coordinates in Modbus.Net Address System - Protocal Coordinate and Abstract Coordinate.
|
||||||
|
|
||||||
|
Here is an example of the differences between them:
|
||||||
|
|
||||||
|
In Register of Modbus, the minimum type is short, but Modbus.Net use type of byte to show the result. If you want to get value from 400003 in protocal coordinate, you actually get 5th and 6th byte value in abstract coordinate.
|
||||||
|
|
||||||
|
Version 1.0 and 1.1 used abstract coordinate so you need to convert the address. But fortunatly after 1.2, AddressUnit uses Protocal Coordinate so that you donnot need the convert the address descripted by modbus protocal itself, but this means if you want to get a bit or byte value in modbus, you need to use the subpos system.
|
||||||
|
|
||||||
|
For example if you want the get a value from the 6th byte in Hold Register. In traditional modbus you can only get 400003 of 2 bytes and get the 2nd byte from it. But in Modbus.Net there is an easy way to get it.
|
||||||
|
```
|
||||||
|
Modbus 400003 2nd byte
|
||||||
|
```
|
||||||
|
Donnot wonder I use real number to implement subpos counter. There are no tolerances because only (1/2 pow n) could be used to count subpos.
|
||||||
|
|
||||||
|
```C#
|
||||||
|
|
||||||
|
class AddressUnit
|
||||||
|
{
|
||||||
|
Area = "4X"
|
||||||
|
Address = 3
|
||||||
|
SubAddress = 8
|
||||||
|
type = typeof(byte)
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
SubAddress 8 means it starts from the 8th bit in that short value.
|
||||||
|
|
||||||
|
Remember subpos system cannot cross a byte in current version. If you want to cross a byte, you can change the function "GetValue" in ValueHelper.cs
|
||||||
@@ -116,7 +116,11 @@ namespace Modbus.Net
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void NotifyThreadPoolOfPendingWork()
|
private void NotifyThreadPoolOfPendingWork()
|
||||||
{
|
{
|
||||||
|
#if NET45
|
||||||
ThreadPool.UnsafeQueueUserWorkItem(_ =>
|
ThreadPool.UnsafeQueueUserWorkItem(_ =>
|
||||||
|
#else
|
||||||
|
ThreadPool.QueueUserWorkItem(_ =>
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
// Note that the current thread is now processing work items.
|
// Note that the current thread is now processing work items.
|
||||||
// This is necessary to enable inlining of tasks into this thread.
|
// This is necessary to enable inlining of tasks into this thread.
|
||||||
@@ -159,7 +159,11 @@ namespace Modbus.Net
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
#if NET40 || NET45 || NET451 || NET452
|
||||||
_socketClient.Close();
|
_socketClient.Close();
|
||||||
|
#else
|
||||||
|
_socketClient.Dispose();
|
||||||
|
#endif
|
||||||
AddInfo("client disconnected successfully.");
|
AddInfo("client disconnected successfully.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -313,9 +317,9 @@ namespace Modbus.Net
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
var stream = _socketClient.GetStream();
|
var stream = _socketClient.GetStream();
|
||||||
stream.Close();
|
stream.Dispose();
|
||||||
_socketClient.Client.Shutdown(SocketShutdown.Both);
|
_socketClient.Client.Shutdown(SocketShutdown.Both);
|
||||||
_socketClient.Client.Close();
|
_socketClient.Client.Dispose();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
16
README.md
16
README.md
@@ -3,7 +3,7 @@ Modbus.Net Oveview
|
|||||||
|
|
||||||
Overview
|
Overview
|
||||||
-------------------
|
-------------------
|
||||||
Modbus.Net is an open hardware communication platform written by C# 6.0.
|
Modbus.Net is an open hardware communication platform written by C# 7.0.
|
||||||
|
|
||||||
You can only focusing on the protocal itself, and the platform can automaticaly create a full asynchronized or synchronized communication library.
|
You can only focusing on the protocal itself, and the platform can automaticaly create a full asynchronized or synchronized communication library.
|
||||||
|
|
||||||
@@ -15,12 +15,13 @@ The real Modbus Implementation has been moved to Modbus.Net.Modbus. If you want
|
|||||||
|
|
||||||
There are also "Modbus.Net.Siemens" that can communicate to Siemens S7-200, S7-200 Smart, S7-300, S7-400, S7-1200, S7-1500 using PPI or TCP/IP.
|
There are also "Modbus.Net.Siemens" that can communicate to Siemens S7-200, S7-200 Smart, S7-300, S7-400, S7-1200, S7-1500 using PPI or TCP/IP.
|
||||||
|
|
||||||
"Modbus.Net.OPC" Implements OPC DA protocal.
|
"Modbus.Net.OPC" Implements OPC DA and OPC UA protocal.
|
||||||
|
|
||||||
Platform Supported
|
Platform Supported
|
||||||
-------------------
|
-------------------
|
||||||
* Visual Studio 2015
|
* Visual Studio 2017
|
||||||
* .Net Framework 4.5
|
* .Net Framework 4.5
|
||||||
|
* .Net Standard 1.5
|
||||||
|
|
||||||
##RoadMap
|
##RoadMap
|
||||||
|
|
||||||
@@ -43,14 +44,15 @@ Platform Supported
|
|||||||
* Name mode in TaskManager (Complete)
|
* Name mode in TaskManager (Complete)
|
||||||
|
|
||||||
###Version 1.2.4
|
###Version 1.2.4
|
||||||
* OPC UA Support (In Road)
|
* OPC UA Support (Complete)
|
||||||
|
* OPC Regex comparer for tags (Complete)
|
||||||
|
|
||||||
###Version 1.3.0
|
###Version 1.3.0
|
||||||
|
* .NET Core Support (Not complete)
|
||||||
|
|
||||||
|
###Version 1.4.0
|
||||||
* New Protocal Pipeline System (In Road)
|
* New Protocal Pipeline System (In Road)
|
||||||
* New ComConnector (In Road)
|
* New ComConnector (In Road)
|
||||||
* Multi station Modbus RTU, ASCII and Siemens PPI (In Road)
|
* Multi station Modbus RTU, ASCII and Siemens PPI (In Road)
|
||||||
* Siemens MPI Support (In Road)
|
* Siemens MPI Support (In Road)
|
||||||
* Github wiki Document (In Road)
|
* Github wiki Document (In Road)
|
||||||
|
|
||||||
###Version 1.4.0
|
|
||||||
* .NET Core Support (In Road)
|
|
||||||
Reference in New Issue
Block a user