Skip to content

Commit

Permalink
Towards 3.4-rc2
Browse files Browse the repository at this point in the history
Increased version numbers
Reverted change of the periodic updater from a task to a low-priority thread
Added partition size to the object model
Added support for JPEG thumbnails
Bug fix: Even object heights were not correctly processed
  • Loading branch information
chrishamm committed Feb 14, 2022
1 parent f95bfce commit 23fd8cf
Show file tree
Hide file tree
Showing 28 changed files with 568 additions and 32 deletions.
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>net6.0</TargetFramework>
<TrimUnusedDependencies>true</TrimUnusedDependencies>
<Version>3.4-rc1</Version>
<Version>3.4-rc2</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>net6.0</TargetFramework>
<TrimUnusedDependencies>true</TrimUnusedDependencies>
<Version>3.4-rc1</Version>
<Version>3.4-rc2</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>net6.0</TargetFramework>
<TrimUnusedDependencies>true</TrimUnusedDependencies>
<Version>3.4-rc1</Version>
<Version>3.4-rc2</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>net6.0</TargetFramework>
<Version>3.4-rc1</Version>
<Version>3.4-rc2</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-rc1</Version>
<Version>3.4-rc2</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/DuetAPI/DuetAPI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<TargetFrameworks>netstandard2.1;net6.0</TargetFrameworks>
<Authors>Christian Hammacher</Authors>
<Company>Duet3D Ltd</Company>
<Version>3.4-rc1</Version>
<Version>3.4-rc2</Version>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<PackageLicenseExpression>LGPL-3.0-or-later</PackageLicenseExpression>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
Expand Down
5 changes: 5 additions & 0 deletions src/DuetAPI/ObjectModel/Job/ThumbnailInfoFormat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ namespace DuetAPI.ObjectModel
[JsonConverter(typeof(JsonLowerCaseStringEnumConverter))]
public enum ThumbnailInfoFormat
{
/// <summary>
/// Joint Photographic Experts Group
/// </summary>
JPEG,

/// <summary>
/// Portable Network Graphics
/// </summary>
Expand Down
11 changes: 11 additions & 0 deletions src/DuetAPI/ObjectModel/Volumes/Volume.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,17 @@ public int? OpenFiles
}
private int? _openFiles;

/// <summary>
/// Total size of this volume (in bytes or null)
/// </summary>

public long? PartitionSize
{
get => _partitionSize;
set => SetPropertyValue(ref _partitionSize, value);
}
private long? _partitionSize;

/// <summary>
/// Logical path of the storage device
/// </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-rc1</Version>
<Version>3.4-rc2</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
3 changes: 2 additions & 1 deletion src/DuetControlServer/Codes/MCodes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,7 @@ public static async Task<Message> Process(Commands.Code code)
slot = index,
present = 1,
capacity = storage.Capacity,
partitionSize = storage.PartitionSize,
free = storage.FreeSpace,
speed = storage.Speed
}
Expand All @@ -492,7 +493,7 @@ public static async Task<Message> Process(Commands.Code code)
}

Volume storage = Model.Provider.Get.Volumes[index];
return new Message(MessageType.Success, $"SD card in slot {index}: capacity {storage.Capacity / (1000 * 1000 * 1000):F2}Gb, free space {storage.FreeSpace / (1000 * 1000 * 1000):F2}Gb, speed {storage.Speed / (1000 * 1000):F2}MBytes/sec");
return new Message(MessageType.Success, $"SD card in slot {index}: capacity {storage.Capacity / (1000 * 1000 * 1000):F2}Gb, partition size {storage.PartitionSize / (1000 * 1000 * 1000):F2}Gb,free space {storage.FreeSpace / (1000 * 1000 * 1000):F2}Gb, speed {storage.Speed / (1000 * 1000):F2}MBytes/sec");
}
}
}
Expand Down
11 changes: 10 additions & 1 deletion src/DuetControlServer/Commands/Plugins/StopPlugins.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using DuetAPI.ObjectModel;
using Nito.AsyncEx;
using System.Collections.Generic;
using System.Net.Sockets;
using System.Text;
using System.Threading.Tasks;

Expand Down Expand Up @@ -62,7 +63,15 @@ public override async Task Execute()
}
}
}
await Task.WhenAll(stopTasks);

try
{
await Task.WhenAll(stopTasks);
}
catch (SocketException)
{
// Can be expected when the remote service is terminated too early
}

using (await Model.Provider.AccessReadWriteAsync())
{
Expand Down
2 changes: 1 addition & 1 deletion 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-rc1</Version>
<Version>3.4-rc2</Version>
<PackageLicenseExpression>GPL-3.0</PackageLicenseExpression>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<RepositoryUrl>https://github.com/Duet3D/DuetSoftwareFramework.git</RepositoryUrl>
Expand Down
2 changes: 2 additions & 0 deletions src/DuetControlServer/Files/ImageProcessing/ImageParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,15 @@ public static async ValueTask ProcessAsync(StreamReader reader, CodeParserBuffer

string trimmedComment = code.Comment.Trim();
if (trimmedComment.StartsWith("thumbnail begin", StringComparison.InvariantCultureIgnoreCase) ||
trimmedComment.StartsWith("thumbnail_JPG begin", StringComparison.InvariantCultureIgnoreCase) ||
trimmedComment.StartsWith("thumbnail_QOI begin", StringComparison.InvariantCultureIgnoreCase))
{
// Exit if we find another start tag before ending the previous image
throw new ImageProcessingException();
}

if (trimmedComment.StartsWith("thumbnail end", StringComparison.InvariantCultureIgnoreCase) ||
trimmedComment.StartsWith("thumbnail_JPG end", StringComparison.InvariantCultureIgnoreCase) ||
trimmedComment.StartsWith("thumbnail_QOI end", StringComparison.InvariantCultureIgnoreCase))
{
if (readThumbnailContent)
Expand Down
15 changes: 12 additions & 3 deletions src/DuetControlServer/Files/InfoParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ private static async Task ParseFooter(StreamReader reader, GCodeFileInfo partial
{
// G0/G1 is an absolute move, see if there is a Z parameter present
CodeParameter zParam = code.Parameter('Z');
if (zParam != null && zParam.Type == typeof(float) &&
if (zParam != null && (zParam.Type == typeof(int) || zParam.Type == typeof(float)) &&
(code.Comment == null || !code.Comment.TrimStart().StartsWith("E", StringComparison.InvariantCultureIgnoreCase)))
{
gotNewInfo = true;
Expand Down Expand Up @@ -528,10 +528,16 @@ private static async ValueTask<bool> ParseThumbnails(StreamReader reader, Code c
string trimmedComment = code.Comment.TrimStart();
if (trimmedComment.StartsWith("thumbnail begin", StringComparison.InvariantCultureIgnoreCase))
{
_logger.Debug("Found embedded thumbnail image");
_logger.Debug("Found embedded thumbnail PNG image");
await ImageParser.ProcessAsync(reader, codeParserBuffer, parsedFileInfo, code, readThumbnailContent, ThumbnailInfoFormat.PNG);
return true;
}
if (trimmedComment.StartsWith("thumbnail_JPG", StringComparison.InvariantCultureIgnoreCase))
{
_logger.Debug("Found embedded thumbnail JPG Image");
await ImageParser.ProcessAsync(reader, codeParserBuffer, parsedFileInfo, code, readThumbnailContent, ThumbnailInfoFormat.JPEG);
return true;
}
if (trimmedComment.StartsWith("thumbnail_QOI", StringComparison.InvariantCultureIgnoreCase))
{
_logger.Debug("Found embedded thumbnail QOI Image");
Expand Down Expand Up @@ -620,7 +626,10 @@ public static async ValueTask<string> ParseThumbnail(string filename, long offse

// Is it the end of this thumbnail?
string content = Encoding.ASCII.GetString(data, lineStart, lineLength);
if ((charsWritten + lineLength < MaxThumbnailLength && lineLength == 0) || content.StartsWith("thumbnail end"))
if ((charsWritten + lineLength < MaxThumbnailLength && lineLength == 0) ||
content.StartsWith("thumbnail end") ||
content.StartsWith("thumbnail_JPG end") ||
content.StartsWith("thumbnail_QOI end"))
{
offset = 0;
break;
Expand Down
14 changes: 7 additions & 7 deletions src/DuetControlServer/Model/PeriodicUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using System.Net.NetworkInformation;
using System.Net.Sockets;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using Code = DuetControlServer.Commands.Code;

namespace DuetControlServer.Model
Expand Down Expand Up @@ -74,7 +75,7 @@ internal static void ProtocolDisabled(NetworkProtocol protocol)
/// This function updates host properties like network interfaces and storage devices
/// </summary>
/// <returns>Asynchronous task</returns>
public static void Run()
public static async Task Run()
{
DateTime lastUpdateTime = DateTime.Now;
DriveInfo[] drives;
Expand All @@ -87,7 +88,7 @@ public static void Run()
drives = DriveInfo.GetDrives();

// Run another update cycle
using (Provider.AccessReadWrite())
using (await Provider.AccessReadWriteAsync())
{
UpdateNetwork(networkInterfaces);
UpdateVolumes(drives);
Expand All @@ -111,7 +112,7 @@ public static void Run()
new('S', DateTime.Now.ToString("HH:mm:ss"))
}
};
code.Execute().Wait();
await code.Execute();
}

// Check if the hostname has to be updated
Expand All @@ -131,12 +132,12 @@ public static void Run()
new('P', lastHostname)
}
};
code.Execute().Wait();
await code.Execute();
}

// Wait for next scheduled update check
lastUpdateTime = DateTime.Now;
Program.CancellationToken.WaitHandle.WaitOne(Settings.HostUpdateInterval);
await Task.Delay(Settings.HostUpdateInterval, Program.CancellationToken);
}
while (!Program.CancellationToken.IsCancellationRequested);
}
Expand Down Expand Up @@ -237,8 +238,6 @@ private static void UpdateNetwork(System.Net.NetworkInformation.NetworkInterface
/// </remarks>
private static void UpdateVolumes(DriveInfo[] drives)
{
// Note: Since NetworkInterface.GetAllNetworkInterfaces() can take up to 1.5s, we query the drives outside the object model, too

int index = 0;
foreach (DriveInfo drive in drives)
{
Expand Down Expand Up @@ -270,6 +269,7 @@ private static void UpdateVolumes(DriveInfo[] drives)
volume.Capacity = (drive.DriveType == DriveType.Network) ? null : totalSize;
volume.FreeSpace = (drive.DriveType == DriveType.Network) ? null : drive.AvailableFreeSpace;
volume.Mounted = drive.IsReady;
volume.PartitionSize = (drive.DriveType == DriveType.Network) ? null : totalSize;
volume.Path = drive.VolumeLabel;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/DuetControlServer/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ private static async Task<int> Main(string[] args)
{ Task.Factory.StartNew(Model.Updater.Run, TaskCreationOptions.LongRunning).Unwrap(), "Update" },
{ Task.Factory.StartNew(IPC.Server.Run, TaskCreationOptions.LongRunning).Unwrap(), "IPC" },
{ Task.Factory.StartNew(FileExecution.Job.Run, TaskCreationOptions.LongRunning).Unwrap(), "Job" },
{ Utility.PriorityThreadRunner.Start(Model.PeriodicUpdater.Run, ThreadPriority.BelowNormal), "Periodic updater" }
{ Task.Factory.StartNew(Model.PeriodicUpdater.Run, TaskCreationOptions.LongRunning).Unwrap(), "Periodic updater" }
};

// Deal with program termination requests (SIGTERM and Ctrl+C)
Expand Down
2 changes: 0 additions & 2 deletions src/DuetControlServer/SPI/Channel/Processor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,6 @@ public void AbortFiles(bool abortAll, bool fromFirmware)
}, TaskContinuationOptions.RunContinuationsAsynchronously);
}


// Abort the macro file
CurrentState.Macro.Abort();
}
Expand Down Expand Up @@ -673,7 +672,6 @@ public async Task AbortFilesAsync(bool abortAll, bool fromFirmware)
}, TaskContinuationOptions.RunContinuationsAsynchronously);
}


// Abort the macro file
await CurrentState.Macro.AbortAsync();
}
Expand Down
2 changes: 1 addition & 1 deletion src/DuetHttpClient/DuetHttpClient.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-rc1</Version>
<Version>3.4-rc2</Version>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Description>Official remote HTTP API client for Duet3D boards (supports standalone and SBC mode)</Description>
<PackageProjectUrl>https://github.com/Duet3D/DuetSoftwareFramework</PackageProjectUrl>
Expand Down
2 changes: 1 addition & 1 deletion src/DuetPiManagementPlugin/DuetPiManagementPlugin.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<Version>3.4-rc1</Version>
<Version>3.4-rc2</Version>
<Company>Duet3D Ltd</Company>
<Copyright>Duet3D Ltd</Copyright>
<PackageLicenseExpression>GPL-3.0</PackageLicenseExpression>
Expand Down
3 changes: 2 additions & 1 deletion src/DuetPluginService/Commands/InstallPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ public override async Task Execute()

if (!File.Exists(sbcExecutable))
{
throw new ArgumentException("SBC executable {0} not found", plugin.SbcExecutable);
throw new ArgumentException($"SBC executable {plugin.SbcExecutable} not found");
}
}

Expand All @@ -194,6 +194,7 @@ public override async Task Execute()
Directory.CreateDirectory(directory);
}

#warning check if this is fixed in ASP.NET 6
#if true
// Copy the file. ASP.NET 5 does not perform lstat on symlinks so files served from symlinks are always truncated
_logger.Debug("Copying {0} -> {1}", pluginWwwPath, installWwwPath);
Expand Down
2 changes: 1 addition & 1 deletion src/DuetPluginService/DuetPluginService.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-rc1</Version>
<Version>3.4-rc2</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/DuetWebServer/DuetWebServer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
<Authors>Christian Hammacher</Authors>
<Company>Duet3D Ltd</Company>
<Version>3.4-rc1</Version>
<Version>3.4-rc2</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/LinuxApi/LinuxApi.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFramework>net6.0</TargetFramework>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<PackageLicenseExpression>LGPL-3.0</PackageLicenseExpression>
<Version>3.4-rc1</Version>
<Version>3.4-rc2</Version>
</PropertyGroup>

<PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/ModelObserver/ModelObserver.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TrimUnusedDependencies>true</TrimUnusedDependencies>
<Version>3.4-rc1</Version>
<Version>3.4-rc2</Version>
<RepositoryUrl>https://github.com/Duet3D/DuetSoftwareFramework.git</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PackageLicenseExpression>GPL-3.0</PackageLicenseExpression>
Expand Down
2 changes: 1 addition & 1 deletion src/PluginManager/PluginManager.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<PackageProjectUrl>https://github.com/Duet3D/DuetSoftwareFramework</PackageProjectUrl>
<RepositoryUrl>https://github.com/Duet3D/DuetSoftwareFramework.git</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<Version>3.4-rc1</Version>
<Version>3.4-rc2</Version>
</PropertyGroup>

<ItemGroup>
Expand Down
Loading

0 comments on commit 23fd8cf

Please sign in to comment.