diff --git a/Libs/CMS_CORE_Library.dll b/Libs/CMS_CORE_Library.dll index 849aa9d8..08a65969 100644 Binary files a/Libs/CMS_CORE_Library.dll and b/Libs/CMS_CORE_Library.dll differ diff --git a/Step.Database/Controllers/NcToolManagerController.cs b/Step.Database/Controllers/NcToolManagerController.cs index d6b49dac..0c4f2cee 100644 --- a/Step.Database/Controllers/NcToolManagerController.cs +++ b/Step.Database/Controllers/NcToolManagerController.cs @@ -75,6 +75,7 @@ namespace Step.Database.Controllers return dbCtx .Families .Where(x => x.FamilyId == familyId) + .Include("Tools") .FirstOrDefault(); } @@ -428,15 +429,15 @@ namespace Step.Database.Controllers return dbShank; } - public DbNcShankModel DeleteShank(int shankId) + public DbNcShankModel DeleteNcShank(int shankId) { DbNcShankModel shank = FindShankWithTools(shankId); - DeleteShank(shank); + DeleteNcShank(shank); return shank; } - public void DeleteShank(DbNcShankModel shank) + public void DeleteNcShank(DbNcShankModel shank) { dbCtx.Shanks.Remove(shank); diff --git a/Step.NC/NcHandler.cs b/Step.NC/NcHandler.cs index 7ea4e575..497446d5 100644 --- a/Step.NC/NcHandler.cs +++ b/Step.NC/NcHandler.cs @@ -1938,14 +1938,30 @@ namespace Step.NC { // Delete db tool toolsManager.DeleteTool(tool.ToolId); + + if (!ToolManagerConfig.FamilyOpt) + { + DbNcFamilyModel fam = toolsManager.FindFamily(tool.FamilyId); + // Check if family is connected to other tools + if (fam != null && fam.Tools.Count() == 1) + { + toolsManager.DeleteFamily(fam.FamilyId); + } + } + DbNcShankModel shank = null; + if (!ToolManagerConfig.ShankOpt && tool.ShankId != null) + { + // If option is active find & delete tool shank + shank = toolsManager.FindShankWithTools(tool.ShankId.Value); + + toolsManager.DeleteNcShank(shank.ShankId); + } bool startIsActive = false; CmsError cmsError = NO_ERROR; if (tool.ShankId != null) { - // If tool is mounted than update Nc data - DbNcShankModel shank = toolsManager.FindShankWithTools(tool.ShankId.Value); if (shank.MagazineId != null) { startIsActive = true; @@ -1962,6 +1978,7 @@ namespace Step.NC } } + ManageErrorAndTransaction(cmsError, dbContextTransaction, startIsActive); return cmsError; @@ -2012,7 +2029,7 @@ namespace Step.NC using (var dbContextTransaction = toolsManager.dbCtx.Database.BeginTransaction()) { // Delete database shank - DbNcShankModel deletedShank = toolsManager.DeleteShank(shankId); + DbNcShankModel deletedShank = toolsManager.DeleteNcShank(shankId); bool startIsActive = false; if (deletedShank.MagazineId != null) { diff --git a/Step/Controllers/WebApi/NcToolManagerController.cs b/Step/Controllers/WebApi/NcToolManagerController.cs index c93aa6eb..8cdce4f4 100644 --- a/Step/Controllers/WebApi/NcToolManagerController.cs +++ b/Step/Controllers/WebApi/NcToolManagerController.cs @@ -201,32 +201,11 @@ namespace Step.Controllers.WebApi { ncHandler.Connect(); - CmsError cmsError; cmsError = ncHandler.DeleteNcTool(tool); if (cmsError.IsError()) return BadRequest(cmsError.localizationKey); - if (!ToolManagerConfig.ShankOpt && tool.ShankId != null) - { - // If option is active find & delete tool shank - DbNcShankModel shank = toolsManager.FindShankWithTools(tool.ShankId.Value); - - cmsError = ncHandler.DeleteNcShank(shank.ShankId); - if (cmsError.IsError()) - return BadRequest(cmsError.localizationKey); - } - if (!ToolManagerConfig.FamilyOpt) - { - DbNcFamilyModel fam = toolsManager.FindFamily(tool.FamilyId); - if(fam.Tools.Count() == 1) - { - cmsError = ncHandler.DeleteNcFamily(tool.FamilyId); - if (cmsError.IsError()) - return BadRequest(cmsError.localizationKey); - } - } - return Ok(); } } diff --git a/Step/wwwroot/src/app_modules/tooling/components/tooling-depot.ts b/Step/wwwroot/src/app_modules/tooling/components/tooling-depot.ts index b0ccdc94..ca213cee 100644 --- a/Step/wwwroot/src/app_modules/tooling/components/tooling-depot.ts +++ b/Step/wwwroot/src/app_modules/tooling/components/tooling-depot.ts @@ -3,7 +3,7 @@ import Component from "vue-class-component"; import { Watch, Prop } from "vue-property-decorator"; import { tool, detailCard, cardToolDepot,cardBusyDepot } from "src/modules/base-components/cards"; -import { store, AppModel,machineInfoActions } from "src/store"; +import { store, AppModel, machineInfoActions } from "src/store"; import { DepotService } from "src/services/depotService"; import { mapGetters } from 'vuex' import { depotBL } from "src/business-logic/depot-bl"; @@ -206,6 +206,7 @@ export default class depot extends Vue { public draggingPosition: number = null; public typeNc: string = "Osai"; + public toolMountedInSpindle = null @Watch("searchText") public applyFilter(n) { @@ -245,11 +246,48 @@ export default class depot extends Vue { return this.depotNc.find(d => d.positionId == position && d.magazineId == this.depotId); } - + // Controllo se l'utensile è un utensile montato nel mandrino + public checkIfToolIsMountedInSpindle(toolId) { + if(!this.toolMountedInSpindle) + this.populateMountedToolsInSplindle() + + for (let i = 0; i < this.toolMountedInSpindle.length; i++) { + const head = this.toolMountedInSpindle[i]; + + if(toolId === head.mountedTool){ + return head.id + } + } + + return 0; + } + + // Polola gli utensili montati in mandrino + public populateMountedToolsInSplindle() + { + this.toolMountedInSpindle = [] + const heads = this.$store.state.machineInfo.heads + + for (let i = 0; i < heads.length; i++) { + const head = this.getHeadsProperty(heads[i].id) + if(head.mountedTool) + this.toolMountedInSpindle.push(head) + } + } + + getHeadsProperty(id) { + var r = this.$store.getters.getHeadsProperty(id); + return r || {}; + } + depotId: number = 0; magazineLocked: boolean = false; editable: boolean = false; + async created() { + this.populateMountedToolsInSplindle(); + } + async mounted() { this.modalBlockMagazine(); this.depotId = this.$route.params.id; @@ -260,6 +298,7 @@ export default class depot extends Vue { toolingActions.updateBusyStatusPositions(store,this.magazineType,this.depot); else toolingActions.updateBusyStatusPositions(store,this.magazineType,this.depotNc); + this.onLoading = false; } @@ -355,10 +394,6 @@ export default class depot extends Vue { } } - public test() { - alert("sadasdsa"); - } - public toolIsInWarning(tool) { if (tool) return (this.$store.getters as ToolingGetters).toolIsInWarning(tool.id); @@ -455,8 +490,6 @@ export default class depot extends Vue { toolingActions.updateBusyStatusPositions(store,this.magazineType,this.depotNc); this.onLoading = false; - console.log("POS" , this.depotNc); - // this.magazines; } @@ -669,7 +702,6 @@ export default class depot extends Vue { } public calculateAvailablePositions() { - console.log(this.isSiemens); if(this.draggingTool){ if(this.isSiemens) toolingActions.setCanLoadTool(store, this.draggingTool.rightSize,this.draggingTool.leftSize,this.magazineType,this.depot); diff --git a/Step/wwwroot/src/app_modules/tooling/components/tooling-depot.vue b/Step/wwwroot/src/app_modules/tooling/components/tooling-depot.vue index acbd425a..20e8829f 100644 --- a/Step/wwwroot/src/app_modules/tooling/components/tooling-depot.vue +++ b/Step/wwwroot/src/app_modules/tooling/components/tooling-depot.vue @@ -174,11 +174,13 @@ @drop="addToDepotPosition(pos, $event)"> {{'depot_avaiable_position' | localize("Posizione disponibile")}} - diff --git a/Step/wwwroot/src/app_modules/tooling/components/tooling-equipment.ts b/Step/wwwroot/src/app_modules/tooling/components/tooling-equipment.ts index 1cabf464..9118f898 100644 --- a/Step/wwwroot/src/app_modules/tooling/components/tooling-equipment.ts +++ b/Step/wwwroot/src/app_modules/tooling/components/tooling-equipment.ts @@ -176,6 +176,8 @@ export default class toolingEquipment extends Vue { await new ToolingService().GetNcShanks(), await new ToolingService().GetToolsConfiguration() ])); + + this.populateMountedToolsInSplindle() } @@ -477,11 +479,49 @@ export default class toolingEquipment extends Vue { return false } else{ - console.log("TODO canEdit() in tooling-equipment.ts") - return true + if(this.selectedTool) + return !this.checkIfToolIsMountedInSpindle(this.selectedTool.id) + + return false } } + public toolMountedInSpindle = null + + // Controllo se l'utensile è un utensile montato nel mandrino + public checkIfToolIsMountedInSpindle(toolId) { + if(!this.toolMountedInSpindle) + this.populateMountedToolsInSplindle() + + for (let i = 0; i < this.toolMountedInSpindle.length; i++) { + const head = this.toolMountedInSpindle[i]; + + if(toolId === head.mountedTool){ + return head.id + } + } + + return 0; + } + + // Polola gli utensili montati in mandrino + public populateMountedToolsInSplindle() + { + this.toolMountedInSpindle = [] + const heads = this.$store.state.machineInfo.heads + + for (let i = 0; i < heads.length; i++) { + const head = this.getHeadsProperty(heads[i].id) + if(head.mountedTool) + this.toolMountedInSpindle.push(head) + } + } + + getHeadsProperty(id) { + var r = this.$store.getters.getHeadsProperty(id); + return r || {}; + } + public getToolIcon = function (id) { if (id == 9999) return "../assets/iicons/Tools/Undefined.png" diff --git a/Step/wwwroot/src/modules/base-components/cards/card-tool-depot.vue b/Step/wwwroot/src/modules/base-components/cards/card-tool-depot.vue index 68dc0c62..3b1b6ad0 100644 --- a/Step/wwwroot/src/modules/base-components/cards/card-tool-depot.vue +++ b/Step/wwwroot/src/modules/base-components/cards/card-tool-depot.vue @@ -9,8 +9,9 @@
{{code}}
+
{{'head_' + headId | localize(headId)}}
-
+
@@ -23,7 +24,8 @@ export default { code: {default:"E13"}, title: {default:"Utensile XYZ"}, imgSource: {default:"../assets/icons/_png/fresa-raggiatura-104x104.png"}, - editable: false + editable: false, + headId: 0 }, methods:{ onClick(){ diff --git a/Step/wwwroot/src/store/tooling.store.ts b/Step/wwwroot/src/store/tooling.store.ts index 1a89755b..a87dffc1 100644 --- a/Step/wwwroot/src/store/tooling.store.ts +++ b/Step/wwwroot/src/store/tooling.store.ts @@ -465,7 +465,7 @@ export const toolingStore = { dimleft = element.maxLeft/2.0; dimright = element.maxRight/2.0; } - console.log("element",element.maxRight,element.maxLeft); + //Check dimensions if(dimleft<0.5) dimleft = 0.5;