2016-06-21 11:23:26 -07:00
|
|
|
|
/*
|
|
|
|
|
|
Copyright (c) 2016, 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 MatterHackers.Agg;
|
2017-08-20 02:34:39 -07:00
|
|
|
|
using MatterHackers.Agg.Platform;
|
2018-11-13 18:43:27 -08:00
|
|
|
|
using MatterHackers.MatterControl;
|
2017-08-20 15:52:43 -07:00
|
|
|
|
using MatterHackers.MatterControl.PrinterCommunication;
|
2016-06-21 11:23:26 -07:00
|
|
|
|
using MatterHackers.MatterControl.SlicerConfiguration;
|
|
|
|
|
|
using MatterHackers.MatterControl.Tests.Automation;
|
|
|
|
|
|
using NUnit.Framework;
|
|
|
|
|
|
|
|
|
|
|
|
namespace MatterControl.Tests.MatterControl
|
|
|
|
|
|
{
|
|
|
|
|
|
[TestFixture]
|
|
|
|
|
|
public class GCodeProcessingTests
|
|
|
|
|
|
{
|
2017-03-21 14:26:54 -07:00
|
|
|
|
[Test, Category("GCodeProcessing")]
|
|
|
|
|
|
public void ReadTemperaturesCorrectly()
|
|
|
|
|
|
{
|
|
|
|
|
|
ParseTempAndValidate("ok B:12.0 /0.0 T0:12.8 /0.0 T1:12.8 /0.0 T2:12.8 /0.0 @:0 B@:0", 12.8, 12.8, 12.8, 12.0);
|
|
|
|
|
|
|
|
|
|
|
|
ParseTempAndValidate("ok T:139.6 /0.0 @:0.00W", 139.6, 0, 0, 0.0);
|
|
|
|
|
|
ParseTempAndValidate("ok T:139.6 B:136.2 /0.0 @:0.00W", 139.6, 0, 0, 136.2);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void ParseTempAndValidate(string gcodeString, double? extruder0, double? extruder1, double? extruder2, double? bedTemp)
|
|
|
|
|
|
{
|
|
|
|
|
|
double[] extruders = new double[16];
|
|
|
|
|
|
double bed = 0;
|
2017-06-13 17:22:49 -07:00
|
|
|
|
PrinterConnection.ParseTemperatureString(gcodeString, extruders, null, ref bed, null);
|
2017-03-21 14:26:54 -07:00
|
|
|
|
Assert.IsTrue(extruders[0] == extruder0);
|
|
|
|
|
|
Assert.IsTrue(extruders[1] == extruder1);
|
|
|
|
|
|
Assert.IsTrue(extruders[2] == extruder2);
|
|
|
|
|
|
Assert.IsTrue(bed == bedTemp);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-11-29 17:34:13 -08:00
|
|
|
|
[Test]
|
|
|
|
|
|
public void SmoothieDualExtruderM105Response()
|
|
|
|
|
|
{
|
|
|
|
|
|
double[] extruders = new double[16];
|
|
|
|
|
|
double bed = 0;
|
|
|
|
|
|
|
|
|
|
|
|
// As of 2018-11-29 with an unknown users config
|
|
|
|
|
|
string smoothieDualExtruderM105Response = "ok T:220.1 /220.0 @109 T1:222.7 /221.0 @49 B:32.2 /0.0 @0";
|
|
|
|
|
|
|
|
|
|
|
|
PrinterConnection.ParseTemperatureString(smoothieDualExtruderM105Response, extruders, null, ref bed, null);
|
|
|
|
|
|
|
|
|
|
|
|
Assert.AreEqual("220.1", extruders[0].ToString("0.#"), "Incorrect Extruder 0 result");
|
|
|
|
|
|
Assert.AreEqual("222.7", extruders[1].ToString("0.#"), "Incorrect Extruder 1 result");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2016-09-20 09:39:57 -07:00
|
|
|
|
[Test, Category("GCodeProcessing")]
|
2016-06-21 11:23:26 -07:00
|
|
|
|
public void ReplaceMacroValuesWorking()
|
|
|
|
|
|
{
|
2022-07-15 17:28:39 -07:00
|
|
|
|
StaticData.RootPath = MatterControlUtilities.StaticDataPath;
|
|
|
|
|
|
MatterControlUtilities.OverrideAppDataLocation(MatterControlUtilities.RootPath);
|
2018-01-18 11:51:19 -08:00
|
|
|
|
|
2019-07-01 16:58:17 -07:00
|
|
|
|
var settings = new PrinterSettings();
|
|
|
|
|
|
settings.Slicer = new EngineMappingsMatterSlice();
|
2019-07-01 15:19:09 -07:00
|
|
|
|
|
2019-07-01 16:58:17 -07:00
|
|
|
|
void TestMacroReplacement(string inputText, string outputControl)
|
|
|
|
|
|
{
|
2021-07-30 15:18:35 -07:00
|
|
|
|
Assert.AreEqual(outputControl, settings.ReplaceSettingsNamesWithValues(inputText));
|
2019-07-01 16:58:17 -07:00
|
|
|
|
}
|
2019-07-01 15:19:09 -07:00
|
|
|
|
|
2016-06-21 11:23:26 -07:00
|
|
|
|
TestMacroReplacement("[temperature]", "200");
|
|
|
|
|
|
TestMacroReplacement("[first_layer_speed]", "1080");
|
|
|
|
|
|
TestMacroReplacement("[bed_remove_part_temperature]", "0");
|
|
|
|
|
|
TestMacroReplacement("[bridge_fan_speed]", "100");
|
2021-02-21 12:39:18 -08:00
|
|
|
|
TestMacroReplacement("[bridge_speed]", "3");
|
2016-06-21 11:23:26 -07:00
|
|
|
|
TestMacroReplacement("[external_perimeter_speed]", "1260");
|
|
|
|
|
|
TestMacroReplacement("[extruder_wipe_temperature]", "0");
|
|
|
|
|
|
TestMacroReplacement("[filament_diameter]", "3");
|
2018-12-18 11:29:44 -08:00
|
|
|
|
TestMacroReplacement("[first_layer_bed_temperature]", "70");
|
2016-06-21 11:23:26 -07:00
|
|
|
|
TestMacroReplacement("[first_layer_temperature]", "205");
|
|
|
|
|
|
TestMacroReplacement("{max_fan_speed}", "100");
|
|
|
|
|
|
TestMacroReplacement("{min_fan_speed}", "35");
|
|
|
|
|
|
TestMacroReplacement("{perimeter_speed}", "1800");
|
|
|
|
|
|
TestMacroReplacement("{raft_print_speed}", "3600");
|
|
|
|
|
|
TestMacroReplacement("{retract_length}", "1");
|
|
|
|
|
|
TestMacroReplacement("{retract_speed}", "1800");
|
|
|
|
|
|
TestMacroReplacement("{support_material_speed}", "3600");
|
|
|
|
|
|
TestMacroReplacement("{temperature}", "200");
|
2019-07-01 15:19:09 -07:00
|
|
|
|
TestMacroReplacement("[bed_temperature]", "70");
|
2016-06-21 11:23:26 -07:00
|
|
|
|
TestMacroReplacement("{infill_speed}", "3600");
|
|
|
|
|
|
TestMacroReplacement("{min_print_speed}", "600");
|
|
|
|
|
|
TestMacroReplacement("{travel_speed}", "7800");
|
2022-04-11 16:38:38 -07:00
|
|
|
|
|
|
|
|
|
|
// make sure we pick up the right temp when there is a bed surface change
|
|
|
|
|
|
settings.SetValue(SettingsKey.has_swappable_bed, "1");
|
|
|
|
|
|
settings.SetValue(SettingsKey.bed_temperature_blue_tape, "84.2");
|
|
|
|
|
|
settings.SetValue(SettingsKey.bed_surface, "Blue Tape");
|
|
|
|
|
|
TestMacroReplacement("[bed_temperature]", "84.2");
|
2016-06-21 11:23:26 -07:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|