def _read(): global running while running: point = scanner.read() if point is not None: x, y, z = point publish('point.cloud', json.dumps({"x": x, "y": y, "z": z}))
def buildBegin(self,filename,params): self.building = True print filename model=self.slicer.parseSVG(filename) t = threading.Thread(target=self.buildLoop, args=(model,params)) t.daemon = True t.start() publish('printStarted','Build began') return "Begin printing"
def buildTest(): test_stl_path = os.path.join(os.getcwd(), 'test', 'test.stl') print test_stl_path with open(test_stl_path, 'w') as file_: import base64 file_.write(base64.b64decode(content)) sunrise.slicer.file_to_svg(test_stl_path, 50) response = name + " successfully sliced" loaded = True publish('sliced', 'File sliced') return response
def buildTest(): test_stl_path=os.path.join(os.getcwd(),'test','test.stl') print test_stl_path with open(test_stl_path, 'w') as file_: import base64 file_.write(base64.b64decode(content)) sunrise.slicer.file_to_svg(test_stl_path,50) response = name + " successfully sliced" loaded=True publish('sliced','File sliced') return response
def buildLoop(self,model,params): self.projector.init_display() for layer in model: if not self.building: break publish('printingLayer',len(layer)) self.projector.expose(layer) time.sleep(params['exposeTime']) self.projector.blank() self.mechComm.moveAxis(self.buildAxis,3,200) self.mechComm.moveAxis(self.buildAxis,-2.95,200) time.sleep(params['blankTime']) self.mechComm.moveAxis(self.buildAxis,20,200) publish('printFinished',"Build finished") return False
def sliceFile(name='name', content='content'): global loaded try: os.mkdir('temp') except Exception: pass temp_stl_path = os.path.join(os.getcwd(), 'temp', 'loaded.stl') print temp_stl_path with open(temp_stl_path, 'w') as file_: import base64 file_.write(base64.b64decode(content)) sunrise.slicer.file_to_svg(temp_stl_path, 50) response = name + " successfully sliced" loaded = True publish('sliced', 'File sliced') return response
def sliceFile(name='name', content='content'): global loaded try: os.mkdir('temp') except Exception: pass temp_stl_path=os.path.join(os.getcwd(),'temp','loaded.stl') print temp_stl_path with open(temp_stl_path, 'w') as file_: import base64 file_.write(base64.b64decode(content)) sunrise.slicer.file_to_svg(temp_stl_path,50) response = name + " successfully sliced" loaded=True publish('sliced','File sliced') return response
def add(a=0, b=1.2, c=False, d={"item": True}, l=[1, 2, 3]): """Add a + b""" publish('event.add', '{0} + {1}'.format(a, b)) return a + b
def pub(): publish('event', 1234)
def sub(a=0, b=3, text="text"): """Subtract a - b""" publish('event.sub', '{0} - {1}'.format(a, b)) return a - b
def add(a=0, b=1.2, c=False, d={"item": True}, l=[1, 2, 3]): """Add a + b""" publish('event.add', '{0} + {1}'.format(a, b)) return a + b
def _start(): global running while running: print("Hello, world!") publish('event.hello', "Hello, world!") time.sleep(3)
def sub(a=0, b=3, text="text"): """Subtract a - b""" publish('event.sub', '{0} - {1}'.format(a, b)) return a - b
def test0(): "Publish an event" publish("event", {"v": 3.14})
def test0(): "Publish an event" publish('event', {'v': 3.14})
def _start(): global running while running: print("Hello, world!") publish('event.hello', "Hello, world!") time.sleep(3)
def pub(): publish('event', 1234)