diff --git a/Libs/CMS_CORE_Library.dll b/Libs/CMS_CORE_Library.dll index 7ff00b43..bb47e0d2 100644 Binary files a/Libs/CMS_CORE_Library.dll and b/Libs/CMS_CORE_Library.dll differ diff --git a/Step.Core/ThreadsFunctions.cs b/Step.Core/ThreadsFunctions.cs index 5a479276..f3929f04 100644 --- a/Step.Core/ThreadsFunctions.cs +++ b/Step.Core/ThreadsFunctions.cs @@ -964,21 +964,23 @@ public static class ThreadsFunctions { // Try reconnection cmsError = ncHandler.Connect(); - if (cmsError.errorCode == CMS_ERROR_CODES.SIEMENS_ENVIRONMENT_NOT_FOUND || cmsError.errorCode == CMS_ERROR_CODES.SIEMENS_HMI_NOT_RUNNING) + if (cmsError.errorCode == CMS_ERROR_CODES.SIEMENS_ENVIRONMENT_NOT_FOUND || cmsError.errorCode == CMS_ERROR_CODES.SIEMENS_HMI_NOT_RUNNING || cmsError.errorCode == CMS_ERROR_CODES.OSAI_TT_FOLDER_NOT_FOUND) ManageLibraryError(cmsError); else if (cmsError.errorCode != CMS_ERROR_CODES.OK) ncHandler.Dispose(); + else + { + // Send status to UI + MessageServices.Current.Publish(SEND_NC_STATUS, null, ncHandler.numericalControl.NC_IsConnected()); - // Send status to UI - MessageServices.Current.Publish(SEND_NC_STATUS, null, ncHandler.numericalControl.NC_IsConnected()); - - Thread.Sleep(1000); + Thread.Sleep(1000); + } } if (ServerStartupConfig.AutoOpenCmsClient) StartCMSClient(null); - if(NcConfig.NcVendor == NC_VENDOR.FANUC || NcConfig.NcVendor == NC_VENDOR.DEMO) + if(NcConfig.NcVendor == NC_VENDOR.FANUC || NcConfig.NcVendor == NC_VENDOR.OSAI) { using (NcToolTableHandler toolTable = new NcToolTableHandler()) { @@ -1030,6 +1032,7 @@ public static class ThreadsFunctions break; case CMS_ERROR_CODES.SIEMENS_ENVIRONMENT_NOT_FOUND: + case CMS_ERROR_CODES.OSAI_TT_FOLDER_NOT_FOUND: Manage(ERROR_LEVEL.FATAL, cmsError.localizationKey); break; diff --git a/Step.Database/Controllers/NcToolManagerController.cs b/Step.Database/Controllers/NcToolManagerController.cs index 6819b161..5c8eb2f6 100644 --- a/Step.Database/Controllers/NcToolManagerController.cs +++ b/Step.Database/Controllers/NcToolManagerController.cs @@ -136,6 +136,13 @@ namespace Step.Database.Controllers return shanks; } + public DbNcShankModel FindShank(int shankId) + { + return dbCtx.Shanks + .Where(x => x.ShankId == shankId) + .FirstOrDefault(); + } + public DbNcShankModel FindShanksByPositions(int magazineId, int positionId) { DbNcShankModel shank = FindShanks() diff --git a/Step/Controllers/WebApi/NcToolManagerController.cs b/Step/Controllers/WebApi/NcToolManagerController.cs index 5d34bcdf..67a3ceaf 100644 --- a/Step/Controllers/WebApi/NcToolManagerController.cs +++ b/Step/Controllers/WebApi/NcToolManagerController.cs @@ -284,18 +284,28 @@ namespace Step.Controllers.WebApi } } - [Route("shank"), HttpPost] - public IHttpActionResult AddShank([FromBody][Required] DTONewNcShankModel dtoShank) - { - if (!ModelState.IsValid) - return BadRequest(ModelState); + [Route("shank/{shankId:int}"), HttpPost] + public IHttpActionResult AddShank(short shankId) + { + using (NcToolManagerController toolsManager = new NcToolManagerController()) + { + // Check if exists a tool with the same id + DbNcShankModel dbShank = toolsManager.FindShank(shankId); + if (dbShank != null) + return BadRequest(API_ERROR_KEYS.ID_ALREADY_EXIST); + } if (!ToolManagerConfig.ShankOpt) return BadRequest(API_ERROR_KEYS.OPTION_NOT_ACTIVE); using (NcToolManagerController toolsManager = new NcToolManagerController()) - { - DTONcShankModel shank = (DTONcShankModel)toolsManager.AddShank(dtoShank); + { + DTONewNcShankModel dtoShank = new DTONewNcShankModel() + { + Balluf = 0, + MagazinePositionType = 0 + }; + DTONcShankModel shank = (DTONcShankModel)toolsManager.AddShank(dtoShank, shankId); return Ok(shank); } diff --git a/Step/SetupActive.iss b/Step/SetupActive.iss index 0b0e5b78..36ec0253 100644 --- a/Step/SetupActive.iss +++ b/Step/SetupActive.iss @@ -98,7 +98,7 @@ english.InstallingDotNet = Installing .Net [Tasks] Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: checkablealone; Components: Demo Fanuc Osai Siemens Name: quicklaunchicon; Description: {cm:CreateQuickLaunchIcon}; GroupDescription: {cm:AdditionalIcons}; Flags: checkablealone; Components: Demo Fanuc Osai Siemens -Name: startupicon; Description: {cm:CreateStartupIcon}; GroupDescription: {cm:AdditionalIcons}; Flags: checkablealone; Components: Fanuc Osai +Name: startupicon; Description: {cm:CreateStartupIcon}; GroupDescription: {cm:AdditionalIcons}; Flags: checkablealone; Components: Demo Fanuc Osai Name: sinumerikicons; Description: {cm:CreateSinumerikIcons}; GroupDescription: {cm:AdditionalIcons}; Flags: checkablealone; Components: Siemens [Files] 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 9d211206..f0b9de24 100644 --- a/Step/wwwroot/src/app_modules/tooling/components/tooling-equipment.ts +++ b/Step/wwwroot/src/app_modules/tooling/components/tooling-equipment.ts @@ -535,11 +535,11 @@ public isEquipmentSelected(offset){ // Controllo se l'utensile può essere eliminato se in magazzino public checkIfCanDeleteTool() { if(this.selectedTool) { - if(!this.isSiemens || this.multitoolOptionActive){ + if(!this.isSiemens && this.multitoolOptionActive){ if(this.selectedTool.shankId) - return true; - else return false; + else + return true; }else{ if (this.magazines.length > 0) { var magId = this.getToolMagPosition(this.selectedTool.shankId) @@ -548,7 +548,6 @@ public isEquipmentSelected(offset){ if (mag) return true; }; - } } @@ -693,8 +692,8 @@ public isEquipmentSelected(offset){ } async saveEdge(tool, model) { - delete model.id; + await awaiter(new ToolingService().SetEdgeData(tool, model).then(response => { this.toolsConfiguration = (this.$store.state as AppModel).tooling.toolsConfiguration; this.edgeConfiguration = (this.$store.state as AppModel).tooling.edgesConfiguration; @@ -750,7 +749,6 @@ public isEquipmentSelected(offset){ } async buttonSave(tool: any, edge: any) { - console.log("ENTRO QUI", tool) if (tool.id) { if (edge && edge.id > 0) { this.modifyEdge(tool, edge); diff --git a/Step/wwwroot/src/app_modules/tooling/components/tooling-shanks.ts b/Step/wwwroot/src/app_modules/tooling/components/tooling-shanks.ts index fba80f9a..d65b460b 100644 --- a/Step/wwwroot/src/app_modules/tooling/components/tooling-shanks.ts +++ b/Step/wwwroot/src/app_modules/tooling/components/tooling-shanks.ts @@ -33,6 +33,8 @@ export default class toolingShanks extends Vue { return (this.$store.state as AppModel).tooling.maxToolsPerMultitools; } + public magazines: server.MagazineModel[] = (this.$store.state as AppModel).tooling.magazines; + public shankConfiguration: server.ShankConfiguration[] = null; public childToolsShank: server.ToolsConfiguration[] = null; @@ -97,6 +99,11 @@ export default class toolingShanks extends Vue { public enableAddShank: any = false; public enableAddChildsTools: any = false; + public newShankId : number = 1 + public useAutoToolId: boolean = true + public canAddNewShank: boolean = false + public enableShankCreation: boolean = false + public maxToolsShanksSiemens(){ if(this.shanks.length < this.maxMultitools){ this.enableAddShank = false; @@ -207,26 +214,43 @@ export default class toolingShanks extends Vue { } - public addShank() { - this.selectedTool = {}; + public createEmptyShank(selectedShank){ this.shankConfiguration = []; - this.enableModify = true; - this.enableEquipment = false; - this.enableParameters = true; - this.disableList = true; - for (let f in (this.$store.state as AppModel).tooling.shankConfiguration) { let element = (this.$store.state as AppModel).tooling.shankConfiguration[f]; if (!element.readOnly) { this.shankConfiguration.push(element); } - this.selectedTool[element.name] = element.minValue; + selectedShank[element.name] = element.minValue; if(element.name == "name"){ - this.selectedTool[element.name] = ""; + selectedShank[element.name] = ""; } } } + public addShank() { + let newShank = {} + this.enableModify = true; + this.enableEquipment = false; + this.disableList = true; + + if(!this.isSiemens){ + this.selectedTool = Object.assign({}, newShank) + this.copySelectedTool = null + this.useAutoToolId = true + this.enableShankCreation = true + this.enableParameters = false + + this.newShankId = null + } + else { + this.enableParameters = true; + this.createEmptyShank(newShank) + this.selectedTool = Object.assign({}, newShank) + this.copySelectedTool = null + } + } + public selectTool(item) { this.selectedTool = item; this.enableParameters = true; @@ -385,6 +409,9 @@ export default class toolingShanks extends Vue { })); } else{ + if(this.useAutoToolId) + item = 0 + awaiter(new ToolingService().SetNcShank(item).then(response => { this.selectedTool = response; let htmlelement = this.$refs.shankList as any; @@ -392,6 +419,11 @@ export default class toolingShanks extends Vue { this.shankConfiguration = (this.$store.state as AppModel).tooling.shankConfiguration; this.disableList = false; + + this.enableModify = false; + this.enableShankCreation = false; + this.useAutoToolId = false + this.enableParameters = true; })); } @@ -513,4 +545,86 @@ export default class toolingShanks extends Vue { } }, null); } + + // Controllo se lo shank può essere eliminato + public checkIfCanEditShank() { + if(this.selectedTool) { + // Check if magazine is locked + if (this.magazines.length > 0) { + var magId = this.getToolMagPosition(this.selectedTool.id) + var mag = this.magazines.find(d => d.id == magId); + + if (mag && !mag.loadingIsActive) + return true; + } + + // Check if tool is in spindle + const heads = this.$store.state.machineInfo.heads + for (let i = 0; i < heads.length; i++) { + const head = this.$store.getters.getHeadsProperty(heads[i].id) + + if(this.selectedTool.childsTools) { + // Check if one of the child tool is mounted in spindle + for(let j = 0; j < this.selectedTool.childsTools.length; j++) { + if(!head.fixedHead && this.selectedTool.childsTools[j].id === head.mountedTool) { + return true + } + } + } + } + } + + return false + } + + // Controllo se lo shank può essere eliminato + public checkIfCanDeleteShank() { + if(this.selectedTool) { + if (this.magazines.length > 0) { + var magId = this.getToolMagPosition(this.selectedTool.id) + var mag = this.magazines.find(d => d.id == magId); + + if (mag) + return true + } + } + + return false + } + + public getToolMagPosition = function (id) { + if (this.multitoolOptionActive) + return null + + var SH = this.ncShanks.filter(t => String(t.id).indexOf(id) >=0); + if(SH.length > 0) + return SH[0].magazineId; + + return null; + } + + public useAutoToolIdF() { + if (this.useAutoToolId) { + this.newShankId = null + } + else { + this.newShankId = 1 + } + } + + @Watch("newShankId") + public canAddTool(){ + if(!this.useAutoToolId && this.newShankId <= 0){ + this.canAddNewShank = false; + return; + } + + var tool = this.ncShanks.find(k => k.id == this.newShankId); + + if(tool) + this.canAddNewShank = false; + else + this.canAddNewShank = true; + + } } 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 f2e6ba72..7eb95c2a 100644 --- a/Step/wwwroot/src/app_modules/tooling/components/tooling-shanks.vue +++ b/Step/wwwroot/src/app_modules/tooling/components/tooling-shanks.vue @@ -1,16 +1,16 @@ + diff --git a/Step/wwwroot/src/services/toolingService.ts b/Step/wwwroot/src/services/toolingService.ts index 80fc2c6f..8739c758 100644 --- a/Step/wwwroot/src/services/toolingService.ts +++ b/Step/wwwroot/src/services/toolingService.ts @@ -159,8 +159,8 @@ export class ToolingService extends baseRestService { return response; } - async SetNcShank(model: any){ - var response = await this.Post(this.BASE_URL + "nc/shank", model); + async SetNcShank(shankId: any){ + var response = await this.Post(this.BASE_URL + "nc/shank/" + shankId, {}); toolingActions.updateNcShank(store, response); return response; }