General fixes

This commit is contained in:
Lucio Maranta
2018-05-29 15:34:13 +00:00
parent 4664199426
commit 79abc2be3f
8 changed files with 262 additions and 225 deletions
+2 -2
View File
@@ -83,8 +83,6 @@ namespace CMS_CORE_Application
List<FamilyModel> famiies = new List<FamilyModel>();
List<PositionModel> positions = new List<PositionModel>();
List<PositionModel> magazine = new List<PositionModel>();
List<MountedMultiToolModel> multiTools = new List<MountedMultiToolModel>();
List<MountedToolModel> tools = new List<MountedToolModel>();
SiemensToolModel newTool = new SiemensToolModel()
{
FamilyName = "TEST1",
@@ -211,6 +209,8 @@ namespace CMS_CORE_Application
}
cmsError = N.TOOLS_WAddShank(ref newShank);
List<MountedToolModel> a = new List<MountedToolModel>() ;
N.TOOLS_RMagazineTools(1, ref a);
// cmsError = N.TOOLS_WDeleteShank(4);
//cmsError = N.TOOLS_WUpdateEdge(1, ref newEdge);
// List<MountedMultiToolModel> a = null;
+19 -21
View File
@@ -332,7 +332,8 @@ namespace CMS_CORE_Library
MAX_FAMILY_REACHED = 14,
MAX_MULTITOOL_REACHED = 15,
MAX_TOOLS_PER_MULTITOOL_REACHED = 16,
MAG_POS_OCCUPIED = 17
MAX_MULTITOOL_LOCATION_REACHED = 17,
MAG_POS_OCCUPIED = 18
}
internal static CmsError NO_ERROR = new CmsError(CMS_ERROR_CODES.OK, "");
@@ -350,6 +351,7 @@ namespace CMS_CORE_Library
internal static CmsError MAX_FAMILY_REACHED_ERROR = new CmsError(CMS_ERROR_CODES.MAX_FAMILY_REACHED, "error_max_family_reached");
internal static CmsError MAX_MULTITOOL_REACHED_ERROR = new CmsError(CMS_ERROR_CODES.MAX_MULTITOOL_REACHED, "error_max_multitools_reached");
internal static CmsError MAX_TOOLS_PER_MULTITOOL_REACHED_ERROR = new CmsError(CMS_ERROR_CODES.MAX_TOOLS_PER_MULTITOOL_REACHED, "error_max_tools_per_multitool_reached");
internal static CmsError MAX_MULTITOOL_LOCATION_REACHED_ERROR = new CmsError(CMS_ERROR_CODES.MAX_MULTITOOL_LOCATION_REACHED, "error_max_multitools_location_reached");
internal static CmsError MAG_POS_OCCUPIED_ERROR = new CmsError(CMS_ERROR_CODES.MAG_POS_OCCUPIED, "error_mag_pos_occupied");
#endregion Cms Errors Codes
@@ -564,30 +566,24 @@ namespace CMS_CORE_Library
public int Number;
}
public class PositionWithMultiToolModel : PositionModel
{
public MountedMultiToolModel ChildShank;
}
public class PositionWithToolModel : PositionModel
{
public MountedToolModel ChildTool;
}
public class MountedMultiToolModel
{
public int Id;
public string Name;
public List<ShankChildModel> ChildsTools;
}
public class MountedToolModel
{
public int Id;
public string FamilyName;
public int ToolType;
public int PositionId;
public int MagazineId;
public int ToolId;
public SiemensToolModel ChildTool;
public ShankModel ChildShank;
}
//public class PositionToolModel : PositionModel
//{
// public MountedMultiToolModel ChildShank;
//}
//public class PositionWithToolModel : PositionModel
//{
// public MountedToolModel ChildTool;
//}
public class NewToolInMagazineModel
{
public int PositionId;
@@ -619,6 +615,8 @@ namespace CMS_CORE_Library
public string Category;
public bool ReadOnly;
public Dictionary<int, string> SelectValues;
public int MinValue;
public int MaxValue;
}
public class FamiliesConfiguration
+26 -47
View File
@@ -28,6 +28,7 @@ namespace CMS_CORE.Demo
// Magazine config parameters
private const int MAX_TOOL_NUMER = 100;
private const int MAX_EDGES_PER_TOOL = 3;
private const int MAX_TOOLS_PER_FAMILY = 5;
private const int MAX_MULTITOOLS_NUMBER = 3;
@@ -2213,37 +2214,39 @@ namespace CMS_CORE.Demo
}
}
public override CmsError TOOLS_RMagazineTools(int magazineId, ref List<PositionModel> magazinePos)
public override CmsError TOOLS_RMagazineTools(int magazineId, ref List<MountedToolModel> magazinePos)
{
// Check if the NC Demo is Connected
CmsError cmsError = CheckConnection();
if (cmsError.IsError())
return cmsError;
// Get shanks data
List<ShankModel> shanks = new List<ShankModel>();
serverService.GetShanks(out shanks);
List<SiemensToolModel> tools = new List<SiemensToolModel>();
cmsError = TOOLS_RToolsData(ref tools);
try
{
magazinePos = new List<PositionModel>();
magazinePos = new List<MountedToolModel>();
// Get tools equipped in the magazine
serverService.GetMagazinePositionsWithTools(magazineId.ToString(), out List<DemoMagPosDataModel> demoMagazinePositions);
foreach (DemoMagPosDataModel demoPos in demoMagazinePositions)
{
if (demoPos.IsMultiTool == false)
if(demoPos.IsMultiTool == true)
{
if (demoPos.ChildTools != null)
if(demoPos.Shank != null)
{
// Create Tool Model
PositionWithToolModel pos = new PositionWithToolModel()
// Create multitool
MountedToolModel pos = new MountedToolModel()
{
PositionId = demoPos.PositionId,
Type = demoPos.Type,
MagazineId = magazineId,
ChildTool = new MountedToolModel
{
Id = demoPos.ChildTools.Id,
FamilyName = demoPos.ChildTools.FamilyName,
ToolType = demoPos.ChildTools.ToolType
}
ToolId = demoPos.Shank.Id,
ChildShank = shanks.Where(x => x.Id == demoPos.Shank.Id).First()
};
magazinePos.Add(pos);
@@ -2251,29 +2254,15 @@ namespace CMS_CORE.Demo
}
else
{
// Get multi tools childs
var childsTools = demoPos.Shank?.ChildsTools?.Select(x => new ShankChildModel() // Get Childs
if(demoPos.ChildTools != null)
{
Id = x.Id,
FamilyName = x.FamilyName,
MultitoolId = x.MultitoolId,
ToolType = x.ToolType
}).ToList();
if (childsTools != null)
{
// Create multi tool model
PositionWithMultiToolModel pos = new PositionWithMultiToolModel()
// Create tool
MountedToolModel pos = new MountedToolModel()
{
PositionId = demoPos.PositionId,
Type = demoPos.Type,
MagazineId = magazineId,
ChildShank = new MountedMultiToolModel()
{
Id = demoPos.Shank.Id,
Name = demoPos.Shank.Name,
ChildsTools = childsTools
}
ToolId = demoPos.ChildTools.Id,
ChildTool = tools.Where(x => x.Id == demoPos.ChildTools.Id).First()
};
magazinePos.Add(pos);
@@ -2289,7 +2278,7 @@ namespace CMS_CORE.Demo
}
}
public override CmsError TOOLS_RAvailableTools(ref List<MountedMultiToolModel> multiTools, ref List<MountedToolModel> tools)
public override CmsError TOOLS_RAvailableTools(ref List<ShankModel> multiTools, ref List<SiemensToolModel> tools)
{
// Check if the NC Demo is Connected
CmsError cmsError = CheckConnection();
@@ -2299,20 +2288,10 @@ namespace CMS_CORE.Demo
try
{
serverService.GetToolsAndMultiTools(out List<ShankModel> shanks, out List<SiemensToolModel> demoTools);
// Parse multiTool Data
multiTools = shanks.Select(x => new MountedMultiToolModel
{
Id = x.Id,
Name = x.Name,
ChildsTools = x.ChildsTools
}).ToList();
// Parse tool data
tools = demoTools.Select(x => new MountedToolModel
{
Id = x.Id,
FamilyName = x.FamilyName,
ToolType = x.ToolType
}).ToList();
// Set multiTool Data
multiTools = shanks;
// Set tool data
tools = demoTools;
return NO_ERROR;
}
+2 -2
View File
@@ -1755,12 +1755,12 @@ namespace CMS_CORE.Fanuc
return NO_ERROR;
}
public override CmsError TOOLS_RMagazineTools(int magazineId, ref List<PositionModel> magazinePos)
public override CmsError TOOLS_RMagazineTools(int magazineId, ref List<MountedToolModel> magazinePos)
{
return NO_ERROR;
}
public override CmsError TOOLS_RAvailableTools(ref List<MountedMultiToolModel> multiTools, ref List<MountedToolModel> tools)
public override CmsError TOOLS_RAvailableTools(ref List<ShankModel> multiTools, ref List<SiemensToolModel> tools)
{
return NO_ERROR;
}
+2 -2
View File
@@ -1360,9 +1360,9 @@ namespace CMS_CORE
public abstract CmsError TOOLS_WUpdateShank(ref ShankModel shank);
public abstract CmsError TOOLS_RMagazineTools(int magazineId, ref List<PositionModel> magazinePos);
public abstract CmsError TOOLS_RMagazineTools(int magazineId, ref List<MountedToolModel> magazinePos);
public abstract CmsError TOOLS_RAvailableTools(ref List<MountedMultiToolModel> multiTools, ref List<MountedToolModel> tools);
public abstract CmsError TOOLS_RAvailableTools(ref List<ShankModel> multitools, ref List<SiemensToolModel> tools);
public abstract CmsError TOOLS_WLoadToolInMagazine(int magazine, NewToolInMagazineModel newMagazineTool);
+2 -2
View File
@@ -2124,12 +2124,12 @@ namespace CMS_CORE.Osai
return NO_ERROR;
}
public override CmsError TOOLS_RMagazineTools(int magazineId, ref List<PositionModel> magazinePos)
public override CmsError TOOLS_RMagazineTools(int magazineId, ref List<MountedToolModel> magazinePos)
{
return NO_ERROR;
}
public override CmsError TOOLS_RAvailableTools(ref List<MountedMultiToolModel> multiTools, ref List<MountedToolModel> tools)
public override CmsError TOOLS_RAvailableTools(ref List<ShankModel> multiTools, ref List<SiemensToolModel> tools)
{
return NO_ERROR;
}
+162 -102
View File
@@ -87,6 +87,7 @@ namespace CMS_CORE.Siemens
private static int MAX_TOOLS_PER_FAMILY;
private static int MAX_MULTITOOLS_NUMBER;
private static int MAX_TOOLS_PER_MULTITOOL;
private static int MAX_MULTITOOLS_LOCATIONS;
private static bool LIFE_OPTION_ACTIVE;
private static bool MULTITOOL_OPTION_ACTIVE;
@@ -100,9 +101,10 @@ namespace CMS_CORE.Siemens
// Tool table static data
private static List<SiemensToolModel> ToolTableData = new List<SiemensToolModel>();
private static List<PositionModel> MagazinePositionsData = new List<PositionModel>();
private static List<ShankModel> MultitoolsData = new List<ShankModel>();
private static List<PositionModel> MagazineMountedTools = new List<PositionModel>();
private static List<MountedToolModel> MagazineMountedTools = new List<MountedToolModel>();
public static List<FamilyModel> FamiliesData = new List<FamilyModel>();
public static MagazineActionModel MagazineAction = new MagazineActionModel();
@@ -212,6 +214,11 @@ namespace CMS_CORE.Siemens
// Read file
string[] toolsStrings = ReadToolTableFile();
// Read max multitools locations
itemToRead = new Item("/NC/_N_NC_TEA_ACX/$MN_MM_NUM_MULTITOOL_LOCATIONS");
dataSvc.Read(itemToRead);
MAX_MULTITOOLS_LOCATIONS = (int)itemToRead.Value;
// Read options from NC
itemToRead = new Item("/NC/_N_NC_TEA_ACX/$MN_MM_TOOL_MANAGEMENT_MASK");
dataSvc.Read(itemToRead);
@@ -254,10 +261,10 @@ namespace CMS_CORE.Siemens
private void MultitoolsNumber_OnChange(Guid guid, Item item, DataSvcStatus status)
{
// Check if an element has been deleted
if((uint)item.Value < multitoolsNumber)
if ((uint)item.Value < multitoolsNumber)
{
// for each saved multitool
for (int i = 0; i < MultitoolsData.Count; i++)
for (int i = 0; i < MultitoolsData.Count; i++)
{
try
{
@@ -2085,6 +2092,11 @@ namespace CMS_CORE.Siemens
private CmsError CheckToolData(ref SiemensToolModel tool)
{
//Check if the NC is Connected
CmsError cmsError = CheckConnection();
if (cmsError.IsError())
return cmsError;
// Check if it can be added a tool
if (ToolTableData.Count == MAX_TOOL_NUMER)
return MAX_TOOL_REACHED_ERROR;
@@ -2112,19 +2124,17 @@ namespace CMS_CORE.Siemens
public override CmsError TOOLS_WAddShank(ref ShankModel shank)
{
// Check if you can add a multitool
if (MultitoolsData.Count >= MAX_MULTITOOLS_NUMBER)
return INCORRECT_PARAMETERS_ERROR;
//if (shank.MaxChilds > MAX_TOOLS_PER_MULTITOOLS)
// return INCORRECT_PARAMETERS_ERROR;
return MAX_MULTITOOL_REACHED_ERROR;
// Check data
CmsError cmsError = CheckMultitoolData(ref shank);
if (cmsError.IsError())
return cmsError;
try
{
if (shank.Name.Count() > 32)
shank.Name = shank.Name.Substring(0, 32);
if (MultitoolsData.Count >= MAX_MULTITOOLS_NUMBER)
return INCORRECT_PARAMETERS_ERROR;
//Create Shank with NC Pi service
string[] piArgs = new string[8];
piArgs[0] = "/NC";
@@ -2143,7 +2153,7 @@ namespace CMS_CORE.Siemens
// Find new tool id
shank.Id = GetLastMultitoolId();
// Update data
CmsError cmsError = TOOLS_WUpdateShank(ref shank);
cmsError = TOOLS_WUpdateShank(ref shank);
if (cmsError.IsError())
return cmsError;
}
@@ -2157,6 +2167,10 @@ namespace CMS_CORE.Siemens
public override CmsError TOOLS_WUpdateShank(ref ShankModel shank)
{
CmsError cmsError = CheckMultitoolData(ref shank);
if (cmsError.IsError())
return cmsError;
try
{
DataSvc dataSvc = new DataSvc();
@@ -2170,12 +2184,11 @@ namespace CMS_CORE.Siemens
// TC_MTP2
new Item("/Tool/MT/multitoolIdent[" + shank.Id + "]") { Value = shank.Name },
// TC_MTP3
new Item() { Path = "/Tool/MT/multitoolsize_left[" + shank.Id + "]", Value = shank.LeftSize == 0 ? 1 : shank.LeftSize },
new Item() { Path = "/Tool/MT/multitoolsize_left[" + shank.Id + "]", Value = shank.LeftSize <= 0 ? 1 : shank.LeftSize },
// TC_MTP4
new Item() { Path = "/Tool/MT/multitoolsize_right[" + shank.Id + "]", Value = shank.RightSize == 0 ? 1 : shank.RightSize },
new Item() { Path = "/Tool/MT/multitoolsize_right[" + shank.Id + "]", Value = shank.RightSize <= 0 ? 1 : shank.RightSize },
// TC_TMP7
new Item() { Path = "/Tool/MT/multitoolplace_spec[" + shank.Id + "]", Value = shank.MagazinePositionType == 0 ? 1 : shank.MagazinePositionType },
new Item() { Path = "/Tool/MT/multitoolplace_spec[" + shank.Id + "]", Value = shank.MagazinePositionType <= 0 ? 1 : shank.MagazinePositionType },
// TC_MTP8
new Item() { Path = "/Tool/MT/multitoolStateL[" + shank.Id + "]", Value = array[0] }
};
@@ -2190,8 +2203,39 @@ namespace CMS_CORE.Siemens
return NO_ERROR;
}
private CmsError CheckMultitoolData(ref ShankModel shank)
{
//Check if the NC is Connected
CmsError cmsError = CheckConnection();
if (cmsError.IsError())
return cmsError;
if (shank.Name.Count() > 32)
shank.Name = shank.Name.Substring(0, 32);
int totalNumberOfChilds = 0;
foreach (ShankModel multi in MultitoolsData)
{
if (shank.Name == multi.Name)
return INCORRECT_PARAMETERS_ERROR;
// Calculate max number of childs
totalNumberOfChilds += multi.MaxChilds;
}
// Check if there are enough locations
if (totalNumberOfChilds + MAX_TOOLS_PER_MULTITOOL > MAX_MULTITOOLS_LOCATIONS)
return MAX_MULTITOOL_LOCATION_REACHED_ERROR;
return NO_ERROR;
}
public override CmsError TOOLS_WDeleteShank(int id)
{
//Check if the NC is Connected
CmsError cmsError = CheckConnection();
if (cmsError.IsError())
return cmsError;
// Find if exists
var multitool = MultitoolsData.Where(x => x.Id == id).FirstOrDefault();
if (multitool == null)
@@ -2259,7 +2303,7 @@ namespace CMS_CORE.Siemens
public override CmsError TOOLS_WDeleteFamily(string name)
{
return NO_ERROR;
return FUNCTION_NOT_ALLOWED_ERROR;
}
#endregion Families functions
@@ -2268,6 +2312,11 @@ namespace CMS_CORE.Siemens
public override CmsError TOOLS_WAddEdge(int toolId, ref EdgeModel edge)
{
//Check if the NC is Connected
CmsError cmsError = CheckConnection();
if (cmsError.IsError())
return cmsError;
var tool = ToolTableData.Where(x => x.Id == toolId).FirstOrDefault();
if (tool == null)
@@ -2293,7 +2342,7 @@ namespace CMS_CORE.Siemens
edge.Id = nextEdgeId;
CmsError cmsError = TOOLS_WUpdateEdge(toolId, ref edge);
cmsError = TOOLS_WUpdateEdge(toolId, ref edge);
if (cmsError.IsError())
return cmsError;
}
@@ -2307,6 +2356,11 @@ namespace CMS_CORE.Siemens
public override CmsError TOOLS_WUpdateEdge(int toolId, ref EdgeModel edge)
{
//Check if the NC is Connected
CmsError cmsError = CheckConnection();
if (cmsError.IsError())
return cmsError;
SiemensToolModel tool = ToolTableData.Where(x => x.Id == toolId).FirstOrDefault();
if (tool == null)
return INCORRECT_PARAMETERS_ERROR;
@@ -2369,6 +2423,11 @@ namespace CMS_CORE.Siemens
public override CmsError TOOLS_WDeleteEdge(int toolId, int edgeId)
{
//Check if the NC is Connected
CmsError cmsError = CheckConnection();
if (cmsError.IsError())
return cmsError;
// Find tool
var tool = ToolTableData.Where(x => x.Id == toolId).FirstOrDefault();
// If tool not exists, return
@@ -2404,8 +2463,13 @@ namespace CMS_CORE.Siemens
public override CmsError TOOLS_WLoadToolInMagazine(int magazineId, NewToolInMagazineModel newMagazineTool)
{
//Check if the NC is Connected
CmsError cmsError = CheckConnection();
if (cmsError.IsError())
return cmsError;
// Check if magazine position is occupied
PositionModel magPos = MagazineMountedTools.Where(x => x.MagazineId == magazineId && x.PositionId == newMagazineTool.PositionId).FirstOrDefault();
MountedToolModel magPos = MagazineMountedTools.Where(x => x.MagazineId == magazineId && x.PositionId == newMagazineTool.PositionId).FirstOrDefault();
if (magPos != null)
return MAG_POS_OCCUPIED_ERROR;
@@ -2436,6 +2500,11 @@ namespace CMS_CORE.Siemens
public override CmsError TOOLS_WUnloadToolInMagazine(int magazineId, int positionId)
{
//Check if the NC is Connected
CmsError cmsError = CheckConnection();
if (cmsError.IsError())
return cmsError;
try
{
//UnLoad tool in magazine
@@ -2463,6 +2532,11 @@ namespace CMS_CORE.Siemens
public override CmsError TOOLS_WLoadToolIntoShank(int shankId, int positionId, int toolId)
{
//Check if the NC is Connected
CmsError cmsError = CheckConnection();
if (cmsError.IsError())
return cmsError;
try
{
// Check if can load
@@ -2493,6 +2567,11 @@ namespace CMS_CORE.Siemens
public override CmsError TOOLS_WUnloadToolFromShank(int shankId, int positionId)
{
//Check if the NC is Connected
CmsError cmsError = CheckConnection();
if (cmsError.IsError())
return cmsError;
try
{
DataSvc dataSvc = new DataSvc();
@@ -2523,6 +2602,11 @@ namespace CMS_CORE.Siemens
public override CmsError TOOLS_WUpdatePosition(PositionModel position)
{
//Check if the NC is Connected
CmsError cmsError = CheckConnection();
if (cmsError.IsError())
return cmsError;
try
{
DataSvc dataSvc = new DataSvc();
@@ -2545,8 +2629,7 @@ namespace CMS_CORE.Siemens
return NO_ERROR;
}
public override CmsError TOOLS_RMagazineTools(int magazineId, ref List<PositionModel> magazinePos)
public override CmsError TOOLS_RMagazineTools(int magazineId, ref List<MountedToolModel> magazinePos)
{
if (magazineId <= 0)
return INCORRECT_PARAMETERS_ERROR;
@@ -2554,52 +2637,52 @@ namespace CMS_CORE.Siemens
magazinePos = MagazineMountedTools
.Where(x => x.MagazineId == magazineId)
.ToList();
foreach (var pos in magazinePos)
{
var tool = GetToolOrMultitool(pos.ToolId);
if (tool is SiemensToolModel)
pos.ChildTool = GetToolOrMultitool(pos.ToolId) as SiemensToolModel;
else if (tool is ShankModel)
pos.ChildShank = tool as ShankModel;
}
return NO_ERROR;
}
public override CmsError TOOLS_RAvailableTools(ref List<MountedMultiToolModel> multiTools, ref List<MountedToolModel> tools)
public override CmsError TOOLS_RAvailableTools(ref List<ShankModel> multitools, ref List<SiemensToolModel> tools)
{
List<int> mountedIds = new List<int>();
// Find ids of tools mounted in the magazines
foreach (var mounted in MagazineMountedTools)
{
if (mounted is PositionWithMultiToolModel) // If multitool
{
var tmp = mounted as PositionWithMultiToolModel;
mountedIds.Add(tmp.ChildShank.Id); // Add multitool id
mountedIds.AddRange(tmp.ChildShank.ChildsTools.Select(x => x.Id).ToList()); // Add childsId
}
else if (mounted is PositionWithToolModel) // If tool
{
var tmp = mounted as PositionWithToolModel;
mountedIds.Add(tmp.ChildTool.Id);
}
}
// Filter tools
tools = ToolTableData
.Where(x => !mountedIds.Contains(x.Id))
.Select(x => new MountedToolModel()
{
Id = x.Id,
FamilyName = x.FamilyName,
ToolType = x.ToolType
})
.ToList();
var tmp = mounted as MountedToolModel;
// Filter multitools
multiTools = MultitoolsData
.Where(x => !mountedIds.Contains(x.Id))
.Select(x => new MountedMultiToolModel()
{
Id = x.Id,
Name = x.Name,
ChildsTools = x.ChildsTools
})
.ToList();
var tool = GetToolOrMultitool(tmp.ToolId);
if (tool is SiemensToolModel)
tools.Add(tool as SiemensToolModel);
else if (tool is ShankModel)
multitools.Add(tool as ShankModel);
}
return NO_ERROR;
}
private object GetToolOrMultitool(int toolId)
{
int toolIndex = ToolTableData.FindIndex(x => x.Id == toolId);
if (toolIndex >= 0)
{
return ToolTableData[toolIndex];
}
else
{
int multiIndex = MultitoolsData.FindIndex(x => x.Id == toolId);
if (multiIndex >= 0)
return MultitoolsData[multiIndex];
}
return null;
}
public override CmsError TOOLS_GetMagazinesStatus(ref MagazineActionModel magazineAction)
{
@@ -2900,28 +2983,21 @@ namespace CMS_CORE.Siemens
return littleEndianValues;
}
private bool PositionContainsTool(PositionModel mounted, int toolId)
private bool PositionContainsTool(MountedToolModel mounted, int toolId)
{
if (mounted is PositionWithMultiToolModel) // If multitool
if (mounted.ToolId == toolId)
return true;
else
{
var tmp = mounted as PositionWithMultiToolModel;
if (tmp.ChildShank.Id == toolId)
return true;
else
// Check if tool is a multitool child
foreach (var multi in MultitoolsData)
{
// Check if tool is a multitool child
int index = tmp.ChildShank.ChildsTools.FindIndex(x => x.Id == toolId);
if (index > 0)
// Check childs id
int index = multi.ChildsTools.FindIndex(x => x.Id == toolId);
if (index >= 0)
return true;
}
}
else if (mounted is PositionWithToolModel) // If simple tool
{
var tmp = mounted as PositionWithToolModel;
// If ids are equal return true
if (tmp.ChildTool.Id == toolId)
return true;
}
return false;
}
@@ -2929,32 +3005,20 @@ namespace CMS_CORE.Siemens
private void MountToolToList(int toolId, int magazineId, int positionId)
{
// Find if position exist
PositionModel mounted = MagazineMountedTools
MountedToolModel mounted = MagazineMountedTools
.Where(x => x.MagazineId == magazineId && x.PositionId == positionId)
.FirstOrDefault();
if (mounted != null)
return;
int foundId = 0;
// Find tool by id
SiemensToolModel tool = ToolTableData.Where(x => x.Id == toolId).FirstOrDefault();
// Find position by id
PositionModel position = MagazinePositionsData.Where(x => x.MagazineId == magazineId && x.PositionId == positionId).FirstOrDefault();
if (tool != null)
{
// Add new Magazine-Tool
MagazineMountedTools.Add(new PositionWithToolModel()
{
MagazineId = magazineId,
PositionId = positionId,
Type = position.Type,
Disabled = position.Disabled,
ChildTool = new MountedToolModel()
{
Id = tool.Id,
FamilyName = tool.FamilyName,
ToolType = tool.ToolType
}
});
foundId = tool.Id;
}
else
{
@@ -2962,22 +3026,18 @@ namespace CMS_CORE.Siemens
ShankModel shank = MultitoolsData.Where(x => x.Id == toolId).FirstOrDefault();
if (shank != null)
{
// Add new Magazine-Multitool
MagazineMountedTools.Add(new PositionWithMultiToolModel()
{
MagazineId = magazineId,
PositionId = positionId,
Type = position.Type,
Disabled = position.Disabled,
ChildShank = new MountedMultiToolModel()
{
Id = shank.Id,
Name = shank.Name,
ChildsTools = shank.ChildsTools
}
});
foundId = shank.Id;
}
}
if (foundId > 0)
// Add new MagazinePos-Tool
MagazineMountedTools.Add(new MountedToolModel()
{
MagazineId = magazineId,
PositionId = positionId,
ToolId = tool.Id
});
}
#endregion Subordinate Private Functions
@@ -3728,7 +3788,7 @@ namespace CMS_CORE.Siemens
{
// Find if its a multitool
int multitoolIndex = MultitoolsData.FindIndex(t => t.Id == toolInfo.tNo);
if (multitoolIndex != -1)
{
// Create model with new data
+47 -47
View File
@@ -70,40 +70,40 @@ namespace CMS_CORE_Library
public static List<FieldsConfiguration> SiemensToolFieldsConfig = new List<FieldsConfiguration>()
{
new FieldsConfiguration{Name = "id", Type = "int", SelectValues = null, Category = "general", ReadOnly = true },
new FieldsConfiguration{Name = "toolType", Type = "select", SelectValues = toolTypeList, Category = "general", ReadOnly = false},
new FieldsConfiguration{Name = "lifeType", Type = "select", SelectValues = toolLifeList, Category = "life", ReadOnly = false},
new FieldsConfiguration{Name = "familyName", Type = "string", SelectValues = null, Category = "family", ReadOnly = false },
new FieldsConfiguration{Name = "childId", Type = "int", SelectValues = null, Category = "family", ReadOnly = true },
new FieldsConfiguration{Name = "isEnabled", Type = "boolean", SelectValues = null, Category = "state", ReadOnly = false},
new FieldsConfiguration{Name = "isActive", Type = "boolean", SelectValues = null, Category = "state", ReadOnly = false},
new FieldsConfiguration{Name = "isInhibited", Type = "boolean", SelectValues = null, Category = "state", ReadOnly = false},
new FieldsConfiguration{Name = "inFixedPlace", Type = "boolean", SelectValues = null, Category = "state", ReadOnly = false},
new FieldsConfiguration{Name = "isMeasured", Type = "boolean", SelectValues = null, Category = "state", ReadOnly = false},
new FieldsConfiguration{Name = "inChangeTool", Type = "boolean", SelectValues = null, Category = "state", ReadOnly = false},
new FieldsConfiguration{Name = "inUse", Type = "boolean", SelectValues = null, Category = "state", ReadOnly = false},
new FieldsConfiguration{Name = "preAlarm", Type = "boolean", SelectValues = null, Category = "state", ReadOnly = false},
new FieldsConfiguration{Name = "cooling1", Type = "boolean", SelectValues = null, Category = "cooling", ReadOnly = false},
new FieldsConfiguration{Name = "cooling2", Type = "boolean", SelectValues = null, Category = "cooling" , ReadOnly = false},
new FieldsConfiguration{Name = "magazinePositionType", Type = "int", SelectValues = null, Category = "magazine", ReadOnly = false},
new FieldsConfiguration{Name = "leftSize", Type = "int", SelectValues = null, Category = "magazine", ReadOnly = false},
new FieldsConfiguration{Name = "rightSize", Type = "int", SelectValues = null, Category = "magazine", ReadOnly = false},
new FieldsConfiguration{Name = "rotation", Type = "select", SelectValues = rotationTypeList, Category = "head", ReadOnly = false},
new FieldsConfiguration{Name = "maxSpeed", Type = "double", SelectValues = null, Category = "head", ReadOnly = false },
new FieldsConfiguration{Name = "maxAcceleration", Type = "double", SelectValues = null, Category = "head", ReadOnly = false },
new FieldsConfiguration{ Name = "id", Type = "int", SelectValues = null, Category = "general", ReadOnly = true, MinValue = 0, MaxValue = 0},
new FieldsConfiguration{ Name = "toolType", Type = "select", SelectValues = toolTypeList, Category = "general", ReadOnly = false, MinValue = 0, MaxValue = 0},
new FieldsConfiguration{ Name = "lifeType", Type = "select", SelectValues = toolLifeList, Category = "life", ReadOnly = false, MinValue = 0, MaxValue = 0},
new FieldsConfiguration{ Name = "familyName", Type = "string", SelectValues = null, Category = "family", ReadOnly = false, MinValue = 0, MaxValue = 0 },
new FieldsConfiguration{ Name = "childId", Type = "int", SelectValues = null, Category = "family", ReadOnly = true, MinValue = 0, MaxValue = 0 },
new FieldsConfiguration{ Name = "isEnabled", Type = "boolean", SelectValues = null, Category = "state", ReadOnly = false, MinValue = 0, MaxValue = 0},
new FieldsConfiguration{ Name = "isActive", Type = "boolean", SelectValues = null, Category = "state", ReadOnly = false, MinValue = 0, MaxValue = 0},
new FieldsConfiguration{ Name = "isInhibited", Type = "boolean", SelectValues = null, Category = "state", ReadOnly = false, MinValue = 0, MaxValue = 0},
new FieldsConfiguration{ Name = "inFixedPlace", Type = "boolean", SelectValues = null, Category = "state", ReadOnly = false, MinValue = 0, MaxValue = 0},
new FieldsConfiguration{ Name = "isMeasured", Type = "boolean", SelectValues = null, Category = "state", ReadOnly = false, MinValue = 0, MaxValue = 0},
new FieldsConfiguration{ Name = "inChangeTool", Type = "boolean", SelectValues = null, Category = "state", ReadOnly = false, MinValue = 0, MaxValue = 0},
new FieldsConfiguration{ Name = "inUse", Type = "boolean", SelectValues = null, Category = "state", ReadOnly = false, MinValue = 0, MaxValue = 0},
new FieldsConfiguration{ Name = "preAlarm", Type = "boolean", SelectValues = null, Category = "state", ReadOnly = false, MinValue = 0, MaxValue = 0},
new FieldsConfiguration{ Name = "cooling1", Type = "boolean", SelectValues = null, Category = "cooling", ReadOnly = false, MinValue = 0, MaxValue = 0},
new FieldsConfiguration{ Name = "cooling2", Type = "boolean", SelectValues = null, Category = "cooling" , ReadOnly = false, MinValue = 0, MaxValue = 0},
new FieldsConfiguration{ Name = "magazinePositionType", Type = "int", SelectValues = null, Category = "magazine", ReadOnly = false, MinValue = 1, MaxValue = 7},
new FieldsConfiguration{ Name = "leftSize", Type = "int", SelectValues = null, Category = "magazine", ReadOnly = false, MinValue = 1, MaxValue = 7},
new FieldsConfiguration{ Name = "rightSize", Type = "int", SelectValues = null, Category = "magazine", ReadOnly = false, MinValue = 1, MaxValue = 7},
new FieldsConfiguration{ Name = "rotation", Type = "select", SelectValues = rotationTypeList, Category = "head", ReadOnly = false, MinValue = 0, MaxValue = 0},
new FieldsConfiguration{ Name = "maxSpeed", Type = "double", SelectValues = null, Category = "head", ReadOnly = false, MinValue = 0, MaxValue = int.MaxValue },
new FieldsConfiguration{ Name = "maxAcceleration", Type = "double", SelectValues = null, Category = "head", ReadOnly = false, MinValue = 0, MaxValue = int.MaxValue },
};
public static FamiliesConfiguration SiemensFamilyFieldsConfig = new FamiliesConfiguration()
{
FamilyConfiguration = new List<FieldsConfiguration>()
{
new FieldsConfiguration{Name = "name", Type = "string", SelectValues = null, Category = "general", ReadOnly = true}
new FieldsConfiguration{ Name = "name", Type = "string", SelectValues = null, Category = "general", ReadOnly = true, MinValue = 0, MaxValue = 0}
},
ToolsConfiguration = new List<FieldsConfiguration>()
{
new FieldsConfiguration{Name = "id", Type = "int", SelectValues = null, Category = "general", ReadOnly = true },
new FieldsConfiguration{Name = "toolType", Type = "select", SelectValues = toolTypeList, Category = "general", ReadOnly = true },
new FieldsConfiguration{Name = "childId", Type = "int", SelectValues = null, Category = "general", ReadOnly = true}
new FieldsConfiguration{ Name = "id", Type = "int", SelectValues = null, Category = "general", ReadOnly = true, MinValue = 0, MaxValue = 0 },
new FieldsConfiguration{ Name = "toolType", Type = "select", SelectValues = toolTypeList, Category = "general", ReadOnly = true, MinValue = 0, MaxValue = 0 },
new FieldsConfiguration{ Name = "childId", Type = "int", SelectValues = null, Category = "general", ReadOnly = true, MinValue = 0, MaxValue = 0}
}
};
@@ -111,42 +111,42 @@ namespace CMS_CORE_Library
{
ShankConfiguration = new List<FieldsConfiguration>()
{
new FieldsConfiguration{Name = "id", Type = "int", SelectValues = null, Category = "general", ReadOnly = true },
new FieldsConfiguration{Name = "name", Type = "string", SelectValues = null, Category = "general", ReadOnly = false },
new FieldsConfiguration{Name = "isEnabled", Type = "boolean", SelectValues = null, Category = "state", ReadOnly = false},
new FieldsConfiguration{Name = "isInhibited", Type = "boolean", SelectValues = null, Category = "state", ReadOnly = false},
new FieldsConfiguration{Name = "inFixedPlace", Type = "boolean", SelectValues = null, Category = "state", ReadOnly = false},
new FieldsConfiguration{Name = "inChangeTool", Type = "boolean", SelectValues = null, Category = "state", ReadOnly = false},
new FieldsConfiguration{Name = "inUse", Type = "boolean", SelectValues = null, Category = "state", ReadOnly = false},
new FieldsConfiguration{Name = "leftSize", Type = "int", SelectValues = null, Category = "magazine", ReadOnly = false},
new FieldsConfiguration{Name = "rightSize", Type = "int", SelectValues = null, Category = "magazine", ReadOnly = false},
new FieldsConfiguration{Name = "magazinePositionType", Type = "int", SelectValues = null, Category = "magazine", ReadOnly = false},
new FieldsConfiguration{ Name = "id", Type = "int", SelectValues = null, Category = "general", ReadOnly = true, MinValue = 0, MaxValue = 0 },
new FieldsConfiguration{ Name = "name", Type = "string", SelectValues = null, Category = "general", ReadOnly = false, MinValue = 0, MaxValue = 0 },
new FieldsConfiguration{ Name = "isEnabled", Type = "boolean", SelectValues = null, Category = "state", ReadOnly = false, MinValue = 0, MaxValue = 0 },
new FieldsConfiguration{ Name = "isInhibited", Type = "boolean", SelectValues = null, Category = "state", ReadOnly = false, MinValue = 0, MaxValue = 0 },
new FieldsConfiguration{ Name = "inFixedPlace", Type = "boolean", SelectValues = null, Category = "state", ReadOnly = false, MinValue = 0, MaxValue = 0 },
new FieldsConfiguration{ Name = "inChangeTool", Type = "boolean", SelectValues = null, Category = "state", ReadOnly = false, MinValue = 0, MaxValue = 0 },
new FieldsConfiguration{ Name = "inUse", Type = "boolean", SelectValues = null, Category = "state", ReadOnly = false, MinValue = 0, MaxValue = 0 },
new FieldsConfiguration{ Name = "leftSize", Type = "int", SelectValues = null, Category = "magazine", ReadOnly = false, MinValue = 1, MaxValue = 7 },
new FieldsConfiguration{ Name = "rightSize", Type = "int", SelectValues = null, Category = "magazine", ReadOnly = false, MinValue = 1, MaxValue = 7 },
new FieldsConfiguration{ Name = "magazinePositionType", Type = "int", SelectValues = null, Category = "magazine", ReadOnly = false, MinValue = 1, MaxValue = 7 },
},
ToolsConfiguration = new List<FieldsConfiguration>()
{
new FieldsConfiguration{Name = "id", Type = "int", SelectValues = null, Category = "general", ReadOnly = true },
new FieldsConfiguration{Name = "multitoolId", Type = "int", SelectValues = null, Category = "general", ReadOnly = true },
new FieldsConfiguration{Name = "familyName", Type = "string", SelectValues = null, Category = "general", ReadOnly = true },
new FieldsConfiguration{Name = "toolType", Type = "select", SelectValues = toolTypeList, Category = "general", ReadOnly = true }
new FieldsConfiguration{ Name = "id", Type = "int", SelectValues = null, Category = "general", ReadOnly = true, MinValue = 0, MaxValue = 0 },
new FieldsConfiguration{ Name = "multitoolId", Type = "int", SelectValues = null, Category = "general", ReadOnly = true, MinValue = 0, MaxValue = 0 },
new FieldsConfiguration{ Name = "familyName", Type = "string", SelectValues = null, Category = "general", ReadOnly = true, MinValue = 0, MaxValue = 0 },
new FieldsConfiguration{ Name = "toolType", Type = "select", SelectValues = toolTypeList, Category = "general", ReadOnly = true, MinValue = 0, MaxValue = 0 }
}
};
public static List<FieldsConfiguration> SiemensMagazinePosFieldsConfig = new List<FieldsConfiguration>()
{
new FieldsConfiguration{Name = "magazineId", Type = "int", SelectValues = null, Category = "general", ReadOnly = true },
new FieldsConfiguration{Name = "positionId", Type = "int", SelectValues = null, Category = "general", ReadOnly = true },
new FieldsConfiguration{Name = "type", Type = "int", SelectValues = null, Category = "general", ReadOnly = true },
new FieldsConfiguration{Name = "disabled", Type = "boolean", SelectValues = null, Category = "general", ReadOnly = true },
new FieldsConfiguration{Name = "magazineId", Type = "int", SelectValues = null, Category = "general", ReadOnly = true, MinValue = 0, MaxValue = 0 },
new FieldsConfiguration{Name = "positionId", Type = "int", SelectValues = null, Category = "general", ReadOnly = true, MinValue = 0, MaxValue = 0 },
new FieldsConfiguration{Name = "type", Type = "int", SelectValues = null, Category = "general", ReadOnly = true, MinValue = 0, MaxValue = 0 },
new FieldsConfiguration{Name = "disabled", Type = "boolean", SelectValues = null, Category = "general", ReadOnly = true, MinValue = 0, MaxValue = 0 },
};
public static EdgesConfiguration SiemensEdgesFieldsConfiguration = new EdgesConfiguration()
{
EdgeConfiguration = new List<FieldsConfiguration>()
{
new FieldsConfiguration{Name = "id", Type = "int", SelectValues = null, Category = "general", ReadOnly = true },
new FieldsConfiguration{Name = "residualLife", Type = "double", SelectValues = null, Category = "life", ReadOnly = false },
new FieldsConfiguration{Name = "nominalLife", Type = "double", SelectValues = null, Category = "life", ReadOnly = false },
new FieldsConfiguration{Name = "preAlmLife", Type = "double", SelectValues = null, Category = "life", ReadOnly = false }
new FieldsConfiguration{Name = "id", Type = "int", SelectValues = null, Category = "general", ReadOnly = true, MinValue = 0, MaxValue = 0 },
new FieldsConfiguration{Name = "residualLife", Type = "double", SelectValues = null, Category = "life", ReadOnly = false, MinValue = 0, MaxValue = int.MaxValue },
new FieldsConfiguration{Name = "nominalLife", Type = "double", SelectValues = null, Category = "life", ReadOnly = false, MinValue = 0, MaxValue = int.MaxValue },
new FieldsConfiguration{Name = "preAlmLife", Type = "double", SelectValues = null, Category = "life", ReadOnly = false, MinValue = 0, MaxValue = int.MaxValue }
},
EdgesAdditionalParamsConfiguration = new Dictionary<int, List<string>>() // Set value runtime, based on NC vendor
};