This commit is contained in:
parallelbgls
2017-12-26 10:36:40 +08:00
parent 7ad440c9e5
commit f5a0a6533c
8 changed files with 16 additions and 18 deletions

View File

@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFrameworks>net45;netstandard20</TargetFrameworks> <TargetFrameworks>net45;netstandard2.0</TargetFrameworks>
<AssemblyName>Modbus.Net.Modbus</AssemblyName> <AssemblyName>Modbus.Net.Modbus</AssemblyName>
<RootNamespace>Modbus.Net.Modbus</RootNamespace> <RootNamespace>Modbus.Net.Modbus</RootNamespace>
<PackageId>Modbus.Net.Modbus</PackageId> <PackageId>Modbus.Net.Modbus</PackageId>
@@ -23,7 +23,7 @@
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DocumentationFile>bin\Debug\net45\Modbus.Net.Modbus.xml</DocumentationFile> <DocumentationFile>bin\Debug\Modbus.Net.Modbus.xml</DocumentationFile>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>

View File

@@ -31,7 +31,7 @@ namespace Modbus.Net.OPC
/// E.g: the tag `foo.bar` reads the tag `bar` on the folder `foo` /// E.g: the tag `foo.bar` reads the tag `bar` on the folder `foo`
/// </param> /// </param>
/// <returns>The value retrieved from the OPC</returns> /// <returns>The value retrieved from the OPC</returns>
T Read<T>(string tag); ReadEvent<T> Read<T>(string tag);
/// <summary> /// <summary>
/// Write a value on the specified opc tag /// Write a value on the specified opc tag
@@ -47,7 +47,7 @@ namespace Modbus.Net.OPC
/// <summary> /// <summary>
/// Read a tag asynchronusly /// Read a tag asynchronusly
/// </summary> /// </summary>
Task<T> ReadAsync<T>(string tag); Task<ReadEvent<T>> ReadAsync<T>(string tag);
/// <summary> /// <summary>
/// Write a value on the specified opc tag asynchronously /// Write a value on the specified opc tag asynchronously

View File

@@ -23,11 +23,11 @@
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DocumentationFile>bin\Debug\net45\Modbus.Net.OPC.xml</DocumentationFile> <DocumentationFile>bin\Debug\Modbus.Net.OPC.xml</DocumentationFile>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="H.Opc" Version="0.9.2" /> <PackageReference Include="H.Opc" Version="0.9.3" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@@ -90,11 +90,11 @@ namespace Modbus.Net.OPC
if (answerTag != null) if (answerTag != null)
{ {
var result = await Client.ReadAsync<object>(answerTag); var result = await Client.ReadAsync<object>(answerTag);
Log.Verbose($"Opc Machine {ConnectionToken} Read opc tag {answerTag} for value {result}"); Log.Verbose($"Opc Machine {ConnectionToken} Read opc tag {answerTag} for value {result.Value}");
return new OpcParamOut return new OpcParamOut
{ {
Success = true, Success = true,
Value = BigEndianValueHelper.Instance.GetBytes(result, result.GetType()) Value = BigEndianValueHelper.Instance.GetBytes(result.Value, result.Value.GetType())
}; };
} }
return new OpcParamOut return new OpcParamOut

View File

@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFrameworks>net45;netstandard20</TargetFrameworks> <TargetFrameworks>net45;netstandard2.0</TargetFrameworks>
<AssemblyName>Modbus.Net.Siemens</AssemblyName> <AssemblyName>Modbus.Net.Siemens</AssemblyName>
<RootNamespace>Modbus.Net.Siemens</RootNamespace> <RootNamespace>Modbus.Net.Siemens</RootNamespace>
<PackageId>Modbus.Net.Siemens</PackageId> <PackageId>Modbus.Net.Siemens</PackageId>
@@ -22,7 +22,7 @@
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DocumentationFile>bin\Debug\net45\Modbus.Net.Siemens.xml</DocumentationFile> <DocumentationFile>bin\Debug\Modbus.Net.Siemens.xml</DocumentationFile>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>

View File

@@ -3,7 +3,6 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using Serilog;
namespace Modbus.Net namespace Modbus.Net
{ {
@@ -121,8 +120,7 @@ namespace Modbus.Net
/// <returns>从等待队列中匹配的信息</returns> /// <returns>从等待队列中匹配的信息</returns>
protected abstract MessageWaitingDef GetMessageFromWaitingList(byte[] receiveMessage); protected abstract MessageWaitingDef GetMessageFromWaitingList(byte[] receiveMessage);
/// <inheritdoc cref="IController.ForceRemoveWaitingMessage(MessageWaitingDef)"/> /// <inheritdoc />
/// <param name="def"></param>
public void ForceRemoveWaitingMessage(MessageWaitingDef def) public void ForceRemoveWaitingMessage(MessageWaitingDef def)
{ {
lock (WaitingMessages) lock (WaitingMessages)

View File

@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFrameworks>net45;netstandard20</TargetFrameworks> <TargetFrameworks>net45;netstandard2.0</TargetFrameworks>
<AssemblyName>Modbus.Net</AssemblyName> <AssemblyName>Modbus.Net</AssemblyName>
<RootNamespace>Modbus.Net</RootNamespace> <RootNamespace>Modbus.Net</RootNamespace>
<PackageId>Modbus.Net</PackageId> <PackageId>Modbus.Net</PackageId>
@@ -23,7 +23,7 @@
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DocumentationFile>bin\Debug\net45\Modbus.Net.xml</DocumentationFile> <DocumentationFile>bin\Debug\Modbus.Net.xml</DocumentationFile>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
@@ -38,7 +38,7 @@
<Reference Include="System.Configuration" /> <Reference Include="System.Configuration" />
</ItemGroup> </ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard20' "> <ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0' ">
<PackageReference Include="Nito.AsyncEx.Tasks" Version="1.1.0" /> <PackageReference Include="Nito.AsyncEx.Tasks" Version="1.1.0" />
<PackageReference Include="Nito.AsyncEx.Coordination" Version="1.0.2" /> <PackageReference Include="Nito.AsyncEx.Coordination" Version="1.0.2" />
<PackageReference Include="System.Collections.NonGeneric" Version="4.3.0" /> <PackageReference Include="System.Collections.NonGeneric" Version="4.3.0" />

View File

@@ -310,10 +310,10 @@ namespace Modbus.Net.Tests
[TestMethod] [TestMethod]
public void TaskManagerGetMachineTest() public void TaskManagerGetMachineTest()
{ {
var machine = _taskManager.GetMachineById<int>(1); var machine = _taskManager.GetMachineById(1);
Assert.AreEqual(machine.MachineName, "Test 1"); Assert.AreEqual(machine.MachineName, "Test 1");
var machine2 = _taskManager.GetMachineByConnectionToken<int>("192.168.3.10"); var machine2 = _taskManager.GetMachineByConnectionToken("192.168.3.10");
Assert.AreEqual(machine2.MachineName, "Test 2"); Assert.AreEqual(machine2.MachineName, "Test 2");
} }