Skip to content

Commit

Permalink
Merge pull request #34 from avmaisak/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
avmaisak authored Feb 17, 2020
2 parents db8c622 + 9db32af commit 4206e64
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/Gcode.Utils/Gcode.Utils.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
<PackageTags>gcode 3d-printing reprap reprap-3d-printer marlin marlin-firmware repitier repitier-firmware json json-parsing gcode-json cura kisslicer slic3r simplify3d</PackageTags>
<RepositoryType>git</RepositoryType>
<Copyright>Anton Maisak</Copyright>
<AssemblyVersion>0.2.0.16</AssemblyVersion>
<AssemblyVersion>0.2.0.17</AssemblyVersion>
<PackageReleaseNotes></PackageReleaseNotes>
<Version>0.2.16</Version>
<FileVersion>0.2.0.16</FileVersion>
<Version>0.2.17</Version>
<FileVersion>0.2.0.17</FileVersion>
<PackageIconUrl></PackageIconUrl>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<PackageIcon>logo.png</PackageIcon>
Expand Down
25 changes: 22 additions & 3 deletions src/Gcode.Utils/SlicerParser/PrusaSlicerParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,34 @@ public override Slic3RInfo GetSlicerInfo(string[] fileContent)
}

if (res.FilamentUsedExtruder1 != null && res.FilamentUsedExtruder1 > 0 && res.FilamentDiameter != null && res.FilamentDiameter > 0)
{
// обьем = сечение * длину
res.FilamentUsedExtruder1Volume = res.FilamentDiameter * res.FilamentUsedExtruder1;
}


if (res.FilamentUsedExtruder2 != null && res.FilamentUsedExtruder2 > 0 && res.FilamentDiameter != null && res.FilamentDiameter > 0)
{
// обьем = сечение * длину
res.FilamentUsedExtruder2Volume = res.FilamentDiameter * res.FilamentUsedExtruder2;

// estimated printing time
var buildTimeStr = fileContent.FirstOrDefault(x => x.StartsWith("; estimated printing time"));

if (!string.IsNullOrWhiteSpace(buildTimeStr))
{
var buildTime = buildTimeStr.Split('=')[1]?.Trim();
if (!string.IsNullOrWhiteSpace(buildTime))
{
var resArr = buildTime.Split(' ');
var hours = 0;
var minutes = 0;
var seconds = 0;

if (resArr.Where(x => x.Contains("h"))?.Count() > 0) hours = Convert.ToInt32(resArr?.FirstOrDefault(x => x.Contains("h"))?.Split('h')?[0] ?? "0");
if (resArr.Where(x => x.Contains("m"))?.Count() > 0) minutes = Convert.ToInt32(resArr?.FirstOrDefault(x => x.Contains("m"))?.Split('m')?[0] ?? "0");
if (resArr.Where(x => x.Contains("s"))?.Count() > 0) seconds = Convert.ToInt32(resArr?.FirstOrDefault(x => x.Contains("s"))?.Split('s')?[0] ?? "0");

var spanDuration = new TimeSpan(0, hours, minutes, seconds);
res.EstimatedBuildTime = Math.Round(Convert.ToDecimal(spanDuration.TotalMinutes), 2);
}
}

return res;
Expand Down
3 changes: 3 additions & 0 deletions tools/TestSuite/Gcode.Test/Parser/PrusaSlicerParserTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public void PrusaSlicerParserTest1()
Assert.IsTrue(res.FilamentUsedExtruder1 == (decimal)11773.6);
Assert.IsTrue(res.FilamentDiameter == (decimal)1.75);
Assert.IsTrue(res.FilamentUsedExtruder1Volume == (decimal)20603.800);
Assert.IsTrue(res.EstimatedBuildTime == (decimal)321.17);
}
}
[TestMethod]
Expand All @@ -39,6 +40,7 @@ public void PrusaSlicerParserTest2()
Assert.IsTrue(res.FilamentUsedExtruder1 == (decimal)912.1);
Assert.IsTrue(res.FilamentDiameter == (decimal)1.75);
Assert.IsTrue(res.FilamentUsedExtruder1Volume == (decimal)1596.175);
Assert.IsTrue(res.EstimatedBuildTime == (decimal)37.35);
}
}
[TestMethod]
Expand All @@ -55,6 +57,7 @@ public void PrusaSlicerParserTest3()
Assert.IsTrue(res.FilamentUsedExtruder1 == (decimal)10604.9);
Assert.IsTrue(res.FilamentUsedExtruder2 == (decimal)62.3);
Assert.IsTrue(res.FilamentDiameter == (decimal)1.75);
Assert.IsTrue(res.EstimatedBuildTime == (decimal)123.25);
}
}
}
Expand Down

0 comments on commit 4206e64

Please sign in to comment.