diff --git a/Libs/CMS_CORE_Library.dll b/Libs/CMS_CORE_Library.dll index 770bdd81..66c69569 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 ac7b401b..54348dd3 100644 --- a/Step.Database/Controllers/NcToolManagerController.cs +++ b/Step.Database/Controllers/NcToolManagerController.cs @@ -136,6 +136,16 @@ namespace Step.Database.Controllers return shank; } + public List FindShanksByFamilyId(int familyId) + { + return dbCtx + .Tools + .Include("Shank") + .Where(x => x.FamilyId == familyId && x.ShankId != null) + .Select(x => x.Shank) + .ToList(); + } + public List GetShanks() { // Get shank from database diff --git a/Step.Model/Constants.cs b/Step.Model/Constants.cs index 6986818e..aa3ad2f3 100644 --- a/Step.Model/Constants.cs +++ b/Step.Model/Constants.cs @@ -230,6 +230,7 @@ namespace Step.Model public const string MAGAZINE_POSITION_OCCUPIED = "error_magazine_position_occupied"; public const string TOOL_IS_MOUNTED = "error_tool_mounted"; public const string OPTION_NOT_ACTIVE = "error_option_not_active"; + public const string MAG_POS_DISABLED = "error_mag_pos_disabled"; } // File paths diff --git a/Step.NC/NcHandler.cs b/Step.NC/NcHandler.cs index ee408ce0..e386fb2f 100644 --- a/Step.NC/NcHandler.cs +++ b/Step.NC/NcHandler.cs @@ -1488,7 +1488,7 @@ namespace Step.NC if (cmsError.IsError()) return cmsError; - if (NcConfig.NcVendor != NC_VENDOR.SIEMENS && NcConfig.NcVendor != NC_VENDOR.DEMO) + if (NcConfig.NcVendor != NC_VENDOR.SIEMENS) { config.FamilyOptionActive = true; config.MultitoolOptionActive = true; @@ -1550,8 +1550,13 @@ namespace Step.NC if (!ToolManagerConfig.ReviveOpt) categories.Add("revive"); - config.ToolsConfiguration = config.ToolsConfiguration.Where(x => !categories.Contains(x.Category)).ToList(); + config.ToolsConfiguration = config.ToolsConfiguration.Where(x => !categories.Contains(x.Category)).ToList(); + + // Remove categories from familyConfig config.FamiliesConfiguration.FamilyConfiguration = config.FamiliesConfiguration.FamilyConfiguration.Where(x => !categories.Contains(x.Category)).ToList(); + // Filter by SUBCATEGORIES because "ReadOnlyFamily" categories are not populated + config.FamiliesConfiguration.FamilyReadOnlyConfiguration = config.FamiliesConfiguration.FamilyReadOnlyConfiguration.Where(x => !categories.Contains(x.SubCategory)).ToList(); + config.ShanksConfiguration.ShankConfiguration = config.ShanksConfiguration.ShankConfiguration.Where(x => !categories.Contains(x.Category)).ToList(); config.MagazinePosConfiguration = config.MagazinePosConfiguration.Where(x => !categories.Contains(x.Category)).ToList(); } @@ -2116,15 +2121,20 @@ namespace Step.NC if (cmsError.IsError()) return cmsError; - toolsManager.DeleteFamily(famId); - // Check if shank opt is disabled if (!ToolManagerConfig.ShankOpt) { - // If the relationship is 1:1 (fam:shank) remove shank + // If the relationship is 1:1 (tool:shank) i have to remove shanks manually // Tools are deleted thanks to foreign keys constraint - toolsManager.DeleteNcShank(famId); + List shanks = toolsManager.FindShanksByFamilyId(famId); + foreach(var shank in shanks) + { + if (shank != null) + toolsManager.DeleteNcShank(shank.ShankId); + } } + + toolsManager.DeleteFamily(famId); // Update Nc families cmsError = UpdateNcFamily(toolsManager); diff --git a/Step/Controllers/WebApi/NcToolManagerController.cs b/Step/Controllers/WebApi/NcToolManagerController.cs index e2594025..8cf35e7a 100644 --- a/Step/Controllers/WebApi/NcToolManagerController.cs +++ b/Step/Controllers/WebApi/NcToolManagerController.cs @@ -12,6 +12,8 @@ using System.Linq; using System.Web.Http; using static Step.Config.ServerConfig; using static Step.Model.Constants; +using static Step.Listeners.SignalRStaticObjects; +using Step.Model.DTOModels; namespace Step.Controllers.WebApi { @@ -81,6 +83,12 @@ namespace Step.Controllers.WebApi DbNcFamilyModel fam = toolsManager.FindFamily(dtoToolWithFamily.FamilyId); if (fam == null) return BadRequest(API_ERROR_KEYS.INCORRECT_PARAMETERS); + + // Update return data + if (ToolManagerConfig.FamilyOpt) + { + dtoToolWithFamily.Name = fam.Name; + } } } else @@ -145,6 +153,10 @@ namespace Step.Controllers.WebApi if (tool == null) return NotFound(); + // Check if tool is mounted in spindle + if (ToolIsInSpindle(toolId)) + return BadRequest(API_ERROR_KEYS.TOOL_IS_MOUNTED); + if (tool.FamilyId != dtoToolWithFamily.FamilyId) { // Check if family exists @@ -204,6 +216,10 @@ namespace Step.Controllers.WebApi if (tool == null) return NotFound(); + // Check if tool is mounted in spindle + if (ToolIsInSpindle(toolId)) + return BadRequest(API_ERROR_KEYS.TOOL_IS_MOUNTED); + using (NcHandler ncHandler = new NcHandler()) { ncHandler.Connect(); @@ -296,6 +312,13 @@ namespace Step.Controllers.WebApi if (shank == null) return NotFound(); + // Check if tools are mounted in spindle + foreach (var tool in shank.Tools) + { + if (ToolIsInSpindle(tool.ToolId)) + return BadRequest(API_ERROR_KEYS.TOOL_IS_MOUNTED); + } + using (NcHandler ncHandler = new NcHandler()) { CmsError cmsError = ncHandler.Connect(); @@ -322,6 +345,13 @@ namespace Step.Controllers.WebApi if (shank == null) return NotFound(); + // Check if tools are mounted in spindle + foreach (var tool in shank.Tools) + { + if (ToolIsInSpindle(tool.ToolId)) + return BadRequest(API_ERROR_KEYS.TOOL_IS_MOUNTED); + } + using (NcHandler ncHandler = new NcHandler()) { CmsError cmsError = ncHandler.Connect(); @@ -383,6 +413,13 @@ namespace Step.Controllers.WebApi if (family == null) return NotFound(); + // Check if tools are mounted in spindle + foreach (var tool in family.Tools) + { + if (ToolIsInSpindle(tool.ToolId)) + return BadRequest(API_ERROR_KEYS.TOOL_IS_MOUNTED); + } + using (NcHandler ncHandler = new NcHandler()) { CmsError cmsError = ncHandler.Connect(); @@ -409,6 +446,13 @@ namespace Step.Controllers.WebApi if (family == null) return NotFound(); + // Check if tools are mounted in spindle + foreach (var tool in family.Tools) + { + if (ToolIsInSpindle(tool.ToolId)) + return BadRequest(API_ERROR_KEYS.TOOL_IS_MOUNTED); + } + using (NcHandler ncHandler = new NcHandler()) { CmsError cmsError = ncHandler.Connect(); @@ -547,7 +591,7 @@ namespace Step.Controllers.WebApi return BadRequest(API_ERROR_KEYS.INCORRECT_PARAMETERS); // Check if the mag pos is disabled if (magPos.Disabled == true) - return BadRequest(API_ERROR_KEYS.INCORRECT_PARAMETERS); + return BadRequest(API_ERROR_KEYS.MAG_POS_DISABLED); using (NcHandler ncHandler = new NcHandler()) { @@ -597,13 +641,20 @@ namespace Step.Controllers.WebApi if (shank == null) return BadRequest(API_ERROR_KEYS.INCORRECT_PARAMETERS); + // Check if tools are mounted in spindle + foreach (var tool in shank.Tools) + { + if (ToolIsInSpindle(tool.ToolId)) + return BadRequest(API_ERROR_KEYS.TOOL_IS_MOUNTED); + } + // Check if magazine position exists DbNcMagazinePositionModel magPos = toolsManager.FindMagazinePosition(magazineId, positionId); if (magPos == null) return BadRequest(API_ERROR_KEYS.INCORRECT_PARAMETERS); - // Check if the mag pos is disabled - if (magPos.Disabled == true) - return BadRequest(API_ERROR_KEYS.INCORRECT_PARAMETERS); + //// Check if the mag pos is disabled + //if (magPos.Disabled == true) + // return BadRequest(API_ERROR_KEYS.INCORRECT_PARAMETERS); // Check if magazine position is not occupied DbNcShankModel shankMounted = toolsManager.FindShanksByPositions(magazineId, positionId); @@ -706,5 +757,21 @@ namespace Step.Controllers.WebApi return Ok(); } } + + + private bool ToolIsInSpindle(int toolId) + { + foreach(var head in LastHeadsData.ToList()) + { + if(head is DTOSpindleModel) + { + var spindle = head as DTOSpindleModel; + if (spindle.MountedTool == toolId) + return true; + } + } + + return false; + } } } \ No newline at end of file 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 7ed19ee1..9911d85e 100644 --- a/Step/wwwroot/src/app_modules/tooling/components/tooling-depot.ts +++ b/Step/wwwroot/src/app_modules/tooling/components/tooling-depot.ts @@ -414,7 +414,7 @@ export default class depot extends Vue { let error = false // Check if one of the childs is in error shank.childsTools.forEach(tool => { - if(this.familyLifeFromId(tool.familyId) && tool.residualLife){ + if(this.familyLifeFromId(tool.familyId) && tool.residualLife <= 0){ error = true } if(tool.disabled || tool.broken){ 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 c026c373..698678d7 100644 --- a/Step/wwwroot/src/app_modules/tooling/components/tooling-equipment.ts +++ b/Step/wwwroot/src/app_modules/tooling/components/tooling-equipment.ts @@ -141,6 +141,7 @@ export default class toolingEquipment extends Vue { public offsetSelected: any = null; public posSelected: any = null; + public toolIsInSpindle: boolean = false public maxToolsSiemens(){ if (this.tools.length < this.maxTools) { @@ -161,6 +162,7 @@ export default class toolingEquipment extends Vue { } async mounted() { + console.log("entro nel mount") this.modalBlockMagazine(); if(this.isSiemens){ awaiter (Promise.all([ @@ -176,14 +178,15 @@ export default class toolingEquipment extends Vue { await new ToolingService().GetToolsConfiguration() ])); - this.populateMountedToolsInSplindle() + console.log(this.ncTools) + + this.checkIfToolIsMountedInSpindle() } this.toolsConfiguration = (this.$store.state as AppModel).tooling.toolsConfiguration; this.edgeConfiguration = (this.$store.state as AppModel).tooling.edgesConfiguration; - let arrayIdFamily = []; if(this.isSiemens){ await this.maxToolsSiemens(); @@ -470,49 +473,24 @@ export default class toolingEquipment extends Vue { } - - private canEdit = function () { - if(this.isSiemens){ - if(this.selectedTool) - return (this.selectedTool.magazineId == 0) - return false - } - else{ - 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() + @Watch("selectedTool") + public checkIfToolIsMountedInSpindle() { - for (let i = 0; i < this.toolMountedInSpindle.length; i++) { - const head = this.toolMountedInSpindle[i]; + if(this.selectedTool){ + const heads = this.$store.state.machineInfo.heads - if(toolId === head.mountedTool){ - return head.id + for (let i = 0; i < heads.length; i++) { + const head = this.getHeadsProperty(heads[i].id) + + if(this.selectedTool.id=== head.mountedTool){ + this.toolIsInSpindle = true + return + } } - } - - 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) + this.toolIsInSpindle = false + return } } diff --git a/Step/wwwroot/src/app_modules/tooling/components/tooling-equipment.vue b/Step/wwwroot/src/app_modules/tooling/components/tooling-equipment.vue index 8cfe200c..8b0b8540 100644 --- a/Step/wwwroot/src/app_modules/tooling/components/tooling-equipment.vue +++ b/Step/wwwroot/src/app_modules/tooling/components/tooling-equipment.vue @@ -69,7 +69,7 @@
- +
{{'tooling_equipment_editlabel' | localize("Modifica utensile %d",selectedTool.id,selectedTool.familyName)}}
{{'tooling_equipment_editlabel' | localize("Modifica utensile %d",selectedTool.id)}}
{{'tooling_equipment_newlabel' | localize("Creazione Nuovo Utensile")}}
@@ -103,8 +103,8 @@
- +
{{'tooling_families_boxright_editlabel' | localize("Modifica della famiglia %s", selectedTool.name)}}
{{'tooling_families_boxright_newlabel' | localize("Aggiunta nuova famiglia")}}
diff --git a/Step/wwwroot/src/app_modules/tooling/components/tooling-shanks.vue b/Step/wwwroot/src/app_modules/tooling/components/tooling-shanks.vue index 5b4a6254..f2e6ba72 100644 --- a/Step/wwwroot/src/app_modules/tooling/components/tooling-shanks.vue +++ b/Step/wwwroot/src/app_modules/tooling/components/tooling-shanks.vue @@ -79,7 +79,7 @@
- +
{{'tooling_shanks_editlabel' | localize("Modifica di Codolo %d",selectedTool.id)}}
{{'tooling_shanks_label_new' | localize("Creazione Utensile")}}
@@ -165,7 +165,7 @@
- +
{{'tooling_shanks_editlabel' | localize("Modifica di Codolo %d",selectedTool.id)}}
{{'tooling_shanks_label_new' | localize("Creazione Utensile")}}
diff --git a/Step/wwwroot/src/store/tooling.store.ts b/Step/wwwroot/src/store/tooling.store.ts index bc234188..bf42162a 100644 --- a/Step/wwwroot/src/store/tooling.store.ts +++ b/Step/wwwroot/src/store/tooling.store.ts @@ -224,6 +224,8 @@ export const toolingStore = { store.ncTools = Array.from(store._ncTools.values()); }, UpdateNcTools(store, model: server.ToolNc[]){ + + store._ncTools = new Map(); // populate _ncTools for(var i = 0; i < model.length; i ++){ store._ncTools.set(model[i].id, model[i]);