Apply analysis throttle only every n lines
Default n = 100, configurable via config.yaml. Should make analysis a bit faster while still giving the Pi air to breathe.
This commit is contained in:
parent
d7b29a8725
commit
d298c3c672
3 changed files with 12 additions and 8 deletions
|
|
@ -308,9 +308,12 @@ class GcodeAnalysisQueue(AbstractAnalysisQueue):
|
|||
def _do_analysis(self, high_priority=False):
|
||||
try:
|
||||
throttle = settings().getFloat(["gcodeAnalysis", "throttle_highprio"]) if high_priority else settings().getFloat(["gcodeAnalysis", "throttle_normalprio"])
|
||||
throttle_lines = settings().getInt(["gcodeAnalysis", "throttle_lines"])
|
||||
if throttle > 0:
|
||||
def throttle_callback():
|
||||
time.sleep(throttle)
|
||||
def throttle_callback(filePos, readBytes):
|
||||
if filePos % throttle_lines == 0:
|
||||
# only apply throttle every 100 lines
|
||||
time.sleep(throttle)
|
||||
else:
|
||||
throttle_callback = None
|
||||
|
||||
|
|
|
|||
|
|
@ -179,7 +179,8 @@ default_settings = {
|
|||
"gcodeAnalysis": {
|
||||
"maxExtruders": 10,
|
||||
"throttle_normalprio": 0.01,
|
||||
"throttle_highprio": 0.0
|
||||
"throttle_highprio": 0.0,
|
||||
"throttle_lines": 100
|
||||
},
|
||||
"feature": {
|
||||
"temperatureGraph": True,
|
||||
|
|
|
|||
|
|
@ -221,7 +221,7 @@ class gcode(object):
|
|||
self._reenqueue = reenqueue
|
||||
|
||||
def _load(self, gcodeFile, printer_profile, throttle=None):
|
||||
filePos = 0
|
||||
lineNo = 0
|
||||
readBytes = 0
|
||||
pos = Vector3D(0.0, 0.0, 0.0)
|
||||
posOffset = Vector3D(0.0, 0.0, 0.0)
|
||||
|
|
@ -245,18 +245,18 @@ class gcode(object):
|
|||
for line in gcodeFile:
|
||||
if self._abort:
|
||||
raise AnalysisAborted(reenqueue=self._reenqueue)
|
||||
filePos += 1
|
||||
lineNo += 1
|
||||
readBytes += len(line)
|
||||
|
||||
if isinstance(gcodeFile, (file)):
|
||||
percentage = float(readBytes) / float(self._fileSize)
|
||||
elif isinstance(gcodeFile, (list)):
|
||||
percentage = float(filePos) / float(len(gcodeFile))
|
||||
percentage = float(lineNo) / float(len(gcodeFile))
|
||||
else:
|
||||
percentage = None
|
||||
|
||||
try:
|
||||
if self.progressCallback is not None and (filePos % 1000 == 0) and percentage is not None:
|
||||
if self.progressCallback is not None and (lineNo % 1000 == 0) and percentage is not None:
|
||||
self.progressCallback(percentage)
|
||||
except:
|
||||
pass
|
||||
|
|
@ -444,7 +444,7 @@ class gcode(object):
|
|||
totalExtrusion.append(0.0)
|
||||
|
||||
if throttle is not None:
|
||||
throttle()
|
||||
throttle(lineNo, readBytes)
|
||||
if self.progressCallback is not None:
|
||||
self.progressCallback(100.0)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue