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:
authorDavid Crocker <dcrocker@eschertech.com>2021-03-08 19:15:10 +0300
committerDavid Crocker <dcrocker@eschertech.com>2021-03-08 19:15:10 +0300
commitcaf4efcc6c823d0cd52e15c2a8afaab43991efea (patch)
treeffa89dc0f2eeac15296b238c1d46371fb0bc495e /src/Storage
parent3e5156684effdcddfe0002b63cf32a7f9ca2f485 (diff)
Support Fusion 360 slicer
Diffstat (limited to 'src/Storage')
-rw-r--r--src/Storage/FileInfoParser.cpp103
-rw-r--r--src/Storage/FileInfoParser.h11
2 files changed, 67 insertions, 47 deletions
diff --git a/src/Storage/FileInfoParser.cpp b/src/Storage/FileInfoParser.cpp
index 21c7a2a0..4e51a650 100644
--- a/src/Storage/FileInfoParser.cpp
+++ b/src/Storage/FileInfoParser.cpp
@@ -133,7 +133,7 @@ GCodeResult FileInfoParser::GetFileInfo(const char *filePath, GCodeFileInfo& inf
// Search for filament usage (Cura puts it at the beginning of a G-code file)
if (parsedFileInfo.numFilaments == 0)
{
- parsedFileInfo.numFilaments = FindFilamentUsed(buf, sizeToScan);
+ parsedFileInfo.numFilaments = FindFilamentUsed(buf);
headerInfoComplete &= (parsedFileInfo.numFilaments != 0);
}
@@ -146,19 +146,19 @@ GCodeResult FileInfoParser::GetFileInfo(const char *filePath, GCodeFileInfo& inf
// Look for layer height
if (parsedFileInfo.layerHeight == 0.0)
{
- headerInfoComplete &= FindLayerHeight(buf, sizeToScan);
+ headerInfoComplete &= FindLayerHeight(buf);
}
// Look for slicer program
if (parsedFileInfo.generatedBy.IsEmpty())
{
- headerInfoComplete &= FindSlicerInfo(buf, sizeToScan);
+ headerInfoComplete &= FindSlicerInfo(buf);
}
// Look for print time
if (parsedFileInfo.printTime == 0)
{
- headerInfoComplete &= FindPrintTime(buf, sizeToScan);
+ headerInfoComplete &= FindPrintTime(buf);
}
// Keep track of the time stats
@@ -261,7 +261,7 @@ GCodeResult FileInfoParser::GetFileInfo(const char *filePath, GCodeFileInfo& inf
// Search for filament used
if (parsedFileInfo.numFilaments == 0)
{
- parsedFileInfo.numFilaments = FindFilamentUsed(buf, sizeToScan);
+ parsedFileInfo.numFilaments = FindFilamentUsed(buf);
if (parsedFileInfo.numFilaments == 0)
{
footerInfoComplete = false;
@@ -271,7 +271,7 @@ GCodeResult FileInfoParser::GetFileInfo(const char *filePath, GCodeFileInfo& inf
// Search for layer height
if (parsedFileInfo.layerHeight == 0.0)
{
- if (!FindLayerHeight(buf, sizeToScan))
+ if (!FindLayerHeight(buf))
{
footerInfoComplete = false;
}
@@ -289,7 +289,7 @@ GCodeResult FileInfoParser::GetFileInfo(const char *filePath, GCodeFileInfo& inf
// Look for print time
if (parsedFileInfo.printTime == 0)
{
- if (!FindPrintTime(buf, sizeToScan) && fileBeingParsed->Length() - nextSeekPos <= GcodeFooterPrintTimeSearchSize)
+ if (!FindPrintTime(buf) && fileBeingParsed->Length() - nextSeekPos <= GcodeFooterPrintTimeSearchSize)
{
footerInfoComplete = false;
}
@@ -298,7 +298,7 @@ GCodeResult FileInfoParser::GetFileInfo(const char *filePath, GCodeFileInfo& inf
// Look for simulated print time. It will always be right at the end of the file, so don't look too far back
if (parsedFileInfo.simulatedTime == 0)
{
- if (!FindSimulatedTime(buf, sizeToScan) && fileBeingParsed->Length() - nextSeekPos <= GcodeFooterPrintTimeSearchSize)
+ if (!FindSimulatedTime(buf) && fileBeingParsed->Length() - nextSeekPos <= GcodeFooterPrintTimeSearchSize)
{
footerInfoComplete = false;
}
@@ -529,7 +529,7 @@ bool FileInfoParser::FindHeight(const char* bufp, size_t len) noexcept
}
// Scan the buffer for the layer height. The buffer is null-terminated.
-bool FileInfoParser::FindLayerHeight(const char *bufp, size_t len) noexcept
+bool FileInfoParser::FindLayerHeight(const char *bufp) noexcept
{
static const char* const layerHeightStrings[] =
{
@@ -578,7 +578,7 @@ bool FileInfoParser::FindLayerHeight(const char *bufp, size_t len) noexcept
return false;
}
-bool FileInfoParser::FindSlicerInfo(const char* bufp, size_t len) noexcept
+bool FileInfoParser::FindSlicerInfo(const char* bufp) noexcept
{
static const char * const GeneratedByStrings[] =
{
@@ -588,7 +588,8 @@ bool FileInfoParser::FindSlicerInfo(const char* bufp, size_t len) noexcept
";Sliced at: ", // Cura (old)
";Generated with ", // Cura (new)
"; Generated by ", // kiri:moto
- ";GENERATOR.NAME:" // Pathio (the version is separate, we don't include that)
+ ";GENERATOR.NAME:", // Pathio (the version is separate, we don't include that)
+ ";Fusion version:" // Fusion 360
};
size_t index = 0;
@@ -620,6 +621,10 @@ bool FileInfoParser::FindSlicerInfo(const char* bufp, size_t len) noexcept
introString = "Cura at ";
pos += strlen(GeneratedByStrings[index]);
break;
+
+ case 7: // Fusion 360
+ pos += 1;
+ break;
}
parsedFileInfo.generatedBy.copy(introString);
@@ -632,9 +637,38 @@ bool FileInfoParser::FindSlicerInfo(const char* bufp, size_t len) noexcept
return false;
}
+// Scan the buffer for a 2-part filament used string. Return the number of filament found.
+void FileInfoParser::FindFilamentUsedEmbedded(const char* p, const char *s1, const char *s2, unsigned int &filamentsFound) noexcept
+{
+ const size_t maxFilaments = reprap.GetGCodes().GetNumExtruders();
+ while (filamentsFound < maxFilaments && (p = strstr(p, s1)) != nullptr)
+ {
+ p += strlen(s1);
+ const char *q1, *q2;
+ uint32_t num = StrToU32(p, &q1);
+ if (q1 != p && num < maxFilaments && (q2 = strstr(q1, s2)) == q1)
+ {
+ p = q1 + strlen(s2);
+ while(strchr(" :\t", *p) != nullptr)
+ {
+ ++p; // this allows for " Used: "
+ }
+ if (isDigit(*p))
+ {
+ float filamentLength = SafeStrtof(p, nullptr);
+ if (!std::isnan(filamentLength) && !std::isinf(filamentLength))
+ {
+ parsedFileInfo.filamentNeeded[filamentsFound] = filamentLength;
+ ++filamentsFound;
+ }
+ }
+ }
+ }
+}
+
// Scan the buffer for the filament used. The buffer is null-terminated.
// Returns the number of filaments found.
-unsigned int FileInfoParser::FindFilamentUsed(const char* bufp, size_t len) noexcept
+unsigned int FileInfoParser::FindFilamentUsed(const char* bufp) noexcept
{
unsigned int filamentsFound = 0;
const size_t maxFilaments = reprap.GetGCodes().GetNumExtruders();
@@ -678,32 +712,12 @@ unsigned int FileInfoParser::FindFilamentUsed(const char* bufp, size_t len) noex
}
}
- // Look for filament usage string generated by Ideamaker
- const char* const filamentUsedStr2 = ";Material#"; // comment string used by Ideamaker, e.g. ";Material#1 Used: 868.0"
- p = bufp;
- while (filamentsFound < maxFilaments && (p = strstr(p, filamentUsedStr2)) != nullptr)
- {
- p += strlen(filamentUsedStr2);
- const char *q;
- uint32_t num = StrToU32(p, &q);
- if (q != p && num < maxFilaments)
- {
- p = q;
- while(strchr(" Used:\t", *p) != nullptr)
- {
- ++p; // this allows for " Used: "
- }
- if (isDigit(*p))
- {
- float filamentLength = SafeStrtof(p, nullptr);
- if (!std::isnan(filamentLength) && !std::isinf(filamentLength))
- {
- parsedFileInfo.filamentNeeded[filamentsFound] = filamentLength;
- ++filamentsFound;
- }
- }
- }
- }
+ // Look for filament usage strings generated by Ideamaker, e.g. ";Material#1 Used: 868.0"
+ FindFilamentUsedEmbedded(bufp, ";Material#", " Used", filamentsFound);
+
+ // Look for filament usage strings generated by Fusion 360, e.g. ";Extruder 1 material used: 1811mm"
+ FindFilamentUsedEmbedded(bufp, ";Extruder ", " material used", filamentsFound);
+
// Look for filament usage as generated by S3D
if (filamentsFound == 0)
@@ -788,7 +802,7 @@ unsigned int FileInfoParser::FindFilamentUsed(const char* bufp, size_t len) noex
}
// Scan the buffer for the estimated print time
-bool FileInfoParser::FindPrintTime(const char* bufp, size_t len) noexcept
+bool FileInfoParser::FindPrintTime(const char* bufp) noexcept
{
static const char* const PrintTimeStrings[] =
{
@@ -800,7 +814,8 @@ bool FileInfoParser::FindPrintTime(const char* bufp, size_t len) noexcept
" Build Time", // KISSlicer "; Estimated Build Time: 332.83 minutes"
// also KISSSlicer 2 alpha "; Calculated-during-export Build Time: 130.62 minutes"
";Print Time:", // Ideamaker
- ";PRINT.TIME:" // Patio
+ ";PRINT.TIME:", // Patio
+ ";Print time:" // Fusion 360
};
for (const char * ptStr : PrintTimeStrings)
@@ -838,7 +853,7 @@ bool FileInfoParser::FindPrintTime(const char* bufp, size_t len) noexcept
++pos;
}
secs = SafeStrtof(pos, &pos);
- while (*pos == ' ')
+ while (*pos == ' ' || *pos == ':') // Fusion 360 gives e.g. ";Print time: 40m:36s"
{
++pos;
}
@@ -854,6 +869,10 @@ bool FileInfoParser::FindPrintTime(const char* bufp, size_t len) noexcept
{
pos += 6;
}
+ else if (StringStartsWithIgnoreCase(pos, "min")) // Fusion 360
+ {
+ pos += 3;
+ }
else
{
++pos;
@@ -869,7 +888,7 @@ bool FileInfoParser::FindPrintTime(const char* bufp, size_t len) noexcept
}
// Scan the buffer for the simulated print time
-bool FileInfoParser::FindSimulatedTime(const char* bufp, size_t len) noexcept
+bool FileInfoParser::FindSimulatedTime(const char* bufp) noexcept
{
const char* pos = strstr(bufp, SimulatedTimeString);
if (pos != nullptr)
diff --git a/src/Storage/FileInfoParser.h b/src/Storage/FileInfoParser.h
index e3ff0b6e..504fed18 100644
--- a/src/Storage/FileInfoParser.h
+++ b/src/Storage/FileInfoParser.h
@@ -55,11 +55,12 @@ private:
// G-Code parser methods
bool FindHeight(const char* bufp, size_t len) noexcept;
bool FindFirstLayerHeight(const char* bufp, size_t len) noexcept;
- bool FindLayerHeight(const char* bufp, size_t len) noexcept;
- bool FindSlicerInfo(const char* bufp, size_t len) noexcept;
- bool FindPrintTime(const char* bufp, size_t len) noexcept;
- bool FindSimulatedTime(const char* bufp, size_t len) noexcept;
- unsigned int FindFilamentUsed(const char* bufp, size_t len) noexcept;
+ bool FindLayerHeight(const char* bufp) noexcept;
+ bool FindSlicerInfo(const char* bufp) noexcept;
+ bool FindPrintTime(const char* bufp) noexcept;
+ bool FindSimulatedTime(const char* bufp) noexcept;
+ unsigned int FindFilamentUsed(const char* bufp) noexcept;
+ void FindFilamentUsedEmbedded(const char* p, const char *s1, const char *s2, unsigned int &filamentsFound) noexcept;
// We parse G-Code files in multiple stages. These variables hold the required information
Mutex parserMutex;