Skip to content

Commit

Permalink
Updated some docs. Added new LogixEnum.cs base class so that we can h…
Browse files Browse the repository at this point in the history
…ave a set of methods for retrieving enumeration options by just providing a Type instance and not using generic type definitions. This simplifies patter matching and gives us a nicer base for all enums. Added and fixed tests.
  • Loading branch information
tnunnink committed Dec 29, 2023
1 parent 80a6ee4 commit ed4e5d0
Show file tree
Hide file tree
Showing 8 changed files with 274 additions and 84 deletions.
30 changes: 17 additions & 13 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.

6 changes: 3 additions & 3 deletions src/L5Sharp.Core/Common/Instruction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ private Instruction(string key, string? signature = null, params Argument[] argu
/// The collection of operand names found in the signature of the instruction.
/// </summary>
///
public IEnumerable<string> Operadns
public IEnumerable<string> Operands
{
get
{
Expand Down Expand Up @@ -143,7 +143,7 @@ public IEnumerable<string> Operadns
/// <summary>
/// Indicates whether the instruction argument cound matches the operand count.
/// </summary>
public bool IsValid => Key is nameof(JSR) or nameof(SBR) or nameof(RET) || Operadns.Count() == Arguments.Count();
public bool IsValid => Key is nameof(JSR) or nameof(SBR) or nameof(RET) || Operands.Count() == Arguments.Count();

/// <summary>
/// Creates a new <see cref="Instruction"/> with the provided key and optional arguments.
Expand Down Expand Up @@ -207,7 +207,7 @@ public static Instruction Parse(string text)
/// <returns>A <see cref="Argument"/> representing the value passed </returns>
public Argument? GetArgument(string operand)
{
var index = Operadns.ToList().IndexOf(operand);
var index = Operands.ToList().IndexOf(operand);
return index >= 0 ? Arguments.ElementAt(index) : default;
}

Expand Down
27 changes: 10 additions & 17 deletions src/L5Sharp.Core/Components/DataType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,18 @@
namespace L5Sharp.Core;

/// <summary>
/// A logix <c>DataType</c> component. Contains the properties that comprise the L5X DataType element.
/// The Logix <c>DataType</c> component. Contains the properties adn functionality that comprise the L5X DataType element.
/// </summary>
/// <remarks>
/// Observe these guidelines when defining a DataType:<br/>
/// • DataTypes must be defined first within the controller body.<br/>
/// • DataTypes can be defined out of order. For example, if Type1 depends on Type2, Type2 can be defined first.<br/>
/// • DataTypes can be unverified. For example if Type1 depends on Type2 and Type2 is never defined, then Type1<br/>
/// will be accessible as an unverified type. Type2 will be typeless type. Tags of Type1 may be created but not of Type2.<br/>
/// • Datatype members can be arrays but only one dimension is allowed.<br/>
/// • These DataTypes cannot be used in a user-defined datatype:<br/>
/// • ALARM_ANALOG<br/>
/// • ALARM_DIGITAL<br/>
/// • AXIS types<br/>
/// • COORDINATE_SYSTEM<br/>
/// • MOTION_GROUP<br/>
/// • MESSAGE<br/>
/// • MODULE<br/>
/// • If one user-defined datatype references a second user-defined datatype defined in the file, the second<br/>
/// user-defined datatype appears before the first one in the import/export file.<br/>
/// <para>
/// A DataType represents a user defined type structure that one can define and reuse within a PLC project.
/// This type inherits <see cref="LogixComponent"/> which specifies <c>Name</c> and <c>Description</c> properties along with other
/// common component functionality. DataTypes also contain <see cref="Members"/> that define the structure of the
/// complex type. This class does not actually represent the type value, but rather the configuration of how a tag structure
/// would look if it referenced this type.
/// </para>
/// <para>DataType components can be defined out of order within an L5X. This means a type that is dependent on another
/// type can be defined first and Logix will import just fine.</para>
/// </remarks>
/// <footer>
/// See <a href="https://literature.rockwellautomation.com/idc/groups/literature/documents/rm/1756-rm084_-en-p.pdf">
Expand Down
8 changes: 4 additions & 4 deletions src/L5Sharp.Core/L5Sharp.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
<Title>L5Sharp</Title>
<Authors>Timothy Nunnink</Authors>
<Version>0.18.0</Version>
<AssemblyVersion>0.18.0</AssemblyVersion>
<FileVersion>0.18.0.0</FileVersion>
<Version>0.18.1</Version>
<AssemblyVersion>0.18.1</AssemblyVersion>
<FileVersion>0.18.1.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>Renamed conflicting properties in WatchTag. Documentation updates.</PackageReleaseNotes>
<PackageReleaseNotes>Added new LogixEnum base class abstraction to allow callers to get options by Type.</PackageReleaseNotes>
<Copyright>Copyright (c) Timothy Nunnink 2022</Copyright>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageId>L5Sharp</PackageId>
Expand Down
Loading

0 comments on commit ed4e5d0

Please sign in to comment.