First parts of a webui for Cura
This commit is contained in:
1 parent
5e1998d6a1
commit
580ebedfa9
17 files changed
+12521
No files matched your search
@@ -52,6 +52,8 @@ def main():
|
||||
help="Internal option, do not use!")
|
||||
parser.add_option("-s", "--slice", action="store_true", dest="slice",
|
||||
help="Slice the given files instead of opening them in Cura")
|
||||
parser.add_option("-w", "--web", action="store_true", dest="webui",
|
||||
help="Start the webui instead of the normal Cura UI")
|
||||
(options, args) = parser.parse_args()
|
||||
|
||||
if options.profile is not None:
|
||||
@@ -65,6 +67,9 @@ def main():
|
||||
elif options.slice is not None:
|
||||
from Cura.util import sliceRun
|
||||
sliceRun.runSlice(args)
|
||||
elif options.webui:
|
||||
import Cura.webui as webapp
|
||||
webapp.run()
|
||||
else:
|
||||
#Place any unused arguments as last file, so Cura starts with opening those files.
|
||||
if len(args) > 0:
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
#!/usr/bin/env python
|
||||
# coding=utf-8
|
||||
__author__ = 'Gina Häußge <osd@foosel.net>'
|
||||
|
||||
from flask import Flask, request, render_template, jsonify
|
||||
|
||||
from printer import Printer
|
||||
|
||||
import tempfile
|
||||
|
||||
app = Flask("Cura.webui")
|
||||
printer = Printer()
|
||||
printer.connect()
|
||||
|
||||
@app.route('/')
|
||||
def index():
|
||||
return render_template('index.html')
|
||||
|
||||
@app.route('/api/printer/connect', methods=['POST'])
|
||||
def connect():
|
||||
printer.connect()
|
||||
return jsonify(state='Connecting')
|
||||
|
||||
@app.route('/api/printer/disconnect', methods=['POST'])
|
||||
def disconnect():
|
||||
printer.disconnect()
|
||||
return jsonify(state='Offline')
|
||||
|
||||
@app.route('/api/printer', methods=['GET'])
|
||||
def printerState():
|
||||
temp = printer.currentTemp
|
||||
bedTemp = printer.currentBedTemp
|
||||
jobData = printer.jobData()
|
||||
|
||||
if jobData != None:
|
||||
return jsonify(state=printer.getStateString(),
|
||||
operational=printer.isOperational(),
|
||||
closedOrError=printer.isClosedOrError(),
|
||||
temp=temp,
|
||||
bedTemp=bedTemp,
|
||||
job=jobData)
|
||||
else:
|
||||
return jsonify(state=printer.getStateString(),
|
||||
temperature=temp,
|
||||
bedTemperature=bedTemp)
|
||||
|
||||
@app.route('/api/printer/messages', methods=['GET'])
|
||||
def printerMessages():
|
||||
return jsonify(messages=printer.messages)
|
||||
|
||||
@app.route('/api/printer/log', methods=['GET'])
|
||||
def printerMessages():
|
||||
return jsonify(log=printer.log)
|
||||
|
||||
@app.route('/api/printer/command', methods=['POST'])
|
||||
def printerCommand():
|
||||
command = request.form['command']
|
||||
printer.command(command)
|
||||
return jsonify(state=printer.getStateString())
|
||||
|
||||
@app.route('/api/printer/temperatures', methods=['GET'])
|
||||
def printerTemperatures():
|
||||
return jsonify(temperatures = printer.temps)
|
||||
|
||||
@app.route('/api/printer/gcode', methods=['POST'])
|
||||
def uploadGcodeFile():
|
||||
file = request.files['gcode_file']
|
||||
if file != None:
|
||||
(handle, filename) = tempfile.mkstemp(suffix='.gcode', prefix='tmp_', text=True)
|
||||
file.save(filename)
|
||||
printer.loadGcode(filename)
|
||||
return jsonify(state=printer.getStateString())
|
||||
|
||||
@app.route('/api/printer/print', methods=['POST'])
|
||||
def printGcode():
|
||||
printer.startPrint()
|
||||
return jsonify(state=printer.getStateString())
|
||||
|
||||
@app.route('/api/printer/pause', methods=['POST'])
|
||||
def pausePrint():
|
||||
printer.togglePausePrint()
|
||||
return jsonify(state=printer.getStateString())
|
||||
|
||||
@app.route('/api/printer/cancel', methods=['POST'])
|
||||
def cancelPrint():
|
||||
printer.cancelPrint()
|
||||
return jsonify(state=printer.getStateString())
|
||||
|
||||
def run():
|
||||
app.debug = True
|
||||
app.run()
|
||||
@@ -0,0 +1,208 @@
|
||||
# coding=utf-8
|
||||
__author__ = 'Gina Häußge <osd@foosel.net>'
|
||||
|
||||
import time
|
||||
import os
|
||||
|
||||
import Cura.util.machineCom as machineCom
|
||||
from Cura.util import gcodeInterpreter
|
||||
|
||||
class Printer():
|
||||
def __init__(self):
|
||||
# state
|
||||
self.temps = {
|
||||
'actual': [],
|
||||
'target': [],
|
||||
'actualBed': [],
|
||||
'targetBed': []
|
||||
}
|
||||
self.messages = []
|
||||
self.log = []
|
||||
self.state = None
|
||||
self.currentZ = None
|
||||
self.progress = None
|
||||
self.printTime = None
|
||||
self.printTimeLeft = None
|
||||
self.currentTemp = None
|
||||
self.currentBedTemp = None
|
||||
|
||||
self.gcode = None
|
||||
self.gcodeList = None
|
||||
self.filename = None
|
||||
|
||||
# comm
|
||||
self.comm = None
|
||||
|
||||
def connect(self):
|
||||
if self.comm != None:
|
||||
self.comm.close()
|
||||
self.comm = machineCom.MachineCom(port='VIRTUAL', callbackObject=self)
|
||||
|
||||
def disconnect(self):
|
||||
if self.comm != None:
|
||||
self.comm.close()
|
||||
self.comm = None
|
||||
|
||||
def command(self, command):
|
||||
self.comm.sendCommand(command)
|
||||
|
||||
def mcLog(self, message):
|
||||
self.log.append(message)
|
||||
self.log = self.log[-300:]
|
||||
|
||||
def mcTempUpdate(self, temp, bedTemp, targetTemp, bedTargetTemp):
|
||||
currentTime = time.time()
|
||||
|
||||
self.temps['actual'].append((currentTime, temp))
|
||||
self.temps['actual'] = self.temps['actual'][-300:]
|
||||
|
||||
self.temps['target'].append((currentTime, targetTemp))
|
||||
self.temps['target'] = self.temps['target'][-300:]
|
||||
|
||||
self.temps['actualBed'].append((currentTime, bedTemp))
|
||||
self.temps['actualBed'] = self.temps['actualBed'][-300:]
|
||||
|
||||
self.temps['targetBed'].append((currentTime, bedTargetTemp))
|
||||
self.temps['targetBed'] = self.temps['targetBed'][-300:]
|
||||
|
||||
self.currentTemp = temp
|
||||
self.currentBedTemp = bedTemp
|
||||
|
||||
def mcStateChange(self, state):
|
||||
self.state = state
|
||||
|
||||
def mcMessage(self, message):
|
||||
self.messages.append(message)
|
||||
self.messages = self.message[-300:]
|
||||
|
||||
def mcProgress(self, lineNr):
|
||||
self.printTime = self.comm.getPrintTime()
|
||||
self.printTimeLeft = self.comm.getPrintTimeRemainingEstimate()
|
||||
self.progress = self.comm.getPrintPos()
|
||||
|
||||
def mcZChange(self, newZ):
|
||||
self.currentZ = newZ
|
||||
|
||||
def jobData(self):
|
||||
if self.gcode != None:
|
||||
formattedPrintTime = None
|
||||
if (self.printTime):
|
||||
"%02d:%02d" % (int(self.printTime / 60), int(self.printTime % 60))
|
||||
|
||||
formattedPrintTimeLeft = None
|
||||
if (self.printTimeLeft):
|
||||
"%02d:%02d" % (int(self.printTimeLeft / 60), int(self.printTimeLeft % 60))
|
||||
|
||||
data = {
|
||||
'currentZ': self.currentZ,
|
||||
'line': self.progress,
|
||||
'totalLines': len(self.gcodeList),
|
||||
'printTime': formattedPrintTime,
|
||||
'printTimeLeft': formattedPrintTimeLeft,
|
||||
'filament': "%.2fm %.2fg" % (
|
||||
self.gcode.extrusionAmount / 1000,
|
||||
self.gcode.calculateWeight() * 1000
|
||||
),
|
||||
'estimatedPrintTime': "%02d:%02d" % (
|
||||
int(self.gcode.totalMoveTimeMinute / 60),
|
||||
int(self.gcode.totalMoveTimeMinute % 60)
|
||||
)
|
||||
}
|
||||
else:
|
||||
data = None
|
||||
return data
|
||||
|
||||
def getStateString(self):
|
||||
if self.comm == None:
|
||||
return 'Offline'
|
||||
else:
|
||||
return self.comm.getStateString()
|
||||
|
||||
def isClosedOrError(self):
|
||||
return self.comm == None or self.comm.isClosedOrError()
|
||||
|
||||
def isOperational(self):
|
||||
return self.comm != None and self.comm.isOperational()
|
||||
|
||||
def loadGcode(self, file):
|
||||
if self.comm != None and self.comm.isPrinting():
|
||||
return
|
||||
|
||||
# delete old temporary file
|
||||
if self.filename != None:
|
||||
os.remove(self.filename)
|
||||
|
||||
#Send an initial M110 to reset the line counter to zero.
|
||||
prevLineType = lineType = 'CUSTOM'
|
||||
gcodeList = ["M110"]
|
||||
for line in open(file, 'r'):
|
||||
if line.startswith(';TYPE:'):
|
||||
lineType = line[6:].strip()
|
||||
if ';' in line:
|
||||
line = line[0:line.find(';')]
|
||||
line = line.strip()
|
||||
if len(line) > 0:
|
||||
if prevLineType != lineType:
|
||||
gcodeList.append((line, lineType, ))
|
||||
else:
|
||||
gcodeList.append(line)
|
||||
prevLineType = lineType
|
||||
gcode = gcodeInterpreter.gcode()
|
||||
gcode.loadList(gcodeList)
|
||||
#print "Loaded: %s (%d)" % (filename, len(gcodeList))
|
||||
self.filename = file
|
||||
self.gcode = gcode
|
||||
self.gcodeList = gcodeList
|
||||
|
||||
def startPrint(self):
|
||||
if self.comm == None or not self.comm.isOperational():
|
||||
return
|
||||
if self.gcodeList == None:
|
||||
return
|
||||
if self.comm.isPrinting():
|
||||
return
|
||||
self.currentZ = -1
|
||||
self.comm.printGCode(self.gcodeList)
|
||||
|
||||
def togglePausePrint(self):
|
||||
if self.comm == None:
|
||||
return
|
||||
self.comm.setPause(not self.comm.isPaused())
|
||||
|
||||
def cancelPrint(self):
|
||||
if self.comm == None:
|
||||
return
|
||||
self.comm.cancelPrint()
|
||||
self.comm.sendCommand("M84")
|
||||
|
||||
class Temperature():
|
||||
def __init__(self, actual=None, target=None):
|
||||
self._actual = actual
|
||||
self._target = target
|
||||
|
||||
def actual(self):
|
||||
return self._actual
|
||||
|
||||
def target(self):
|
||||
return self._target
|
||||
|
||||
def asDict(self):
|
||||
return {'actual': self._actual, 'target': self._target}
|
||||
|
||||
class Position():
|
||||
def __init__(self, x=None, y=None, z=None):
|
||||
self._x = x
|
||||
self._y = y
|
||||
self._z = z
|
||||
|
||||
def update(self, x=None, y=None, z=None):
|
||||
if x != None:
|
||||
self._x = x
|
||||
if y != None:
|
||||
self._y = y
|
||||
if z != None:
|
||||
self._z = z
|
||||
|
||||
def get(self):
|
||||
return {'x': self._x, 'y': self._y, 'z': self._z}
|
||||
|
||||
+1092
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,9 @@
|
||||
/*!
|
||||
* Bootstrap Responsive v2.2.2
|
||||
*
|
||||
* Copyright 2012 Twitter, Inc
|
||||
* Licensed under the Apache License v2.0
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Designed and built with all the love in the world @twitter by @mdo and @fat.
|
||||
*/@-ms-viewport{width:device-width}.clearfix{*zoom:1}.clearfix:before,.clearfix:after{display:table;line-height:0;content:""}.clearfix:after{clear:both}.hide-text{font:0/0 a;color:transparent;text-shadow:none;background-color:transparent;border:0}.input-block-level{display:block;width:100%;min-height:30px;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.hidden{display:none;visibility:hidden}.visible-phone{display:none!important}.visible-tablet{display:none!important}.hidden-desktop{display:none!important}.visible-desktop{display:inherit!important}@media(min-width:768px) and (max-width:979px){.hidden-desktop{display:inherit!important}.visible-desktop{display:none!important}.visible-tablet{display:inherit!important}.hidden-tablet{display:none!important}}@media(max-width:767px){.hidden-desktop{display:inherit!important}.visible-desktop{display:none!important}.visible-phone{display:inherit!important}.hidden-phone{display:none!important}}@media(min-width:1200px){.row{margin-left:-30px;*zoom:1}.row:before,.row:after{display:table;line-height:0;content:""}.row:after{clear:both}[class*="span"]{float:left;min-height:1px;margin-left:30px}.container,.navbar-static-top .container,.navbar-fixed-top .container,.navbar-fixed-bottom .container{width:1170px}.span12{width:1170px}.span11{width:1070px}.span10{width:970px}.span9{width:870px}.span8{width:770px}.span7{width:670px}.span6{width:570px}.span5{width:470px}.span4{width:370px}.span3{width:270px}.span2{width:170px}.span1{width:70px}.offset12{margin-left:1230px}.offset11{margin-left:1130px}.offset10{margin-left:1030px}.offset9{margin-left:930px}.offset8{margin-left:830px}.offset7{margin-left:730px}.offset6{margin-left:630px}.offset5{margin-left:530px}.offset4{margin-left:430px}.offset3{margin-left:330px}.offset2{margin-left:230px}.offset1{margin-left:130px}.row-fluid{width:100%;*zoom:1}.row-fluid:before,.row-fluid:after{display:table;line-height:0;content:""}.row-fluid:after{clear:both}.row-fluid [class*="span"]{display:block;float:left;width:100%;min-height:30px;margin-left:2.564102564102564%;*margin-left:2.5109110747408616%;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.row-fluid [class*="span"]:first-child{margin-left:0}.row-fluid .controls-row [class*="span"]+[class*="span"]{margin-left:2.564102564102564%}.row-fluid .span12{width:100%;*width:99.94680851063829%}.row-fluid .span11{width:91.45299145299145%;*width:91.39979996362975%}.row-fluid .span10{width:82.90598290598291%;*width:82.8527914166212%}.row-fluid .span9{width:74.35897435897436%;*width:74.30578286961266%}.row-fluid .span8{width:65.81196581196582%;*width:65.75877432260411%}.row-fluid .span7{width:57.26495726495726%;*width:57.21176577559556%}.row-fluid .span6{width:48.717948717948715%;*width:48.664757228587014%}.row-fluid .span5{width:40.17094017094017%;*width:40.11774868157847%}.row-fluid .span4{width:31.623931623931625%;*width:31.570740134569924%}.row-fluid .span3{width:23.076923076923077%;*width:23.023731587561375%}.row-fluid .span2{width:14.52991452991453%;*width:14.476723040552828%}.row-fluid .span1{width:5.982905982905983%;*width:5.929714493544281%}.row-fluid .offset12{margin-left:105.12820512820512%;*margin-left:105.02182214948171%}.row-fluid .offset12:first-child{margin-left:102.56410256410257%;*margin-left:102.45771958537915%}.row-fluid .offset11{margin-left:96.58119658119658%;*margin-left:96.47481360247316%}.row-fluid .offset11:first-child{margin-left:94.01709401709402%;*margin-left:93.91071103837061%}.row-fluid .offset10{margin-left:88.03418803418803%;*margin-left:87.92780505546462%}.row-fluid .offset10:first-child{margin-left:85.47008547008548%;*margin-left:85.36370249136206%}.row-fluid .offset9{margin-left:79.48717948717949%;*margin-left:79.38079650845607%}.row-fluid .offset9:first-child{margin-left:76.92307692307693%;*margin-left:76.81669394435352%}.row-fluid .offset8{margin-left:70.94017094017094%;*margin-left:70.83378796144753%}.row-fluid .offset8:first-child{margin-left:68.37606837606839%;*margin-left:68.26968539734497%}.row-fluid .offset7{margin-left:62.393162393162385%;*margin-left:62.28677941443899%}.row-fluid .offset7:first-child{margin-left:59.82905982905982%;*margin-left:59.72267685033642%}.row-fluid .offset6{margin-left:53.84615384615384%;*margin-left:53.739770867430444%}.row-fluid .offset6:first-child{margin-left:51.28205128205128%;*margin-left:51.175668303327875%}.row-fluid .offset5{margin-left:45.299145299145295%;*margin-left:45.1927623204219%}.row-fluid .offset5:first-child{margin-left:42.73504273504273%;*margin-left:42.62865975631933%}.row-fluid .offset4{margin-left:36.75213675213675%;*margin-left:36.645753773413354%}.row-fluid .offset4:first-child{margin-left:34.18803418803419%;*margin-left:34.081651209310785%}.row-fluid .offset3{margin-left:28.205128205128204%;*margin-left:28.0987452264048%}.row-fluid .offset3:first-child{margin-left:25.641025641025642%;*margin-left:25.53464266230224%}.row-fluid .offset2{margin-lefLine truncated
|
||||
Vendored
+6039
File diff suppressed because it is too large.
Load diff
+9
@@ -0,0 +1,9 @@
|
||||
/*!
|
||||
* Bootstrap v2.2.2
|
||||
*
|
||||
* Copyright 2012 Twitter, Inc
|
||||
* Licensed under the Apache License v2.0
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Designed and built with all the love in the world @twitter by @mdo and @fat.
|
||||
*/article,aside,details,figcaption,figure,footer,header,hgroup,nav,section{display:block}audio,canvas,video{display:inline-block;*display:inline;*zoom:1}audio:not([controls]){display:none}html{font-size:100%;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%}a:focus{outline:thin dotted #333;outline:5px auto -webkit-focus-ring-color;outline-offset:-2px}a:hover,a:active{outline:0}sub,sup{position:relative;font-size:75%;line-height:0;vertical-align:baseline}sup{top:-0.5em}sub{bottom:-0.25em}img{width:auto\9;height:auto;max-width:100%;vertical-align:middle;border:0;-ms-interpolation-mode:bicubic}#map_canvas img,.google-maps img{max-width:none}button,input,select,textarea{margin:0;font-size:100%;vertical-align:middle}button,input{*overflow:visible;line-height:normal}button::-moz-focus-inner,input::-moz-focus-inner{padding:0;border:0}button,html input[type="button"],input[type="reset"],input[type="submit"]{cursor:pointer;-webkit-appearance:button}label,select,button,input[type="button"],input[type="reset"],input[type="submit"],input[type="radio"],input[type="checkbox"]{cursor:pointer}input[type="search"]{-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box;-webkit-appearance:textfield}input[type="search"]::-webkit-search-decoration,input[type="search"]::-webkit-search-cancel-button{-webkit-appearance:none}textarea{overflow:auto;vertical-align:top}@media print{*{color:#000!important;text-shadow:none!important;background:transparent!important;box-shadow:none!important}a,a:visited{text-decoration:underline}a[href]:after{content:" (" attr(href) ")"}abbr[title]:after{content:" (" attr(title) ")"}.ir a:after,a[href^="javascript:"]:after,a[href^="#"]:after{content:""}pre,blockquote{border:1px solid #999;page-break-inside:avoid}thead{display:table-header-group}tr,img{page-break-inside:avoid}img{max-width:100%!important}@page{margin:.5cm}p,h2,h3{orphans:3;widows:3}h2,h3{page-break-after:avoid}}.clearfix{*zoom:1}.clearfix:before,.clearfix:after{display:table;line-height:0;content:""}.clearfix:after{clear:both}.hide-text{font:0/0 a;color:transparent;text-shadow:none;background-color:transparent;border:0}.input-block-level{display:block;width:100%;min-height:30px;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}body{margin:0;font-family:"Helvetica Neue",Helvetica,Arial,sans-serif;font-size:14px;line-height:20px;color:#333;background-color:#fff}a{color:#08c;text-decoration:none}a:hover{color:#005580;text-decoration:underline}.img-rounded{-webkit-border-radius:6px;-moz-border-radius:6px;border-radius:6px}.img-polaroid{padding:4px;background-color:#fff;border:1px solid #ccc;border:1px solid rgba(0,0,0,0.2);-webkit-box-shadow:0 1px 3px rgba(0,0,0,0.1);-moz-box-shadow:0 1px 3px rgba(0,0,0,0.1);box-shadow:0 1px 3px rgba(0,0,0,0.1)}.img-circle{-webkit-border-radius:500px;-moz-border-radius:500px;border-radius:500px}.row{margin-left:-20px;*zoom:1}.row:before,.row:after{display:table;line-height:0;content:""}.row:after{clear:both}[class*="span"]{float:left;min-height:1px;margin-left:20px}.container,.navbar-static-top .container,.navbar-fixed-top .container,.navbar-fixed-bottom .container{width:940px}.span12{width:940px}.span11{width:860px}.span10{width:780px}.span9{width:700px}.span8{width:620px}.span7{width:540px}.span6{width:460px}.span5{width:380px}.span4{width:300px}.span3{width:220px}.span2{width:140px}.span1{width:60px}.offset12{margin-left:980px}.offset11{margin-left:900px}.offset10{margin-left:820px}.offset9{margin-left:740px}.offset8{margin-left:660px}.offset7{margin-left:580px}.offset6{margin-left:500px}.offset5{margin-left:420px}.offset4{margin-left:340px}.offset3{margin-left:260px}.offset2{margin-left:180px}.offset1{margin-left:100px}.row-fluid{width:100%;*zoom:1}.row-fluid:before,.row-fluid:after{display:table;line-height:0;content:""}.row-fluid:after{clear:both}.row-fluid [class*="span"]{display:block;float:left;width:100%;min-height:30px;margin-left:2.127659574468085%;*margin-left:2.074468085106383%;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.row-fluid [class*="span"]:first-child{margin-left:0}.row-fluid .controls-row [class*="span"]+[class*="span"]{margin-left:2.127659574468085%}.row-fluid .span12{width:100%;*width:99.94680851063829%}.row-fluid .span11{width:91.48936170212765%;*width:91.43617021276594%}.row-fluid .span10{width:82.97872340425532%;*width:82.92553191489361%}.row-fluid .span9{width:74.46808510638297%;*width:74.41489361702126%}.row-fluid .span8{width:65.95744680851064%;*width:65.90425531914893%}.row-fluid .span7{width:57.44680851063829%;*width:57.39361702127659%}.row-fluid .span6{width:48.93617021276595%;*width:48.88297872340425%}.row-fluid .span5{width:40.42553191489362%;*width:40.37234042553192%}.row-fluid .span4{width:31.914893617021278%;*width:31.861702127659576%}.row-fluid .span3{width:23.404255319148934%;*width:23.351063829787233%}.row-fluid .span2{width:14.893617021276595%;*width:14.840425531914894%Line truncated
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 8.6 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 12 KiB |
Vendored
+2159
File diff suppressed because it is too large.
Load diff
+6
@@ -0,0 +1,6 @@
|
||||
/*!
|
||||
* Bootstrap.js by @fat & @mdo
|
||||
* Copyright 2012 Twitter, Inc.
|
||||
* http://www.apache.org/licenses/LICENSE-2.0.txt
|
||||
*/
|
||||
!function($){"use strict";$(function(){$.support.transition=function(){var transitionEnd=function(){var name,el=document.createElement("bootstrap"),transEndEventNames={WebkitTransition:"webkitTransitionEnd",MozTransition:"transitionend",OTransition:"oTransitionEnd otransitionend",transition:"transitionend"};for(name in transEndEventNames)if(void 0!==el.style[name])return transEndEventNames[name]}();return transitionEnd&&{end:transitionEnd}}()})}(window.jQuery),!function($){"use strict";var dismiss='[data-dismiss="alert"]',Alert=function(el){$(el).on("click",dismiss,this.close)};Alert.prototype.close=function(e){function removeElement(){$parent.trigger("closed").remove()}var $parent,$this=$(this),selector=$this.attr("data-target");selector||(selector=$this.attr("href"),selector=selector&&selector.replace(/.*(?=#[^\s]*$)/,"")),$parent=$(selector),e&&e.preventDefault(),$parent.length||($parent=$this.hasClass("alert")?$this:$this.parent()),$parent.trigger(e=$.Event("close")),e.isDefaultPrevented()||($parent.removeClass("in"),$.support.transition&&$parent.hasClass("fade")?$parent.on($.support.transition.end,removeElement):removeElement())};var old=$.fn.alert;$.fn.alert=function(option){return this.each(function(){var $this=$(this),data=$this.data("alert");data||$this.data("alert",data=new Alert(this)),"string"==typeof option&&data[option].call($this)})},$.fn.alert.Constructor=Alert,$.fn.alert.noConflict=function(){return $.fn.alert=old,this},$(document).on("click.alert.data-api",dismiss,Alert.prototype.close)}(window.jQuery),!function($){"use strict";var Button=function(element,options){this.$element=$(element),this.options=$.extend({},$.fn.button.defaults,options)};Button.prototype.setState=function(state){var d="disabled",$el=this.$element,data=$el.data(),val=$el.is("input")?"val":"html";state+="Text",data.resetText||$el.data("resetText",$el[val]()),$el[val](data[state]||this.options[state]),setTimeout(function(){"loadingText"==state?$el.addClass(d).attr(d,d):$el.removeClass(d).removeAttr(d)},0)},Button.prototype.toggle=function(){var $parent=this.$element.closest('[data-toggle="buttons-radio"]');$parent&&$parent.find(".active").removeClass("active"),this.$element.toggleClass("active")};var old=$.fn.button;$.fn.button=function(option){return this.each(function(){var $this=$(this),data=$this.data("button"),options="object"==typeof option&&option;data||$this.data("button",data=new Button(this,options)),"toggle"==option?data.toggle():option&&data.setState(option)})},$.fn.button.defaults={loadingText:"loading..."},$.fn.button.Constructor=Button,$.fn.button.noConflict=function(){return $.fn.button=old,this},$(document).on("click.button.data-api","[data-toggle^=button]",function(e){var $btn=$(e.target);$btn.hasClass("btn")||($btn=$btn.closest(".btn")),$btn.button("toggle")})}(window.jQuery),!function($){"use strict";var Carousel=function(element,options){this.$element=$(element),this.options=options,"hover"==this.options.pause&&this.$element.on("mouseenter",$.proxy(this.pause,this)).on("mouseleave",$.proxy(this.cycle,this))};Carousel.prototype={cycle:function(e){return e||(this.paused=!1),this.options.interval&&!this.paused&&(this.interval=setInterval($.proxy(this.next,this),this.options.interval)),this},to:function(pos){var $active=this.$element.find(".item.active"),children=$active.parent().children(),activePos=children.index($active),that=this;if(!(pos>children.length-1||0>pos))return this.sliding?this.$element.one("slid",function(){that.to(pos)}):activePos==pos?this.pause().cycle():this.slide(pos>activePos?"next":"prev",$(children[pos]))},pause:function(e){return e||(this.paused=!0),this.$element.find(".next, .prev").length&&$.support.transition.end&&(this.$element.trigger($.support.transition.end),this.cycle()),clearInterval(this.interval),this.interval=null,this},next:function(){return this.sliding?void 0:this.slide("next")},prev:function(){return this.sliding?void 0:this.slide("prev")},slide:function(type,next){var e,$active=this.$element.find(".item.active"),$next=next||$active[type](),isCycling=this.interval,direction="next"==type?"left":"right",fallback="next"==type?"first":"last",that=this;if(this.sliding=!0,isCycling&&this.pause(),$next=$next.length?$next:this.$element.find(".item")[fallback](),e=$.Event("slide",{relatedTarget:$next[0]}),!$next.hasClass("active")){if($.support.transition&&this.$element.hasClass("slide")){if(this.$element.trigger(e),e.isDefaultPrevented())return;$next.addClass(type),$next[0].offsetWidth,$active.addClass(direction),$next.addClass(direction),this.$element.one($.support.transition.end,function(){$next.removeClass([type,direction].join(" ")).addClass("active"),$active.removeClass(["active",direction].join(" ")),that.sliding=!1,setTimeout(function(){that.$element.trigger("slid")},0)})}else{if(this.$element.trigger(e),e.isDefaultPrevented())return;$active.removeClass("active"),$next.addClass("active"),this.sliding=!1,this.$element.trigger("slid")}return isCycling&&this.cycle()Line truncated
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,88 @@
|
||||
var printerstate = function() {
|
||||
|
||||
var updateInterval = 500;
|
||||
function update() {
|
||||
function onDataReceived(response) {
|
||||
$("#printer_state").text(response.state);
|
||||
$("#printer_temp").text(response.temp + " °C");
|
||||
$("#printer_bedTemp").text(response.bedTemp + " °C");
|
||||
|
||||
if (response.job) {
|
||||
var currentLine = (response.job.line ? response.job.line : 0);
|
||||
var progress = currentLine * 100 / response.job.totalLines;
|
||||
$("#job_filament").text(response.job.filament);
|
||||
$("#job_estimatedPrintTime").text(response.job.estimatedPrintTime);
|
||||
$("#job_line").text((currentLine == 0 ? "-" : currentLine) + "/" + response.job.totalLines + " " + progress + "%");
|
||||
$("#job_height").text(response.job.currentZ);
|
||||
$("#job_printTime").text(response.job.printTime);
|
||||
$("#job_printTimeLeft").text(response.job.printTimeLeft);
|
||||
$("#job_progressBar").width(progress + "%");
|
||||
} else {
|
||||
$("#job_filament").text("-");
|
||||
$("#job_estimatedPrintTime").text("-");
|
||||
$("#job_line").text("-");
|
||||
$("#job_height").text("-");
|
||||
$("#job_printTime").text("-");
|
||||
$("#job_printTimeLefT").text("-");
|
||||
$("#job_progressBar").width("0%");
|
||||
}
|
||||
|
||||
if (!response.closedOrError) {
|
||||
$("#printer_connect").click(function(){});
|
||||
$("#printer_connect").addClass("disabled");
|
||||
} else {
|
||||
$("#printer_connect").click(connect);
|
||||
$("#printer_connect").removeClass("disabled");
|
||||
}
|
||||
|
||||
$("#job_print").click(function() {
|
||||
$.ajax({
|
||||
url: "/api/printer/print",
|
||||
type: 'POST',
|
||||
dataType: 'json',
|
||||
success: function(){}
|
||||
})
|
||||
})
|
||||
$("#job_pause").click(function() {
|
||||
$.ajax({
|
||||
url: "/api/printer/pause",
|
||||
type: 'POST',
|
||||
dataType: 'json',
|
||||
success: function(){}
|
||||
})
|
||||
})
|
||||
$("#job_cancel").click(function() {
|
||||
$.ajax({
|
||||
url: "/api/printer/cancel",
|
||||
type: 'POST',
|
||||
dataType: 'json',
|
||||
success: function(){}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
url: "/api/printer",
|
||||
method: 'GET',
|
||||
dataType: 'json',
|
||||
success: onDataReceived
|
||||
});
|
||||
|
||||
setTimeout(update, updateInterval);
|
||||
}
|
||||
|
||||
function connect() {
|
||||
$.ajax({
|
||||
url: "/api/printer/connect",
|
||||
type: 'POST',
|
||||
dataType: 'json',
|
||||
success: function(response) {
|
||||
// do nothing
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
update();
|
||||
}
|
||||
|
||||
printerstate();
|
||||
@@ -0,0 +1,45 @@
|
||||
|
||||
var temperaturegraph = function() {
|
||||
|
||||
var options = {
|
||||
yaxis: {
|
||||
min: 0,
|
||||
max: 310,
|
||||
ticks: 10
|
||||
},
|
||||
xaxis: {
|
||||
mode: "time"
|
||||
},
|
||||
legend: {
|
||||
noColumns: 4
|
||||
}
|
||||
};
|
||||
|
||||
var updateInterval = 500;
|
||||
function update() {
|
||||
function onDataReceived(response) {
|
||||
var temps = response.temperatures;
|
||||
var data = [
|
||||
{label: "Actual", color: "#FF4040", data: temps.actual},
|
||||
{label: "Target", color: "#FFA0A0", data: temps.target},
|
||||
{label: "Bed Actual", color: "#4040FF", data: temps.actualBed},
|
||||
{label: "Bed Target", color: "#A0A0FF", data: temps.targetBed}
|
||||
]
|
||||
$.plot($("#temperature-graph"), data, options);
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
url: "/api/printer/temperatures",
|
||||
method: 'GET',
|
||||
dataType: 'json',
|
||||
success: onDataReceived
|
||||
})
|
||||
|
||||
setTimeout(update, updateInterval);
|
||||
}
|
||||
|
||||
update();
|
||||
|
||||
}
|
||||
|
||||
temperaturegraph();
|
||||
@@ -0,0 +1,49 @@
|
||||
var terminaloutput = function() {
|
||||
|
||||
var updateInterval = 1000;
|
||||
function update() {
|
||||
function onDataReceived(response) {
|
||||
var log = response.log;
|
||||
var output = '';
|
||||
for (var i = 0; i < log.length; i++) {
|
||||
output += log[i] + '<br>';
|
||||
}
|
||||
|
||||
var container = $("#terminal-output");
|
||||
var autoscroll = (container.scrollTop() == container[0].scrollHeight - container.height);
|
||||
|
||||
container.html(output);
|
||||
|
||||
if (autoscroll) {
|
||||
container.scrollTop(container[0].scrollHeight - container.height())
|
||||
}
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
url: "/api/printer/log",
|
||||
type: 'GET',
|
||||
dataType: 'json',
|
||||
success: onDataReceived
|
||||
})
|
||||
|
||||
setTimeout(update, updateInterval);
|
||||
}
|
||||
|
||||
update();
|
||||
|
||||
$("#terminal-send").click(function () {
|
||||
var command = $("#terminal-command").val();
|
||||
$.ajax({
|
||||
url: "/api/printer/command",
|
||||
type: 'POST',
|
||||
dataType: 'json',
|
||||
data: 'command=' + command,
|
||||
success: function(response) {
|
||||
// do nothing
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
terminaloutput();
|
||||
@@ -0,0 +1,121 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Bootstrap 101 Template</title>
|
||||
<link href="{{ url_for('static', filename='css/bootstrap.min.css') }}" rel="stylesheet" media="screen">
|
||||
<script src="http://code.jquery.com/jquery-latest.js"></script>
|
||||
<script src="{{ url_for('static', filename='js/bootstrap.js') }}"></script>
|
||||
<script src="{{ url_for('static', filename='js/jquery.flot.js') }}"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container-fluid">
|
||||
<div class="row-fluid">
|
||||
<h1>Cura WebUI</h1>
|
||||
</div>
|
||||
|
||||
<div class="row-fluid">
|
||||
<div class="span3">
|
||||
<h2>Printer</h2>
|
||||
Machine State: <strong id="printer_state"></strong><br>
|
||||
<button class="btn" id="printer_connect">Connect</button>
|
||||
|
||||
<h2>Job</h2>
|
||||
Filament: <strong id="job_filament"></strong><br>
|
||||
Estimated Print Time: <strong id="job_estimatedPrintTime"></strong><br>
|
||||
Line: <strong id="job_line"></strong><br>
|
||||
Height: <strong id="job_currentZ"></strong><br>
|
||||
Print Time: <strong id="job_printTime"></strong><br>
|
||||
Print Time Left: <strong id="job_printTimeLeft"></strong><br>
|
||||
|
||||
<div class="progress">
|
||||
<div class="bar" id="job_progressBar" style="width: 30%;"></div>
|
||||
</div>
|
||||
|
||||
<button class="btn" id="job_print">Print</button>
|
||||
<button class="btn" id="job_pause">Pause</button>
|
||||
<button class="btn" id="job_cancel">Cancel</button>
|
||||
|
||||
<form action="/api/printer/gcode" method="post" enctype="multipart/form-data">
|
||||
<input type="file" name="gcode_file">
|
||||
<button class="btn" type="submit">Load</button>
|
||||
</form>
|
||||
</div>
|
||||
<div class="span9 tabbable tabs-left">
|
||||
|
||||
<ul class="nav nav-tabs">
|
||||
<li class="active"><a href="#temp" data-toggle="tab">Temp</a></li>
|
||||
<li><a href="#jog" data-toggle="tab">Jog</a></li>
|
||||
<li><a href="#speed" data-toggle="tab">Speed</a></li>
|
||||
<li><a href="#term" data-toggle="tab">Term</a></li>
|
||||
</ul>
|
||||
|
||||
<div class="tab-content">
|
||||
<div class="tab-pane active" id="temp">
|
||||
<div id="temperature-graph" class="span6 " style="height: 350px"></div>
|
||||
<div class="span3">
|
||||
Temp: <strong id="printer_temp"></strong><br>
|
||||
Bed Temp: <strong id="printer_bedTemp"></strong><br>
|
||||
</div>
|
||||
</div>
|
||||
<div class="tab-pane" id="jog">
|
||||
<div class="span9">
|
||||
<div class="row">
|
||||
<div class="span1 offset1 btn-group btn-group-vertical">
|
||||
<button class="btn btn-block btn-large" type="button"><i class="icon-chevron-up"></i></button>
|
||||
<button class="btn btn-block" type="button"><i class="icon-chevron-up"></i></button>
|
||||
<button class="btn btn-block btn-small" type="button"><i class="icon-chevron-up"></i></button>
|
||||
</div>
|
||||
<div class="span1 offset1 btn-group btn-group-vertical">
|
||||
<button class="btn btn-block btn-large" type="button"><i class="icon-chevron-up"></i></button>
|
||||
<button class="btn btn-block" type="button"><i class="icon-chevron-up"></i></button>
|
||||
<button class="btn btn-block btn-small" type="button"><i class="icon-chevron-up"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="span1 btn-group btn-group">
|
||||
<button class="btn" type="button"><i class="icon-chevron-left"></i></button>
|
||||
<button class="btn" type="button"><i class="icon-chevron-left"></i></button>
|
||||
<button class="btn" type="button"><i class="icon-chevron-left"></i></button>
|
||||
</div>
|
||||
<div class="span1">
|
||||
<button class="btn btn-block" type="button"><i class="icon-home"></i></button>
|
||||
</div>
|
||||
<div class="span1 btn-group btn-group">
|
||||
<button class="btn" type="button"><i class="icon-chevron-right"></i></button>
|
||||
<button class="btn" type="button"><i class="icon-chevron-right"></i></button>
|
||||
<button class="btn" type="button"><i class="icon-chevron-right"></i></button>
|
||||
</div>
|
||||
<div class="span1">
|
||||
<button class="btn btn-block" type="button"><i class="icon-home"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="span1 offset1 btn-group btn-group-vertical">
|
||||
<button class="btn btn-block btn-small" type="button"><i class="icon-chevron-down"></i></button>
|
||||
<button class="btn btn-block" type="button"><i class="icon-chevron-down"></i></button>
|
||||
<button class="btn btn-block btn-large" type="button"><i class="icon-chevron-down"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="tab-pane" id="speed">
|
||||
Here be speed settings
|
||||
</div>
|
||||
<div class="tab-pane" id="term">
|
||||
<pre id="terminal-output" class="pre-scrollable"></pre>
|
||||
<div class="input-append">
|
||||
<input type="text" class="span9" id="terminal-command">
|
||||
<button class="btn" type="button" id="terminal-send">Send</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Here be scripts -->
|
||||
<script src="{{ url_for('static', filename='js/printerstate.js') }}"></script>
|
||||
<script src="{{ url_for('static', filename='js/temperaturegraph.js') }}"></script>
|
||||
<script src="{{ url_for('static', filename='js/terminaloutput.js') }}"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,3 +1,4 @@
|
||||
flask>=0.9
|
||||
PyOpenGL>=3.0.2
|
||||
numpy>=1.6.2
|
||||
pyserial>=2.6
|
||||
|
||||
Reference in new issue
Block a user