Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ module.exports = new Vue({
'estop': {template: '#estop-template'},
'view-loading': {template: '<h1>Loading...</h1>'},
'view-control': require('./view-control'),
'view-macros': require('./view-macros'),
'view-viewer': require('./view-viewer'),
'view-editor': require('./view-editor'),
'view-settings': require('./view-settings'),
Expand Down
19 changes: 16 additions & 3 deletions src/js/axis-vars.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,20 +111,25 @@ module.exports = {
let enabled = typeof motor.enabled != 'undefined' && motor.enabled
let homingMode = motor['homing-mode']
let homed = this.state[motor_id + 'homed']
let referenced = this.state[motor_id + 'referenced']
let min = this.state[motor_id + 'tn']
let max = this.state[motor_id + 'tm']
let dim = max - min
let bounds = this.toolpath.bounds
let pathMin = bounds ? bounds.min[axis] : 0
let pathMax = bounds ? bounds.max[axis] : 0
let pathDim = pathMax - pathMin
let klass = (homed ? 'homed' : 'unhomed') + ' axis-' + axis
let klass = 'axis-' + axis
let state = 'UNHOMED'
let icon = 'question-circle'
let fault = this.state[motor_id + 'df'] & 0x1f
let shutdown = this.state.power_shutdown
let title

if (homed) klass += ' homed'
else if (referenced) klass += ' warn'
else klass += ' unhomed'

if (fault || shutdown) {
state = shutdown ? 'SHUTDOWN' : 'FAULT'
klass += ' error'
Expand All @@ -138,11 +143,19 @@ module.exports = {
} else if (homed) {
state = 'HOMED'
icon = 'check-circle'

} else if (referenced) {
state = 'ZEROED'
icon = 'exclamation-triangle'
}

switch (state) {
case 'UNHOMED': title = 'Click the home button to home axis.'; break
case 'HOMED': title = 'Axis successfully homed.'; break
case 'ZEROED':
title = 'Position set manually. Verify the program stays within ' +
'machine bounds.'
break

case 'NO FIT':
title = 'Tool path dimensions exceed axis dimensions by ' +
Expand All @@ -165,8 +178,8 @@ module.exports = {

return {
name: axis, pos: abs - off, abs, off, min, max, dim, pathMin, pathMax,
pathDim, motor: motor_id, enabled, homingMode, homed, klass, state,
icon, title,
pathDim, motor: motor_id, enabled, homingMode, homed, referenced,
klass, state, icon, title,
}
}
}
Expand Down
12 changes: 11 additions & 1 deletion src/js/color-picker.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ module.exports = {
type: String,
required: true,
twoWay: true
},

disabled: {
type: Boolean,
default: false
}
},

Expand Down Expand Up @@ -73,16 +78,20 @@ module.exports = {

methods: {
change() {
if (this.disabled) return
this.value = this.jscolor.toHEXString()
this.hexInput = this.value
this.$emit('change', this.value)
},


show() {this.jscolor.show()},
show() {
if (!this.disabled) this.jscolor.show()
},


onHexInput(e) {
if (this.disabled) return
let hex = e.target.value.trim()

// Add # if missing
Expand All @@ -98,6 +107,7 @@ module.exports = {


onHexBlur(e) {
if (this.disabled) return
let hex = e.target.value.trim()

// Add # if missing
Expand Down
98 changes: 0 additions & 98 deletions src/js/settings-macros.js

This file was deleted.

152 changes: 149 additions & 3 deletions src/js/view-control.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ module.exports = {
jog_step: cookie.get_bool('jog-step'),
jog_adjust: parseInt(cookie.get('jog-adjust', 2)),
tab: 'auto',
macro_tab: undefined,
highlighted_line: 0,
toolpath: {}
}
Expand Down Expand Up @@ -164,6 +165,42 @@ module.exports = {
if (!this.toolpath.time || this.is_ready) return 0
let p = this.plan_time / this.toolpath.time
return p < 1 ? p : 1
},


macro_tabs() {
let tabs = this.config.macro_tabs
if (!tabs || !tabs.length) return [{id: 'default', name: 'Macros'}]
return tabs
},


current_macro_tab() {
if (this.macro_tab) return this.macro_tab
return this.macro_tabs.length ? this.macro_tabs[0].id : 'default'
},


visible_macros() {
let macros = this.config.macros || []
let current = this.current_macro_tab
let first = this.macro_tabs.length ? this.macro_tabs[0].id : 'default'
let visible = []

for (let i = 0; i < macros.length; i++) {
let macro = macros[i]
if (macro.visible === false) continue
if ((macro.tab || first) != current) continue

visible.push({
name: macro.name,
path: macro.path,
color: macro.color,
originalIndex: i
})
}

return visible
}
},

Expand Down Expand Up @@ -202,16 +239,125 @@ module.exports = {
get_bounds() {return this.toolpath.bounds},


get_error_message(error, fallback) {
let xhr = error && error.xhr

if (xhr && xhr.response && xhr.response.message)
return xhr.response.message

if (xhr && xhr.responseText) {
try {
let response = JSON.parse(xhr.responseText)
if (response && response.message) return response.message
} catch (e) {}
}

if (xhr && xhr.statusText) return xhr.statusText
return fallback
},


get_motor_id(axis) {
let motors = this.config.motors || []

for (let i = 0; i < motors.length; i++) {
let motor = motors[i]
if ((motor.axis || '').toLowerCase() == axis) return i
}

return -1
},


get_missing_reference_axes() {
let missing = []
let motors = this.config.motors || []

for (let axis of 'xyzabc') {
let motor = this.get_motor_id(axis)
if (motor == -1) continue

let config = motors[motor]
if (!config.enabled) continue

let required = config['reference-required']
if (required == undefined || required == 'Auto')
required = axis == 'x' || axis == 'y' || axis == 'z'
else required = required == 'Yes'

if (required && !this.state[motor + 'referenced'])
missing.push(axis.toUpperCase())
}

return missing
},


format_reference_error(missing) {
if (missing.length == 1) {
let axis = missing[0]
return 'Cannot start: ' + axis + ' axis position is unknown. ' +
'Please home or zero the ' + axis + ' axis before running.'
}

if (missing.length == 2)
return 'Cannot start: ' + missing.join(' and ') +
' axis positions are unknown. Please home or zero these axes ' +
'before running.'

return 'Cannot start: ' + missing.join(', ') + ' axis positions are ' +
'unknown. Please home or zero all axes before running.'
},


goto(hash) {window.location.hash = hash},
send(msg) {this.$dispatch('send', msg)},
on_scroll(cm, e) {e.preventDefault()},


select_macro_tab(tabId) {this.macro_tab = tabId},


async run_macro(macro) {
try {
return this.$api.put('macro/' + macro)
} catch (e) {
this.$root.error_dialog('Failed to run macro "' + macro + '":\n' + e)
let index = macro

if (typeof macro == 'object' && macro.originalIndex !== undefined)
index = macro.originalIndex

let macros = this.config.macros || []
if (index < 0 || index >= macros.length)
throw new Error('Invalid macro index: ' + index)

let config = macros[index]
if (!config.skip_reference_check) {
let missing = this.get_missing_reference_axes()
if (missing.length) {
await this.$root.error_dialog(this.format_reference_error(missing))
return
}
}

if (config.confirm !== false) {
let name = config.name || ('Macro ' + (index + 1))
let result = await this.$root.open_dialog({
header: 'Confirm Macro',
icon: 'question',
body: 'Run macro "' + name + '"?\n\nFile: ' + config.path,
buttons: [
{text: 'Cancel'},
{text: 'Run', class: 'button-success', action: 'run'}
]
})

if (result != 'run') return
}

await this.$api.put('macro/' + (index + 1), undefined, {error() {}})

} catch (error) {
await this.$root.error_dialog('Failed to run macro.\n' +
this.get_error_message(error, 'Unable to start macro.'))
}
},

Expand Down
Loading