From 867895ab81c11c199ff8f1682249b192f9f80368 Mon Sep 17 00:00:00 2001 From: Teja Date: Sat, 4 Jul 2015 17:06:46 +0200 Subject: [PATCH] terminal fixed --- .../templates/override_index.jinja2 | 649 ------------------ src/octoprint/printer/standard.py | 388 ----------- .../static/js/app/viewmodels/terminal.js | 53 +- src/octoprint/templates/mrbeam_index.jinja2 | 3 +- src/octoprint/util/comm_acc.py | 1 - 5 files changed, 10 insertions(+), 1084 deletions(-) delete mode 100644 src/octoprint/plugins/svgtogcode/templates/override_index.jinja2 diff --git a/src/octoprint/plugins/svgtogcode/templates/override_index.jinja2 b/src/octoprint/plugins/svgtogcode/templates/override_index.jinja2 deleted file mode 100644 index 94ef18e6..00000000 --- a/src/octoprint/plugins/svgtogcode/templates/override_index.jinja2 +++ /dev/null @@ -1,649 +0,0 @@ - - - - Mr Beam - - - - - - {% include 'stylesheets.jinja2' %} - {% include 'initscript.jinja2' %} - - -
- - -
-
-
-
-
-
- -
- -
- -
-
- Mr Beam is in a locked state as it does not know its position. - First remove any objects blocking the gantry's travel range. - Then do a homing cycle. -
- -
- - -
-
-
-
- {{ _('Position') }}: - - -
-
- -
- XY-Axes -
- -
-
- - - -
-
- -
-
-
-
- Z-Axis -
- - - -
-
-
- -
-
- -
- - Jog distance: 10mm -
- -
-
-
-
- -
-
- - - - - - - -
-
-
-
- {{ _('Machine State') }}:
- -
- - - {{ _('Approx. Total Job Time') }}:
-
-
{{ _('Processed') }} :
-
- - - - -
-
-
-
- -
- -
- - - -
- -
-
-
-
-
- - - - - - - -
-
-
- - - -
- - - -
- - - - - add designs via - the design library - or drag 'n' drop - - - - - - - -
-
-
-
-
- -
-
-
- - -
- -
- - -
-
    -
  • - G0: - rapid position move -
    parameters: X,Y
    -
    example: G0 X100 Y0
    -
  • -
  • - F: - set feedrate for G1,G2,G3 -
    parameters: value
    -
    example: F300
    -
  • -
  • - G1: - work move, line -
    parameters: X,Y,F
    -
    example: G1 X100 Y0 F800
    -
  • -
  • - G2: - work move, arc clockwise -
    parameters: X,Y,I,J,F
    -
    example: G2 X10 Y10 I8 J5
    -
  • -
  • - G3: - work move, arc counterclockwise -
    parameters: X,Y,I,J,F
    -
    example: G3 X10 Y10 I8 J5
    -
  • -
  • - G4: - dwell -
    parameters: P
    -
    example: G4 P0.5
    -
  • -
  • - M3: - laser on -
    parameters: S
    -
    example: M3 S10
    -
  • -
  • - M5: - laser off -
    parameters: -
    -
    example: M5
    -
  • -
  • - M8: - fan on -
    parameters: -
    -
    example: M8
    -
  • -
  • - M9: - fan off -
    parameters: -
    -
    example: M9
    -
  • -
  • - M2: - machine off -
    parameters: -
    -
    example: M2
    -
  • -
  • - G90: - absolute coordinate mode -
    parameters: -
    -
    example: G90
    -
  • -
  • - G91: - relative coordinate mode -
    parameters: -
    -
    example: G91
    -
  • -
  • - G92: - set coordinate origin -
    parameters: X,Y
    -
    example: G92 X0 Y0
    -
  • -
  • - G20: - set units to inches -
    parameters: -
    -
    example: G20
    -
  • -
  • - G21: - set units to millimeters -
    parameters: -
    -
    example: G21
    -
  • -
-
-
-
- -

-								
-							
- -
-
-
- -
-
-
-
-
    -
  1. Add designs to your working area with the -button
  2. -
  3. Afterwards switch back to the working area
  4. - -
-
-
- {{ _('Files') }} - - -
- - - -
- {{ _('Free') }}: -
-
-
- - - - {{ _('Upload') }} - - -
-
-
-
-
- {{ _('Hint: You can also drag and drop files on this page to upload them.') }} -
-
-
-
-
-
-
- -
-
- -
-
-
- - - - - - - -
-
-
-
-
-
-
-
- -
-
-
-
-
    -
  • 1. Place your material on the working area
  • -
  • 2. Move the laser over the material
  • -
  • 3. Put on your safety glasses
  • -
  • 4. Turn the laser safety switch to on
  • -
  • → Now enable the focus mode
  • -
  • 5. Adjust the focus until the laser beam is as small as possible
  • -
  • → Disable the focus mode.
  • -
-
-
- - -
-
- -
-
- - Z-Axis -
- - -
-
-
- -
-
-
-
-
-
-
-
- -
-
-
- {% include 'tabs/gcodeviewer.jinja2' %} - -
-
-
- -
-
-
- -
- {% include 'dialogs/settings.jinja2' %} -
- -
-
-
- -
- - -
- - - - - -
- - - - - {% if templatePlugins %} - {% for plugin_name in templatePlugins %} - {% include plugin_name+".jinja2" ignore missing %} - {% endfor %} - {% endif %} - - - - - {% include 'dialogs/confirmation.jinja2' %} - {% include 'dialogs/firstrun.jinja2' %} - {#% include 'dialogs/settings.jinja2' %#} - {% include 'dialogs/slicing.jinja2' %} - - - - {% include 'overlays/dragndrop.jinja2' %} - {% include 'overlays/offline.jinja2' %} - - - - {% for data in genericEntries %} - {% include data.template ignore missing %} - {% endfor %} - - - {% include 'javascripts.jinja2' %} - - diff --git a/src/octoprint/printer/standard.py b/src/octoprint/printer/standard.py index 27b64931..a12abb69 100644 --- a/src/octoprint/printer/standard.py +++ b/src/octoprint/printer/standard.py @@ -875,394 +875,6 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback): self._stateMonitor.setWorkPosition(WPosString) self._stateMonitor.setMachinePosition(MPosString) - - - #<<<<<<< HEAD - - -# -# -# def home(self, axes): -# if(settings().getBoolean(["feature", "grbl"])): -# self.commands(["$H", "G92X0Y0Z0", "G90", "G21"]) -# else: -# self.commands(["G91", "G28 %s" % " ".join(map(lambda x: "%s0" % x.upper(), axes)), "G90"]) -# -# def extrude(self, amount): -# printer_profile = self._printerProfileManager.get_current_or_default() -# extrusion_speed = printer_profile["axes"]["e"]["speed"] -# self.commands(["G91", "G1 E%s F%d" % (amount, extrusion_speed), "G90"]) -# -# def changeTool(self, tool): -# try: -# toolNum = int(tool[len("tool"):]) -# self.command("T%d" % toolNum) -# except ValueError: -# pass -# -# def setTemperature(self, type, value): -# if type.startswith("tool"): -# printer_profile = self._printerProfileManager.get_current_or_default() -# extruder_count = printer_profile["extruder"]["count"] -# if extruder_count > 1: -# try: -# toolNum = int(type[len("tool"):]) -# self.command("M104 T%d S%f" % (toolNum, value)) -# except ValueError: -# pass -# else: -# self.command("M104 S%f" % value) -# elif type == "bed": -# self.command("M140 S%f" % value) -# -# def setTemperatureOffset(self, offsets={}): -# if self._comm is None: -# return -# -# tool, bed = self._comm.getOffsets() -# -# validatedOffsets = {} -# -# for key in offsets: -# value = offsets[key] -# if key == "bed": -# bed = value -# validatedOffsets[key] = value -# elif key.startswith("tool"): -# try: -# toolNum = int(key[len("tool"):]) -# tool[toolNum] = value -# validatedOffsets[key] = value -# except ValueError: -# pass -# -# self._comm.setTemperatureOffset(tool, bed) -# self._stateMonitor.setTempOffsets(validatedOffsets) -# -# def selectFile(self, filename, sd, printAfterSelect=False): -# if self._comm is None or (self._comm.isBusy() or self._comm.isStreaming()): -# self._logger.info("Cannot load file: printer not connected or currently busy") -# return -# -# self._printAfterSelect = printAfterSelect -# self._comm.selectFile(filename, sd) -# self._setProgressData(0, None, None, None) -# self._setCurrentZ(None) -# -# def unselectFile(self): -# if self._comm is not None and (self._comm.isBusy() or self._comm.isStreaming()): -# return -# -# self._comm.unselectFile() -# self._setProgressData(0, None, None, None) -# self._setCurrentZ(None) -# -# def startPrint(self): -# """ -# Starts the currently loaded print job. -# Only starts if the printer is connected and operational, not currently printing and a printjob is loaded -# """ -# if self._comm is None or not self._comm.isOperational() or self._comm.isPrinting(): -# return -# if self._selectedFile is None: -# return -# -# self._timeEstimationData = TimeEstimationHelper() -# self._lastProgressReport = None -# self._setCurrentZ(None) -# self._comm.startPrint() -# self._addPositionData(None, None) -# - -# -# def togglePausePrint(self): -# """ -# Pause the current printjob. -# """ -# if self._comm is None: -# return -# -# self._comm.setPause(not self._comm.isPaused()) -# -# def cancelPrint(self, disableMotorsAndHeater=True): -# """ -# Cancel the current printjob. -# """ -# if self._comm is None: -# return -# -# self._comm.cancelPrint() -# -# if disableMotorsAndHeater: -# printer_profile = self._printerProfileManager.get_current_or_default() -# extruder_count = printer_profile["extruder"]["count"] -# -# # disable motors, switch off hotends, bed and fan -# #commands = ["M84"] -# #commands.extend(map(lambda x: "M104 T%d S0" % x, range(extruder_count))) -# #commands.extend(["M140 S0", "M106 S0"]) -# commands = ["M05", "G0X0Y0", "M09"] -# self.commands(commands) -# -# # reset progress, height, print time -# self._setCurrentZ(None) -# self._setProgressData(None, None, None, None) -# -# # mark print as failure -# if self._selectedFile is not None: -# self._fileManager.log_print(FileDestinations.SDCARD if self._selectedFile["sd"] else FileDestinations.LOCAL, self._selectedFile["filename"], time.time(), self._comm.getPrintTime(), False, self._printerProfileManager.get_current_or_default()["id"]) -# payload = { -# "file": self._selectedFile["filename"], -# "origin": FileDestinations.LOCAL -# } -# if self._selectedFile["sd"]: -# payload["origin"] = FileDestinations.SDCARD -# eventManager().fire(Events.PRINT_FAILED, payload) -# -# #~~ state monitoring -# -# def _setCurrentZ(self, currentZ): -# self._currentZ = currentZ -# self._stateMonitor.setCurrentZ(self._currentZ) -# -# def _setState(self, state): -# self._state = state -# self._stateMonitor.setState({"text": self.getStateString(), "flags": self._getStateFlags()}) -# -# def _addLog(self, log): -# self._log.append(log) -# self._stateMonitor.addLog(log) -# -# def _addMessage(self, message): -# self._messages.append(message) -# self._stateMonitor.addMessage(message) -# -# def _estimateTotalPrintTime(self, progress, printTime): -# if not progress or not printTime or not self._timeEstimationData: -# #self._estimationLogger.info("{progress};{printTime};;;;".format(**locals())) -# return None -# -# else: -# newEstimate = printTime / progress -# self._timeEstimationData.update(newEstimate) -# -# result = None -# if self._timeEstimationData.is_stable(): -# result = self._timeEstimationData.average_total_rolling -# -# #averageTotal = self._timeEstimationData.average_total -# #averageTotalRolling = self._timeEstimationData.average_total_rolling -# #averageDistance = self._timeEstimationData.average_distance -# -# #self._estimationLogger.info("{progress};{printTime};{newEstimate};{averageTotal};{averageTotalRolling};{averageDistance}".format(**locals())) -# -# return result -# -# def _setProgressData(self, progress, filepos, printTime, cleanedPrintTime): -# estimatedTotalPrintTime = self._estimateTotalPrintTime(progress, cleanedPrintTime) -# statisticalTotalPrintTime = None -# totalPrintTime = estimatedTotalPrintTime -# -# if self._selectedFile and "estimatedPrintTime" in self._selectedFile and self._selectedFile["estimatedPrintTime"]: -# statisticalTotalPrintTime = self._selectedFile["estimatedPrintTime"] -# if progress and cleanedPrintTime: -# if estimatedTotalPrintTime is None: -# totalPrintTime = statisticalTotalPrintTime -# else: -# if progress < 0.5: -# sub_progress = progress * 2 -# else: -# sub_progress = 1.0 -# totalPrintTime = (1 - sub_progress) * statisticalTotalPrintTime + sub_progress * estimatedTotalPrintTime -# -# #self._printTimeLogger.info("{progress};{cleanedPrintTime};{estimatedTotalPrintTime};{statisticalTotalPrintTime};{totalPrintTime}".format(**locals())) -# -# self._progress = progress -# self._printTime = printTime -# self._printTimeLeft = totalPrintTime - cleanedPrintTime if (totalPrintTime is not None and cleanedPrintTime is not None) else None -# -# self._stateMonitor.setProgress({ -# "completion": self._progress * 100 if self._progress is not None else None, -# "filepos": filepos, -# "printTime": int(self._printTime) if self._printTime is not None else None, -# "printTimeLeft": int(self._printTimeLeft) if self._printTimeLeft is not None else None -# }) -# -# if progress: -# progress_int = int(progress * 100) -# if self._lastProgressReport != progress_int: -# self._lastProgressReport = progress_int -# self._reportPrintProgressToPlugins(progress_int) -# -# -# def _addTemperatureData(self, temp, bedTemp): -# currentTimeUtc = int(time.time()) -# -# data = { -# "time": currentTimeUtc -# } -# for tool in temp.keys(): -# data["tool%d" % tool] = { -# "actual": temp[tool][0], -# "target": temp[tool][1] -# } -# if bedTemp is not None and isinstance(bedTemp, tuple): -# data["bed"] = { -# "actual": bedTemp[0], -# "target": bedTemp[1] -# } -# -# self._temps.append(data) -# -# self._temp = temp -# self._bedTemp = bedTemp -# -# self._stateMonitor.addTemperature(data) -# -# def _setJobData(self, filename, filesize, sd): -# if filename is not None: -# self._selectedFile = { -# "filename": filename, -# "filesize": filesize, -# "sd": sd, -# "estimatedPrintTime": None -# } -# else: -# self._selectedFile = None -# self._stateMonitor.setJobData({ -# "file": { -# "name": None, -# "origin": None, -# "size": None, -# "date": None -# }, -# "estimatedPrintTime": None, -# "averagePrintTime": None, -# "lastPrintTime": None, -# "filament": None, -# }) -# return -# -# estimatedPrintTime = None -# lastPrintTime = None -# averagePrintTime = None -# date = None -# filament = None -# if filename: -# # Use a string for mtime because it could be float and the -# # javascript needs to exact match -# if not sd: -# date = int(os.stat(filename).st_ctime) -# -# try: -# fileData = self._fileManager.get_metadata(FileDestinations.SDCARD if sd else FileDestinations.LOCAL, filename) -# except: -# fileData = None -# if fileData is not None: -# if "analysis" in fileData: -# if estimatedPrintTime is None and "estimatedPrintTime" in fileData["analysis"]: -# estimatedPrintTime = fileData["analysis"]["estimatedPrintTime"] -# if "filament" in fileData["analysis"].keys(): -# filament = fileData["analysis"]["filament"] -# if "statistics" in fileData: -# printer_profile = self._printerProfileManager.get_current_or_default()["id"] -# if "averagePrintTime" in fileData["statistics"] and printer_profile in fileData["statistics"]["averagePrintTime"]: -# averagePrintTime = fileData["statistics"]["averagePrintTime"][printer_profile] -# if "lastPrintTime" in fileData["statistics"] and printer_profile in fileData["statistics"]["lastPrintTime"]: -# lastPrintTime = fileData["statistics"]["lastPrintTime"][printer_profile] -# -# if averagePrintTime is not None: -# self._selectedFile["estimatedPrintTime"] = averagePrintTime -# elif estimatedPrintTime is not None: -# # TODO apply factor which first needs to be tracked! -# self._selectedFile["estimatedPrintTime"] = estimatedPrintTime -# -# self._stateMonitor.setJobData({ -# "file": { -# "name": os.path.basename(filename) if filename is not None else None, -# "origin": FileDestinations.SDCARD if sd else FileDestinations.LOCAL, -# "size": filesize, -# "date": date -# }, -# "estimatedPrintTime": estimatedPrintTime, -# "averagePrintTime": averagePrintTime, -# "lastPrintTime": lastPrintTime, -# "filament": filament, -# }) -# -# def _sendInitialStateUpdate(self, callback): -# try: -# data = self._stateMonitor.getCurrentData() -# data.update({ -# "temps": list(self._temps), -# "logs": list(self._log), -# "messages": list(self._messages) -# }) -# callback.sendHistoryData(data) -# except Exception, err: -# import sys -# sys.stderr.write("ERROR: %s\n" % str(err)) -# pass -# -# def _getStateFlags(self): -# return { -# "operational": self.isOperational(), -# "locked": self.isLocked(), -# "printing": self.isPrinting(), -# "closedOrError": self.isClosedOrError(), -# "error": self.isError(), -# "paused": self.isPaused(), -# "ready": self.isReady(), -# "sdReady": self.isSdReady() -# } -# -# #~~ callbacks triggered from self._comm -# -# def mcLog(self, message): -# """ -# Callback method for the comm object, called upon log output. -# #""" -# self._addLog(message) -# -# def mcTempUpdate(self, temp, bedTemp): -# self._addTemperatureData(temp, bedTemp) -# - -# -# def mcStateChange(self, state): -# """ -# Callback method for the comm object, called if the connection state changes. -# #""" -# oldState = self._state -# -# # forward relevant state changes to gcode manager -# if self._comm is not None and oldState == self._comm.STATE_PRINTING: -# if self._selectedFile is not None: -# if state == self._comm.STATE_OPERATIONAL: -# self._fileManager.log_print(FileDestinations.SDCARD if self._selectedFile["sd"] else FileDestinations.LOCAL, self._selectedFile["filename"], time.time(), self._comm.getPrintTime(), True, self._printerProfileManager.get_current_or_default()["id"]) -# elif state == self._comm.STATE_CLOSED or state == self._comm.STATE_ERROR or state == self._comm.STATE_CLOSED_WITH_ERROR: -# self._fileManager.log_print(FileDestinations.SDCARD if self._selectedFile["sd"] else FileDestinations.LOCAL, self._selectedFile["filename"], time.time(), self._comm.getPrintTime(), False, self._printerProfileManager.get_current_or_default()["id"]) -# self._analysisQueue.resume() # printing done, put those cpu cycles to good use -# elif self._comm is not None and state == self._comm.STATE_PRINTING: -# self._analysisQueue.pause() # do not analyse files while printing -# -# self._setState(state) -# -# def mcMessage(self, message): -# """ -# Callback method for the comm object, called upon message exchanges via serial. -# Stores the message in the message buffer, truncates buffer to the last 300 lines. -# #""" -# self._addMessage(message) -# -# def mcProgress(self): -# """ -# Callback method for the comm object, called upon any change in progress of the printjob. -# Triggers storage of new values for printTime, printTimeLeft and the current progress. -# #""" -# -# self._setProgressData(self._comm.getPrintProgress(), self._comm.getPrintFilepos(), self._comm.getPrintTime(), self._comm.getCleanedPrintTime()) -#======= class StateMonitor(object): def __init__(self, interval=0.5, on_update=None, on_add_temperature=None, on_add_log=None, on_add_message=None): diff --git a/src/octoprint/static/js/app/viewmodels/terminal.js b/src/octoprint/static/js/app/viewmodels/terminal.js index 946e905b..054115b2 100644 --- a/src/octoprint/static/js/app/viewmodels/terminal.js +++ b/src/octoprint/static/js/app/viewmodels/terminal.js @@ -1,9 +1,6 @@ //<<<<<<< HEAD //function TerminalViewModel(loginStateViewModel, settingsViewModel) { -// var self = this; -// -// self.loginState = loginStateViewModel; -// self.settings = settingsViewModel; + // // self.log = []; // @@ -31,10 +28,7 @@ // self.updateOutput(); // }); // -// self.fromCurrentData = function(data) { -// self._processStateData(data.state); -// self._processCurrentLogData(data.logs); -// }; + // // self.fromHistoryData = function(data) { // self._processStateData(data.state); @@ -54,16 +48,7 @@ // self.updateOutput(); // }; // -// self._processStateData = function(data) { -// self.isErrorOrClosed(data.flags.closedOrError); -// self.isOperational(data.flags.operational); -// self.isLocked(data.flags.locked); -// self.isPaused(data.flags.paused); -// self.isPrinting(data.flags.printing); -// self.isError(data.flags.error); -// self.isReady(data.flags.ready); -// self.isLoading(data.flags.loading); -// }; + // // self.updateFilterRegex = function() { // var filterRegexStr = self.activeFilters().join("|").trim(); @@ -93,21 +78,7 @@ // }; // -// -// self.sendCommand = function() { -// var command = self.command(); -// if (!command) { -// return; -// } -// -// //var re = /^([gmt][0-9]+)(\s.*)?/; -// var re = /^([gmtfs][0-9]+|\$[cinhgx#$]|[?~!])(.*)?/; // grbl style -// var commandMatch = command.match(re); -// if (commandMatch != null) { -// command = commandMatch[1].toUpperCase() + ((commandMatch[2] !== undefined) ? commandMatch[2].toUpperCase() : ""); -// } -// -// if (command) { + //======= $(function() { function TerminalViewModel(parameters) { @@ -264,12 +235,14 @@ $(function() { return; } - var re = /^([gmt][0-9]+)(\s.*)?/; +// var re = /^([gmt][0-9]+)(\s.*)?/; + var re = /^([gmtfs][0-9]+|\$[cinhgx#$]|[?~!])(.*)?/; // grbl style var commandMatch = command.match(re); if (commandMatch != null) { command = commandMatch[1].toUpperCase() + ((commandMatch[2] !== undefined) ? commandMatch[2] : ""); + command = commandMatch[1].toUpperCase() + ((commandMatch[2] !== undefined) ? commandMatch[2].toUpperCase() : ""); } - + if (command) { $.ajax({ url: API_BASEURL + "printer/command", @@ -323,19 +296,13 @@ $(function() { self.handleKeyUp = function(event) { if (event.keyCode == 13) { - self.sendCommand(); + self.sendCommandWithSafetyPopup(); } // do not prevent default action return true; }; -//<<<<<<< HEAD -// self.handleKeyUp = function(event) { -// if (event.keyCode == 13) { -// self.sendCommandWithSafetyPopup(); -// } -//======= self.onAfterTabChange = function(current, previous) { if (current != "#term") { return; @@ -344,7 +311,6 @@ $(function() { self.scrollToEnd(); } }; -//>>>>>>> upstream/maintenance self.sendCommandWithSafetyPopup = function () { var command = self.command().split(' ').join(''); @@ -352,7 +318,6 @@ $(function() { return; } - console.log(command); var parts = command.match(/^(M3|M03)(S[0-9.]+)?/i); if (parts !== null) { diff --git a/src/octoprint/templates/mrbeam_index.jinja2 b/src/octoprint/templates/mrbeam_index.jinja2 index 65cd06ed..c2c1b938 100644 --- a/src/octoprint/templates/mrbeam_index.jinja2 +++ b/src/octoprint/templates/mrbeam_index.jinja2 @@ -399,8 +399,7 @@
- -

+