button.save.pure-button.button-success(:disabled="!modified",
@click="save") Save
+ select.units(v-model="config.settings.units", @change="modified = true")
+ option(value="METRIC") Metric
+ option(value="IMPERIAL") Imperial
+
.pure-menu
ul.pure-menu-list
li.pure-menu-heading
v-if="enabled('#{axis}')")
th.name #{axis}
td.position
- | {{(state.#{axis}p + get_offset('#{axis}')) || 0 | fixed 3}}
- td.absolute {{state.#{axis}p || 0 | fixed 3}}
- td.offset {{get_offset('#{axis}') | fixed 3}}
+ unit-value(:value="state.#{axis}p + get_offset('#{axis}')",
+ precision="3")
+ td.absolute: unit-value(:value="state.#{axis}p", precision="3")
+ td.offset: unit-value(:value="get_offset('#{axis}')", precision="3")
th.actions
button.pure-button(:disabled="!is_ready",
title="Set {{'#{axis}' | upper}} axis position.",
th Message
td.reason(:class="{attention: highlight_reason}") {{reason}}
td
- tr
+ tr(title="Currently active machine units")
th Units
td {{state.imperial ? 'IMPERIAL' : 'METRIC'}}
td
tr
th Feed
- td {{state.feed || 0 | fixed 0}}
- td mm/min
+ td: unit-value(:value="state.feed", precision="2", unit="", iunit="")
+ td {{metric ? 'mm/min' : 'IPM'}}
tr
th Speed
- td {{state.speed || 0 | fixed 0}} ({{state.s || 0 | fixed 0}})
+ td
+ | {{state.speed || 0 | fixed 0}}
+ span(v-if="!isNaN(state.s)") ({{state.s | fixed 0}})
td RPM
table.info
- tr
+ tr(
+ title="Current velocity in {{metric ? 'meters' : 'inches'}} per minute")
th Velocity
- td {{state.v || 0 | fixed 2}}
- td m/min
+ td: unit-value(:value="state.v", precision="2", unit="", iunit="",
+ scale="0.0254")
+ td {{metric ? 'm/min' : 'IPM'}}
tr
th Line
td {{0 <= state.line ? state.line : '-'}}
label.extra(v-if="$key == 'max-velocity'", slot="extra",
title="Revolutions Per Minute") ({{rpm | fixed 0}} RPM)
- label.extra(v-if="$key == 'max-accel'", slot="extra",
+ label.extra(v-if="$key == 'max-accel' && metric", slot="extra",
title="G-force") ({{gForce | fixed 3}} g)
- label.extra(v-if="$key == 'max-jerk'", slot="extra",
+ label.extra(v-if="$key == 'max-jerk' && metric", slot="extra",
title="G-force per minute") ({{gForcePerMin | fixed 2}} g/min)
label.extra(v-if="$key == 'step-angle'", slot="extra",
title="Steps per revolution") ({{stepsPerRev | fixed 0}} steps/rev)
- label.extra(v-if="$key == 'travel-per-rev'", slot="extra",
+ label.extra(v-if="$key == 'travel-per-rev' && metric", slot="extra",
title="Micrometers per step") ({{umPerStep | fixed 1}} µm/step)
+
+ label.extra(v-if="$key == 'travel-per-rev' && !metric", slot="extra",
+ title="Thousandths of an inch per step")
+ | ({{milPerStep | fixed 2}} mil/step)
title="Default {{template.default}} {{template.unit || ''}}")
label(:for="name") {{name}}
- select(v-if="template.type == 'enum' || template.values", v-model="model",
+ select(v-if="template.type == 'enum' || template.values", v-model="view",
:name="name", @change="change")
option(v-for="opt in template.values", :value="opt") {{opt}}
- input(v-if="template.type == 'bool'", type="checkbox",
- v-model="model", :name="name", @change="change")
+ input(v-if="template.type == 'bool'", type="checkbox", v-model="view",
+ :name="name", @change="change")
- input(v-if="template.type == 'float'", v-model="model", number,
+ input(v-if="template.type == 'float'", v-model="view", number,
:min="template.min", :max="template.max", :step="template.step || 'any'",
type="number", :name="name", @change="change")
- input(v-if="template.type == 'int' && !template.values", v-model="model",
+ input(v-if="template.type == 'int' && !template.values", v-model="view",
number, :min="template.min", :max="template.max", type="number",
:name="name", @change="change")
- input(v-if="template.type == 'string'", v-model="model",
- type="text", :name="name", @change="change")
-
- textarea(v-if="template.type == 'text'", v-model="model",
+ input(v-if="template.type == 'string'", v-model="view", type="text",
:name="name", @change="change")
+ textarea(v-if="template.type == 'text'", v-model="view", :name="name",
+ @change="change")
+
span.range(v-if="template.type == 'percent'")
- input(type="range", v-model="model", :name="name", number, min="0",
+ input(type="range", v-model="view", :name="name", number, min="0",
max="100", step="1", @change="change")
- | {{model}}
+ | {{view}}
- label.units {{template.unit}}
+ label.units {{units}}
slot(name="extra")
index: -1,
modified: false,
template: {motors: {template: {}}},
- config: {motors: [{}, {}, {}, {}], version: '<loading>'},
+ config: {
+ settings: {units: 'METRIC'},
+ motors: [{}, {}, {}, {}],
+ version: '<loading>'
+ },
state: {},
messages: [],
errorTimeout: 30,
'config-changed': function () {this.modified = true;},
'hostname-changed': function (hostname) {this.hostname = hostname},
+
send: function (msg) {
if (this.status == 'connected') {
console.debug('>', msg);
methods: {
+ metric: function () {return this.config.settings.units != 'IMPERIAL'},
+
+
block_error_dialog: function () {
this.errorTimeoutStart = Date.now();
this.errorShow = false;
computed: {
+ metric: function () {return this.$root.metric()},
+
+
mach_state: function () {
var cycle = this.state.cycle;
var state = this.state.xx;
Vue.component('message', require('./message'));
Vue.component('indicators', require('./indicators'));
Vue.component('console', require('./console'));
+ Vue.component('unit-value', require('./unit-value'));
Vue.filter('percent', function (value, precision) {
if (typeof precision == 'undefined') precision = 2;
computed: {
+ metric: function () {return this.$root.metric()},
+
+
is_slave: function () {
for (var i = 0; i < this.index; i++)
if (this.motor.axis == this.config.motors[i].axis)
umPerStep: function () {
return this.motor['travel-per-rev'] * this.motor['step-angle'] / 0.36
- }
+ },
+
+
+ milPerStep: function () {return this.umPerStep / 25.4}
},
props: ['name', 'model', 'template'],
+ data: function () {return {view: ''}},
+
+
+ computed: {
+ metric: function () {return this.$root.metric()},
+
+
+ units: function () {
+ return (this.metric || !this.template.iunit) ?
+ this.template.unit : this.template.iunit;
+ }
+ },
+
+
+ watch: {
+ metric: function () {this.set_view()},
+ model: function () {this.set_view()}
+ },
+
+
+ ready: function () {this.set_view()},
+
+
methods: {
+ set_view: function () {
+ if (this.template.scale && !this.metric)
+ this.view = (this.model / this.template.scale).toFixed(2);
+ else this.view = this.model;
+ },
+
+
change: function () {
+ if (this.template.scale && !this.metric)
+ this.model = 1 * (this.view * this.template.scale).toFixed(3);
+ else this.model = this.view;
+
this.$dispatch('input-changed');
}
}
--- /dev/null
+/******************************************************************************\
+
+ This file is part of the Buildbotics firmware.
+
+ Copyright (c) 2015 - 2018, Buildbotics LLC
+ All rights reserved.
+
+ This file ("the software") is free software: you can redistribute it
+ and/or modify it under the terms of the GNU General Public License,
+ version 2 as published by the Free Software Foundation. You should
+ have received a copy of the GNU General Public License, version 2
+ along with the software. If not, see <http://www.gnu.org/licenses/>.
+
+ The software is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the software. If not, see
+ <http://www.gnu.org/licenses/>.
+
+ For information regarding this software email:
+ "Joseph Coffland" <joseph@buildbotics.com>
+
+\******************************************************************************/
+
+'use strict'
+
+
+module.exports = {
+ replace: true,
+ template: '{{text}}<span class="unit">{{metric ? unit : iunit}}</span>',
+ props: ['value', 'precision', 'unit', 'iunit', 'scale'],
+
+
+ computed: {
+ metric: function () {return this.$root.metric()},
+
+
+ text: function () {
+ var value = this.value;
+ if (typeof value == 'undefined') return '';
+
+ if (!this.metric) value /= this.scale;
+
+ return (1 * value.toFixed(this.precision)).toLocaleString();
+ }
+ },
+
+
+ ready: function () {
+ if (typeof this.precision == 'undefined') this.precision = 0;
+ if (typeof this.unit == 'undefined') this.unit = 'mm';
+ if (typeof this.iunit == 'undefined') this.iunit = 'in';
+ if (typeof this.scale == 'undefined') this.scale = 25.4;
+ }
+}
{
+ "settings": {
+ "units": {
+ "type": "enum",
+ "values": ["METRIC", "IMPERIAL"],
+ "default": "METRIC"
+ }
+ },
"motors": {
"type": "list",
"index": "0123",
"type": "float",
"min": 0,
"unit": "m/min",
+ "iunit": "IPM",
+ "scale": 0.0254,
"default": 5,
"code": "vm"
},
"type": "float",
"min": 0,
"unit": "km/min²",
+ "iunit": "g-force",
+ "scale": 35.304,
"default": 10,
"code": "am"
},
"type": "float",
"min": 0,
"unit": "km/min³",
+ "iunit": "g/min",
+ "scale": 35.304,
"default": 50,
"code": "jm"
},
"travel-per-rev": {
"type": "float",
"unit": "mm",
+ "iunit": "in",
+ "scale": 25.4,
"default": 5,
"code": "tr"
}
"min-soft-limit": {
"type": "float",
"unit": "mm",
+ "iunit": "in",
+ "scale": 25.4,
"default": 0,
"code": "tn"
},
"max-soft-limit": {
"type": "float",
"unit": "mm",
+ "iunit": "in",
+ "scale": 25.4,
"default": 0,
"code": "tm"
},
"type": "float",
"min": 0,
"unit": "m/min",
+ "iunit": "IPM",
+ "scale": 0.0254,
"default": 0.5,
"code": "sv"
},
"type": "float",
"min": 0,
"unit": "m/min",
+ "iunit": "IPM",
+ "scale": 0.0254,
"default": 0.1,
"code": "lv"
},
"type": "float",
"min": 0,
"unit": "mm",
+ "iunit": "in",
+ "scale": 25.4,
"default": 5,
"code": "lb"
},
"type": "float",
"min": 0,
"unit": "mm",
+ "iunit": "in",
+ "scale": 25.4,
"default": 1,
"code": "zb"
}
color #000
animation attention 2s step-start 0s infinite
+span.unit
+ font-size 60%
+
.status
color #eee
text-align center
top 50%
#menu
- .save
+ .save, .units
display block
- margin 0.25em auto
+ margin 0.25em 0.6em
.pure-menu-heading
background inherit