WIP: laser tool support

This commit is contained in:
David Carley
2021-10-09 13:39:38 -07:00
parent 91d2f2b979
commit f22252011a
4 changed files with 80 additions and 49 deletions

View File

@@ -30,12 +30,10 @@
var api = require('./api');
var modbus = require('./modbus.js');
module.exports = {
template: '#tool-view-template',
props: ['config', 'template', 'state'],
data: function () {
return {
address: 0,
@@ -43,74 +41,96 @@ module.exports = {
}
},
components: {'modbus-reg': require('./modbus-reg.js')},
watch: {
'state.mr': function () {this.value = this.state.mr}
components: {
'modbus-reg': require('./modbus-reg.js')
},
watch: {
'state.mr': function () { this.value = this.state.mr }
},
events: {
'input-changed': function() {
'input-changed': function () {
this.$dispatch('config-changed');
return false;
}
},
ready: function () {this.value = this.state.mr},
computed: {
regs_tmpl: function () {return this.template['modbus-spindle'].regs},
tool_type: function () {return this.config.tool['tool-type'].toUpperCase()},
is_modbus: function () {
return this.tool_type != 'DISABLED' && this.tool_type != 'PWM SPINDLE'
},
modbus_status: function () {return modbus.status_to_string(this.state.mx)}
ready: function () {
this.value = this.state.mr;
},
computed: {
regs_tmpl: function () {
return this.template['modbus-spindle'].regs;
},
tool_type: function () {
return this.config.tool['tool-type'].toUpperCase();
},
show_tool_settings: function() {
return !(
this.tool_type == "DISABLED" ||
this.is_laser
);
},
is_pwm_spindle: function() {
return this.tool_type == 'PWM SPINDLE';
},
is_laser: function() {
return this.tool_type.includes("LASER");
},
is_router: function() {
return this.tool_type.includes("ROUTER");
},
is_modbus: function () {
return this.tool_type != 'DISABLED' &&
!this.is_pwm_spindle && !this.is_laser && !this.is_router;
},
modbus_status: function () {
return modbus.status_to_string(this.state.mx);
}
},
methods: {
get_reg_type: function (reg) {
return this.regs_tmpl.template['reg-type'].values[this.state[reg + 'vt']]
return this.regs_tmpl.template['reg-type'].values[this.state[reg + 'vt']];
},
get_reg_addr: function (reg) {
return this.state[reg + 'va'];
},
get_reg_addr: function (reg) {return this.state[reg + 'va']},
get_reg_value: function (reg) {return this.state[reg + 'vv']},
get_reg_value: function (reg) {
return this.state[reg + 'vv'];
},
get_reg_fails: function (reg) {
var fails = this.state[reg + 'vr']
return fails == 255 ? 'Max' : fails;
},
show_modbus_field: function (key) {
return key != 'regs' &&
(key != 'multi-write' || this.tool_type == 'CUSTOM MODBUS VFD');
},
read: function (e) {
e.preventDefault();
api.put('modbus/read', {address: this.address});
api.put('modbus/read', { address: this.address });
},
write: function (e) {
e.preventDefault();
api.put('modbus/write', {address: this.address, value: this.value});
api.put('modbus/write', { address: this.address, value: this.value });
},
customize: function (e) {
e.preventDefault();
this.config.tool['tool-type'] = 'Custom Modbus VFD';
@@ -118,30 +138,28 @@ module.exports = {
var regs = this.config['modbus-spindle'].regs;
for (var i = 0; i < regs.length; i++) {
var reg = this.regs_tmpl.index[i];
regs[i]['reg-type'] = this.get_reg_type(reg);
regs[i]['reg-addr'] = this.get_reg_addr(reg);
regs[i]['reg-type'] = this.get_reg_type(reg);
regs[i]['reg-addr'] = this.get_reg_addr(reg);
regs[i]['reg-value'] = this.get_reg_value(reg);
}
this.$dispatch('config-changed');
},
clear: function (e) {
e.preventDefault();
this.config.tool['tool-type'] = 'Custom Modbus VFD';
var regs = this.config['modbus-spindle'].regs;
for (var i = 0; i < regs.length; i++) {
regs[i]['reg-type'] = 'disabled';
regs[i]['reg-addr'] = 0;
regs[i]['reg-type'] = 'disabled';
regs[i]['reg-addr'] = 0;
regs[i]['reg-value'] = 0;
}
this.$dispatch('config-changed');
},
reset_failures: function (e) {
e.preventDefault();
var regs = this.config['modbus-spindle'].regs;

View File

@@ -31,7 +31,7 @@ script#templated-input-template(type="text/x-template")
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}}
option(v-for="opt in template.values", :value="opt" :disabled="opt === '-----' ? true : false") {{opt}}
input(v-if="template.type == 'bool'", type="checkbox", v-model="view",
:name="name", @change="change")

View File

@@ -33,14 +33,13 @@ script#tool-view-template(type="text/x-template")
fieldset
templated-input(v-for="templ in template.tool", :name="$key",
:model.sync="config.tool[$key]", :template="templ",
v-if="tool_type != 'DISABLED' || $key == 'tool-type'")
v-if="$key == 'tool-type' || show_tool_settings")
label.extra(slot="extra",
v-if="$key == 'tool-enable-mode' || $key == 'tool-direction-mode'")
label.extra(slot="extra", v-if="$key == 'tool-enable-mode' || $key == 'tool-direction-mode'")
| Pin {{templ.pin}}
io-indicator(:name="$key", :state="state")
fieldset(v-if="tool_type == 'PWM SPINDLE'")
fieldset(v-if="is_pwm_spindle")
h2 PWM Spindle
templated-input(v-for="templ in template['pwm-spindle']",
:name="$key", :model.sync="config['pwm-spindle'][$key]",

View File

@@ -29,6 +29,7 @@
"default": true
}
},
"motors": {
"type": "list",
"index": "0123",
@@ -250,10 +251,23 @@
"tool": {
"tool-type": {
"type": "enum",
"values": ["Disabled", "PWM Spindle", "Huanyang VFD", "Custom Modbus VFD",
"AC-Tech VFD", "Nowforever VFD", "Delta VFD015M21A (Beta)",
"YL600, YL620, YL620-A VFD (Beta)", "FR-D700 (Beta)",
"Sunfar E300 (Beta)", "OMRON MX2"],
"values": [
"Disabled",
"-----",
"Router (Makita, etc)",
"J Tech Laser",
"PWM Spindle",
"-----",
"Huanyang VFD",
"Custom Modbus VFD",
"AC-Tech VFD",
"Nowforever VFD",
"Delta VFD015M21A (Beta)",
"YL600, YL620, YL620-A VFD (Beta)",
"FR-D700 (Beta)",
"Sunfar E300 (Beta)",
"OMRON MX2"
],
"default": "Disabled",
"code": "st"
},