removedd all changes related to EM-60

This commit is contained in:
saifullah-N
2023-01-29 12:38:44 +05:30
parent 18f3501aab
commit 1974f0b583
7 changed files with 656 additions and 643 deletions

View File

@@ -5,252 +5,261 @@ const modbus = require("./modbus.js");
const merge = require("lodash.merge");
module.exports = {
template: "#tool-view-template",
props: [ "config", "template", "state" ],
template: "#tool-view-template",
props: ["config", "template", "state"],
data: function() {
return {
address: 0,
value: 0,
toolList: [
{
id: "disabled",
name: "Disabled",
},
{
id: "router",
type: "PWM Spindle",
name: "Router (Makita, etc)",
},
{
id: "laser",
type: "PWM Spindle",
name: "Laser (J Tech, etc)",
},
{
id: "pwm",
name: "PWM Spindle",
},
{
id: "unsupported-separator",
name: "Unsupported Tools",
disabled: true,
unsupported: true,
},
{
id: "huanyang-vfd",
name: "Huanyang VFD",
unsupported: true,
},
{
id: "custom-modbus-vfd",
name: "Custom Modbus VFD",
unsupported: true,
},
{
id: "ac-tech-vfd",
name: "AC-Tech VFD",
unsupported: true,
},
{
id: "nowforever-vfd",
name: "Nowforever VFD",
unsupported: true,
},
{
id: "delta-vfd",
name: "Delta VFD015M21A (Beta)",
unsupported: true,
},
{
id: "yl600-vfd",
name: "YL600, YL620, YL620-A VFD (Beta)",
unsupported: true,
},
{
id: "fr-d700-vfd",
name: "FR-D700 (Beta)",
unsupported: true,
},
{
id: "sunfar-e300-vfd",
name: "Sunfar E300 (Beta)",
unsupported: true,
},
{
id: "omron-mx2-vfd",
name: "OMRON MX2",
unsupported: true,
},
// {
// id: "EM60",
// name: "EM60",
// },
],
};
data: function () {
return {
address: 0,
value: 0,
toolList: [
{
id: "disabled",
name: "Disabled",
},
{
id: "router",
type: "PWM Spindle",
name: "Router (Makita, etc)",
},
{
id: "laser",
type: "PWM Spindle",
name: "Laser (J Tech, etc)",
},
{
id: "pwm",
name: "PWM Spindle",
},
{
id: "unsupported-separator",
name: "Unsupported Tools",
disabled: true,
unsupported: true,
},
{
id: "huanyang-vfd",
name: "Huanyang VFD",
unsupported: true,
},
{
id: "custom-modbus-vfd",
name: "Custom Modbus VFD",
unsupported: true,
},
{
id: "ac-tech-vfd",
name: "AC-Tech VFD",
unsupported: true,
},
{
id: "nowforever-vfd",
name: "Nowforever VFD",
unsupported: true,
},
{
id: "delta-vfd",
name: "Delta VFD015M21A (Beta)",
unsupported: true,
},
{
id: "yl600-vfd",
name: "YL600, YL620, YL620-A VFD (Beta)",
unsupported: true,
},
{
id: "fr-d700-vfd",
name: "FR-D700 (Beta)",
unsupported: true,
},
{
id: "sunfar-e300-vfd",
name: "Sunfar E300 (Beta)",
unsupported: true,
},
{
id: "omron-mx2-vfd",
name: "OMRON MX2",
unsupported: true,
},
],
};
},
components: {
"modbus-reg": require("./modbus-reg.js"),
},
watch: {
"state.mr": function () {
this.value = this.state.mr;
},
},
events: {
"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;
},
components: {
"modbus-reg": require("./modbus-reg.js")
tool_type: function () {
return this.config.tool["tool-type"].toUpperCase();
},
watch: {
"state.mr": function() {
this.value = this.state.mr;
}
selected_tool: function () {
return this.config.tool["selected-tool"];
},
events: {
"input-changed": function() {
this.$dispatch("config-changed");
return false;
},
is_pwm_spindle: function () {
return this.selected_tool == "pwm";
},
ready: function() {
this.value = this.state.mr;
is_modbus: function () {
switch (this.selected_tool) {
case "disabled":
case "laser":
case "router":
case "pwm":
return false;
default:
return true;
}
},
computed: {
regs_tmpl: function() {
return this.template["modbus-spindle"].regs;
},
modbus_status: function () {
return modbus.status_to_string(this.state.mx);
},
},
tool_type: function() {
return this.config.tool["tool-type"].toUpperCase();
},
methods: {
change_selected_tool: function () {
const selectedToolSettings = this.config["selected-tool-settings"] || {};
const settings = selectedToolSettings[this.selected_tool] || {};
this.config.tool = merge({}, this.config.tool, settings["tool"]);
this.config["pwm-spindle"] = merge(
{},
this.config["pwm-spindle"],
settings["pwm-spindle"]
);
this.config["modbus-spindle"] = merge(
{},
this.config["modbus-spindle"],
settings["modbus-spindle"]
);
selected_tool: function() {
return this.config.tool["selected-tool"];
},
const tool = this.toolList.find(
(tool) => tool.id == this.config.tool["selected-tool"]
);
this.config.tool["tool-type"] = tool.type || tool.name;
is_pwm_spindle: function() {
return this.selected_tool == "pwm";
},
is_modbus: function() {
switch (this.selected_tool) {
case "disabled":
case "laser":
case "router":
case "pwm":
return false;
default:
return true;
}
},
modbus_status: function() {
return modbus.status_to_string(this.state.mx);
}
this.$dispatch("config-changed");
},
methods: {
change_selected_tool: function() {
const selectedToolSettings = this.config["selected-tool-settings"] || {};
const settings = selectedToolSettings[this.selected_tool] || {};
this.config.tool = merge({}, this.config.tool, settings["tool"]);
this.config["pwm-spindle"] = merge({}, this.config["pwm-spindle"], settings["pwm-spindle"]);
this.config["modbus-spindle"] = merge({}, this.config["modbus-spindle"], settings["modbus-spindle"]);
show_tool_settings: function (key) {
switch (true) {
case key === "tool-type":
case key === "selected-tool":
return false;
const tool = this.toolList.find(tool => tool.id == this.config.tool["selected-tool"]);
this.config.tool["tool-type"] = tool.type || tool.name;
case this.selected_tool === "disabled":
return false;
this.$dispatch("config-changed");
},
case this.selected_tool === "laser":
case this.selected_tool === "router":
switch (key) {
case "tool-enable-mode":
return true;
show_tool_settings: function(key) {
switch (true) {
case key === "tool-type":
case key === "selected-tool":
return false;
default:
return false;
}
case this.selected_tool === "disabled":
return false;
default:
return true;
}
},
case this.selected_tool === "laser":
case this.selected_tool === "router":
switch (key) {
case "tool-enable-mode":
return true;
get_reg_type: function (reg) {
return this.regs_tmpl.template["reg-type"].values[this.state[`${reg}vt`]];
},
default:
return false;
}
get_reg_addr: function (reg) {
return this.state[`${reg}va`];
},
default:
return true;
}
},
get_reg_value: function (reg) {
return this.state[`${reg}vv`];
},
get_reg_type: function(reg) {
return this.regs_tmpl.template["reg-type"].values[this.state[`${reg}vt`]];
},
get_reg_fails: function (reg) {
const fails = this.state[`${reg}vr`];
return fails == 255 ? "Max" : fails;
},
get_reg_addr: function(reg) {
return this.state[`${reg}va`];
},
show_modbus_field: function (key) {
return (
key != "regs" &&
(key != "multi-write" || this.tool_type == "CUSTOM MODBUS VFD")
);
},
get_reg_value: function(reg) {
return this.state[`${reg}vv`];
},
read: function (e) {
e.preventDefault();
api.put("modbus/read", { address: this.address });
},
get_reg_fails: function(reg) {
const fails = this.state[`${reg}vr`];
return fails == 255 ? "Max" : fails;
},
write: function (e) {
e.preventDefault();
api.put("modbus/write", { address: this.address, value: this.value });
},
show_modbus_field: function(key) {
return key != "regs" && (key != "multi-write" || this.tool_type == "CUSTOM MODBUS VFD");
},
customize: function (e) {
e.preventDefault();
this.config.tool["tool-type"] = "Custom Modbus VFD";
read: function(e) {
e.preventDefault();
api.put("modbus/read", { address: this.address });
},
const regs = this.config["modbus-spindle"].regs;
for (let i = 0; i < regs.length; i++) {
const 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-value"] = this.get_reg_value(reg);
}
write: function(e) {
e.preventDefault();
api.put("modbus/write", { address: this.address, value: this.value });
},
this.$dispatch("config-changed");
},
customize: function(e) {
e.preventDefault();
this.config.tool["tool-type"] = "Custom Modbus VFD";
clear: function (e) {
e.preventDefault();
this.config.tool["tool-type"] = "Custom Modbus VFD";
const regs = this.config["modbus-spindle"].regs;
for (let i = 0; i < regs.length; i++) {
const 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-value"] = this.get_reg_value(reg);
}
const regs = this.config["modbus-spindle"].regs;
for (let i = 0; i < regs.length; i++) {
regs[i]["reg-type"] = "disabled";
regs[i]["reg-addr"] = 0;
regs[i]["reg-value"] = 0;
}
this.$dispatch("config-changed");
},
this.$dispatch("config-changed");
},
clear: function(e) {
e.preventDefault();
this.config.tool["tool-type"] = "Custom Modbus VFD";
const regs = this.config["modbus-spindle"].regs;
for (let i = 0; i < regs.length; i++) {
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();
const regs = this.config["modbus-spindle"].regs;
for (let reg = 0; reg < regs.length; reg++) {
this.$dispatch("send", `$${reg}vr=0`);
}
}
}
reset_failures: function (e) {
e.preventDefault();
const regs = this.config["modbus-spindle"].regs;
for (let reg = 0; reg < regs.length; reg++) {
this.$dispatch("send", `$${reg}vr=0`);
}
},
},
};