Package entities :: Module GcodeCommand'
[hide private]
[frames] | no frames]

Source Code for Module entities.GcodeCommand'

 1  from collections import OrderedDict 
 2  from config import config 
 3  from fabmetheus_utilities import archive, svg_writer, euclidean 
 4  from fabmetheus_utilities.vector3 import Vector3 
 5  from math import log10, floor, pi 
 6  from utilities import memory_tracker 
 7  from StringIO import StringIO 
 8  import gcodes 
 9  import math 
10  import sys 
11  import time 
12 13 -class GcodeCommand:
14 - def __init__(self, commandLetter, parameters=None):
15 self.commandLetter = commandLetter 16 if parameters == None: 17 parameters = {} 18 self.parameters = OrderedDict(parameters)
19
20 - def __str__(self):
21 return self.str(False)
22
23 - def str(self, verbose=False):
24 '''Get the string representation.''' 25 output = StringIO() 26 output.write('%s ' % (self.commandLetter[0])) 27 for name, value in self.parameters.items(): 28 output.write('%s%s ' % (name, value)) 29 if (verbose): 30 output.write(';%20s ' % (self.commandLetter[1])) 31 return output.getvalue().strip()
32 33 34 @staticmethod
35 - def printCommand(command, verbose=False):
36 if command == None: 37 return 38 if isinstance(command, GcodeCommand): 39 return'%s\n' % command.str(verbose) 40 else: 41 return '%s\n' % command
42