From 9a18f43c4e3d570727674ead5bf3c12de8d6b7d5 Mon Sep 17 00:00:00 2001 From: Paolo Possanzini Date: Fri, 21 Sep 2018 09:29:06 +0200 Subject: [PATCH] fix editor --- .../src/components/job-editor-detail.ts | 11 ++++- .../src/components/job-editor-detail.vue | 2 +- Step/wwwroot/src/components/job-editor.ts | 42 +++++++++---------- Step/wwwroot/src/services/jobService.ts | 11 +++++ 4 files changed, 42 insertions(+), 24 deletions(-) create mode 100644 Step/wwwroot/src/services/jobService.ts diff --git a/Step/wwwroot/src/components/job-editor-detail.ts b/Step/wwwroot/src/components/job-editor-detail.ts index 4fb3cc7f..c9ae8156 100644 --- a/Step/wwwroot/src/components/job-editor-detail.ts +++ b/Step/wwwroot/src/components/job-editor-detail.ts @@ -9,6 +9,7 @@ import "./job-editor-lang-definition" import { Container, Draggable } from "vue-smooth-dnd"; import { objectsJob } from "src/modules/base-components/cards"; import * as pf from "sprintf-js"; +import { jobService } from "../services/jobService"; @Component({ components: { ace, Container, Draggable, objectsJob } }) export default class JobEditorDetail extends Vue { @@ -22,6 +23,8 @@ export default class JobEditorDetail extends Vue { commands = new Array(); interactive: boolean = false; + macros: Array = []; + get sortedCommands() { return Array.from(this.activeCommandSet).sort((a, b) => { if (a.order > b.order) return 1; @@ -55,9 +58,9 @@ export default class JobEditorDetail extends Vue { commandsChanged(n, o) { if (n && this.interactive) { var result = ""; - + debugger this.commands.forEach(c => { - result += pf.vsprintf(c.definition.command, c.value || "", c.value2 || "") + "\n"; + result += pf.vsprintf(c.definition.command, [c.value || "", c.value2 || ""]) + "\n"; }); this.isoProgram = result; @@ -108,6 +111,10 @@ export default class JobEditorDetail extends Vue { vScrollBarAlwaysVisible: true }) } + + async mounted() { + this.macros = await jobService.GetMacroList(); + } } interface commandDefinition { diff --git a/Step/wwwroot/src/components/job-editor-detail.vue b/Step/wwwroot/src/components/job-editor-detail.vue index 2170b88e..1f2c6acc 100644 --- a/Step/wwwroot/src/components/job-editor-detail.vue +++ b/Step/wwwroot/src/components/job-editor-detail.vue @@ -31,7 +31,7 @@
diff --git a/Step/wwwroot/src/components/job-editor.ts b/Step/wwwroot/src/components/job-editor.ts index 89cacc09..9d1e10ee 100644 --- a/Step/wwwroot/src/components/job-editor.ts +++ b/Step/wwwroot/src/components/job-editor.ts @@ -30,34 +30,34 @@ export default class JobEditor extends Vue { const siemensJobItems = [ - { title: 'job_item_part_program', layout: "big", command: 'CALL "%s"', rx: /CALL "(.+)";?|CALL "(.+)";([.]*)"/, order: 0 }, - { title: 'job_item_macro_cms', layout: "big", command: 'PCALL /_N_CMA_DIR/%s', rx: /PCALL \/_N_CMA_DIR\/(.+);?|PCALL \/_N_CMA_DIR\/(.+);?([.]*)/, order: 0 }, - { title: 'job_item_text', layout: "big", command: "%s", rx: /(.+);?|(.+);([.]*)/, order: 100 }, - { title: 'job_item_pause', layout: "small", command: "M0;%s", rx: /^M0;?|^M0;([.]*)/, order: 0 }, - { title: 'job_item_delay', layout: "small", command: "G04 F%s;", rx: /G04 F(\d*);?|G04 F(\d*);([.]*)/, order: 0 }, - { title: 'job_item_origin', layout: "small", command: "G%s", rx: /G(.+);?|G(.+);([.]*)/, order: 0 }, - { title: 'job_item_end_program', layout: "small", command: "M30", rx: /M30;?|M30;([.]*)/, order: 0 }, + { title: 'job_item_part_program', layout: "big", command: 'CALL "%s";%s', rx: /CALL "(.+)";(.*)|CALL "(.+)";?/, order: 0 }, + { title: 'job_item_macro_cms', layout: "big", command: 'PCALL /_N_CMA_DIR/%s;%s', rx: /PCALL \/_N_CMA_DIR\/(.+);(.*)|PCALL \/_N_CMA_DIR\/(.+);?/, order: 0 }, + { title: 'job_item_text', layout: "big", command: "%s;%s", rx: /(.+);(.*)|(.+);?/, order: 100 }, + { title: 'job_item_pause', layout: "small", command: "M0;%s", rx: /^M0;(.*)|^M0;?/, order: 0 }, + { title: 'job_item_delay', layout: "small", command: "G04 F%s;%s", rx: /G04 F(\d*);(.*)|G04 F(\d*);?/, order: 0 }, + { title: 'job_item_origin', layout: "small", command: "G%s;%s", rx: /G(.+);(.*)|G(.+);?/, order: 0 }, + { title: 'job_item_end_program', layout: "small", command: "M30;%s", rx: /M30;(.*)|M30;?/, order: 0 }, ]; // Da controllare comandi e regex const osaiJobItems = [ - { title: 'job_item_part_program', layout: "big", command: 'M198 %s', rx: /M198 (.+);?[.]*/, order: 0 }, - { title: 'job_item_macro_cms', layout: "big", command: 'M98 P%s', rx: /M98 P(.+);?[.]*/, order: 0 }, - { title: 'job_item_text', layout: "big", command: "%s", rx: /(.+);?[.]*/, order: 100 }, - { title: 'job_item_pause', layout: "small", command: "M0", rx: /^M0;?[.]*/, order: 0 }, - { title: 'job_item_delay', layout: "small", command: "G04 X%s;", rx: /G04 X(.+);?[.]*/, order: 0 }, - { title: 'job_item_origin', layout: "small", command: "G54 P%s", rx: /G54 P(.+);?[.]*/, order: 0 }, - { title: 'job_item_end_program', layout: "small", command: "M30;", rx: /M30;?[.]*/, order: 0 }, + { title: 'job_item_part_program', layout: "big", command: 'M198 %s', rx: /M198 (.+);(.*)|M198 (.+);?/, order: 0 }, + { title: 'job_item_macro_cms', layout: "big", command: 'M98 P%s', rx: /M98 P(.+);(.*)|M98 P(.+);?/, order: 0 }, + { title: 'job_item_text', layout: "big", command: "%s", rx: /(.+);(.*)|(.+);?/, order: 100 }, + { title: 'job_item_pause', layout: "small", command: "M0", rx: /^M0;(.*)|^M0;?/, order: 0 }, + { title: 'job_item_delay', layout: "small", command: "G04 X%s;", rx: /G04 X(.+);(.*)|G04 X(.+);?/, order: 0 }, + { title: 'job_item_origin', layout: "small", command: "G54 P%s", rx: /G54 P(.+);(.*)|G54 P(.+);?/, order: 0 }, + { title: 'job_item_end_program', layout: "small", command: "M30;", rx: /M30;(.*)|M30;?/, order: 0 }, ]; // Da controllare comandi e regex const fanucJobItems = [ - { title: 'job_item_part_program', layout: "big", command: 'CALL "%s"', rx: /M198 (.+);?[.]*/, order: 0 }, - { title: 'job_item_macro_cms', layout: "big", command: 'PCALL /_N_CMA_DIR/%s', rx: /M98 P(.+);?[.]*/, order: 0 }, - { title: 'job_item_text', layout: "big", command: "%s", rx: /(.+);?[.]*/, order: 100 }, - { title: 'job_item_pause', layout: "small", command: "M0", rx: /^M0;?[.]*/, order: 0 }, - { title: 'job_item_delay', layout: "small", command: "G04 F%s;", rx: /G04 X(.+);?[.]*/, order: 0 }, - { title: 'job_item_origin', layout: "small", command: "G%s", rx: /G54 P(.+);?[.]*/, order: 0 }, - { title: 'job_item_end_program', layout: "small", command: "M30", rx: /M30;?[.]*/, order: 0 }, + { title: 'job_item_part_program', layout: "big", command: 'CALL "%s"', rx: /M198 (.+);?.*/, order: 0 }, + { title: 'job_item_macro_cms', layout: "big", command: 'PCALL /_N_CMA_DIR/%s', rx: /M98 P(.+);?.*/, order: 0 }, + { title: 'job_item_text', layout: "big", command: "%s", rx: /(.+);?.*/, order: 100 }, + { title: 'job_item_pause', layout: "small", command: "M0", rx: /^M0;?.*/, order: 0 }, + { title: 'job_item_delay', layout: "small", command: "G04 F%s;", rx: /G04 X(.+);?.*/, order: 0 }, + { title: 'job_item_origin', layout: "small", command: "G%s", rx: /G54 P(.+);?.*/, order: 0 }, + { title: 'job_item_end_program', layout: "small", command: "M30", rx: /M30;?.*/, order: 0 }, ]; diff --git a/Step/wwwroot/src/services/jobService.ts b/Step/wwwroot/src/services/jobService.ts new file mode 100644 index 00000000..2da9714d --- /dev/null +++ b/Step/wwwroot/src/services/jobService.ts @@ -0,0 +1,11 @@ +import { baseRestService } from "src/_base/baseRestService"; + +export class JobService extends baseRestService { + + async GetMacroList(): Promise> { + return await this.Get("api/file_manager/macros"); + } +} + + +export const jobService = new JobService();