diff --git a/Libs/CMS_CORE_Library.dll b/Libs/CMS_CORE_Library.dll index a36ef1d4..8455d416 100644 Binary files a/Libs/CMS_CORE_Library.dll and b/Libs/CMS_CORE_Library.dll differ diff --git a/Step.Model/DTOModels/ToolModels/DTOSiemensToolModel.cs b/Step.Model/DTOModels/ToolModels/DTOSiemensToolModel.cs index 5f7cccf3..50b1caa5 100644 --- a/Step.Model/DTOModels/ToolModels/DTOSiemensToolModel.cs +++ b/Step.Model/DTOModels/ToolModels/DTOSiemensToolModel.cs @@ -14,6 +14,9 @@ namespace Step.Model.DTOModels.ToolModels [Required] public int ToolType { get; set; } + [Required] + public SIEMENS_LIFE_TYPE LifeType { get; set; } + [Required] public int LeftSize { get; set; } @@ -50,7 +53,30 @@ namespace Step.Model.DTOModels.ToolModels [Required] public bool PreAlarm { get; set; } - // public List> EdgesData; + public static explicit operator SiemensToolModel(DTOSiemensToolModel dtoModel) + { + return new SiemensToolModel() + { + MagazinePositionType = dtoModel.MagazinePositionType, + ToolType = dtoModel.ToolType, + LifeType = dtoModel.LifeType, + FamilyName = dtoModel.FamilyName, + + IsActive = dtoModel.IsActive, + IsInhibited = dtoModel.IsInhibited, + IsInUse = dtoModel.IsInUse, + IsMeasured = dtoModel.IsMeasured, + InChangeTool = dtoModel.InChangeTool, + InFixedPlace = dtoModel.InFixedPlace, + PreAlarm = dtoModel.PreAlarm, + + Cooling1 = dtoModel.Cooling1, + Cooling2 = dtoModel.Cooling2, + LeftSize = dtoModel.LeftSize, + RightSize = dtoModel.RightSize, + Rotation = dtoModel.Rotation + }; + } } public class DTOMagazinesPositionsModel diff --git a/Step.NC/NcHandler.cs b/Step.NC/NcHandler.cs index 846308e4..157b958e 100644 --- a/Step.NC/NcHandler.cs +++ b/Step.NC/NcHandler.cs @@ -808,9 +808,9 @@ namespace Step.NC return numericalControl.TOOLS_WDeleteEdge(toolId, edgeId); } - public CmsError GetMagazinePositionsAndTools(int magazineId, out List magazinePos) + public CmsError GetMagazinePositionsAndTools(int magazineId, out List magazinePos) { - magazinePos = new List(); + magazinePos = new List(); return numericalControl.TOOLS_RMagazineTools(magazineId, ref magazinePos); } diff --git a/Step/Controllers/WebApi/ToolTableController.cs b/Step/Controllers/WebApi/ToolTableController.cs index b79394c0..a111fdf1 100644 --- a/Step/Controllers/WebApi/ToolTableController.cs +++ b/Step/Controllers/WebApi/ToolTableController.cs @@ -3,6 +3,7 @@ using Step.NC; using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; +using System.Diagnostics; using System.Linq; using System.Web.Http; using static CMS_CORE_Library.DataStructures; @@ -32,12 +33,15 @@ namespace Step.Controllers.WebApi { using (NcHandler ncHandler = new NcHandler()) { + ncHandler.Connect(); + Stopwatch sw = new Stopwatch(); + sw.Start(); CmsError libraryError = ncHandler.GetToolTableData(out List tools); if (libraryError.IsError()) if (libraryError.errorCode != CMS_ERROR_CODES.NOT_CONNECTED) return BadRequest(libraryError.message); - + Console.WriteLine(sw.ElapsedMilliseconds); return Ok(tools); } } @@ -51,7 +55,7 @@ namespace Step.Controllers.WebApi using (NcHandler ncHandler = new NcHandler()) { // Convert from DTOModel to library model - SiemensToolModel siemensModel = ConvertFromDTOtoSiemensModel(tool); + SiemensToolModel siemensModel = (SiemensToolModel)tool; ; ncHandler.Connect(); CmsError libraryError = ncHandler.AddTool(ref siemensModel); @@ -72,7 +76,7 @@ namespace Step.Controllers.WebApi using (NcHandler ncHandler = new NcHandler()) { // Convert from DTOModel to library model - SiemensToolModel siemensModel = ConvertFromDTOtoSiemensModel(tool); + SiemensToolModel siemensModel = (SiemensToolModel)tool; siemensModel.Id = id; ncHandler.Connect(); @@ -86,31 +90,6 @@ namespace Step.Controllers.WebApi } } - private SiemensToolModel ConvertFromDTOtoSiemensModel(DTOSiemensToolModel dtoModel) - { - return new SiemensToolModel() - { - MagazinePositionType = dtoModel.MagazinePositionType, - ToolType = dtoModel.ToolType, - - FamilyName = dtoModel.FamilyName, - - IsActive = dtoModel.IsActive, - IsInhibited = dtoModel.IsInhibited, - IsInUse = dtoModel.IsInUse, - IsMeasured = dtoModel.IsMeasured, - InChangeTool = dtoModel.InChangeTool, - InFixedPlace = dtoModel.InFixedPlace, - PreAlarm = dtoModel.PreAlarm, - - Cooling1 = dtoModel.Cooling1, - Cooling2 = dtoModel.Cooling2, - LeftSize = dtoModel.LeftSize, - RightSize = dtoModel.RightSize, - Rotation = dtoModel.Rotation - }; - } - [Route("tool/{id:int}"), HttpDelete] public IHttpActionResult DeleteTool(int id) { @@ -378,7 +357,7 @@ namespace Step.Controllers.WebApi { ncHandler.Connect(); // Call delete library function - CmsError libraryError = ncHandler.GetMagazinePositionsAndTools(magazineId, out List magazinePos); + CmsError libraryError = ncHandler.GetMagazinePositionsAndTools(magazineId, out List magazinePos); if (libraryError.IsError()) if (libraryError.errorCode != CMS_ERROR_CODES.NOT_CONNECTED) return BadRequest(libraryError.message);