From 624504619d0627e40af53d7309ffdccaa3326047 Mon Sep 17 00:00:00 2001 From: = Date: Mon, 6 Jul 2020 12:03:51 +0200 Subject: [PATCH] invio immediato dei dati --- .../setup/ciclo/components/show-ciclo-info.ts | 12 +++++++++--- .../components/show-controstampo-info.ts | 12 +++++++++--- .../components/show-estrazione-info.ts | 12 +++++++++--- .../formato/components/show-formato-info.ts | 11 ++++++++--- .../setup/imbutitura/show-imbutitura-info.ts | 9 ++++++--- .../setup/opzioni/show-opzioni-info.ts | 12 +++++++++--- .../pirometro/components/show-pirometro-info.ts | 11 ++++++++--- .../components/show-quote-velocita-info.ts | 11 ++++++++--- .../components/show-raffreddamento-info.ts | 11 ++++++++--- .../riscaldi/components/show-riscaldi-info.ts | 11 ++++++++--- .../setup/vuoto/show-vuoto-info.ts | 12 +++++++++--- Thermo.Active/wwwroot/src/services/hub.ts | 2 +- .../wwwroot/src/services/recipeService.ts | 17 +++++++++++++++++ .../wwwroot/src/store/modules.store.ts | 8 ++++---- 14 files changed, 113 insertions(+), 38 deletions(-) diff --git a/Thermo.Active/wwwroot/src/app_modules_thermo/setup/ciclo/components/show-ciclo-info.ts b/Thermo.Active/wwwroot/src/app_modules_thermo/setup/ciclo/components/show-ciclo-info.ts index 58c62c1d..f6c123b7 100644 --- a/Thermo.Active/wwwroot/src/app_modules_thermo/setup/ciclo/components/show-ciclo-info.ts +++ b/Thermo.Active/wwwroot/src/app_modules_thermo/setup/ciclo/components/show-ciclo-info.ts @@ -1,6 +1,6 @@ import Vue from 'vue'; import Component from 'vue-class-component'; -import { Prop } from 'vue-property-decorator'; +import { Prop, Watch } from 'vue-property-decorator'; import StepFooter from "@/app_modules_thermo/setup/components/step-footer.vue"; import { Modal, ModalHelper } from "@/components/modals"; import { Factory, messageService, awaiter } from "@/_base"; @@ -26,8 +26,9 @@ export default class ShowCicloInfo extends Vue { // this.deferred.resolve(-1); }; - async conferma() { - // recipeActions.setCurrent(store, this.recipe); + + @Watch('recipe', { deep: true }) + async recipeChanged(n, o) { await recipeService.Update( { cycle_forming_type: this.recipe.cycle_forming_type, @@ -54,6 +55,11 @@ export default class ShowCicloInfo extends Vue { cycle_loader_manualunloading_enabled: this.recipe.cycle_loader_manualunloading_enabled, } ); + }; + + async conferma() { + // recipeActions.setCurrent(store, this.recipe); + await recipeService.Confirm('Cycle'); ModalHelper.HideModal(); this.deferred.resolve(1); diff --git a/Thermo.Active/wwwroot/src/app_modules_thermo/setup/controstampo_setup/components/show-controstampo-info.ts b/Thermo.Active/wwwroot/src/app_modules_thermo/setup/controstampo_setup/components/show-controstampo-info.ts index 483d6463..907c2262 100644 --- a/Thermo.Active/wwwroot/src/app_modules_thermo/setup/controstampo_setup/components/show-controstampo-info.ts +++ b/Thermo.Active/wwwroot/src/app_modules_thermo/setup/controstampo_setup/components/show-controstampo-info.ts @@ -1,6 +1,6 @@ import Vue from 'vue'; import Component from 'vue-class-component'; -import { Prop } from 'vue-property-decorator'; +import { Prop, Watch } from 'vue-property-decorator'; import { Factory, messageService, awaiter } from "@/_base"; import { Modal, ModalHelper } from "@/components/modals"; import StepFooter from "@/app_modules_thermo/setup/components/step-footer.vue"; @@ -37,8 +37,8 @@ export default class ShowControstampoInfo extends Vue { // this.deferred.resolve(-1); }; - async conferma() { - // recipeActions.setCurrent(store, this.recipe); + @Watch('recipe', { deep: true }) + async recipeChanged(n, o) { await recipeService.Update( { upperplate_cycle_type: this.recipe.upperplate_cycle_type, @@ -71,6 +71,12 @@ export default class ShowControstampoInfo extends Vue { upperplate_extraction_manual: this.recipe.upperplate_extraction_manual, } ); + } + + + async conferma() { + // recipeActions.setCurrent(store, this.recipe); + await recipeService.Confirm('UpperPlate'); ModalHelper.HideModal(); this.deferred.resolve(1); diff --git a/Thermo.Active/wwwroot/src/app_modules_thermo/setup/estrazione/components/show-estrazione-info.ts b/Thermo.Active/wwwroot/src/app_modules_thermo/setup/estrazione/components/show-estrazione-info.ts index 771298ee..82f39774 100644 --- a/Thermo.Active/wwwroot/src/app_modules_thermo/setup/estrazione/components/show-estrazione-info.ts +++ b/Thermo.Active/wwwroot/src/app_modules_thermo/setup/estrazione/components/show-estrazione-info.ts @@ -1,6 +1,6 @@ import Vue from 'vue'; import Component from 'vue-class-component'; -import { Prop } from 'vue-property-decorator'; +import { Prop, Watch } from 'vue-property-decorator'; import { Factory, messageService, awaiter } from "@/_base"; import { Modal, ModalHelper } from "@/components/modals"; import StepFooter from "@/app_modules_thermo/setup/components/step-footer.vue"; @@ -34,8 +34,9 @@ export default class ShowEstrazioneInfo extends Vue { // this.deferred.resolve(-1); }; - async conferma() { - // recipeActions.setCurrent(store, this.recipe); + @Watch('recipe', { deep: true }) + async recipeChanged(n, o) { + await recipeService.Update( { extraction_main_type: this.recipe.extraction_main_type, @@ -51,6 +52,11 @@ export default class ShowEstrazioneInfo extends Vue { extraction_aux_manual: this.recipe.extraction_aux_manual, } ); + } + + async conferma() { + // recipeActions.setCurrent(store, this.recipe); + await recipeService.Confirm('Extraction'); ModalHelper.HideModal(); this.deferred.resolve(1); diff --git a/Thermo.Active/wwwroot/src/app_modules_thermo/setup/formato/components/show-formato-info.ts b/Thermo.Active/wwwroot/src/app_modules_thermo/setup/formato/components/show-formato-info.ts index 07dd026b..0627dba8 100644 --- a/Thermo.Active/wwwroot/src/app_modules_thermo/setup/formato/components/show-formato-info.ts +++ b/Thermo.Active/wwwroot/src/app_modules_thermo/setup/formato/components/show-formato-info.ts @@ -2,7 +2,7 @@ import Vue from "vue"; import { Modal, ModalHelper } from "@/components/modals"; import { Factory, messageService, awaiter } from "@/_base"; import Component from "vue-class-component"; -import { Prop } from 'vue-property-decorator'; +import { Prop, Watch } from 'vue-property-decorator'; import Stampo from "./stampo.vue"; import Lastra from "./lastra.vue"; import Piastra from "./piastra_riduzione.vue"; @@ -55,8 +55,8 @@ export default class ShowFormatoInfo extends Vue { // this.deferred.resolve(-1); }; - async conferma() { - // recipeActions.setCurrent(store, this.recipe); + @Watch('recipe', { deep: true }) + async recipeChanged(n, o) { await recipeService.Update( { general_sizes_mould_dim_x: this.recipe.general_sizes_mould_dim_x, @@ -78,6 +78,11 @@ export default class ShowFormatoInfo extends Vue { general_area_working_dxsx: this.recipe.general_area_working_dxsx, } ); + } + + async conferma() { + // recipeActions.setCurrent(store, this.recipe); + await recipeService.Confirm('General'); ModalHelper.HideModal(); this.deferred.resolve(1); diff --git a/Thermo.Active/wwwroot/src/app_modules_thermo/setup/imbutitura/show-imbutitura-info.ts b/Thermo.Active/wwwroot/src/app_modules_thermo/setup/imbutitura/show-imbutitura-info.ts index 9de79c32..21070312 100644 --- a/Thermo.Active/wwwroot/src/app_modules_thermo/setup/imbutitura/show-imbutitura-info.ts +++ b/Thermo.Active/wwwroot/src/app_modules_thermo/setup/imbutitura/show-imbutitura-info.ts @@ -3,7 +3,7 @@ import { Modal, ModalHelper } from "@/components/modals"; import { Factory, messageService, awaiter } from "@/_base"; import Component from "vue-class-component"; import StepFooter from "@/app_modules_thermo/setup/components/step-footer.vue" -import { Prop } from "vue-property-decorator"; +import { Prop, Watch } from "vue-property-decorator"; import Slider from "@/app_modules_thermo/components/slider.vue"; import Scheda from "@/app_modules_thermo/components/scheda.vue"; import { recipeActions } from "@/store/recipe.store"; @@ -45,8 +45,8 @@ export default class ShowImbutituraInfo extends Vue { // this.deferred.resolve(-1); }; - async conferma(name: string) { - // recipeActions.setCurrent(store, this.recipe); + @Watch('recipe', { deep: true }) + async recipeChanged(n, o) { await recipeService.Update( { drawing_type: this.recipe.drawing_type, @@ -60,6 +60,9 @@ export default class ShowImbutituraInfo extends Vue { drawing_mould_up_delay: this.recipe.drawing_mould_up_delay, } ); + } + + async conferma(name: string) { await recipeService.Confirm('Drawing'); ModalHelper.HideModal(); this.deferred.resolve(1); diff --git a/Thermo.Active/wwwroot/src/app_modules_thermo/setup/opzioni/show-opzioni-info.ts b/Thermo.Active/wwwroot/src/app_modules_thermo/setup/opzioni/show-opzioni-info.ts index 9878b08d..54fd95e8 100644 --- a/Thermo.Active/wwwroot/src/app_modules_thermo/setup/opzioni/show-opzioni-info.ts +++ b/Thermo.Active/wwwroot/src/app_modules_thermo/setup/opzioni/show-opzioni-info.ts @@ -8,7 +8,7 @@ import SottosquadraControstampo from "./components/sottosquadra-controstampo.vue import Termoregolatori from "./components/termoregolatori.vue"; import { recipeActions } from "@/store/recipe.store"; import { store } from "@/store"; -import { Prop } from "vue-property-decorator"; +import { Prop, Watch } from "vue-property-decorator"; import { Deferred } from "@/services"; import { recipeService } from "@/services/recipeService"; @@ -35,8 +35,9 @@ export default class ShowOpzioniInfo extends Vue { // this.deferred.resolve(-1); }; - async conferma() { - // recipeActions.setCurrent(store, this.recipe); + + @Watch('recipe', { deep: true }) + async recipeChanged(n, o) { await recipeService.Update( { options_undercutmould_1_mode: this.recipe.options_undercutmould_1_mode, @@ -141,6 +142,11 @@ export default class ShowOpzioniInfo extends Vue { options_thermoregulator_10_setpoint: this.recipe.options_thermoregulator_10_setpoint, } ); + } + + async conferma() { + // recipeActions.setCurrent(store, this.recipe); + await recipeService.Confirm('Options'); ModalHelper.HideModal(); this.deferred.resolve(1); diff --git a/Thermo.Active/wwwroot/src/app_modules_thermo/setup/pirometro/components/show-pirometro-info.ts b/Thermo.Active/wwwroot/src/app_modules_thermo/setup/pirometro/components/show-pirometro-info.ts index bf2c2f20..f6d46488 100644 --- a/Thermo.Active/wwwroot/src/app_modules_thermo/setup/pirometro/components/show-pirometro-info.ts +++ b/Thermo.Active/wwwroot/src/app_modules_thermo/setup/pirometro/components/show-pirometro-info.ts @@ -2,7 +2,7 @@ import Vue from "vue"; import { Modal, ModalHelper } from "@/components/modals"; import { Factory, messageService, awaiter } from "@/_base"; import Component from "vue-class-component"; -import { Prop } from 'vue-property-decorator'; +import { Prop, Watch } from 'vue-property-decorator'; import Pirometro from "./base-components/pirometro.vue"; import TermoregolazioneSuperiore from "./base-components/termo-superiore.vue"; import TermoregolazioneInferiore from "./base-components/termo-inferiore.vue"; @@ -27,8 +27,8 @@ export default class ShowPirometroInfo extends Vue { // this.deferred.resolve(-1); }; - async conferma() { - // recipeActions.setCurrent(store, this.recipe); + @Watch('recipe', { deep: true }) + async recipeChanged(n, o) { await recipeService.Update( { pyrometer_pyrometer_enabled: this.recipe.pyrometer_pyrometer_enabled, @@ -52,6 +52,11 @@ export default class ShowPirometroInfo extends Vue { pyrometer_lowerthermoregulator_working_temperature: this.recipe.pyrometer_lowerthermoregulator_working_temperature, } ); + } + + async conferma() { + // recipeActions.setCurrent(store, this.recipe); + await recipeService.Confirm('Pyrometer'); ModalHelper.HideModal(); this.deferred.resolve(1); diff --git a/Thermo.Active/wwwroot/src/app_modules_thermo/setup/quote-velocita/components/show-quote-velocita-info.ts b/Thermo.Active/wwwroot/src/app_modules_thermo/setup/quote-velocita/components/show-quote-velocita-info.ts index 5072dc5a..234844d3 100644 --- a/Thermo.Active/wwwroot/src/app_modules_thermo/setup/quote-velocita/components/show-quote-velocita-info.ts +++ b/Thermo.Active/wwwroot/src/app_modules_thermo/setup/quote-velocita/components/show-quote-velocita-info.ts @@ -8,7 +8,7 @@ import Controstampo from "./controstampo.vue"; import StepFooter from "@/app_modules_thermo/setup/components/step-footer.vue"; import { recipeActions } from "@/store/recipe.store"; import { store } from "@/store"; -import { Prop } from "vue-property-decorator"; +import { Prop, Watch } from "vue-property-decorator"; import { Deferred } from "@/services"; import { recipeService } from "@/services/recipeService"; @@ -35,8 +35,8 @@ export default class ShowQuoteVelocitaInfo extends Vue { // this.deferred.resolve(-1); }; - async conferma() { - // recipeActions.setCurrent(store, this.recipe); + @Watch('recipe', { deep: true }) + async recipeChanged(n, o) { await recipeService.Update( { positions_mould_lower_position: this.recipe.positions_mould_lower_position, @@ -65,6 +65,11 @@ export default class ShowQuoteVelocitaInfo extends Vue { positions_upperplate_lowerdeceleration_speed: this.recipe.positions_upperplate_lowerdeceleration_speed, } ); + } + + async conferma() { + // recipeActions.setCurrent(store, this.recipe); + await recipeService.Confirm('Positions'); ModalHelper.HideModal(); this.deferred.resolve(1); diff --git a/Thermo.Active/wwwroot/src/app_modules_thermo/setup/raffreddamento/components/show-raffreddamento-info.ts b/Thermo.Active/wwwroot/src/app_modules_thermo/setup/raffreddamento/components/show-raffreddamento-info.ts index 8cd614bb..c510e596 100644 --- a/Thermo.Active/wwwroot/src/app_modules_thermo/setup/raffreddamento/components/show-raffreddamento-info.ts +++ b/Thermo.Active/wwwroot/src/app_modules_thermo/setup/raffreddamento/components/show-raffreddamento-info.ts @@ -1,6 +1,6 @@ import Vue from 'vue'; import Component from 'vue-class-component'; -import { Prop } from 'vue-property-decorator'; +import { Prop, Watch } from 'vue-property-decorator'; import StepFooter from "@/app_modules_thermo/setup/components/step-footer.vue"; import { Modal, ModalHelper } from "@/components/modals"; import { Factory, messageService, awaiter } from "@/_base"; @@ -39,8 +39,8 @@ export default class Raffreddamento extends Vue { // this.deferred.resolve(-1); }; - async conferma() { - // recipeActions.setCurrent(store, this.recipe); + @Watch('recipe', { deep: true }) + async recipeChanged(n, o) { await recipeService.Update( { cooling_blowing_type: this.recipe.cooling_blowing_type, @@ -74,6 +74,11 @@ export default class Raffreddamento extends Vue { cooling_shutter_16_opening_perc: this.recipe.cooling_shutter_16_opening_perc, } ); + } + + async conferma() { + // recipeActions.setCurrent(store, this.recipe); + await recipeService.Confirm('Cooling'); ModalHelper.HideModal(); this.deferred.resolve(1); diff --git a/Thermo.Active/wwwroot/src/app_modules_thermo/setup/riscaldi/components/show-riscaldi-info.ts b/Thermo.Active/wwwroot/src/app_modules_thermo/setup/riscaldi/components/show-riscaldi-info.ts index afe4c9dd..983fb9b3 100644 --- a/Thermo.Active/wwwroot/src/app_modules_thermo/setup/riscaldi/components/show-riscaldi-info.ts +++ b/Thermo.Active/wwwroot/src/app_modules_thermo/setup/riscaldi/components/show-riscaldi-info.ts @@ -2,7 +2,7 @@ import Vue from "vue"; import { Modal, ModalHelper } from "@/components/modals"; import { Factory, messageService, awaiter } from "@/_base"; import Component from "vue-class-component"; -import { Prop } from 'vue-property-decorator'; +import { Prop, Watch } from 'vue-property-decorator'; import StepFooter from "@/app_modules_thermo/setup/components/step-footer.vue"; import RiscaldiSup from "./base-components/riscaldi-superiori.vue"; import RiscaldiInf from "./base-components/riscaldi-inferiori.vue"; @@ -28,8 +28,8 @@ export default class ShowRiscaldamentoSuperioreInfo extends Vue { // this.deferred.resolve(-1); }; - async conferma(name: string) { - // recipeActions.setCurrent(store, this.recipe); + @Watch('recipe', { deep: true }) + async recipeChanged(n, o) { await recipeService.Update( { heats_lowerheaters_max_time: this.recipe.heats_lowerheaters_max_time, @@ -49,6 +49,11 @@ export default class ShowRiscaldamentoSuperioreInfo extends Vue { heats_decomsustain_smoke_function_enabled: this.recipe.heats_decomsustain_smoke_function_enabled, } ); + } + + async conferma(name: string) { + // recipeActions.setCurrent(store, this.recipe); + await warmersService.Update(store.state.warmers.channels.reduce((p, c) => { p[c.idChannel] = c.setpointHMI; return p; }, {})); await warmersService.Confirm(); await recipeService.Confirm('Heats'); diff --git a/Thermo.Active/wwwroot/src/app_modules_thermo/setup/vuoto/show-vuoto-info.ts b/Thermo.Active/wwwroot/src/app_modules_thermo/setup/vuoto/show-vuoto-info.ts index b4335575..7ac59a2f 100644 --- a/Thermo.Active/wwwroot/src/app_modules_thermo/setup/vuoto/show-vuoto-info.ts +++ b/Thermo.Active/wwwroot/src/app_modules_thermo/setup/vuoto/show-vuoto-info.ts @@ -2,7 +2,7 @@ import Vue from "vue"; import { Modal, ModalHelper } from "@/components/modals"; import { Factory, messageService, awaiter } from "@/_base"; import Component from "vue-class-component"; -import { Prop } from 'vue-property-decorator'; +import { Prop, Watch } from 'vue-property-decorator'; import StepFooter from "@/app_modules_thermo/setup/components/step-footer.vue"; import VuotoPrincipale from "./base-components/vuoto-principale.vue"; import VuotoDiretto from "./base-components/vuoto-diretto.vue"; @@ -38,8 +38,9 @@ export default class ShowVuotoInfo extends Vue { // this.deferred.resolve(-1); }; - async conferma() { - // recipeActions.setCurrent(store, this.recipe); + + @Watch('recipe', { deep: true }) + async recipeChanged(n, o) { await recipeService.Update( { vacuum_main_start: this.recipe.vacuum_main_start, @@ -76,6 +77,11 @@ export default class ShowVuotoInfo extends Vue { vacuum_pre_3_chart_setpointy: this.recipe.vacuum_pre_3_chart_setpointy, } ); + } + + async conferma() { + // recipeActions.setCurrent(store, this.recipe); + await recipeService.Confirm('Vacuum'); ModalHelper.HideModal(); this.deferred.resolve(1); diff --git a/Thermo.Active/wwwroot/src/services/hub.ts b/Thermo.Active/wwwroot/src/services/hub.ts index eacd40d8..a637772e 100644 --- a/Thermo.Active/wwwroot/src/services/hub.ts +++ b/Thermo.Active/wwwroot/src/services/hub.ts @@ -149,7 +149,7 @@ export class Hub { } public static modulesData(data) { - modulesActions.set(store, data); + modulesActions.setBlock(store, data); } public static recipeFullData(data) { diff --git a/Thermo.Active/wwwroot/src/services/recipeService.ts b/Thermo.Active/wwwroot/src/services/recipeService.ts index bb8fe935..0df4c75c 100644 --- a/Thermo.Active/wwwroot/src/services/recipeService.ts +++ b/Thermo.Active/wwwroot/src/services/recipeService.ts @@ -36,6 +36,23 @@ export class RecipeService extends baseRestService { return result; } + async UpdateChanges(newmodel: { [id: string]: Recipe.IValue }, oldmodel: { [id: string]: Recipe.IValue }) { + let toupdate: { [id: string]: Recipe.IValue } = {}; + let needsUpdate: boolean = false + for (const key in newmodel) { + let n = newmodel[key]; + let o = oldmodel[key]; + + if (n.setpointHMI != o.setpointPLC) { + toupdate[key] = n; + needsUpdate = true; + } + } + + if (needsUpdate) + await this.Update(toupdate); + } + async Confirm(section: string) { let result = await this.Put((await this.BASE_URL()) + "confirm?section=" + section, true); return result; diff --git a/Thermo.Active/wwwroot/src/store/modules.store.ts b/Thermo.Active/wwwroot/src/store/modules.store.ts index 4341c7e4..ec3a4b32 100644 --- a/Thermo.Active/wwwroot/src/store/modules.store.ts +++ b/Thermo.Active/wwwroot/src/store/modules.store.ts @@ -7,7 +7,7 @@ export interface ModulesStoreModel { export interface ModulesActions { - set(context, model: { [id: string]: server.Modblock }); + setBlock(context, model: { [id: string]: server.Modblock }); } export interface ModulesGetters { @@ -24,7 +24,7 @@ export const modulesStore = { mutations: { - SetCurrent(state: ModulesStoreModel, model: { [id: string]: server.Modblock }) { + SetModule(state: ModulesStoreModel, model: { [id: string]: server.Modblock }) { for (const key in model) { let result = state.blocks.find(i => i.id.toString() == key.toString()) if (result) @@ -39,8 +39,8 @@ export const modulesStore = { actions: { - async set(context, model: { [id: string]: server.Modblock }) { - context.commit("SetCurrent", model); + async setBlock(context, model: { [id: string]: server.Modblock }) { + context.commit("SetModule", model); }, } as ModulesActions