WIP: laser tool support
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user