Skip to content

Commit

Permalink
Change to async gcode processing
Browse files Browse the repository at this point in the history
Bugs
#134, #124, #128, #131, #127, #126
Enhance
#132 State-Section
101, #117 option to deactivate adding M117 layer-indicators
  • Loading branch information
OllisGit committed Apr 8, 2020
1 parent cd68951 commit 6341392
Show file tree
Hide file tree
Showing 5 changed files with 403 additions and 132 deletions.
58 changes: 58 additions & 0 deletions octoprint_DisplayLayerProgress/CommandQueue.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# coding=utf-8
from __future__ import absolute_import

import re
from queue import Queue
from threading import Thread

import time
import logging

class CommandQueue():

def __init__(self):
self._logger = logging.getLogger(__name__)
self._worker = None
self._workerMethod = None
self._executionCommandQueue = Queue()
self._isQueueRunning = False

def initCommandQueue(self, workerMethod):
self._workerMethod = workerMethod

def addToQueue(self, commandKey):
self._executionCommandQueue.put(commandKey)
self._startQueue()
pass

def _startQueue(self):
if (self._isQueueRunning == False):
self._worker = Thread(target=self._processQueue, args=(self._workerMethod,))
self._isQueueRunning = True
self._worker.start()
pass

def _processQueue(self, workerMethod):
while (self._executionCommandQueue.empty() == False):
commandKey = self._executionCommandQueue.get()
workerMethod(commandKey)
#time.sleep(3)
self._executionCommandQueue.task_done()
self._isQueueRunning = False
pass


## TEST ZONE
#print("START")
#myCommandQueue = CommandQueue()

#myCommandQueue.initCommandDefinitions()
#myOsCommand = OSCommand()
#myCommandQueue.addToQueue(CommandQueue.EVENTTYPE_SYSTEM, "hallowelt")
#time.sleep(3)
#myCommandQueue.addToQueue(myOsCommand)
#time.sleep(10)
#myCommandQueue.addToQueue(myOsCommand)
#time.sleep(1)
#myCommandQueue.addToQueue(myOsCommand)
#print("END")
Loading

0 comments on commit 6341392

Please sign in to comment.