public (double fixedTime, double variableTime, double totalTime) GetLayerTimes() { IntPoint lastPosition = gcodeExport.GetPosition(); double fixedTime = 0.0; double variableTime = 0.0; foreach (var path in paths) { for (int pointIndex = 0; pointIndex < path.Polygon.Count; pointIndex++) { IntPoint currentPosition = path.Polygon[pointIndex]; double thisTime = (lastPosition - currentPosition).LengthMm() / (double)(path.Speed); thisTime = Estimator.GetSecondsForMovement((lastPosition - currentPosition).LengthMm(), path.Speed, config.MaxAcceleration, config.MaxVelocity, config.JerkVelocity) * config.PrintTimeEstimateMultiplier; if (PathCanAdjustSpeed(path)) { variableTime += thisTime; } else { fixedTime += thisTime; } lastPosition = currentPosition; } } return(fixedTime, variableTime, fixedTime + variableTime); }
public void CorrectLayerTimeConsideringMinimumLayerTime(double minTime, int minimumPrintingSpeed) { IntPoint lastPosition = gcodeExport.GetPosition(); double travelTime = 0.0; double extrudeTime = 0.0; for (int pathIndex = 0; pathIndex < paths.Count; pathIndex++) { GCodePath path = paths[pathIndex]; for (int pointIndex = 0; pointIndex < path.Polygon.Count; pointIndex++) { IntPoint currentPosition = path.Polygon[pointIndex]; double thisTime = (lastPosition - currentPosition).LengthMm() / (double)(path.config.speed); if (path.config.lineWidth_um != 0) { extrudeTime += thisTime; } else { travelTime += thisTime; } lastPosition = currentPosition; } } gcodeExport.LayerTime = extrudeTime + travelTime; if (gcodeExport.LayerTime < minTime && extrudeTime > 0.0) { double minExtrudeTime = minTime - travelTime; if (minExtrudeTime < 1) { minExtrudeTime = 1; } gcodeExport.LayerSpeedRatio = GetNewLayerSpeedRatio(minimumPrintingSpeed, extrudeTime, minExtrudeTime); gcodeExport.LayerTime = (extrudeTime / gcodeExport.LayerSpeedRatio) + travelTime; } this.totalPrintTime = gcodeExport.LayerTime; }
public void ForceMinimumLayerTime(double minTime, int minimumPrintingSpeed) { Point3 lastPosition = gcodeExport.GetPosition(); double travelTime = 0.0; double extrudeTime = 0.0; for (int n = 0; n < paths.Count; n++) { GCodePath path = paths[n]; for (int pointIndex = 0; pointIndex < path.points.Count; pointIndex++) { Point3 currentPosition = path.points[pointIndex]; double thisTime = (lastPosition - currentPosition).LengthMm() / (double)(path.config.speed); if (path.config.lineWidth_um != 0) { extrudeTime += thisTime; } else { travelTime += thisTime; } lastPosition = currentPosition; } } double totalTime = extrudeTime + travelTime; if (totalTime < minTime && extrudeTime > 0.0) { double minExtrudeTime = minTime - travelTime; if (minExtrudeTime < 1) { minExtrudeTime = 1; } double factor = extrudeTime / minExtrudeTime; for (int n = 0; n < paths.Count; n++) { GCodePath path = paths[n]; if (path.config.lineWidth_um == 0) { continue; } int speed = (int)(path.config.speed * factor); if (speed < minimumPrintingSpeed) { factor = (double)(minimumPrintingSpeed) / (double)(path.config.speed); } } //Only slow down with the minimum time if that will be slower then a factor already set. First layer slowdown also sets the speed factor. if (factor * 100 < getExtrudeSpeedFactor()) { SetExtrudeSpeedFactor((int)(factor * 100)); } else { factor = getExtrudeSpeedFactor() / 100.0; } if (minTime - (extrudeTime / factor) - travelTime > 0.1) { //TODO: Use up this extra time (circle around the print?) this.extraTime = minTime - (extrudeTime / factor) - travelTime; } this.totalPrintTime = (extrudeTime / factor) + travelTime; } else { this.totalPrintTime = totalTime; } }