Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/Duet3D/RepRapFirmware.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/GCodes/GCodes2.cpp4
-rw-r--r--src/PrintMonitor.cpp26
-rw-r--r--src/PrintMonitor.h9
3 files changed, 34 insertions, 5 deletions
diff --git a/src/GCodes/GCodes2.cpp b/src/GCodes/GCodes2.cpp
index 21d30c23..60a81097 100644
--- a/src/GCodes/GCodes2.cpp
+++ b/src/GCodes/GCodes2.cpp
@@ -1268,6 +1268,10 @@ bool GCodes::HandleMcode(GCodeBuffer& gb, const StringRef& reply) THROWS(GCodeEx
}
break;
+ case 73: // Slicer-inserted print time values
+ result = reprap.GetPrintMonitor().ProcessM73(gb, reply);
+ break;
+
case 80: // ATX power on
atxPowerControlled = true;
platform.AtxPowerOn();
diff --git a/src/PrintMonitor.cpp b/src/PrintMonitor.cpp
index 048302bd..84f5a61f 100644
--- a/src/PrintMonitor.cpp
+++ b/src/PrintMonitor.cpp
@@ -19,7 +19,8 @@ Licence: GPL
#include "PrintMonitor.h"
-#include "GCodes/GCodes.h"
+#include <GCodes/GCodes.h>
+#include <GCodes/GCodeBuffer/GCodeBuffer.h>
#include "Heating/Heat.h"
#include "Movement/Move.h"
#include "Platform.h"
@@ -82,9 +83,10 @@ constexpr ObjectModelTableEntry PrintMonitor::objectModelTable[] =
{ "filament", OBJECT_MODEL_FUNC(self->EstimateTimeLeftAsExpression(filamentBased)), ObjectModelEntryFlags::live },
{ "file", OBJECT_MODEL_FUNC(self->EstimateTimeLeftAsExpression(fileBased)), ObjectModelEntryFlags::live },
{ "layer", OBJECT_MODEL_FUNC(self->EstimateTimeLeftAsExpression(layerBased)), ObjectModelEntryFlags::live },
+ { "slicer", OBJECT_MODEL_FUNC(self->EstimateTimeLeftAsExpression(slicerBased)), ObjectModelEntryFlags::live },
};
-constexpr uint8_t PrintMonitor::objectModelTableDescriptor[] = { 3, 10 + TRACK_OBJECT_NAMES, 11, 3 };
+constexpr uint8_t PrintMonitor::objectModelTableDescriptor[] = { 3, 10 + TRACK_OBJECT_NAMES, 11, 4 };
DEFINE_GET_OBJECT_MODEL_TABLE(PrintMonitor)
@@ -137,6 +139,17 @@ void PrintMonitor::SetPrintingFileInfo(const char *filename, GCodeFileInfo &info
reprap.JobUpdated();
}
+GCodeResult PrintMonitor::ProcessM73(GCodeBuffer& gb, const StringRef& reply) THROWS(GCodeException)
+{
+ if (gb.Seen('R'))
+ {
+ slicerTimeLeft = gb.GetFValue() * MinutesToSeconds;
+ whenSlicerTimeLeftSet = millis();
+ }
+ // M73 without P Q R or S parameters reports print progress in some implementations, but we don't currently do that
+ return GCodeResult::ok;
+}
+
void PrintMonitor::Spin() noexcept
{
#if HAS_LINUX_INTERFACE
@@ -288,6 +301,8 @@ void PrintMonitor::StartingPrint(const char* filename) noexcept
# endif
{
printingFileParsed = (MassStorage::GetFileInfo(filenameBeingPrinted.c_str(), printingFileInfo, false) != GCodeResult::notFinished);
+ slicerTimeLeft = (printingFileParsed) ? printingFileInfo.printTime : 0.0;
+ whenSlicerTimeLeftSet = millis();
}
reprap.JobUpdated();
#endif
@@ -303,6 +318,7 @@ void PrintMonitor::Reset() noexcept
lastLayerChangeTime = lastLayerFilament = lastLayerZ = 0.0;
lastLayerNumberNotified = 0;
lastLayerStartHeightNotified = 0.0;
+ slicerTimeLeft = 0.0;
reprap.JobUpdated();
}
@@ -550,10 +566,12 @@ float PrintMonitor::EstimateTimeLeft(PrintEstimationMethod method) const noexcep
// Layer-based estimations are made after each layer change, only reflect this value
if (layerEstimatedTimeLeft > 0.0)
{
- float timeLeft = layerEstimatedTimeLeft - (GetPrintDuration() - lastLayerChangeTime);
- return (timeLeft > 0.0) ? timeLeft : 0.1;
+ return max<float>(0.1, layerEstimatedTimeLeft - (GetPrintDuration() - lastLayerChangeTime));
}
break;
+
+ case slicerBased:
+ return max<float>(0.1, slicerTimeLeft - (millis() - whenSlicerTimeLeftSet) * MillisToSeconds);
}
return 0.0;
diff --git a/src/PrintMonitor.h b/src/PrintMonitor.h
index 77e872c2..579db17a 100644
--- a/src/PrintMonitor.h
+++ b/src/PrintMonitor.h
@@ -21,6 +21,7 @@ Licence: GPL
#define PRINTMONITOR_H
#include <RepRapFirmware.h>
+#include <GCodes/GCodeResult.h>
#include <GCodes/GCodeFileInfo.h>
#include <ObjectModel/ObjectModel.h>
@@ -37,7 +38,8 @@ enum PrintEstimationMethod
{
filamentBased,
fileBased,
- layerBased
+ layerBased,
+ slicerBased
};
class PrintMonitor INHERIT_OBJECT_MODEL
@@ -73,6 +75,8 @@ public:
bool GetPrintingFileInfo(GCodeFileInfo& info) noexcept;
void SetPrintingFileInfo(const char *filename, GCodeFileInfo& info) noexcept;
+ GCodeResult ProcessM73(GCodeBuffer& gb, const StringRef& reply) THROWS(GCodeException);
+
protected:
DECLARE_OBJECT_MODEL
OBJECT_MODEL_ARRAY(filament)
@@ -108,6 +112,9 @@ private:
float fileProgressPerLayer[MAX_LAYER_SAMPLES];
float layerEstimatedTimeLeft;
+ float slicerTimeLeft; // time left in seconds as reported by slicer
+ uint32_t whenSlicerTimeLeftSet;
+
unsigned int lastLayerNumberNotified;
float lastLayerStartHeightNotified;