1 """
2 Apply the cooling by moving the nozzle around the print.
3 """
4 from config import config
5 from data_structures import GcodeCommand
6 from fabmetheus_utilities import euclidean
7 import gcodes
8
10 '''Returns an instance of the strategy'''
11 return OrbitCoolStrategy(runtimeParameters)
12
14 '''Allows a layer to cool by orbiting around the model for a set time.'''
16
17 self.minimumLayerTime = config.getfloat('cool','minimum.layer.time')
18 self.orbitalFeedRateSecond = runtimeParameters.orbitalFeedRateSecond
19 self.orbitalFeedRateMinute = runtimeParameters.orbitalFeedRateMinute
20 self.oribitalMarginDistance = config.getfloat('cool','orbital.margin')
21 self.oribitalMargin = complex(self.oribitalMarginDistance, self.oribitalMarginDistance)
22 self.decimalPlaces = runtimeParameters.decimalPlaces
23
24
25 - def cool(self, layer):
26 '''Apply the cooling by moving the nozzle around the print.'''
27
28 if layer.index == 0:
29
30 return
31
32 (layerDistance, layerDuration) = layer.getDistanceAndDuration()
33 remainingOrbitTime = max(self.minimumLayerTime - layerDuration, 0.0)
34
35 boundaryLayerLoops = []
36 for nestedRing in layer.nestedRings:
37 boundaryLayerLoops.append(nestedRing.getXYBoundaries())
38
39 if remainingOrbitTime > 0.0 and boundaryLayerLoops != None:
40 if len(boundaryLayerLoops) < 1:
41 return
42
43 largestLoop = euclidean.getLargestLoop(boundaryLayerLoops)
44 cornerMinimum = euclidean.getMinimumByComplexPath(largestLoop) - self.oribitalMargin
45 cornerMaximum = euclidean.getMaximumByComplexPath(largestLoop) + self.oribitalMargin
46
47 largestLoop = euclidean.getSquareLoopWiddershins(cornerMaximum, cornerMinimum)
48
49 if len(largestLoop) > 1 and remainingOrbitTime > 1.5 :
50 timeInOrbit = 0.0
51
52 while timeInOrbit < remainingOrbitTime:
53 for point in largestLoop:
54 gcodeArgs = [('X', round(point.real, self.decimalPlaces)),
55 ('Y', round(point.imag, self.decimalPlaces)),
56 ('Z', round(layer.z, self.decimalPlaces)),
57 ('F', round(self.orbitalFeedRateMinute, self.decimalPlaces))]
58 layer.preLayerGcodeCommands.append(GcodeCommand(gcodes.LINEAR_GCODE_MOVEMENT, gcodeArgs))
59 timeInOrbit += euclidean.getLoopLength(largestLoop) / self.orbitalFeedRateSecond
60