84904a3bb5
Fix tool table
253 lines
9.5 KiB
C#
253 lines
9.5 KiB
C#
using CMS_CORE_Library.Models;
|
|
using Step.Model.DTOModels.ToolModels;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using static Step.Config.ServerConfig;
|
|
using static Step.Model.Constants;
|
|
|
|
namespace Step.NC
|
|
{
|
|
public class SiemensToolTableHandler : NcHandler
|
|
{
|
|
public CmsError GetToolTableConfiguration(out ToolTableConfiguration config)
|
|
{
|
|
config = new ToolTableConfiguration();
|
|
CmsError cmsError = numericalControl.TOOLS_RConfiguration(ref config);
|
|
if (cmsError.IsError())
|
|
return cmsError;
|
|
|
|
// Set magazine assisted tooling from config
|
|
foreach (var magConfig in ToolManagerConfig.MagazineNames)
|
|
{
|
|
var mag = config.Magazines.FirstOrDefault(x => magConfig.MagazineId == x.Id);
|
|
if (mag != null)
|
|
mag.AssistedToolingIsActive = magConfig.AssistedTooling;
|
|
}
|
|
|
|
config.RadiusMetricType = (ToolManagerConfig.ToolMetricType == RADIUS_METRIC);
|
|
|
|
if (NcConfig.NcVendor != NC_VENDOR.SIEMENS && NcConfig.NcVendor != NC_VENDOR.DEMO)
|
|
{
|
|
// Setup options
|
|
config.FamilyOptionActive = true;
|
|
config.MultitoolOptionActive = true;
|
|
config.OffsetOptionActive = true;
|
|
config.SelfAdaptivePathOptionActive = true;
|
|
|
|
// Add categories to be removed
|
|
List<string> categories = new List<string>();
|
|
if (!ToolManagerConfig.ShankOpt)
|
|
{
|
|
config.MultitoolOptionActive = false;
|
|
categories.Add("shankType");
|
|
config.ToolsConfiguration = config.ToolsConfiguration.Where(x => !(x.Name == "shankId")).ToList();
|
|
}
|
|
|
|
if (!ToolManagerConfig.FamilyOpt)
|
|
{
|
|
config.FamilyOptionActive = false;
|
|
categories.Add("family");
|
|
config.ToolsConfiguration = config.ToolsConfiguration.Where(x => !(x.Name == "familyId")).ToList();
|
|
config.ToolsConfiguration = config.FamiliesConfiguration.FamilyConfiguration.Concat(config.ToolsConfiguration).ToList();
|
|
}
|
|
//else
|
|
//{
|
|
// config.ToolsConfiguration = config.ToolsConfiguration.Concat(config.FamiliesConfiguration.FamilyReadOnlyConfiguration).ToList();
|
|
//}
|
|
|
|
if (!ToolManagerConfig.OffsetOpt)
|
|
config.OffsetOptionActive = false;
|
|
if (!ToolManagerConfig.SelfAdaptivePathOpt)
|
|
config.SelfAdaptivePathOptionActive = false;
|
|
|
|
categories.Add("offset");
|
|
|
|
if (!ToolManagerConfig.TcpOpt)
|
|
categories.Add("tcp");
|
|
|
|
if (!ToolManagerConfig.CoolingOpt)
|
|
categories.Add("cooling");
|
|
|
|
if (!ToolManagerConfig.DynamicCompensationOpt)
|
|
categories.Add("dynamicCompensation");
|
|
|
|
if (!ToolManagerConfig.GammaOpt)
|
|
categories.Add("gamma");
|
|
|
|
if (!ToolManagerConfig.LifeOpt)
|
|
categories.Add("life");
|
|
|
|
if (!ToolManagerConfig.MagPosTypeOpt)
|
|
categories.Add("magPos");
|
|
|
|
if (!ToolManagerConfig.MultidimensionalShankOpt)
|
|
categories.Add("shankOpt");
|
|
|
|
if (!ToolManagerConfig.SelfAdaptivePathOpt)
|
|
categories.Add("selfAdaptive");
|
|
|
|
if (!ToolManagerConfig.BallufOpt)
|
|
categories.Add("balluf");
|
|
|
|
if (!ToolManagerConfig.ReviveOpt)
|
|
categories.Add("revive");
|
|
|
|
// Remove category from configurations
|
|
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();
|
|
}
|
|
|
|
return cmsError;
|
|
}
|
|
|
|
public CmsError GetToolTableData(out List<SiemensToolModel> config)
|
|
{
|
|
config = new List<SiemensToolModel>();
|
|
return numericalControl.TOOLS_RToolsData(ref config);
|
|
}
|
|
|
|
public CmsError GetShanksData(out List<ShankModel> shanks)
|
|
{
|
|
shanks = new List<ShankModel>();
|
|
return numericalControl.TOOLS_RShanksData(ref shanks);
|
|
}
|
|
|
|
public CmsError GetFamiliesData(out List<FamilyModel> families)
|
|
{
|
|
families = new List<FamilyModel>();
|
|
return numericalControl.TOOLS_RFamilyData(ref families);
|
|
}
|
|
|
|
public CmsError GetMagazinesPositionsData(out List<PositionModel> magazinesPositions)
|
|
{
|
|
magazinesPositions = new List<PositionModel>();
|
|
return numericalControl.TOOLS_RMagazinePositions(ref magazinesPositions);
|
|
}
|
|
|
|
public CmsError GetMagazineStatus(out DTOMagazineActionModel magazineStatus)
|
|
{
|
|
// Set up models
|
|
magazineStatus = new DTOMagazineActionModel();
|
|
MagazineActionModel libModel = new MagazineActionModel();
|
|
// Read status from NC
|
|
CmsError cmsError = numericalControl.TOOLS_RMagazineAction(ref libModel);
|
|
if (cmsError.IsError())
|
|
return cmsError;
|
|
|
|
magazineStatus = (DTOMagazineActionModel)libModel;
|
|
|
|
return cmsError;
|
|
}
|
|
|
|
public CmsError AddTool(ref SiemensToolModel tool)
|
|
{
|
|
return numericalControl.TOOLS_WAddTool(ref tool);
|
|
}
|
|
|
|
public CmsError UpdateTool(ref SiemensToolModel tool)
|
|
{
|
|
return numericalControl.TOOLS_WUpdateTool(ref tool);
|
|
}
|
|
|
|
public CmsError AddFamily(string name, out FamilyModel family)
|
|
{
|
|
family = new FamilyModel()
|
|
{
|
|
Name = name
|
|
};
|
|
|
|
return numericalControl.TOOLS_WAddFamily(ref family);
|
|
}
|
|
|
|
public CmsError AddShank(ref ShankModel shank)
|
|
{
|
|
return numericalControl.TOOLS_WAddShank(ref shank);
|
|
}
|
|
|
|
public CmsError UpdateShank(ref ShankModel shank)
|
|
{
|
|
return numericalControl.TOOLS_WUpdateShank(ref shank);
|
|
}
|
|
|
|
public CmsError UpdateFamilyName(string oldName, string newName)
|
|
{
|
|
return numericalControl.TOOLS_WUpdateFamilyData(oldName, newName);
|
|
}
|
|
|
|
public CmsError UpdateMagazinePosition(PositionModel magazinePosition)
|
|
{
|
|
return numericalControl.TOOLS_WUpdatePosition(magazinePosition);
|
|
}
|
|
|
|
public CmsError DeleteTool(int id)
|
|
{
|
|
return numericalControl.TOOLS_WDeleteTool(id);
|
|
}
|
|
|
|
public CmsError DeleteShank(int id)
|
|
{
|
|
return numericalControl.TOOLS_WDeleteShank(id);
|
|
}
|
|
|
|
public CmsError DeleteFamily(string name)
|
|
{
|
|
return numericalControl.TOOLS_WDeleteFamily(name);
|
|
}
|
|
|
|
public CmsError AddEdge(int toolId, ref EdgeModel edge)
|
|
{
|
|
return numericalControl.TOOLS_WAddEdge(toolId, ref edge);
|
|
}
|
|
|
|
public CmsError UpdateEdge(int toolId, ref EdgeModel edge)
|
|
{
|
|
return numericalControl.TOOLS_WUpdateEdge(toolId, ref edge);
|
|
}
|
|
|
|
public CmsError DeleteEdge(int toolId, int edgeId)
|
|
{
|
|
return numericalControl.TOOLS_WDeleteEdge(toolId, edgeId);
|
|
}
|
|
|
|
public CmsError GetMagazinePositionsAndTools(int magazineId, out List<MountedToolModel> magazinePos)
|
|
{
|
|
magazinePos = new List<MountedToolModel>();
|
|
return numericalControl.TOOLS_RMountedTools(magazineId, ref magazinePos);
|
|
}
|
|
|
|
public CmsError GetNotInMagazinesTools(out List<ShankModel> multiTools, out List<SiemensToolModel> tools)
|
|
{
|
|
multiTools = new List<ShankModel>();
|
|
tools = new List<SiemensToolModel>();
|
|
return numericalControl.TOOLS_RAvailableTools(ref multiTools, ref tools);
|
|
}
|
|
|
|
public CmsError LoadToolInMagazine(int magazineId, NewToolInMagazineModel newMag, out MountedToolModel mounted)
|
|
{
|
|
mounted = new MountedToolModel();
|
|
return numericalControl.TOOLS_WLoadToolInMagazine(magazineId, newMag, ref mounted);
|
|
}
|
|
|
|
public CmsError UnloadToolInMagazine(int magazineId, int positionId)
|
|
{
|
|
return numericalControl.TOOLS_WUnloadToolFromMagazine(magazineId, positionId);
|
|
}
|
|
|
|
public CmsError LoadTooolIntoShank(int shankId, int positionId, int toolId)
|
|
{
|
|
return numericalControl.TOOLS_WLoadToolIntoShank(shankId, positionId, toolId);
|
|
}
|
|
|
|
public CmsError UnloadTooolFromShank(int shankId, int positionId)
|
|
{
|
|
return numericalControl.TOOLS_WUnloadToolFromShank(shankId, positionId);
|
|
}
|
|
}
|
|
} |