Add plc series types to support FP7 and EcoLogiX

- add new checksum calculation for Mewtocol 7
This commit is contained in:
Felix Weiß
2023-07-07 16:37:04 +02:00
parent 2615f8c428
commit 5d6cef91ec
9 changed files with 253 additions and 33 deletions

View File

@@ -0,0 +1,40 @@
using MewtocolNet;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xunit;
using Xunit.Abstractions;
namespace MewtocolTests;
public class BCCBuilderChecks {
private readonly ITestOutputHelper output;
public BCCBuilderChecks (ITestOutputHelper output) {
this.output = output;
}
[Fact(DisplayName = "Test CRC Generation (CRC-8)")]
public void BuildBCCFrameGeneration() {
string test = "%01#RCSX0000";
string expect = "%01#RCSX00001D";
Assert.Equal(expect, test.BCC_Mew());
}
[Fact(DisplayName = "Test CRC Generation (CRC-16/MCRF4XX)")]
public void BuildBCC7FrameGeneration() {
string test = ">@EEE00$30STRD00070300000453045304530100000000660100";
string expect = ">@EEE00$30STRD00070300000453045304530100000000660100A7A5";
Assert.Equal(expect, test.BCC_Mew7());
}
}

View File

@@ -66,16 +66,6 @@ namespace MewtocolTests {
}
[Fact(DisplayName = nameof(MewtocolHelpers.BuildBCCFrame))]
public void BuildBCCFrameGeneration() {
string test = "%01#RCSX0000";
string expect = "%01#RCSX00001D";
Assert.Equal(expect, test.BuildBCCFrame());
}
[Fact(DisplayName = nameof(MewtocolHelpers.ParseDTByteString))]
public void ParseDTByteStringGeneration() {
@@ -87,7 +77,7 @@ namespace MewtocolTests {
foreach (var item in testList) {
Assert.Equal(item, $"%01$RD{item}".BuildBCCFrame().ParseDTByteString());
Assert.Equal(item, $"%01$RD{item}".BCC_Mew().ParseDTByteString());
}
@@ -96,8 +86,8 @@ namespace MewtocolTests {
[Fact(DisplayName = nameof(MewtocolHelpers.ParseRCSingleBit))]
public void ParseRCSingleBitGeneration() {
Assert.True($"%01$RC1".BuildBCCFrame().ParseRCSingleBit());
Assert.False($"%01$RC0".BuildBCCFrame().ParseRCSingleBit());
Assert.True($"%01$RC1".BCC_Mew().ParseRCSingleBit());
Assert.False($"%01$RC0".BCC_Mew().ParseRCSingleBit());
}