Skip to content

Commit

Permalink
Version 3.4-b6
Browse files Browse the repository at this point in the history
Added new OM key for move segmentation
Codes being printed are output as part of the diagnostics
Bug fix: Files starting with digits (but no file paths) could lead to exceptions
Bug fix: If the first or last G1 Z parameter were an expression, the file info may not be parsed
Bug fix: Model dictionaries were not cleared when they were set to null (e.g. global variables)
  • Loading branch information
chrishamm committed Nov 6, 2021
1 parent ebed71e commit 760388f
Show file tree
Hide file tree
Showing 12 changed files with 65 additions and 18 deletions.
1 change: 1 addition & 0 deletions src/DuetAPI/ObjectModel/Base/ModelDictionary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ public void Clear()
}
else
{
_dictionary.Clear();
DictionaryCleared?.Invoke(this, new EventArgs());
}
}
Expand Down
10 changes: 10 additions & 0 deletions src/DuetAPI/ObjectModel/Move/Kinematics/Kinematics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@ public KinematicsName Name
}
private KinematicsName _name = KinematicsName.Unknown;

/// <summary>
/// Segmentation parameters or null if not configured
/// </summary>
public MoveSegmentation Segmentation
{
get => _segmentation;
set => SetPropertyValue(ref _segmentation, value);
}
private MoveSegmentation _segmentation;

/// <summary>
/// Figure out the required type for the given kinematics name
/// </summary>
Expand Down
28 changes: 28 additions & 0 deletions src/DuetAPI/ObjectModel/Move/MoveSegmentation.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
namespace DuetAPI.ObjectModel
{
/// <summary>
/// Move segmentation parameters
/// </summary>
public sealed class MoveSegmentation : ModelObject
{
/// <summary>
/// Number of segments per second
/// </summary>
public int SegmentsPerSec
{
get => _segmentsPerSec;
set => SetPropertyValue(ref _segmentsPerSec, value);
}
private int _segmentsPerSec;

/// <summary>
/// Minimum length of a segment (in mm)
/// </summary>
public float MinSegmentLength
{
get => _minSegmentLength;
set => SetPropertyValue(ref _minSegmentLength, value);
}
private float _minSegmentLength;
}
}
3 changes: 1 addition & 2 deletions src/DuetControlServer/Codes/MCodes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -996,9 +996,8 @@ private static async Task Diagnostics(Message result)
builder.AppendLine("=== Duet Control Server ===");
builder.AppendLine($"Duet Control Server v{Program.Version}");

await SPI.Interface.Diagnostics(builder);
SPI.DataTransfer.Diagnostics(builder);
await FileExecution.Job.Diagnostics(builder);
await SPI.Interface.Diagnostics(builder);

result.Append(MessageType.Success, builder.ToString());
}
Expand Down
16 changes: 8 additions & 8 deletions src/DuetControlServer/Files/FilePath.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public static class FilePath
/// <returns>Resolved file path</returns>
public static string ToPhysical(string filePath, FileDirectory directory)
{
Match match = Regex.Match(filePath, "^(\\d+):?/?(.*)");
Match match = Regex.Match(filePath, @"^(\d+):/(.*)");
if (match.Success && int.TryParse(match.Groups[1].Value, out int driveNumber))
{
if (driveNumber == 0)
Expand Down Expand Up @@ -101,7 +101,7 @@ public static string ToPhysical(string filePath, FileDirectory directory)
_ => Model.Provider.Get.Directories.System,
};

match = Regex.Match(directoryPath, "^(\\d+):?/?(.*)");
match = Regex.Match(directoryPath, @"^(\d+):/(.*)");
if (match.Success && int.TryParse(match.Groups[1].Value, out driveNumber))
{
if (driveNumber == 0)
Expand Down Expand Up @@ -129,7 +129,7 @@ public static string ToPhysical(string filePath, FileDirectory directory)
/// <returns>Resolved file path</returns>
public static async Task<string> ToPhysicalAsync(string filePath, FileDirectory directory)
{
Match match = Regex.Match(filePath, "^(\\d+):?/?(.*)");
Match match = Regex.Match(filePath, @"^(\d+):/(.*)");
if (match.Success && int.TryParse(match.Groups[1].Value, out int driveNumber))
{
if (driveNumber == 0)
Expand Down Expand Up @@ -166,7 +166,7 @@ public static async Task<string> ToPhysicalAsync(string filePath, FileDirectory
_ => Model.Provider.Get.Directories.System,
};

match = Regex.Match(directoryPath, "^(\\d+):?/?(.*)");
match = Regex.Match(directoryPath, @"^(\d+):/(.*)");
if (match.Success && int.TryParse(match.Groups[1].Value, out driveNumber))
{
if (driveNumber == 0)
Expand Down Expand Up @@ -194,7 +194,7 @@ public static async Task<string> ToPhysicalAsync(string filePath, FileDirectory
/// <returns>Resolved file path</returns>
public static string ToPhysical(string filePath, string directory = null)
{
Match match = Regex.Match(filePath, "^(\\d+):?/?(.*)");
Match match = Regex.Match(filePath, @"^(\d+):/(.*)");
if (match.Success && int.TryParse(match.Groups[1].Value, out int driveNumber))
{
if (driveNumber == 0)
Expand All @@ -215,7 +215,7 @@ public static string ToPhysical(string filePath, string directory = null)

if (directory != null && !filePath.StartsWith('/'))
{
match = Regex.Match(directory, "^(\\d+):?/?(.*)");
match = Regex.Match(directory, @"^(\d+):/(.*)");
if (match.Success && int.TryParse(match.Groups[1].Value, out driveNumber))
{
if (driveNumber == 0)
Expand Down Expand Up @@ -246,7 +246,7 @@ public static string ToPhysical(string filePath, string directory = null)
/// <returns>Resolved file path</returns>
public static async Task<string> ToPhysicalAsync(string filePath, string directory = null)
{
Match match = Regex.Match(filePath, "^(\\d+):?/?(.*)");
Match match = Regex.Match(filePath, @"^(\d+):/(.*)");
if (match.Success && int.TryParse(match.Groups[1].Value, out int driveNumber))
{
if (driveNumber == 0)
Expand All @@ -267,7 +267,7 @@ public static async Task<string> ToPhysicalAsync(string filePath, string directo

if (directory != null && !filePath.StartsWith('/'))
{
match = Regex.Match(directory, "^(\\d+):?/?(.*)");
match = Regex.Match(directory, @"^(\d+):/(.*)");
if (match.Success && int.TryParse(match.Groups[1].Value, out driveNumber))
{
if (driveNumber == 0)
Expand Down
5 changes: 3 additions & 2 deletions src/DuetControlServer/Files/InfoParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ private static async Task ParseHeader(StreamReader reader, ParsedFileInfo partia
{
// G0/G1 is a move, see if there is a Z parameter present
CodeParameter zParam = code.Parameter('Z');
if (zParam != null)
if (zParam != null && zParam.Type == typeof(float))
{
float z = zParam;
if (z <= Settings.MaxLayerHeight)
Expand Down Expand Up @@ -189,7 +189,8 @@ private static async Task ParseFooter(StreamReader reader, ParsedFileInfo partia
{
// G0/G1 is an absolute move, see if there is a Z parameter present
CodeParameter zParam = code.Parameter('Z');
if (zParam != null && (code.Comment == null || !code.Comment.TrimStart().StartsWith("E")))
if (zParam != null && zParam.Type == typeof(float) &&
(code.Comment == null || !code.Comment.TrimStart().StartsWith("E", StringComparison.InvariantCultureIgnoreCase)))
{
gotNewInfo = true;
partialFileInfo.Height = zParam;
Expand Down
1 change: 1 addition & 0 deletions src/DuetControlServer/SPI/Interface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ public static async Task Diagnostics(StringBuilder builder)
{
await _channels.Diagnostics(builder);
builder.AppendLine($"Code buffer space: {_bufferSpace}");
DataTransfer.Diagnostics(builder);
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion src/DuetHttpClient/Connector/BaseConnector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ protected BaseConnector(Uri baseUri, DuetHttpOptions options)
}

/// <summary>
/// HTTP cient of this connector
/// HTTP client of this connector
/// </summary>
public HttpClient HttpClient { get; } = new();

Expand Down
7 changes: 6 additions & 1 deletion src/DuetHttpClient/Connector/PollConnector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,12 @@ private async Task MaintainSession()
}
catch (Exception e) when (e is OperationCanceledException || e is HttpRequestException)
{
// expected when the remote end is still offline or unavailable
// This happens when the remote end is offline or unavailable
lock (Model)
{
Model.State.Status = MachineStatus.Disconnected;
Model.Global.Clear();
}
}

// Wait a moment before attempting to reconnect
Expand Down
3 changes: 2 additions & 1 deletion src/DuetHttpClient/Connector/RestConnector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -312,10 +312,11 @@ private async Task ReceiveObjectModel()
}
catch (Exception e) when (e is not OperationCanceledException)
{
// Something went wrong, the remote end is offline or unavailable
lock (Model)
{
// Something went wrong, no longer connected
Model.State.Status = MachineStatus.Disconnected;
Model.Global.Clear();
}
}

Expand Down
5 changes: 3 additions & 2 deletions src/DuetWebServer/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,9 @@ public static IHostBuilder CreateHostBuilder(string[] args) =>
})
.ConfigureServices(services =>
{
services.AddSingleton(typeof(IModelProvider), typeof(ModelProvider));
services.AddSingleton(typeof(ISessionStorage), typeof(SessionStorage));
services.AddSingleton<IModelProvider, ModelProvider>();
services.AddSingleton<ISessionStorage, SessionStorage>();
services.AddHostedService<Services.ModelObserver>();
services.AddHostedService<Services.SessionExpiry>();
});
Expand Down
Loading

0 comments on commit 760388f

Please sign in to comment.