Skip to content

Commit

Permalink
Removed member constructor since it was causing a bunch of errors and…
Browse files Browse the repository at this point in the history
… it was not really needed. Fixed tests.
  • Loading branch information
tnunnink committed May 4, 2024
1 parent c07bc8e commit 751d186
Show file tree
Hide file tree
Showing 11 changed files with 18 additions and 211 deletions.
186 changes: 7 additions & 179 deletions src/.idea/.idea.L5Sharp/.idea/workspace.xml

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions src/L5Sharp.Core/Components/Module.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ public Module() : base(L5XName.Module)
{
CatalogNumber = string.Empty;
Revision = new Revision();
Vendor = Vendor.Rockwell;
ProductType = ProductType.Unknown;
ParentModule = string.Empty;
ParentModPortId = default;
Inhibited = false;
Expand Down
16 changes: 0 additions & 16 deletions src/L5Sharp.Core/Data/Member.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,20 +51,6 @@ public Member(string name, LogixData data) : base(CreateMember(name, data))
{
}

/// <summary>
/// Creates a new <see cref="Member"/> object with the provided name and data type name.
/// </summary>
/// <param name="name">The name of the member.</param>
/// <param name="dataType">The name of the data type for the member.</param>
/// <remarks>
/// This constructor will use the <see cref="LogixData.Create(string)"/> factory method to instantiate a new instance
/// of the specified type. If <paramref name="dataType"/> represents a complex type that is not statically defined,
/// it will defualt to creating a <see cref="ComplexData"/> instance having the provided name.
/// </remarks>
public Member(string name, string dataType) : base(CreateMember(name, LogixData.Create(dataType)))
{
}

/// <inheritdoc />
/// <remarks>
/// Internal will make <see cref="Member"/> not something that is deserializable since we only look for public
Expand Down Expand Up @@ -168,8 +154,6 @@ protected override void SetData(LogixData? data)
//Otherwise this is a normal decorated data element, and we need to handle the set based on the current value.
switch (Value)
{
case NullData: //todo perhaps make a decision on if this should or should not be here.
throw new InvalidOperationException("The member data is null and can not be... ");
case AtomicData:
var atomicType = (AtomicData)data;
SetAtomic(atomicType);
Expand Down
2 changes: 1 addition & 1 deletion src/L5Sharp.Core/Elements/DataTypeMember.cs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ public int? BitNumber
/// not attached or the L5X does not container the data type reference, this will return a default component with the
/// name specified by this member.
/// </remarks>
public DataType Definition => GetDefinition(); //todo we need to handle atomic types
public DataType Definition => GetDefinition();

/// <summary>
/// Converts the current instance of <see cref="DataTypeMember"/> to a <see cref="Member"/>.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
<Module Name="" CatalogNumber="" Vendor="0" ProductType="0" ProductCode="0" Major="1" Minor="0" ParentModule="" ParentModPortId="0" Inhibited="false" MajorFault="false" SafetyEnabled="false">
<Module Name="" CatalogNumber="" Major="1" Minor="0" Vendor="1" ProductType="0" ParentModule="" ParentModPortId="0" Inhibited="false" MajorFault="false" SafetyEnabled="false">
<EKey State="CompatibleModule" />
<Ports />
<Communications>
<ConfigTag />
<Connections />
</Communications>
</Module>
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
<Module Name="Test" CatalogNumber="ABCD-1234" Vendor="1" ProductType="10" ProductCode="1" Major="1" Minor="3" ParentModule="Local" ParentModPortId="1" Inhibited="true" MajorFault="true" SafetyEnabled="true">
<Module Name="Test" CatalogNumber="ABCD-1234" Major="1" Minor="3" Vendor="1" ProductType="10" ParentModule="Local" ParentModPortId="1" Inhibited="true" MajorFault="true" SafetyEnabled="true" ProductCode="1">
<Description><![CDATA[This is a test module]]></Description>
<EKey State="Disabled" />
<Ports>
<Port Id="1" Type="ICP" Address="1" Upstream="true" />
</Ports>
<Communications>
<ConfigTag />
<Connections />
</Communications>
</Module>
2 changes: 1 addition & 1 deletion tests/L5Sharp.Tests/Components/ModuleTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public void New_Default_ShouldHaveExpectedValues()
module.Description.Should().BeNull();
module.CatalogNumber.Should().BeEmpty();
module.Revision.Should().Be("1.0");
module.Vendor.Should().Be(Vendor.Unknown);
module.Vendor.Should().Be(Vendor.Rockwell);
module.ProductType.Should().Be(ProductType.Unknown);
module.ProductCode.Should().Be(0);
module.ParentModule.Should().BeEmpty();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<RSLogix5000Content SchemaRevision="1.0" TargetName="Test" TargetType="Controller" ContainsContext="false" Owner="tnunn">
<Controller Name="Test" ProcessorType="1756-L84E">
<RSLogix5000Content SchemaRevision="1.0" SoftwareRevision="33.1" TargetName="Test" TargetType="Controller" ContainsContext="false" Owner="tnunn">
<Controller Name="Test" Use="Target" MajorRev="33" MinorRev="1" ProcessorType="1756-L84E">
<DataTypes />
<Modules />
<AddOnInstructionDefinitions />
Expand Down
2 changes: 2 additions & 0 deletions tests/L5Sharp.Tests/Components/TaskTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,8 @@ public Task AddProgram_ValidProgram_ShouldBeVerified()
var xml = content.Serialize().ToString();

return VerifyXml(xml)
.IgnoreMember("ProjectCreationDate")
.IgnoreMember("LastModifiedDate")
.IgnoreMember("ExportDate");
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/L5Sharp.Tests/Data/ComplexDataTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ public void AddRange_ValidMembers_ShouldHaveExpectedMember()
{
new("Atomic", 123),
new("String", "Test Value"),
new("Structure", new TIMER { PRE = 2000 }),
new("Structure", new TIMER { PRE = 2000 })
};
var type = new ComplexData();

Expand Down
1 change: 0 additions & 1 deletion tests/L5Sharp.Tests/L5XBasicTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ public void New_WithControllerAndProcessorNames_ShouldNotBeNullAndExpectedValues
content.Controller.Name.Should().Be("ControllerName");
content.Controller.ProcessorType.Should().Be("1756-L83E");
content.Controller.Revision.Should().BeEquivalentTo(new Revision(33, 1));
content.Modules.Should().HaveCount(1);
}

[Test]
Expand Down

0 comments on commit 751d186

Please sign in to comment.