@@ -139,4 +139,83 @@ public sealed class AbLegacyAddressTests
|
||||
AbLegacyPlcFamilyProfile.MicroLogix.OctalIoAddressing.ShouldBeFalse();
|
||||
AbLegacyPlcFamilyProfile.LogixPccc.OctalIoAddressing.ShouldBeFalse();
|
||||
}
|
||||
|
||||
// ---- MicroLogix function-file letters (Issue #245) ----
|
||||
//
|
||||
// MicroLogix 1100/1400 expose RTC/HSC/DLS/MMI/PTO/PWM/STI/EII/IOS/BHI function files. Other
|
||||
// PCCC families (SLC500 / PLC-5 / LogixPccc) reject those file letters.
|
||||
|
||||
[Theory]
|
||||
[InlineData("RTC:0.HR", "RTC", "HR")]
|
||||
[InlineData("RTC:0.MIN", "RTC", "MIN")]
|
||||
[InlineData("RTC:0.YR", "RTC", "YR")]
|
||||
[InlineData("HSC:0.ACC", "HSC", "ACC")]
|
||||
[InlineData("HSC:0.PRE", "HSC", "PRE")]
|
||||
[InlineData("HSC:0.EN", "HSC", "EN")]
|
||||
[InlineData("DLS:0.STR", "DLS", "STR")]
|
||||
[InlineData("PTO:0.OF", "PTO", "OF")]
|
||||
[InlineData("PWM:0.EN", "PWM", "EN")]
|
||||
[InlineData("STI:0.SPM", "STI", "SPM")]
|
||||
[InlineData("EII:0.PFN", "EII", "PFN")]
|
||||
[InlineData("MMI:0.FT", "MMI", "FT")]
|
||||
[InlineData("BHI:0.OS", "BHI", "OS")]
|
||||
[InlineData("IOS:0.ID", "IOS", "ID")]
|
||||
public void TryParse_MicroLogix_accepts_function_files(string input, string expectedLetter, string expectedSub)
|
||||
{
|
||||
var a = AbLegacyAddress.TryParse(input, AbLegacyPlcFamily.MicroLogix);
|
||||
a.ShouldNotBeNull();
|
||||
a.FileLetter.ShouldBe(expectedLetter);
|
||||
a.SubElement.ShouldBe(expectedSub);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("RTC:0.HR")]
|
||||
[InlineData("HSC:0.ACC")]
|
||||
[InlineData("PTO:0.OF")]
|
||||
[InlineData("BHI:0.OS")]
|
||||
public void TryParse_Slc500_rejects_function_files(string input)
|
||||
{
|
||||
AbLegacyAddress.TryParse(input, AbLegacyPlcFamily.Slc500).ShouldBeNull();
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("RTC:0.HR")]
|
||||
[InlineData("HSC:0.ACC")]
|
||||
public void TryParse_Plc5_and_LogixPccc_reject_function_files(string input)
|
||||
{
|
||||
AbLegacyAddress.TryParse(input, AbLegacyPlcFamily.Plc5).ShouldBeNull();
|
||||
AbLegacyAddress.TryParse(input, AbLegacyPlcFamily.LogixPccc).ShouldBeNull();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TryParse_Default_overload_rejects_function_files()
|
||||
{
|
||||
// Without a family the parser cannot allow MicroLogix-only letters — back-compat with
|
||||
// the family-less overload from before #244.
|
||||
AbLegacyAddress.TryParse("RTC:0.HR").ShouldBeNull();
|
||||
AbLegacyAddress.TryParse("HSC:0.ACC").ShouldBeNull();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void MicroLogixProfile_advertises_function_file_support()
|
||||
{
|
||||
AbLegacyPlcFamilyProfile.MicroLogix.SupportsFunctionFiles.ShouldBeTrue();
|
||||
AbLegacyPlcFamilyProfile.Slc500.SupportsFunctionFiles.ShouldBeFalse();
|
||||
AbLegacyPlcFamilyProfile.Plc5.SupportsFunctionFiles.ShouldBeFalse();
|
||||
AbLegacyPlcFamilyProfile.LogixPccc.SupportsFunctionFiles.ShouldBeFalse();
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("RTC", "HR", ZB.MOM.WW.OtOpcUa.Core.Abstractions.DriverDataType.Int32)]
|
||||
[InlineData("RTC", "EN", ZB.MOM.WW.OtOpcUa.Core.Abstractions.DriverDataType.Boolean)]
|
||||
[InlineData("HSC", "ACC", ZB.MOM.WW.OtOpcUa.Core.Abstractions.DriverDataType.Int32)]
|
||||
[InlineData("HSC", "EN", ZB.MOM.WW.OtOpcUa.Core.Abstractions.DriverDataType.Boolean)]
|
||||
[InlineData("DLS", "STR", ZB.MOM.WW.OtOpcUa.Core.Abstractions.DriverDataType.Int32)]
|
||||
[InlineData("DLS", "EN", ZB.MOM.WW.OtOpcUa.Core.Abstractions.DriverDataType.Boolean)]
|
||||
[InlineData("PWM", "OUT", ZB.MOM.WW.OtOpcUa.Core.Abstractions.DriverDataType.Boolean)]
|
||||
public void FunctionFile_subelement_catalogue_maps_to_expected_driver_type(
|
||||
string letter, string sub, ZB.MOM.WW.OtOpcUa.Core.Abstractions.DriverDataType expected)
|
||||
{
|
||||
AbLegacyFunctionFile.SubElementType(letter, sub).ShouldBe(expected);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user