Merge branch 'design_tools' into design_tools

This commit is contained in:
Lars Brubaker 2018-03-14 17:35:03 -07:00 committed by GitHub
commit afc02fdfd6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 130 additions and 46 deletions

View file

@ -40,7 +40,6 @@
<SchemaVersion>2.0</SchemaVersion>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<TargetFrameworkProfile />
<ReleaseVersion>1.2.0</ReleaseVersion>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">.\</SolutionDir>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
@ -474,6 +473,7 @@
<Compile Include="CustomWidgets\SplitButton.cs" />
<Compile Include="ControlElements\DropDownMenuFactory.cs" />
<Compile Include="ControlElements\SplitButtonFactory.cs" />
<Compile Include="PrinterCommunication\Io\SendProgressStream.cs" />
</ItemGroup>
<ItemGroup>
<Reference Include="Microsoft.CSharp" />

View file

@ -0,0 +1,69 @@
/*
Copyright (c) 2015, Lars Brubaker
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 MatterHackers.MatterControl.DataStorage;
using MatterHackers.MatterControl.SlicerConfiguration;
using System;
namespace MatterHackers.MatterControl.PrinterCommunication.Io
{
public class SendProgressStream : GCodeStreamProxy
{
private double nextPercent = -1;
PrinterConfig printer;
PrintTask activePrintTask;
public SendProgressStream(PrinterConfig printer, GCodeStream internalStream)
: base(internalStream)
{
this.printer = printer;
}
public override string ReadLine()
{
if (printer.Settings.GetValue(SettingsKey.progress_reporting) != "None"
&& printer.Connection.CommunicationState == CommunicationStates.Printing
&& printer.Connection.activePrintTask != null
&& printer.Connection.activePrintTask.PercentDone > nextPercent)
{
nextPercent = Math.Round(printer.Connection.activePrintTask.PercentDone) + 0.5;
if (printer.Settings.GetValue(SettingsKey.progress_reporting) == "M73")
{
return String.Format("M73 P{0:0}", printer.Connection.activePrintTask.PercentDone);
}
else
{
return String.Format("M117 Printing: {0:0}%", printer.Connection.activePrintTask.PercentDone);
}
}
return base.ReadLine();
}
}
}

View file

@ -154,7 +154,7 @@ namespace MatterHackers.MatterControl.PrinterCommunication
private object locker = new object();
private PrintTask activePrintTask;
public PrintTask activePrintTask;
private double actualBedTemperature;
@ -187,17 +187,18 @@ namespace MatterHackers.MatterControl.PrinterCommunication
private PrinterMove lastReportedPosition;
private GCodeFileStream gCodeFileStream0 = null;
private PauseHandlingStream pauseHandlingStream1 = null;
private QueuedCommandsStream queuedCommandStream2 = null;
private MacroProcessingStream macroProcessingStream3 = null;
private RelativeToAbsoluteStream relativeToAbsoluteStream4 = null;
private PrintLevelingStream printLevelingStream5 = null;
private WaitForTempStream waitForTempStream6 = null;
private BabyStepsStream babyStepsStream7 = null;
private ExtrusionMultiplyerStream extrusionMultiplyerStream8 = null;
private FeedRateMultiplyerStream feedrateMultiplyerStream9 = null;
private RequestTemperaturesStream requestTemperaturesStream10 = null;
private ProcessWriteRegexStream processWriteRegExStream11 = null;
private SendProgressStream sendProgressStream1 = null;
private PauseHandlingStream pauseHandlingStream2 = null;
private QueuedCommandsStream queuedCommandStream3 = null;
private MacroProcessingStream macroProcessingStream4 = null;
private RelativeToAbsoluteStream relativeToAbsoluteStream5 = null;
private PrintLevelingStream printLevelingStream6 = null;
private WaitForTempStream waitForTempStream7 = null;
private BabyStepsStream babyStepsStream8 = null;
private ExtrusionMultiplyerStream extrusionMultiplyerStream9 = null;
private FeedRateMultiplyerStream feedrateMultiplyerStream10 = null;
private RequestTemperaturesStream requestTemperaturesStream11 = null;
private ProcessWriteRegexStream processWriteRegExStream12 = null;
private GCodeStream totalGCodeStream = null;
@ -1679,7 +1680,7 @@ namespace MatterHackers.MatterControl.PrinterCommunication
return;
}
pauseHandlingStream1.DoPause(PauseHandlingStream.PauseReason.UserRequested);
pauseHandlingStream2.DoPause(PauseHandlingStream.PauseReason.UserRequested);
}
}
@ -1707,7 +1708,7 @@ namespace MatterHackers.MatterControl.PrinterCommunication
}
else
{
pauseHandlingStream1.Resume();
pauseHandlingStream2.Resume();
CommunicationState = CommunicationStates.Printing;
}
}
@ -1771,7 +1772,7 @@ namespace MatterHackers.MatterControl.PrinterCommunication
if (lineToWrite.Trim().Length > 0)
{
// insert the command into the printing queue at the head
queuedCommandStream2?.Add(lineToWrite, forceTopOfQueue);
queuedCommandStream3?.Add(lineToWrite, forceTopOfQueue);
}
}
}
@ -2129,17 +2130,18 @@ namespace MatterHackers.MatterControl.PrinterCommunication
if (this.RecoveryIsEnabled
&& activePrintTask != null) // We are resuming a failed print (do lots of interesting stuff).
{
pauseHandlingStream1 = new PauseHandlingStream(printer, new PrintRecoveryStream(printer, gCodeFileStream0, activePrintTask.PercentDone));
sendProgressStream1 = new SendProgressStream(printer, new PrintRecoveryStream(printer, gCodeFileStream0, activePrintTask.PercentDone));
// And increment the recovery count
activePrintTask.RecoveryCount++;
activePrintTask.Commit();
}
else
{
pauseHandlingStream1 = new PauseHandlingStream(printer, gCodeFileStream0);
sendProgressStream1 = new SendProgressStream(printer, gCodeFileStream0);
}
firstStream = pauseHandlingStream1;
pauseHandlingStream2 = new PauseHandlingStream(printer, sendProgressStream1);
firstStream = pauseHandlingStream2;
}
else
{
@ -2147,25 +2149,25 @@ namespace MatterHackers.MatterControl.PrinterCommunication
firstStream = new NotPrintingStream();
}
queuedCommandStream2 = new QueuedCommandsStream(firstStream);
macroProcessingStream3 = new MacroProcessingStream(queuedCommandStream2, printer);
relativeToAbsoluteStream4 = new RelativeToAbsoluteStream(macroProcessingStream3);
printLevelingStream5 = new PrintLevelingStream(printer.Settings, relativeToAbsoluteStream4, true);
waitForTempStream6 = new WaitForTempStream(this, printLevelingStream5);
babyStepsStream7 = new BabyStepsStream(printer.Settings, waitForTempStream6, gcodeFilename == null ? 2000 : 1);
queuedCommandStream3 = new QueuedCommandsStream(firstStream);
macroProcessingStream4 = new MacroProcessingStream(queuedCommandStream3, printer);
relativeToAbsoluteStream5 = new RelativeToAbsoluteStream(macroProcessingStream4);
printLevelingStream6 = new PrintLevelingStream(printer.Settings, relativeToAbsoluteStream5, true);
waitForTempStream7 = new WaitForTempStream(this, printLevelingStream6);
babyStepsStream8 = new BabyStepsStream(printer.Settings, waitForTempStream7, gcodeFilename == null ? 2000 : 1);
if (activePrintTask != null)
{
// make sure we are in the position we were when we stopped printing
babyStepsStream7.Offset = new Vector3(activePrintTask.PrintingOffsetX, activePrintTask.PrintingOffsetY, activePrintTask.PrintingOffsetZ);
babyStepsStream8.Offset = new Vector3(activePrintTask.PrintingOffsetX, activePrintTask.PrintingOffsetY, activePrintTask.PrintingOffsetZ);
}
extrusionMultiplyerStream8 = new ExtrusionMultiplyerStream(babyStepsStream7);
feedrateMultiplyerStream9 = new FeedRateMultiplyerStream(extrusionMultiplyerStream8);
requestTemperaturesStream10 = new RequestTemperaturesStream(this, feedrateMultiplyerStream9);
processWriteRegExStream11 = new ProcessWriteRegexStream(this.printer.Settings, requestTemperaturesStream10, queuedCommandStream2);
totalGCodeStream = processWriteRegExStream11;
extrusionMultiplyerStream9 = new ExtrusionMultiplyerStream(babyStepsStream8);
feedrateMultiplyerStream10 = new FeedRateMultiplyerStream(extrusionMultiplyerStream9);
requestTemperaturesStream11 = new RequestTemperaturesStream(this, feedrateMultiplyerStream10);
processWriteRegExStream12 = new ProcessWriteRegexStream(this.printer.Settings, requestTemperaturesStream11, queuedCommandStream3);
totalGCodeStream = processWriteRegExStream12;
// Force a reset of the printer checksum state (but allow it to be write regexed)
var transformedCommand = processWriteRegExStream11?.ProcessWriteRegEx("M110 N1");
var transformedCommand = processWriteRegExStream12?.ProcessWriteRegEx("M110 N1");
if (transformedCommand != null)
{
foreach (var line in transformedCommand)
@ -2198,13 +2200,13 @@ namespace MatterHackers.MatterControl.PrinterCommunication
// Only update the amount done if it is greater than what is recorded.
// We don't want to mess up the resume before we actually resume it.
if (activePrintTask != null
&& babyStepsStream7 != null
&& babyStepsStream8 != null
&& activePrintTask.PercentDone < currentDone)
{
activePrintTask.PercentDone = currentDone;
activePrintTask.PrintingOffsetX = (float)babyStepsStream7.Offset.X;
activePrintTask.PrintingOffsetY = (float)babyStepsStream7.Offset.Y;
activePrintTask.PrintingOffsetZ = (float)babyStepsStream7.Offset.Z;
activePrintTask.PrintingOffsetX = (float)babyStepsStream8.Offset.X;
activePrintTask.PrintingOffsetY = (float)babyStepsStream8.Offset.Y;
activePrintTask.PrintingOffsetZ = (float)babyStepsStream8.Offset.Z;
activePrintTask?.Commit();
// Interval looks to be ~10ms
@ -2293,11 +2295,11 @@ namespace MatterHackers.MatterControl.PrinterCommunication
{
DetailedPrintingState = DetailedPrintingState.HomingAxis;
}
else if (waitForTempStream6?.HeatingBed ?? false)
else if (waitForTempStream7?.HeatingBed ?? false)
{
DetailedPrintingState = DetailedPrintingState.HeatingBed;
}
else if (waitForTempStream6?.HeatingExtruder ?? false)
else if (waitForTempStream7?.HeatingExtruder ?? false)
{
DetailedPrintingState = DetailedPrintingState.HeatingExtruder;
}
@ -2620,21 +2622,21 @@ namespace MatterHackers.MatterControl.PrinterCommunication
public void MacroStart()
{
queuedCommandStream2?.Reset();
macroProcessingStream3.Reset();
queuedCommandStream3?.Reset();
macroProcessingStream4.Reset();
}
public void MacroCancel()
{
babyStepsStream7?.CancelMoves();
waitForTempStream6?.Cancel();
queuedCommandStream2?.Cancel();
macroProcessingStream3?.Cancel();
babyStepsStream8?.CancelMoves();
waitForTempStream7?.Cancel();
queuedCommandStream3?.Cancel();
macroProcessingStream4?.Cancel();
}
public void MacroContinue()
{
macroProcessingStream3?.Continue();
macroProcessingStream4?.Continue();
}
public class ReadThread
@ -2776,4 +2778,4 @@ namespace MatterHackers.MatterControl.PrinterCommunication
public int Index0Based { get; }
public double Temperature { get; }
}
}
}

View file

@ -124,6 +124,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
public const string print_leveling_required_to_print = nameof(print_leveling_required_to_print);
public const string print_leveling_solution = nameof(print_leveling_solution);
public const string printer_name = nameof(printer_name);
public const string progress_reporting = nameof(progress_reporting);
public const string publish_bed_image = nameof(publish_bed_image);
public const string read_regex = nameof(read_regex);
public const string recover_first_layer_speed = nameof(recover_first_layer_speed);

View file

@ -105,6 +105,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
SettingsKey.max_acceleration,
SettingsKey.ip_address,
SettingsKey.ip_port,
SettingsKey.progress_reporting,
"load_filament_length",
"trim_image",
"clean_nozzle_image",

View file

@ -156,6 +156,8 @@ Printer
recover_is_enabled
recover_first_layer_speed
recover_position_before_z_home
Other
progress_reporting
Leveling
Print Leveling
print_leveling_solution

View file

@ -1928,5 +1928,14 @@
"DataEditType": "STRING",
"DefaultValue": "x,3000,y,3000,z,315,e0,150",
"RebuildGCodeOnChange": false
},
{
"SlicerConfigName": "progress_reporting",
"PresentationName": "Progress Reporting",
"HelpText": "Choose the command for showing the print progress on the printer's LCD screen, if it has one.",
"DataEditType": "LIST",
"ListValues": "None,M73,M117",
"DefaultValue": "M117",
"RebuildGCodeOnChange": false
}
]