Skip to content

Commit

Permalink
Added ComponentClass.cs. Working on adding IParse to components.
Browse files Browse the repository at this point in the history
  • Loading branch information
tnunnink committed Mar 9, 2024
1 parent 8ce0a13 commit 3c16bf1
Show file tree
Hide file tree
Showing 16 changed files with 183 additions and 81 deletions.
59 changes: 31 additions & 28 deletions src/.idea/.idea.L5Sharp/.idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions src/L5Sharp.Core/Components/AddOnInstruction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,19 @@ public AddOnInstruction() : base(new XElement(L5XName.AddOnInstructionDefinition
public AddOnInstruction(XElement element) : base(element)
{
}

/// <summary>
/// The <see cref="ComponentClass"/> value indicating whether this component is a standard or safety type component.
/// </summary>
/// <value>A <see cref="Core.ComponentClass"/> option representing class of the component.</value>
/// <remarks>
/// Specify the class of the Add-On Instruction. This attribute applies only to safety controller projects.
/// </remarks>
public ComponentClass? Class
{
get => GetValue<ComponentClass>();
set => SetValue(value);
}

/// <summary>
/// The revision of the instruction.
Expand Down
14 changes: 14 additions & 0 deletions src/L5Sharp.Core/Components/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,20 @@ public ProgramType Type
get => GetValue<ProgramType>() ?? ProgramType.Normal;
set => SetValue(value);
}

/// <summary>
/// The <see cref="ComponentClass"/> value indicating whether this component is a standard or safety type component.
/// </summary>
/// <value>A <see cref="Core.ComponentClass"/> option representing class of the component.</value>
/// <remarks>
/// Specify the class of the program. This attribute applies only to safety controller projects.
/// Do not use this attribute if the program is an Equipment Phase program.
/// </remarks>
public ComponentClass? Class
{
get => GetValue<ComponentClass>();
set => SetValue(value);
}

/// <summary>
/// The value indicating whether the program has current test edits pending.
Expand Down
23 changes: 17 additions & 6 deletions src/L5Sharp.Core/Components/Tag.cs
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,17 @@ public ExternalAccess? ExternalAccess
set => SetValue(value);
}

/// <summary>
/// The <see cref="ComponentClass"/> value indicating whether this component is a standard or safety type component.
/// </summary>
/// <value>A <see cref="Core.ComponentClass"/> option representing class of the component.</value>
/// <remarks>Specify the class of the tag. This attribute applies only to safety controller projects.</remarks>
public ComponentClass? Class
{
get => GetValue<ComponentClass>();
set => SetValue(value);
}

/// <summary>
/// A type indicating whether the current tag component is a base tag, or alias for another tag instance.
/// </summary>
Expand Down Expand Up @@ -214,7 +225,7 @@ public bool? Constant
get => GetValue<bool?>();
set => SetValue(value);
}

/// <summary>
/// The <see cref="Core.ProduceInfo"/> defining the configuration for a produced tag.
/// </summary>
Expand All @@ -228,7 +239,7 @@ public ProduceInfo? ProduceInfo
get => GetComplex<ProduceInfo>();
set => SetComplex(value);
}

/// <summary>
/// The <see cref="Core.ConsumeInfo"/> defining the configuration for a consumed tag.
/// </summary>
Expand Down Expand Up @@ -330,7 +341,7 @@ public Tag this[TagName tagName]
return remaining.IsEmpty ? tag : tag[remaining];
}
}

/// <summary>
/// Adds a new member to the tag's complex data structure.
/// </summary>
Expand Down Expand Up @@ -481,8 +492,8 @@ public IEnumerable<Tag> MembersOf(TagName tagName)
/// <typeparam name="TLogixType">The logix data type of the tag. Type must have parameterless constructor to create.</typeparam>
/// <returns>A new <see cref="Tag"/> object with specified parameters.</returns>
public static Tag New<TLogixType>(string name) where TLogixType : LogixType, new() =>
new() {Name = name, Value = new TLogixType()};
new() { Name = name, Value = new TLogixType() };

/// <summary>
/// Removes a member with the specified name from the tag's complex data structure.
/// </summary>
Expand All @@ -499,7 +510,7 @@ public void Remove(string name)
throw new InvalidOperationException("Can only mutate ComplexType tags.");
complexType.Remove(name);
}

/// <summary>
/// Returns a collection of all descendent tag names of the current <c>Tag</c>, including the tag name of the
/// this <c>Tag</c>.
Expand Down
23 changes: 19 additions & 4 deletions src/L5Sharp.Core/Components/Task.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Xml.Linq;
using JetBrains.Annotations;

namespace L5Sharp.Core;

Expand All @@ -20,6 +21,7 @@ namespace L5Sharp.Core;
/// See <a href="https://literature.rockwellautomation.com/idc/groups/literature/documents/rm/1756-rm084_-en-p.pdf">
/// `Logix 5000 Controllers Import/Export`</a> for more information.
/// </footer>
[PublicAPI]
public class Task : LogixComponent
{
/// <summary>
Expand Down Expand Up @@ -56,6 +58,19 @@ public TaskType Type
set => SetRequiredValue(value);
}

/// <summary>
/// The <see cref="ComponentClass"/> value indicating whether this component is a standard or safety type component.
/// </summary>
/// <value>A <see cref="Core.ComponentClass"/> option representing class of the component.</value>
/// <remarks>
/// Specify the class of the task. This attribute applies only to safety controller projects.
/// </remarks>
public ComponentClass? Class
{
get => GetValue<ComponentClass>();
set => SetValue(value);
}

/// <summary>
/// The scan priority of the task component. Default of 10.
/// </summary>
Expand Down Expand Up @@ -117,7 +132,7 @@ public TaskEventTrigger? EventTrigger
get => GetValue<TaskEventTrigger>(L5XName.EventInfo.XName());
set => SetValue(value, L5XName.EventInfo.XName());
}

/// <summary>
/// The tag name that the event task consumes. Only used for event tasks.
/// </summary>
Expand All @@ -130,7 +145,7 @@ public TagName? EventTag
get => GetValue<TagName>(L5XName.EventInfo.XName());
set => SetValue(value, L5XName.EventInfo.XName());
}

/// <summary>
/// The value indicating whether timeouts are enabled for the event task. Only used for event tasks.
/// </summary>
Expand Down Expand Up @@ -175,12 +190,12 @@ public override L5X Export(Revision? softwareRevision = null)
public override void Delete()
{
if (Element.Parent is null || !IsAttached) return;

foreach (var program in Programs)
{
program.Delete();
}

Element.Remove();
}

Expand Down
21 changes: 21 additions & 0 deletions src/L5Sharp.Core/Enums/ComponentClass.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
namespace L5Sharp.Core;

/// <summary>
/// An enumeration of all <see cref="ComponentClass"/> for a various components.
/// </summary>
public class ComponentClass : LogixEnum<ComponentClass, string>
{
private ComponentClass(string name, string value) : base(name, value)
{
}

/// <summary>
/// Represents a <b>Standard</b> <see cref="ComponentClass"/> value.
/// </summary>
public static readonly ComponentClass Standard = new(nameof(Standard), nameof(Standard));

/// <summary>
/// Represents a <b>Safety</b> <see cref="ConnectionPriority"/> value.
/// </summary>
public static readonly ComponentClass Safety = new(nameof(Safety), nameof(Safety));
}
8 changes: 4 additions & 4 deletions src/L5Sharp.Core/L5Sharp.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
<Title>L5Sharp</Title>
<Authors>Timothy Nunnink</Authors>
<Version>0.19.4</Version>
<AssemblyVersion>0.19.4</AssemblyVersion>
<FileVersion>0.19.4.0</FileVersion>
<Version>0.19.5</Version>
<AssemblyVersion>0.19.5</AssemblyVersion>
<FileVersion>0.19.5.0</FileVersion>
<Description>A library for intuitively interacting with Rockwell's L5X import/export files.</Description>
<RepositoryUrl>https://github.com/tnunnink/L5Sharp</RepositoryUrl>
<PackageTags>csharp allen-bradely l5x logix plc-programming rockwell-automation logix5000</PackageTags>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<!--<PackageIcon>icon.png</PackageIcon>-->
<RepositoryType>git</RepositoryType>
<PackageReleaseNotes>Bug fix to the LogixParser.cs TryParse</PackageReleaseNotes>
<PackageReleaseNotes>Added ComponentClass enum to component classes.</PackageReleaseNotes>
<Copyright>Copyright (c) Timothy Nunnink 2022</Copyright>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageId>L5Sharp</PackageId>
Expand Down
Loading

0 comments on commit 3c16bf1

Please sign in to comment.