Skip to content

Commit

Permalink
Version 3.4-b3
Browse files Browse the repository at this point in the history
Updated WHATS_NEW, version numbers and dependencies
Added new IPC command to invalidate codes and files
Added new OM properties from RRF
Implemented support for file redirections of echo command
Minor refactoring
Bug fix: Under certain cirumstances prints could not be cancelled properly
  • Loading branch information
chrishamm committed Aug 24, 2021
1 parent 0fe6403 commit 6dd3b8a
Show file tree
Hide file tree
Showing 29 changed files with 220 additions and 53 deletions.
12 changes: 12 additions & 0 deletions WHATS_NEW.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
Summary of important changes in recent versions
===============================================

Version 3.4-b3
==============

New features:
- Implemented file redirections of the `echo` command (see [here](https://duet3d.dozuki.com/Wiki/GCode_Meta_Commands?revisionid=HEAD#Section_Echo_command))
- Added support for new `InvalidateChannel` command allowing plugins to cancel already queued codes and files

Bug fixes:
- Resolved race condition for M0/M1 which could cause stop.g to be executed instead of cancel.g
- Fixed an exception that could occur when codes were cancelled and their result was combined
- Under certain conditions paused prints could not be cancelled properly

Version 3.4-b2
==============

Expand Down
2 changes: 1 addition & 1 deletion src/CodeConsole/CodeConsole.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
<TrimUnusedDependencies>true</TrimUnusedDependencies>
<Version>3.4-b2</Version>
<Version>3.4-b3</Version>
<RepositoryType>git</RepositoryType>
<RepositoryUrl>https://github.com/Duet3D/DuetSoftwareFramework.git</RepositoryUrl>
<PackageLicenseExpression>GPL-3.0</PackageLicenseExpression>
Expand Down
2 changes: 1 addition & 1 deletion src/CodeLogger/CodeLogger.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
<TrimUnusedDependencies>true</TrimUnusedDependencies>
<Version>3.4-b2</Version>
<Version>3.4-b3</Version>
<RepositoryUrl>https://github.com/Duet3D/DuetSoftwareFramework.git</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<Authors>Christian Hammacher</Authors>
Expand Down
2 changes: 1 addition & 1 deletion src/CodeStream/CodeStream.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
<TrimUnusedDependencies>true</TrimUnusedDependencies>
<Version>3.4-b2</Version>
<Version>3.4-b3</Version>
<RepositoryType>git</RepositoryType>
<RepositoryUrl>https://github.com/Duet3D/DuetSoftwareFramework.git</RepositoryUrl>
<PackageLicenseExpression>GPL-3.0</PackageLicenseExpression>
Expand Down
2 changes: 1 addition & 1 deletion src/CustomHttpEndpoint/CustomHttpEndpoint.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
<Version>3.4-b2</Version>
<Version>3.4-b3</Version>
<RepositoryUrl>https://github.com/Duet3D/DuetSoftwareFramework.git</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<Authors>Christian Hammacher</Authors>
Expand Down
2 changes: 1 addition & 1 deletion src/DocGen/DocGen.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<LangVersion>default</LangVersion>
<Authors>Christian Hammacher</Authors>
<Company>Duet3D Ltd</Company>
<Version>3.4.0-b2</Version>
<Version>3.4-b3</Version>
<PackageLicenseExpression>GPL-3.0</PackageLicenseExpression>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<RepositoryUrl>https://github.com/Duet3D/DuetSoftwareFramework.git</RepositoryUrl>
Expand Down
2 changes: 1 addition & 1 deletion src/Documentation/Documentation.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="docfx.console" Version="2.58.0">
<PackageReference Include="docfx.console" Version="2.58.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
16 changes: 16 additions & 0 deletions src/DuetAPI/Commands/Generic/InvalidateChannel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using DuetAPI.Utility;

namespace DuetAPI.Commands
{
/// <summary>
/// Invalidate all pending codes and files on a given channel (including buffered codes from DSF in RepRapFirmware)
/// </summary>
[RequiredPermissions(SbcPermissions.CodeInterceptionReadWrite)]
public class InvalidateChannel : Command
{
/// <summary>
/// Code channel to invalidate
/// </summary>
public CodeChannel Channel { get; set; }
}
}
2 changes: 1 addition & 1 deletion src/DuetAPI/DuetAPI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<TargetFrameworks>net5.0</TargetFrameworks>
<Authors>Christian Hammacher</Authors>
<Company>Duet3D Ltd</Company>
<Version>3.4-b2</Version>
<Version>3.4-b3</Version>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<PackageLicenseExpression>LGPL-3.0-or-later</PackageLicenseExpression>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
Expand Down
1 change: 1 addition & 0 deletions src/DuetAPI/ObjectModel/Directories/Directories.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ public string Scans
/// <summary>
/// Path to the system directory
/// </summary>
[SbcProperty(true)]
public string System
{
get => _system;
Expand Down
20 changes: 20 additions & 0 deletions src/DuetAPI/ObjectModel/Move/Axis.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,26 @@ public bool MinProbed
}
private bool _minProbed;

/// <summary>
/// Percentage applied to the motor current (0..100)
/// </summary>
public int PercentCurrent
{
get => _percentCurrent;
set => SetPropertyValue(ref _percentCurrent, value);
}
private int _percentCurrent = 100;

/// <summary>
/// Percentage applied to the motor current during standstill (0..100 or null if not supported)
/// </summary>
public int? PercentStstCurrent
{
get => _percentStstCurrent;
set => SetPropertyValue(ref _percentStstCurrent, value);
}
private int? _percentStstCurrent;

/// <summary>
/// Maximum speed (in mm/min)
/// </summary>
Expand Down
20 changes: 20 additions & 0 deletions src/DuetAPI/ObjectModel/Move/Extruder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,26 @@ public float Jerk
/// </summary>
public ExtruderNonlinear Nonlinear { get; private set; } = new ExtruderNonlinear();

/// <summary>
/// Percentage applied to the motor current (0..100)
/// </summary>
public int PercentCurrent
{
get => _percentCurrent;
set => SetPropertyValue(ref _percentCurrent, value);
}
private int _percentCurrent = 100;

/// <summary>
/// Percentage applied to the motor current during standstill (0..100 or null if not supported)
/// </summary>
public int? PercentStstCurrent
{
get => _percentStstCurrent;
set => SetPropertyValue(ref _percentStstCurrent, value);
}
private int? _percentStstCurrent;

/// <summary>
/// Extruder position (in mm)
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion src/DuetAPIClient/DuetAPIClient.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<Company>Duet3D Ltd</Company>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<PackageLicenseExpression>LGPL-3.0-or-later</PackageLicenseExpression>
<Version>3.4-b2</Version>
<Version>3.4-b3</Version>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Description>Official client API library for Duet Software Framework (Duet 3) by Duet3D</Description>
<PackageProjectUrl>https://github.com/Duet3D/DuetSoftwareFramework</PackageProjectUrl>
Expand Down
78 changes: 77 additions & 1 deletion src/DuetControlServer/Codes/Keywords.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
using DuetAPI.Commands;
using DuetAPI.ObjectModel;
using DuetControlServer.Files;
using DuetControlServer.Model;
using System;
using System.IO;
using System.Threading.Tasks;
using Code = DuetControlServer.Commands.Code;

Expand Down Expand Up @@ -31,7 +33,81 @@ public static async Task<Message> Process(Code code)

if (code.Keyword == KeywordType.Echo || code.Keyword == KeywordType.Abort)
{
string result = string.IsNullOrEmpty(code.KeywordArgument) ? string.Empty : await Expressions.Evaluate(code, true);
string result = string.Empty;
if (code.Keyword == KeywordType.Echo && !string.IsNullOrEmpty(code.KeywordArgument))
{
string keywordArgument = code.KeywordArgument.TrimStart();
if (keywordArgument.StartsWith('>'))
{
// File redirection requested
bool append = keywordArgument.StartsWith(">>");
keywordArgument = keywordArgument.Substring(append ? 2 : 1).TrimStart();

// Get the file string or expression to write to
bool inQuotes = false, isComplete = false;
int numCurlyBraces = 0;
string filenameExpression = string.Empty;
for (int i = 0; i < keywordArgument.Length; i++)
{
char c = keywordArgument[i];
if (inQuotes)
{
if (c == '"')
{
inQuotes = false;
isComplete = (numCurlyBraces == 0);
}
}
else if (c == '"')
{
inQuotes = true;
}
else if (c == '{')
{
numCurlyBraces++;
}
else if (c == '}')
{
numCurlyBraces--;
isComplete = (numCurlyBraces == 0);
}
else if (char.IsWhiteSpace(c))
{
// Whitespaces after the initial > or >> are not permitted
isComplete = (numCurlyBraces == 0);
}

if (isComplete)
{
if (i == 0)
{
return new Message(MessageType.Error, "Missing filename for file redirection");
}

filenameExpression = keywordArgument[..(i + 1)];
code.KeywordArgument = keywordArgument[(i + 1)..];
break;
}
}

// Evaluate the filename and result to write
string filename = await Expressions.EvaluateExpression(code, filenameExpression, false, false);
string physicalFilename = await FilePath.ToPhysicalAsync(filename, FileDirectory.System);
result = await Expressions.Evaluate(code, true);

// Write it to the SD card
_logger.Debug("{0} '{1}' to {2}", append ? "Appending" : "Writing", result, filename);
using (FileStream fs = new(physicalFilename, append ? FileMode.Append : FileMode.Create, FileAccess.Write))
{
using StreamWriter writer = new(fs);
await writer.WriteLineAsync(result);
}

// Done
return new Message();
}
}
result = await Expressions.Evaluate(code, true);

if (code.Keyword == KeywordType.Abort)
{
Expand Down
36 changes: 36 additions & 0 deletions src/DuetControlServer/Commands/Generic/InvalidateChannel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using DuetControlServer.IPC;
using System;
using System.Threading.Tasks;

namespace DuetControlServer.Commands
{
/// <summary>
/// Implementation of the <see cref="DuetAPI.Commands.InvalidateChannel"/> command
/// </summary>
public sealed class InvalidateChannel : DuetAPI.Commands.InvalidateChannel, IConnectionCommand
{
/// <summary>
/// Source connection of this command
/// </summary>
public Connection Connection { get; set; }

/// <summary>
/// Wait for all pending codes of the given channel to finish
/// </summary>
/// <returns>Asynchronous task</returns>
public override async Task Execute()
{
// Check if the corresponding code channel has been disabled
using (await Model.Provider.AccessReadOnlyAsync())
{
if (Model.Provider.Get.Inputs[Channel] == null)
{
throw new InvalidOperationException("Requested code channel has been disabled");
}
}

// Wait for all codes and files to be invalidated
await SPI.Interface.AbortAll(Channel);
}
}
}
8 changes: 4 additions & 4 deletions src/DuetControlServer/Commands/Plugins/StartPlugins.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@ public override async Task Execute()
Channel = DuetAPI.CodeChannel.SBC,
Type = DuetAPI.Commands.CodeType.MCode,
MajorNumber = 98,
Parameters = new List<DuetAPI.Commands.CodeParameter>
{
new DuetAPI.Commands.CodeParameter('P', FilePath.DsfConfigFile)
}
Parameters = new()
{
new DuetAPI.Commands.CodeParameter('P', FilePath.DsfConfigFile)
}
};
await dsfConfigCode.Execute();
}
Expand Down
4 changes: 2 additions & 2 deletions src/DuetControlServer/DuetControlServer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<LangVersion>default</LangVersion>
<Authors>Christian Hammacher</Authors>
<Company>Duet3D Ltd</Company>
<Version>3.4-b2</Version>
<Version>3.4-b3</Version>
<PackageLicenseExpression>GPL-3.0</PackageLicenseExpression>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<RepositoryUrl>https://github.com/Duet3D/DuetSoftwareFramework.git</RepositoryUrl>
Expand All @@ -31,7 +31,7 @@
<ItemGroup>
<PackageReference Include="DynamicExpresso.Core" Version="2.8.1" />
<PackageReference Include="Nito.AsyncEx" Version="5.1.0" />
<PackageReference Include="NLog" Version="4.7.10" />
<PackageReference Include="NLog" Version="4.7.11" />
<PackageReference Include="SixLabors.ImageSharp" Version="1.0.3" />
</ItemGroup>

Expand Down
3 changes: 1 addition & 2 deletions src/DuetControlServer/FileExecution/Job.cs
Original file line number Diff line number Diff line change
Expand Up @@ -364,10 +364,9 @@ public static async Task Run()
using (await _lock.LockAsync(Program.CancellationToken))
{
// Notify RepRapFirmware that the print file has been closed
#warning FIXME Don't call StopPrint unless aborted from DSF
if (IsCancelled)
{
await SPI.Interface.StopPrint(PrintStoppedReason.UserCancelled);
// Prints are cancelled by M0/M1 which is processed by RRF
_logger.Info("Cancelled job file");
}
else if (IsAborted)
Expand Down
Loading

0 comments on commit 6dd3b8a

Please sign in to comment.