Print3dServer.Core 1.0.0-preview

This is a prerelease version of Print3dServer.Core.
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package Print3dServer.Core --version 1.0.0-preview
NuGet\Install-Package Print3dServer.Core -Version 1.0.0-preview
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Print3dServer.Core" Version="1.0.0-preview" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Print3dServer.Core --version 1.0.0-preview
#r "nuget: Print3dServer.Core, 1.0.0-preview"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Print3dServer.Core as a Cake Addin
#addin nuget:?package=Print3dServer.Core&version=1.0.0-preview&prerelease

// Install Print3dServer.Core as a Cake Tool
#tool nuget:?package=Print3dServer.Core&version=1.0.0-preview&prerelease

Print3dServer.Core

A C# based core library for our 3d Print Server nugets (Moonraker, Repetier Server, OctoPrint and so on)

Available print servers

Planned

  • PrusaConnect

Usage

Base Client

In order to create your own PrintServerClient, inherit from the base client Print3dServerClient, IPrintServerClient as shown below.

public partial class OctoPrintClient : Print3dServerClient, IPrintServerClient
{
 //...
}

The base class holds all needed Methods and Properties needed to communicate with a print server (via REST API and WebSocket).

Example migration for OctoPrint

To query data from your server, simply call send the needed Command. The result will contain the data as JsonString, which can be accessed over the Result property.

async Task<OctoPrintFiles> GetFilesAsync(string location, string path = "", bool recursive = true)
{
    try
    {
        string files = string.IsNullOrEmpty(path) ? string.Format("files/{0}", location) : string.Format("files/{0}/{1}", location, path);
        Dictionary<string, string> urlSegments = new()
        {
            //get all files & folders 
            { "recursive", recursive ? "true" : "false" }
        };

        string targetUri = $"{OctoPrintCommands.Api}";
        IRestApiRequestRespone result = await SendRestApiRequestAsync(
               requestTargetUri: targetUri,
               method: Method.Get,
               command: files,
               jsonObject: null,
               authHeaders: AuthHeaders,
               urlSegments: urlSegments,
               cts: default
               )
            .ConfigureAwait(false);
        OctoPrintFiles list = JsonConvert.DeserializeObject<OctoPrintFiles>(result.Result);
        if (list != null)
        {
            FreeDiskSpace = list.Free;
            TotalDiskSpace = list.Total;
        }
        return list;
    }
    catch (Exception exc)
    {
        OnError(new UnhandledExceptionEventArgs(exc, false));
        return new OctoPrintFiles();
    }
}

Time differences

Each print server uses a different time base for PrintDuration, StartTime and EndTime.

Property Core Moonraker OctoPrint Repetier Server
PrintDuration double? (UNIX Hours) double? (UNIX Hours) tbd double? (Seconds)
Modified double? (UNIX DT) double? (UNIX DT) tbd double? (Seconds)
Created double? (UNIX DT) double? (UNIX DT) tbd long? (Seconds)

Converters

Available Converters for XamlBindings: https://github.com/AndreasReitberger/SharedMauiCoreLibrary/tree/main/src/SharedMauiCoreLibrary/Converters

Or for code behind, use TimeBaseConvertHelper.

 [ObservableProperty]
 double printTime;
 partial void OnPrintTimeChanged(double value)
 {
     PrintTimeGeneralized = TimeBaseConvertHelper.FromUnixDoubleHours(value);          
 }

[ObservableProperty]
TimeSpan? printTimeGeneralized;
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (3)

Showing the top 3 NuGet packages that depend on Print3dServer.Core:

Package Downloads
OctoPrintSharpApi

A simple Rest-API-Client for interacting with a OctoPrint instance from any C# project.

RepetierServerSharpApi

A simple RestApi for interacting with a Repetier Server Pro instance.

MoonrakerSharpWebApi

A simple Rest-API library for interacting with Moonraker web api (used by Fluidd and MainsailOS).

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.1-preview 65 4/22/2024
1.0.0-preview 118 4/19/2024

Check GitHub releases for changelog.