Fix name field & added offset update
This commit is contained in:
@@ -160,7 +160,7 @@ namespace Step.Model.DTOModels.ToolModels
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
public List<DTONcToolModel> Tools { get; set; }
|
||||
public List<DTONcToolModel> ChildTools { get; set; }
|
||||
|
||||
public static explicit operator DTONcFamilyModel(DbNcFamilyModel obj)
|
||||
{
|
||||
@@ -205,7 +205,7 @@ namespace Step.Model.DTOModels.ToolModels
|
||||
LifeType = obj.LifeType,
|
||||
NominalLife = obj.NominalLife,
|
||||
ReviveDelta = obj.ReviveDelta,
|
||||
Tools = tools
|
||||
ChildsTools = tools
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
+74
-69
@@ -996,68 +996,6 @@ namespace Step.NC
|
||||
return cmsError;
|
||||
}
|
||||
|
||||
// OSAI FANUC TOOL MANAGER
|
||||
|
||||
public CmsError GetToolsData(out List<DTONcToolModel> dtoTools)
|
||||
{
|
||||
dtoTools = new List<DTONcToolModel>();
|
||||
|
||||
CmsError cmsError = NO_ERROR;
|
||||
|
||||
using (NcToolManagerController toolsManager = new NcToolManagerController())
|
||||
{
|
||||
List<DbNcToolModel> tools = toolsManager.FindToolsWithDependencies();
|
||||
|
||||
foreach (DbNcToolModel tool in tools)
|
||||
{
|
||||
DTONcToolModel dtoTool = (DTONcToolModel)tool;
|
||||
|
||||
cmsError = GetToolData(tool, ref dtoTool);
|
||||
|
||||
dtoTools.Add(dtoTool);
|
||||
}
|
||||
|
||||
return cmsError;
|
||||
}
|
||||
}
|
||||
|
||||
public CmsError GetToolData(DbNcToolModel tool, ref DTONcToolModel dtoTool)
|
||||
{
|
||||
dtoTool = (DTONcToolModel)tool;
|
||||
|
||||
OffsetModel offset = new OffsetModel();
|
||||
CmsError cmsError = NO_ERROR;
|
||||
|
||||
if (tool.OffsetId1 != null && tool.OffsetId1 != 0)
|
||||
{
|
||||
// Read first offset data
|
||||
cmsError = numericalControl.TOOLS_ROffset((short)tool.OffsetId1, ref offset);
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
dtoTool.Offset1 = offset;
|
||||
}
|
||||
if (tool.OffsetId2 != null && tool.OffsetId2 != 0)
|
||||
{
|
||||
// Read second offset data
|
||||
cmsError = numericalControl.TOOLS_ROffset((short)tool.OffsetId2, ref offset);
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
dtoTool.Offset2 = offset;
|
||||
}
|
||||
if (tool.OffsetId3 != null && tool.OffsetId3 != 0)
|
||||
{
|
||||
// Read third offset data
|
||||
cmsError = numericalControl.TOOLS_ROffset((short)tool.OffsetId3, ref offset);
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
dtoTool.Offset3 = offset;
|
||||
}
|
||||
|
||||
return cmsError;
|
||||
}
|
||||
|
||||
#endregion Read Data
|
||||
|
||||
@@ -1119,6 +1057,7 @@ namespace Step.NC
|
||||
// Set to true power on data by id
|
||||
return numericalControl.PLC_WPowerOnData(id, true);
|
||||
}
|
||||
#endregion Write data
|
||||
|
||||
#region Siemens Tools
|
||||
|
||||
@@ -1231,6 +1170,69 @@ namespace Step.NC
|
||||
|
||||
#region Osai/Fanuc Tools
|
||||
|
||||
// OSAI FANUC TOOL MANAGER
|
||||
|
||||
public CmsError GetToolsData(out List<DTONcToolModel> dtoTools)
|
||||
{
|
||||
dtoTools = new List<DTONcToolModel>();
|
||||
|
||||
CmsError cmsError = NO_ERROR;
|
||||
|
||||
using (NcToolManagerController toolsManager = new NcToolManagerController())
|
||||
{
|
||||
List<DbNcToolModel> tools = toolsManager.FindToolsWithDependencies();
|
||||
|
||||
foreach (DbNcToolModel tool in tools)
|
||||
{
|
||||
DTONcToolModel dtoTool = (DTONcToolModel)tool;
|
||||
|
||||
cmsError = GetToolData(tool, ref dtoTool);
|
||||
|
||||
dtoTools.Add(dtoTool);
|
||||
}
|
||||
|
||||
return cmsError;
|
||||
}
|
||||
}
|
||||
|
||||
public CmsError GetToolData(DbNcToolModel tool, ref DTONcToolModel dtoTool)
|
||||
{
|
||||
dtoTool = (DTONcToolModel)tool;
|
||||
|
||||
OffsetModel offset = new OffsetModel();
|
||||
CmsError cmsError = NO_ERROR;
|
||||
|
||||
if (tool.OffsetId1 != null && tool.OffsetId1 != 0)
|
||||
{
|
||||
// Read first offset data
|
||||
cmsError = numericalControl.TOOLS_ROffset((short)tool.OffsetId1, ref offset);
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
dtoTool.Offset1 = offset;
|
||||
}
|
||||
if (tool.OffsetId2 != null && tool.OffsetId2 != 0)
|
||||
{
|
||||
// Read second offset data
|
||||
cmsError = numericalControl.TOOLS_ROffset((short)tool.OffsetId2, ref offset);
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
dtoTool.Offset2 = offset;
|
||||
}
|
||||
if (tool.OffsetId3 != null && tool.OffsetId3 != 0)
|
||||
{
|
||||
// Read third offset data
|
||||
cmsError = numericalControl.TOOLS_ROffset((short)tool.OffsetId3, ref offset);
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
dtoTool.Offset3 = offset;
|
||||
}
|
||||
|
||||
return cmsError;
|
||||
}
|
||||
|
||||
public DTONcToolModel AddTool(DTONewNcToolModel tool)
|
||||
{
|
||||
using (NcToolManagerController toolsManager = new NcToolManagerController())
|
||||
@@ -1254,7 +1256,7 @@ namespace Step.NC
|
||||
{
|
||||
// Update database tool Tool
|
||||
DbNcToolModel dbTool = toolsManager.UpdateTool(toolId, newTool);
|
||||
|
||||
|
||||
// Populate updated tool with offset data
|
||||
CmsError cmsError = GetToolData(dbTool, ref toolWithOffsets);
|
||||
if (cmsError.IsError())
|
||||
@@ -1315,6 +1317,11 @@ namespace Step.NC
|
||||
return numericalControl.TOOLS_WUpdateTools(tools);
|
||||
}
|
||||
|
||||
public CmsError UpdateOffset(short offsetId, OffsetModel offsetData)
|
||||
{
|
||||
return numericalControl.TOOLS_WOffset(offsetId, offsetData);
|
||||
}
|
||||
|
||||
public CmsError DeleteNcTool(DbNcToolModel tool)
|
||||
{
|
||||
using (NcToolManagerController toolsManager = new NcToolManagerController())
|
||||
@@ -1521,7 +1528,7 @@ namespace Step.NC
|
||||
// Update nc families
|
||||
return numericalControl.TOOLS_WUpdateFamilies(families);
|
||||
}
|
||||
|
||||
|
||||
public CmsError UpdateMagazinePosition(DbNcMagazinePositionModel dbPos, DTONcMagazinePositionModel dtoPos, out DTONcMagazinePositionModel magPos)
|
||||
{
|
||||
magPos = new DTONcMagazinePositionModel();
|
||||
@@ -1540,7 +1547,7 @@ namespace Step.NC
|
||||
|
||||
// Update database data
|
||||
magPos = (DTONcMagazinePositionModel)toolsManager.UpdatePosition(dbPos, dtoPos);
|
||||
|
||||
|
||||
// Get magazines positions
|
||||
List<NcMagazinePositionModel> positions = toolsManager.FindMagazinesPositions()
|
||||
.Select(x => (NcMagazinePositionModel)x)
|
||||
@@ -1563,7 +1570,7 @@ namespace Step.NC
|
||||
// Close transaction
|
||||
dbContextTransaction.Rollback();
|
||||
// Restore backup
|
||||
if(ncStartIsActive)
|
||||
if (ncStartIsActive)
|
||||
numericalControl.TOOLS_WRestoreBackup();
|
||||
}
|
||||
else
|
||||
@@ -1576,7 +1583,6 @@ namespace Step.NC
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public DTONcShankModel LoadIntoShank(DbNcToolModel tool, int shankId)
|
||||
{
|
||||
using (NcToolManagerController toolsManager = new NcToolManagerController())
|
||||
@@ -1717,7 +1723,7 @@ namespace Step.NC
|
||||
{
|
||||
updatedStatus = new Dictionary<int, byte>();
|
||||
updatedLives = new Dictionary<int, uint>();
|
||||
return numericalControl.TOOLS_RUpdatedToolsData(ref updatedStatus, ref updatedLives);
|
||||
return numericalControl.TOOLS_RUpdatedToolsData(ref updatedStatus, ref updatedLives);
|
||||
}
|
||||
|
||||
public CmsError CheckIfShankCanFit(int magazineId, int positionId, DbNcShankModel shankToBeLoaded)
|
||||
@@ -1786,6 +1792,5 @@ namespace Step.NC
|
||||
}
|
||||
|
||||
#endregion Osai/Fanuc Tools
|
||||
#endregion Write data
|
||||
}
|
||||
}
|
||||
@@ -571,5 +571,20 @@ namespace Step.Controllers.WebApi
|
||||
return Ok();
|
||||
}
|
||||
}
|
||||
|
||||
[Route("offset/{offsetId:int}"), HttpPut]
|
||||
public IHttpActionResult UpdateOffset(short offsetId, OffsetModel offsetData)
|
||||
{
|
||||
using (NcHandler ncHandler = new NcHandler())
|
||||
{
|
||||
ncHandler.Connect();
|
||||
|
||||
CmsError cmsError = ncHandler.UpdateOffset(offsetId, offsetData);
|
||||
if (cmsError.IsError())
|
||||
return BadRequest(cmsError.localizationKey);
|
||||
|
||||
return Ok();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user