-
Notifications
You must be signed in to change notification settings - Fork 426
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Added a first test for the decoder
- Fixed issues in the float and double processing of the ReadBuffer - Made the PlcValues comparable for equality
- Loading branch information
Showing
29 changed files
with
449 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
sandbox/plc4net/drivers/knxnetip-test/plc4net-driver-knxproj-test.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<!-- | ||
Licensed to the Apache Software Foundation (ASF) under one | ||
or more contributor license agreements. See the NOTICE file | ||
distributed with this work for additional information | ||
regarding copyright ownership. The ASF licenses this file | ||
to you under the Apache License, Version 2.0 (the | ||
"License"); you may not use this file except in compliance | ||
with the License. You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, | ||
software distributed under the License is distributed on an | ||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
KIND, either express or implied. See the License for the | ||
specific language governing permissions and limitations | ||
under the License. | ||
--> | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net452</TargetFramework> | ||
<RootNamespace>org.apache.plc4net</RootNamespace> | ||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild> | ||
<Authors>Apache PLC4X</Authors> | ||
<Copyright>The Apache Software Foundation</Copyright> | ||
<PackageProjectUrl>https://plc4x.apache.org</PackageProjectUrl> | ||
<Title>PLC4Net: Driver: KNXNet/IP: Test</Title> | ||
<PackageLicenseUrl>https://www.apache.org/licenses/LICENSE-2.0</PackageLicenseUrl> | ||
<PackageVersion>0.8.0-SNAPSHOT</PackageVersion> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="xunit" Version="2.4.1" /> | ||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3"> | ||
<PrivateAssets>all</PrivateAssets> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
</PackageReference> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\knxnetip\plc4net-driver-knxproj.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
File renamed without changes.
42 changes: 42 additions & 0 deletions
42
sandbox/plc4net/drivers/knxnetip-test/test/knxnetip/readwrite/model/KnxDatapointTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using org.apache.plc4net.api.value; | ||
using org.apache.plc4net.drivers.knxnetip.readwrite.model; | ||
using org.apache.plc4net.spi.generation; | ||
using org.apache.plc4net.spi.model.values; | ||
using Xunit; | ||
|
||
namespace org.apache.plc4net.test.knxnetip.readwrite.model | ||
{ | ||
public class KnxDatapointTests | ||
{ | ||
[Fact] | ||
public void DecodeKnxData1() | ||
{ | ||
var formatName = "F32"; | ||
var input = StrToByteArray("0041b00000"); | ||
IPlcValue expected = new PlcREAL(22.0f); | ||
|
||
var actual = new KnxDatapoint().Parse(new ReadBuffer(input), formatName); | ||
|
||
Assert.Equal(expected, actual); | ||
} | ||
|
||
private static byte[] StrToByteArray(string str) | ||
{ | ||
var hexIndex = new Dictionary<string, byte>(); | ||
for (var i = 0; i <= 255; i++) | ||
{ | ||
hexIndex.Add(i.ToString("X2"), (byte) i); | ||
} | ||
|
||
var hexRes = new List<byte>(); | ||
for (var i = 0; i < str.Length; i += 2) | ||
{ | ||
hexRes.Add(hexIndex[str.Substring(i, 2).ToUpper()]); | ||
} | ||
return hexRes.ToArray(); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.