Package plugins :: Module cool
[hide private]
[frames] | no frames]

Source Code for Module plugins.cool

 1  """ 
 2  Cool is a script to cool the shape. 
 3   
 4  Credits: 
 5          Original Author: Enrique Perez (http://skeinforge.com) 
 6          Contributors: Please see the documentation in Skeinforge  
 7          Modifed as SFACT: Ahmet Cem Turan (github.com/ahmetcemturan/SFACT)       
 8   
 9  License:  
10          GNU Affero General Public License http://www.gnu.org/licenses/agpl.html 
11  """ 
12   
13  from config import config 
14  from fabmetheus_utilities import archive, euclidean, intercircle 
15  from entities import GcodeCommand 
16  import gcodes 
17  import logging 
18  from importlib import import_module 
19  import os, sys 
20   
21  name = __name__ 
22  logger = logging.getLogger(name) 
23   
24 -def performAction(slicedModel):
25 'Give the extrusion time to cool down.' 26 if not config.getboolean(name, 'active'): 27 logger.info("%s plugin is not active", name.capitalize()) 28 return 29 CoolSkein(slicedModel).cool()
30
31 -class CoolSkein:
32 'A class to cool a skein of extrusions.'
33 - def __init__(self, slicedModel):
34 self.slicedModel = slicedModel 35 36 self.turnFanOnAtBeginning = config.getboolean(name, 'turn.on.fan.at.beginning') 37 self.turnFanOffAtEnding = config.getboolean(name, 'turn.off.fan.at.end') 38 self.nameOfCoolStartFile = config.get(name, 'cool.start.file') 39 self.nameOfCoolEndFile = config.get(name, 'cool.end.file') 40 self.coolStrategyName = config.get(name, 'strategy') 41 self.coolStrategyPath = config.get(name, 'strategy.path') 42 self.absoluteCoolStartFilePath = os.path.join('alterations', self.nameOfCoolStartFile) 43 self.absoluteCoolEndFilePath = os.path.join('alterations', self.nameOfCoolEndFile) 44 self.coolStartLines = archive.getTextLines(archive.getFileText(self.absoluteCoolEndFilePath, printWarning=False)) 45 self.coolEndLines = archive.getTextLines(archive.getFileText(self.absoluteCoolEndFilePath, printWarning=False))
46
47 - def cool(self):
48 'Apply the cool strategy.' 49 50 if self.turnFanOnAtBeginning: 51 self.slicedModel.startGcodeCommands.append(GcodeCommand(gcodes.TURN_FAN_ON)) 52 53 coolStrategy = None 54 try: 55 if self.coolStrategyPath not in sys.path: 56 sys.path.insert(0, self.coolStrategyPath) 57 coolStrategy = import_module(self.coolStrategyName).getStrategy(self.slicedModel.runtimeParameters) 58 logger.info("Using cool strategy: %s", self.coolStrategyName) 59 except ImportError as inst: 60 logger.warning("Could not find module for cooling strategy called: %s. %s", self.coolStrategyName, inst) 61 except Exception as inst: 62 logger.warning("Exception reading strategy %s: %s", self.coolStrategyName, inst) 63 64 for layer in self.slicedModel.layers.values(): 65 for line in self.coolStartLines: 66 layer.preLayerGcodeCommands.append(line) 67 68 if coolStrategy != None: 69 coolStrategy.cool(layer) 70 71 for line in self.coolEndLines: 72 layer.postLayerGcodeCommands.append(line) 73 74 if self.turnFanOffAtEnding: 75 self.slicedModel.endGcodeCommands.append(GcodeCommand(gcodes.TURN_FAN_OFF))
76