making autopilot report time better
Making autopilot write to history
This commit is contained in:
parent
eb8038305c
commit
874bd53def
11 changed files with 94 additions and 30 deletions
|
|
@ -35,6 +35,7 @@ using System.Linq;
|
|||
using System.Runtime.InteropServices;
|
||||
using System.Threading;
|
||||
using g3;
|
||||
using gs;
|
||||
using MatterHackers.Agg;
|
||||
using MatterHackers.MatterControl.DesignTools;
|
||||
using MatterHackers.PolygonMesh;
|
||||
|
|
@ -156,10 +157,10 @@ namespace MatterHackers.PolygonMesh
|
|||
{
|
||||
var bounds = root.Bounds();
|
||||
|
||||
var c = new MarchingCubes()
|
||||
var c = new MarchingCubesPro()
|
||||
{
|
||||
Implicit = root,
|
||||
RootMode = MarchingCubes.RootfindingModes.LerpSteps, // cube-edge convergence method
|
||||
RootMode = MarchingCubesPro.RootfindingModes.LerpSteps, // cube-edge convergence method
|
||||
RootModeSteps = 5, // number of iterations
|
||||
Bounds = bounds,
|
||||
CubeSize = bounds.MaxDim / numCells,
|
||||
|
|
|
|||
|
|
@ -1788,7 +1788,7 @@ namespace MatterHackers.MatterControl
|
|||
leftChild.Padding = new BorderDouble(padding.Left, padding.Bottom, sourceExentionArea.Width, padding.Height);
|
||||
}
|
||||
|
||||
public async Task PrintPart(EditContext editContext, PrinterConfig printer, IProgress<ProgressStatus> reporter, CancellationToken cancellationToken, bool recordPrintHistory)
|
||||
public async Task PrintPart(EditContext editContext, PrinterConfig printer, IProgress<ProgressStatus> reporter, CancellationToken cancellationToken, PrinterConnection.PrintingModes printingMode)
|
||||
{
|
||||
var partFilePath = editContext.SourceFilePath;
|
||||
var gcodeFilePath = await editContext.GCodeFilePath(printer);
|
||||
|
|
@ -1859,7 +1859,7 @@ namespace MatterHackers.MatterControl
|
|||
if (messageBoxResponse)
|
||||
{
|
||||
printer.Connection.CommunicationState = CommunicationStates.PreparingToPrint;
|
||||
this.ArchiveAndStartPrint(partFilePath, gcodeFilePath, printer, recordPrintHistory);
|
||||
this.ArchiveAndStartPrint(partFilePath, gcodeFilePath, printer, printingMode);
|
||||
}
|
||||
},
|
||||
"The file you are attempting to print is a GCode file.\n\nIt is recommended that you only print Gcode files known to match your printer's configuration.\n\nAre you sure you want to print this GCode file?".Localize(),
|
||||
|
|
@ -1874,7 +1874,7 @@ namespace MatterHackers.MatterControl
|
|||
else
|
||||
{
|
||||
printer.Connection.CommunicationState = CommunicationStates.PreparingToPrint;
|
||||
this.ArchiveAndStartPrint(partFilePath, gcodeFilePath, printer, recordPrintHistory);
|
||||
this.ArchiveAndStartPrint(partFilePath, gcodeFilePath, printer, printingMode);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
@ -1889,7 +1889,7 @@ namespace MatterHackers.MatterControl
|
|||
// Only start print if slicing completed
|
||||
if (slicingSucceeded)
|
||||
{
|
||||
this.ArchiveAndStartPrint(partFilePath, finalPath, printer, recordPrintHistory);
|
||||
this.ArchiveAndStartPrint(partFilePath, finalPath, printer, printingMode);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -2057,7 +2057,7 @@ namespace MatterHackers.MatterControl
|
|||
/// </summary>
|
||||
/// <param name="sourcePath">The source file which originally caused the slice->print operation</param>
|
||||
/// <param name="gcodeFilePath">The resulting GCode to print</param>
|
||||
private async void ArchiveAndStartPrint(string sourcePath, string gcodeFilePath, PrinterConfig printer, bool recordPrintHistory)
|
||||
private async void ArchiveAndStartPrint(string sourcePath, string gcodeFilePath, PrinterConfig printer, PrinterConnection.PrintingModes printingMode)
|
||||
{
|
||||
if (File.Exists(sourcePath)
|
||||
&& File.Exists(gcodeFilePath))
|
||||
|
|
@ -2088,7 +2088,7 @@ namespace MatterHackers.MatterControl
|
|||
|
||||
if (originalIsGCode)
|
||||
{
|
||||
await printer.Connection.StartPrint(gcodeFilePath, recordPrintHistory: recordPrintHistory);
|
||||
await printer.Connection.StartPrint(gcodeFilePath, printingMode: printingMode);
|
||||
|
||||
MonitorPrintTask(printer);
|
||||
|
||||
|
|
@ -2099,7 +2099,7 @@ namespace MatterHackers.MatterControl
|
|||
// Ask for slicer specific gcode validation
|
||||
if (printer.Settings.Slicer.ValidateFile(gcodeFilePath))
|
||||
{
|
||||
await printer.Connection.StartPrint(gcodeFilePath, recordPrintHistory: recordPrintHistory);
|
||||
await printer.Connection.StartPrint(gcodeFilePath, printingMode: printingMode);
|
||||
MonitorPrintTask(printer);
|
||||
return;
|
||||
}
|
||||
|
|
@ -2235,7 +2235,7 @@ namespace MatterHackers.MatterControl
|
|||
public void Connection_PrintFinished(object sender, string e)
|
||||
{
|
||||
if (sender is PrinterConnection printerConnection
|
||||
&& printerConnection.RecordPrintHistory)
|
||||
&& printerConnection.PrintingMode == PrinterConnection.PrintingModes.Normal)
|
||||
{
|
||||
var printTasks = PrintHistoryData.Instance.GetHistoryItems(10);
|
||||
var printHistoryEditor = new PrintHistoryEditor(((PrinterConnection)sender).Printer, AppContext.Theme, printerConnection.ActivePrintTask, printTasks);
|
||||
|
|
@ -2249,7 +2249,7 @@ namespace MatterHackers.MatterControl
|
|||
public void Connection_PrintCanceled(object sender, EventArgs e)
|
||||
{
|
||||
if (sender is PrinterConnection printerConnection
|
||||
&& printerConnection.RecordPrintHistory)
|
||||
&& printerConnection.PrintingMode == PrinterConnection.PrintingModes.Normal)
|
||||
{
|
||||
var printTasks = PrintHistoryData.Instance.GetHistoryItems(10);
|
||||
var printHistoryEditor = new PrintHistoryEditor(((PrinterConnection)sender).Printer, AppContext.Theme, printerConnection.CanceledPrintTask, printTasks);
|
||||
|
|
|
|||
|
|
@ -43,6 +43,7 @@ using MatterHackers.Localizations;
|
|||
using MatterHackers.MatterControl.DataStorage;
|
||||
using MatterHackers.MatterControl.Library;
|
||||
using MatterHackers.MatterControl.PartPreviewWindow;
|
||||
using MatterHackers.MatterControl.PrinterCommunication;
|
||||
using MatterHackers.MatterControl.SlicerConfiguration;
|
||||
using MatterHackers.MeshVisualizer;
|
||||
using MatterHackers.PolygonMesh;
|
||||
|
|
@ -316,7 +317,7 @@ namespace MatterHackers.MatterControl
|
|||
this.Printer,
|
||||
null,
|
||||
CancellationToken.None,
|
||||
true);
|
||||
PrinterConnection.PrintingModes.Normal);
|
||||
}
|
||||
|
||||
public async Task StashAndPrint(IEnumerable<ILibraryItem> selectedLibraryItems)
|
||||
|
|
@ -337,7 +338,7 @@ namespace MatterHackers.MatterControl
|
|||
this.Printer,
|
||||
null,
|
||||
CancellationToken.None,
|
||||
true);
|
||||
PrinterConnection.PrintingModes.Normal);
|
||||
}
|
||||
|
||||
private GCodeFile loadedGCode;
|
||||
|
|
|
|||
|
|
@ -243,7 +243,7 @@ namespace MatterHackers.MatterControl
|
|||
ContentStore = null // No content store for GCode
|
||||
});
|
||||
|
||||
await printer.Connection.StartPrint(finalGCodePath, recordPrintHistory: false);
|
||||
await printer.Connection.StartPrint(finalGCodePath, printingMode: PrinterConnection.PrintingModes.Calibration);
|
||||
ApplicationController.Instance.MonitorPrintTask(printer);
|
||||
}
|
||||
else
|
||||
|
|
|
|||
38
MatterControlLib/DesignTools/Attributes/DisplayAsTime.cs
Normal file
38
MatterControlLib/DesignTools/Attributes/DisplayAsTime.cs
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
Copyright (c) 2018, Lars Brubaker, John Lewin
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
The views and conclusions contained in the software and documentation are those
|
||||
of the authors and should not be interpreted as representing official policies,
|
||||
either expressed or implied, of the FreeBSD Project.
|
||||
*/
|
||||
|
||||
using System;
|
||||
|
||||
namespace MatterHackers.MatterControl.DesignTools
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Property)]
|
||||
public class DisplayAsTimeAttribute : Attribute
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
@ -618,11 +618,26 @@ namespace MatterHackers.MatterControl.DesignTools
|
|||
{
|
||||
if (readOnly)
|
||||
{
|
||||
var valueField = new TextWidget(string.Format("{0:n0}", intValue),
|
||||
string FormateInt(int value)
|
||||
{
|
||||
if (property.PropertyInfo.GetCustomAttributes(true).OfType<DisplayAsTimeAttribute>().FirstOrDefault() != null)
|
||||
{
|
||||
var minutes = intValue / 60;
|
||||
var hours = minutes / 60;
|
||||
return $"{hours:00}:{minutes % 60:00}:{intValue % 60:00}";
|
||||
}
|
||||
else
|
||||
{
|
||||
return string.Format("{0:n0}", intValue);
|
||||
}
|
||||
}
|
||||
|
||||
var valueField = new TextWidget(FormateInt(intValue),
|
||||
textColor: theme.TextColor,
|
||||
pointSize: 10)
|
||||
{
|
||||
AutoExpandBoundsToText = true
|
||||
AutoExpandBoundsToText = true,
|
||||
Margin = new BorderDouble(0, 0, 7, 0),
|
||||
};
|
||||
|
||||
rowContainer = new SettingsRow(property.DisplayName.Localize(),
|
||||
|
|
@ -635,7 +650,7 @@ namespace MatterHackers.MatterControl.DesignTools
|
|||
if (e.InvalidateType.HasFlag(InvalidateType.DisplayValues))
|
||||
{
|
||||
int newValue = (int)property.Value;
|
||||
valueField.Text = string.Format("{0:n0}", newValue);
|
||||
valueField.Text = string.Format(FormateInt(intValue), newValue);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -773,7 +788,7 @@ namespace MatterHackers.MatterControl.DesignTools
|
|||
|
||||
var wrapContainer = new GuiWidget()
|
||||
{
|
||||
Margin = new BorderDouble(displayName.Width + displayName.Margin.Width + 15, 9, 9, 9),
|
||||
Margin = new BorderDouble(displayName.Width + displayName.Margin.Width + 15, 3, 3, 3),
|
||||
HAnchor = HAnchor.Stretch,
|
||||
VAnchor = VAnchor.Fit
|
||||
};
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ using MatterHackers.MatterControl.CustomWidgets;
|
|||
using MatterHackers.MatterControl.Library;
|
||||
using MatterHackers.MatterControl.Library.Export;
|
||||
using MatterHackers.MatterControl.Plugins.X3GDriver;
|
||||
using MatterHackers.MatterControl.PrinterCommunication;
|
||||
using MatterHackers.MatterControl.SlicerConfiguration;
|
||||
using MatterHackers.VectorMath;
|
||||
|
||||
|
|
@ -348,7 +349,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
printer,
|
||||
null,
|
||||
CancellationToken.None,
|
||||
true);
|
||||
PrinterConnection.PrintingModes.Normal);
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -49,6 +49,7 @@ using MatterHackers.Localizations;
|
|||
using MatterHackers.MatterControl.CustomWidgets;
|
||||
using MatterHackers.MatterControl.DesignTools;
|
||||
using MatterHackers.MatterControl.Library;
|
||||
using MatterHackers.MatterControl.PrinterCommunication;
|
||||
using MatterHackers.MatterControl.PrinterControls.PrinterConnections;
|
||||
using MatterHackers.MatterControl.SlicerConfiguration;
|
||||
using MatterHackers.RayTracer;
|
||||
|
|
@ -942,7 +943,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
printer,
|
||||
null,
|
||||
CancellationToken.None,
|
||||
true).ConfigureAwait(false);
|
||||
PrinterConnection.PrintingModes.Normal).ConfigureAwait(false);
|
||||
});
|
||||
}
|
||||
else if (ProfileManager.Instance.ActiveProfiles.Count() <= 0)
|
||||
|
|
@ -1053,7 +1054,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
printer,
|
||||
null,
|
||||
CancellationToken.None,
|
||||
true);
|
||||
PrinterConnection.PrintingModes.Normal);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2110,24 +2110,31 @@ Make sure that your printer is turned on. Some printers will appear to be connec
|
|||
}
|
||||
}
|
||||
|
||||
public bool RecordPrintHistory { get; private set; }
|
||||
public PrintingModes PrintingMode { get; private set; }
|
||||
|
||||
private CancellationTokenSource printingCancellation;
|
||||
|
||||
public async Task StartPrint(string gcodeFilename, PrintTask printTaskToUse = null, bool recordPrintHistory = true)
|
||||
public enum PrintingModes
|
||||
{
|
||||
var gcodeStream = new StreamReader(gcodeFilename);
|
||||
await StartPrint(gcodeStream.BaseStream, gcodeFilename, printTaskToUse, recordPrintHistory);
|
||||
Normal,
|
||||
Calibration,
|
||||
AutoPilot,
|
||||
}
|
||||
|
||||
public async Task StartPrint(Stream gcodeStream, string gcodeFileNameForTask, PrintTask printTaskToUse, bool recordPrintHistory)
|
||||
public async Task StartPrint(string gcodeFilename, PrintTask printTaskToUse = null, PrintingModes printingMode = PrintingModes.Normal)
|
||||
{
|
||||
var gcodeStream = new StreamReader(gcodeFilename);
|
||||
await StartPrint(gcodeStream.BaseStream, gcodeFilename, printTaskToUse, printingMode);
|
||||
}
|
||||
|
||||
public async Task StartPrint(Stream gcodeStream, string gcodeFileNameForTask, PrintTask printTaskToUse, PrintingModes printingMode)
|
||||
{
|
||||
if (!this.IsConnected || Printing)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
this.RecordPrintHistory = recordPrintHistory;
|
||||
this.PrintingMode = printingMode;
|
||||
|
||||
printingCancellation = new CancellationTokenSource();
|
||||
|
||||
|
|
@ -2170,7 +2177,7 @@ Make sure that your printer is turned on. Some printers will appear to be connec
|
|||
|
||||
if (gcodeFileNameForTask != null
|
||||
&& ActivePrintTask == null
|
||||
&& RecordPrintHistory)
|
||||
&& PrintingMode != PrintingModes.Calibration)
|
||||
{
|
||||
// TODO: Fix printerItemID int requirement
|
||||
ActivePrintTask = new PrintTask
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit 503b73e80b06db075a0b3572498c916ff816b77e
|
||||
Subproject commit 22cfd2547fbffefc41b538488a4cad1a1a4bef06
|
||||
|
|
@ -595,7 +595,7 @@ namespace MatterControl.Tests.MatterControl.ToolChanges
|
|||
|
||||
// start a print
|
||||
printer.Connection.CommunicationState = CommunicationStates.PreparingToPrint;
|
||||
await printer.Connection.StartPrint(inputStream, null, null, true);
|
||||
await printer.Connection.StartPrint(inputStream, null, null, PrinterConnection.PrintingModes.Normal);
|
||||
|
||||
// wait up to 40 seconds for the print to finish
|
||||
timer = Stopwatch.StartNew();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue