Skip to content

Commit

Permalink
Added tests for LogixElement.cs. Added register method to LogixSerial…
Browse files Browse the repository at this point in the history
…izer.cs. Updates some docs.
  • Loading branch information
tnunnink committed Nov 28, 2023
1 parent f3992a7 commit 5ce0fa4
Show file tree
Hide file tree
Showing 44 changed files with 1,354 additions and 93 deletions.
110 changes: 75 additions & 35 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: 4 additions & 2 deletions src/L5Sharp/Components/Task.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ public Task()
Priority = new TaskPriority(10);
Rate = new ScanRate(10);
Watchdog = new Watchdog(500);
InhibitTask = false;
DisableUpdateOutputs = false;
}

/// <summary>
Expand All @@ -51,7 +53,7 @@ public Task(XElement element) : base(element)
/// Gets the type of the task component (Continuous, Periodic, Event).
/// </summary>
/// <value>A <see cref="Enums.TaskType"/> enum representing the type of the task.</value>
public TaskType? Type
public TaskType Type
{
get => GetRequiredValue<TaskType>();
set => SetRequiredValue(value);
Expand Down Expand Up @@ -174,7 +176,7 @@ public void Schedule(string program)
}

/// <summary>
/// Removes the specified program name from the underlying list of <see cref="Scheduled"/>
/// Removes the specified program name from the underlying list of <see cref="Scheduled"/> programs.
/// </summary>
/// <param name="program">The name of the program to cancel.</param>
public void Cancel(string program)
Expand Down
25 changes: 25 additions & 0 deletions src/L5Sharp/Elements/DiagramElement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -149,4 +149,29 @@ public override bool Equals(object? obj)

/// <inheritdoc />
public override int GetHashCode() => ID.GetHashCode();

/// <summary>
/// Gets a collection of values for the specified attribute name parsed as the specified generic type parameter if it exists.
/// If the element does not exist, returns an empty collection of the generic type parameter.
/// </summary>
/// <param name="name">The name of the attribute.</param>
/// <param name="separator">The value separator character. Default is ' '.</param>
/// <typeparam name="T">The return type of the value.</typeparam>
/// <returns>
/// If found, all values of the attribute split on the specified separator and parsed as the generic type parameter.
/// If not found, returns an empty collection.
/// </returns>
/// <remarks>
/// This method makes getting/setting attributes with collection of values as a single string with a certain separator
/// character as concise as possible for derived classes. This method is added here since only types like <see cref="Block"/>
/// are using this method overload.
/// </remarks>
protected IEnumerable<T> GetValues<T>(string name, char separator = ' ')
{
var value = Element.Attribute(name)?.Value;

return value is not null
? value.Split(separator, StringSplitOptions.RemoveEmptyEntries).Select(v => v.Parse<T>())
: Enumerable.Empty<T>();
}
}
6 changes: 3 additions & 3 deletions src/L5Sharp/L5Sharp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
<Title>L5Sharp</Title>
<Authors>Timothy Nunnink</Authors>
<Version>0.16.0</Version>
<AssemblyVersion>0.16.0</AssemblyVersion>
<FileVersion>0.16.0.0</FileVersion>
<Version>0.16.1</Version>
<AssemblyVersion>0.16.1</AssemblyVersion>
<FileVersion>0.16.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>
Expand Down
Loading

0 comments on commit 5ce0fa4

Please sign in to comment.