Files
Tiago Conceição 4600e81b08 v3.0.0
- **(Add) Suggestions:**
   - A new module that detect bad or parameters out of a defined range and suggest a change on the file, those can be auto applied if configured to do so
   - **Avaliable suggestions:**
      - **Bottom layer count:** Bottom layers should be kept to a minimum, usually from 2 to 3, it function is to provide a good adhesion to the first layer on the build plate, using a high count have disadvantages.
      - **Wait time before cure:** Rest some time before cure the layer is crucial to let the resin settle after the lift sequence and allow some time for the arm settle at the correct Z position as the resin will offer some resistance and push the structure.
                                   This lead to better quality with more successful prints, less lamination problems, better first layers with more success of stick to the build plate and less elephant foot effect.
      - **Wait time after cure:** Rest some time after cure the layer and before the lift sequence can be important to allow the layer to cooldown a bit and detach better from the FEP.
      - **Layer height:** Using the right layer height is important to get successful prints:
                          Thin layers may cause problems on adhesion, lamination, will print much slower and have no real visual benefits.
                          Thick layers may not fully cure no matter the exposure time you use, causing lamination and other hazards. Read your resin dtasheet to know the limits.
                          Using layer height with too many decimal digits may produce a wrong positioning due stepper step loss and/or Z axis quality.
- **Core:**
   - Convert the project to Nullable aware and "null-safe"
- **File Formats:**
   - (Add) `Volume` property to get the total model volume
   - (Add) `SanitizeLayers` method to reassign indexes and force attribute parent file
   - (Improvement) Merge `LayerManager` into `FileFormat` and cleanup: This affects the whole project and external scripts.
   If using scripts please update them, search for `.LayerManager.` and replace by `.`
   - (Change) Chitubox encrypted format can now be saved as normal
   - (Fix) Converted files layers was pointing to the source file and related to it
- **Layers:**
   - (Add) Methods: `ResetParameters`, `CopyParametersTo`, `CopyExposureTo`, `CopyWaitTimesTo`
   - (Improvement) `IsBottomLayer` property will also return true when the index is inside bottom layer count
- **Scripting:**
   - (Add) Configuration variable: `MinimumVersionToRun` - Sets the minimum version able to run the script
   - (Improvement) Allow run scripts written in C# 10 with the new namespace; style as well as nullables methods
   - (Improvement) Convert scripts to use Nullable code
- **UI:**
   - (Add) Fluent Dark theme
   - (Add) Default Light theme
   - (Add) Default Dark theme
   - (Change) Use fontawesome and material design to render the icons instead of static png images
   - (Change) Some icons
   - (Change) Move log tab to clipboard tab
   - (Change) Tooltip overlay default color
   - (Improvement) Windows position for tool windows, sometimes framework can return negative values affecting positions, now limits to 0 (#387)
   - (Fix) Center image icon for layer action button
   - (Fix) Center image icon for save layer image button
- **Tools:**
   - (Add) Layer re-height: Offset mode, change layers position by a defined offset (#423)
   - (Improvement) Rotate: Unable to use an angle of 0
   - (Improvement) Remove layers: Will not recalcualte and reset properties of layers anymore, allowing removing layers on dynamic layer height models and others
   - (Improvement) Clone layers: Will not recalcualte and reset properties of layers anymore, allowing cloning layers on dynamic layer height models and others
   - (Fix) Exposure time finder: Very small printers may not print the stock object as it is configured, lead to a unknown error while generating the test. It will now show a better error message and advice a solution (#426)
- **Terminal:**
   - (Add) More default namespaces
   - (Improvement) Set a MinHeight for the rows to prevent spliter from eat the elements
   - (Change) Set working space to the MainWindow instead of TerminalWindow
- **(Upgrade) .NET from 5.0.14 to 6.0.3**
   - This brings big performance improvements, better JIT, faster I/O operations and others
   - Read more: https://devblogs.microsoft.com/dotnet/performance-improvements-in-net-6
   - Due this macOS requirement starts at 10.15 (Catalina)
   - Read more: https://github.com/dotnet/core/blob/main/release-notes/6.0/supported-os.md
- (Add) Native support for MacOS ARM64 architecture (Mac M1 and upcomming Mac's) (#187)
- (Exchange) Dependency Newtonsoft Json by System.Text.Json to parse the json documents
- (Remove) "Automations - Light-off delay" in favor of new suggestion "wait time before cure" module
- (Fix) File - Send to: Winrar or 7zip have a wrong extension on the list (uvt) when should be (uvj)
- (Upgrade) AvaloniaUI from 0.10.12 to 0.10.13
2022-03-12 21:04:47 +00:00

272 lines
7.5 KiB
C#

/*
* GNU AFFERO GENERAL PUBLIC LICENSE
* Version 3, 19 November 2007
* Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
* Everyone is permitted to copy and distribute verbatim copies
* of this license document, but changing it is not allowed.
*/
using System;
namespace UVtools.Core.Objects;
/// <summary>
/// Represents a material to feed in the printer
/// </summary>
public class Material : BindableBase, ICloneable
{
#region Members
private string _name = null!;
private uint _bottleVolume = 1000;
private decimal _density = 1;
private decimal _bottleCost = 30;
private int _bottlesInStock = 1;
private decimal _bottleRemainingVolume = 1000;
private decimal _consumedVolume;
private double _printTime;
#endregion
#region Properties
public string Name
{
get => _name;
set => RaiseAndSetIfChanged(ref _name, value);
}
/// <summary>
/// Gets or sets the bottle volume in milliliters
/// </summary>
public uint BottleVolume
{
get => _bottleVolume;
set
{
if(!RaiseAndSetIfChanged(ref _bottleVolume, value)) return;
RaisePropertyChanged(nameof(BottleWeight));
RaisePropertyChanged(nameof(ConsumedBottles));
RaisePropertyChanged(nameof(TotalCost));
RaisePropertyChanged(nameof(VolumeInStock));
}
}
/// <summary>
/// Gets or sets the bottle weight in grams
/// </summary>
public decimal BottleWeight => _bottleVolume * _density;
/// <summary>
/// Gets or sets the material density in g/ml
/// </summary>
public decimal Density
{
get => _density;
set
{
if(!RaiseAndSetIfChanged(ref _density, value)) return;
RaisePropertyChanged(nameof(BottleWeight));
}
}
/// <summary>
/// Gets or sets the bottle cost
/// </summary>
public decimal BottleCost
{
get => _bottleCost;
set
{
if(!RaiseAndSetIfChanged(ref _bottleCost, value)) return;
RaisePropertyChanged(nameof(TotalCost));
}
}
public decimal TotalCost => OwnedBottles * _bottleCost;
/// <summary>
/// Gets or sets the number of bottles in stock
/// </summary>
public int BottlesInStock
{
get => _bottlesInStock;
set
{
if(!RaiseAndSetIfChanged(ref _bottlesInStock, value)) return;
RaisePropertyChanged(nameof(OwnedBottles));
RaisePropertyChanged(nameof(TotalCost));
RaisePropertyChanged(nameof(VolumeInStock));
}
}
/// <summary>
/// Gets or sets the current bottle remaining material in milliliters
/// </summary>
public decimal BottleRemainingVolume
{
get => Math.Round(_bottleRemainingVolume, 2);
set
{
if(!RaiseAndSetIfChanged(ref _bottleRemainingVolume, value)) return;
RaisePropertyChanged(nameof(VolumeInStock));
}
}
/// <summary>
/// Gets the total available volume in stock in milliliters
/// </summary>
public decimal VolumeInStock => _bottlesInStock * _bottleVolume - (_bottleVolume - _bottleRemainingVolume);
/// <summary>
/// Gets the number of consumed bottles
/// </summary>
public uint ConsumedBottles => (uint)(_consumedVolume / _bottleVolume);
/// <summary>
/// Gets the total number of owned bottles
/// </summary>
public int OwnedBottles => (int) (_bottlesInStock + ConsumedBottles);
/// <summary>
/// Gets or sets the total number of consumed volume in milliliters
/// </summary>
public decimal ConsumedVolume
{
get => _consumedVolume;
set
{
if(!RaiseAndSetIfChanged(ref _consumedVolume, value)) return;
RaisePropertyChanged(nameof(ConsumedVolumeLiters));
}
}
/// <summary>
/// Gets total number of consumed volume in liters
/// </summary>
public decimal ConsumedVolumeLiters => ConsumedVolume / 1000;
/// <summary>
/// Gets or sets the total print time using with material in hours
/// </summary>
public double PrintTime
{
get => _printTime;
set
{
if(!RaiseAndSetIfChanged(ref _printTime, value)) return;
RaisePropertyChanged(nameof(PrintTimeSpan));
}
}
public TimeSpan PrintTimeSpan => TimeSpan.FromHours(_printTime);
#endregion
#region Constructors
public Material() { }
public Material(string name, uint bottleVolume = 1000, decimal density = 1, decimal bottleCost = 30, int bottlesInStock = 1)
{
_name = name;
_bottleVolume = bottleVolume;
_density = density;
_bottleCost = bottleCost;
_bottlesInStock = bottlesInStock;
_bottleRemainingVolume = bottleVolume;
}
#endregion
#region Overrides
protected bool Equals(Material other)
{
return _name == other._name;
}
public override bool Equals(object? obj)
{
if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) return true;
if (obj.GetType() != GetType()) return false;
return Equals((Material) obj);
}
public override int GetHashCode()
{
return (_name != null ? _name.GetHashCode() : 0);
}
public override string ToString()
{
return $"{_name} ({_bottleRemainingVolume}/{VolumeInStock}ml)";
}
public object Clone()
{
return MemberwiseClone();
}
public Material CloneMaterial()
{
return (Material)Clone();
}
#endregion
#region Methods
/// <summary>
/// Gets the cost for a given volume
/// </summary>
/// <param name="volume">Volume in ml</param>
/// <returns></returns>
public decimal GetVolumeCost(decimal volume) => _bottleVolume > 0 ? volume * _bottleCost / _bottleVolume : 0;
/// <summary>
/// Gets the grams for a given volume
/// </summary>
/// <param name="volume">Volume in ml</param>
/// <returns></returns>
public decimal GetVolumeGrams(decimal volume) => volume * _density;
/// <summary>
/// Consume material from current bottle and manage stock
/// </summary>
/// <param name="volume">Volume to consume in milliliters</param>
/// <param name="printSeconds">Time in seconds it took to print</param>
/// <returns>True if still have bottles in stock, otherwise false</returns>
public bool Consume(decimal volume, double printSeconds = 0)
{
if (volume <= 0 || _bottleVolume == 0) return true; // Safe check
int consumedBottles = (int)(volume / _bottleVolume);
decimal remainder = volume % _bottleVolume;
if (remainder > 0)
{
decimal remainingVolume = _bottleRemainingVolume - remainder;
if (remainingVolume < 0)
{
consumedBottles++;
remainingVolume += _bottleVolume;
}
BottleRemainingVolume = remainingVolume;
}
BottlesInStock -= consumedBottles;
ConsumedVolume += volume;
AddPrintTimeSeconds(printSeconds);
return _bottlesInStock > 0;
}
/// <summary>
/// Add print time with this material
/// </summary>
/// <param name="seconds">Seconds to add</param>
public void AddPrintTimeSeconds(double seconds)
{
if (seconds <= 0) return;
PrintTime += seconds / 60 / 60;
}
#endregion
}