This commit is contained in:
@@ -224,7 +224,7 @@ namespace CMS_CORE_Application
|
||||
// PositionId = 1
|
||||
//});
|
||||
// cmsError = N.TOOLS_WUnloadToolInMagazine(1, 53);
|
||||
// cmsError = N.TOOLS_WLoadToolInMagazine(1, new NewToolInMagazineModel() { PositionId = 31, ToolId = 3 });
|
||||
cmsError = N.TOOLS_WLoadToolInMagazine(1, new NewToolInMagazineModel() { PositionId = 1, ToolId = 4 });
|
||||
//cmsError = N.PLC_WRefreshAllMessages();
|
||||
//cmsError = N.PLC_RHeadsData(headsTest, 1);
|
||||
|
||||
|
||||
@@ -454,9 +454,11 @@ namespace CMS_CORE_Library
|
||||
|
||||
public enum MAGAZINE_TYPE
|
||||
{
|
||||
MAGAZINE = 0,
|
||||
SPINDLE = 1,
|
||||
MAGAZINE_GROUND = 2
|
||||
CHAIN = 1,
|
||||
REVOLVER = 3,
|
||||
BOX_MAGAZINE = 5,
|
||||
MAGAZINE_TOOL_BUFFER = 7,
|
||||
MAGAZINE_LOADING_STATION = 9
|
||||
}
|
||||
|
||||
public enum SIEMENS_LIFE_TYPE
|
||||
@@ -490,6 +492,9 @@ namespace CMS_CORE_Library
|
||||
public bool PreAlarm;
|
||||
public double MaxSpeed;
|
||||
public double MaxAcceleration;
|
||||
public int MagazineId;
|
||||
public int PositionId;
|
||||
public int MultitoolId;
|
||||
public List<EdgeModel> EdgesData;
|
||||
|
||||
public SiemensToolModel()
|
||||
@@ -525,6 +530,8 @@ namespace CMS_CORE_Library
|
||||
public int RightSize;
|
||||
public int MagazinePositionType;
|
||||
public int MaxChilds;
|
||||
public int MagazineId;
|
||||
public int PositionId;
|
||||
public List<ShankChildModel> ChildsTools;
|
||||
|
||||
public ShankModel()
|
||||
@@ -645,10 +652,13 @@ namespace CMS_CORE_Library
|
||||
public Dictionary<int, List<string>> EdgesAdditionalParamsConfiguration;
|
||||
}
|
||||
|
||||
public class MagazineModel
|
||||
public class MagazineConfigModel
|
||||
{
|
||||
public int Id;
|
||||
public string Name;
|
||||
public MAGAZINE_TYPE Type;
|
||||
public int MaxPositions;
|
||||
public bool LoadingIsActive;
|
||||
}
|
||||
|
||||
public class ToolTableConfiguration
|
||||
@@ -663,7 +673,7 @@ namespace CMS_CORE_Library
|
||||
public bool FamilyOptionActive;
|
||||
public bool MagPositionOptionActive;
|
||||
|
||||
public List<MagazineModel> Magazines;
|
||||
public List<MagazineConfigModel> Magazines;
|
||||
public List<FieldsConfiguration> ToolsConfiguration;
|
||||
public FamiliesConfiguration FamiliesConfiguration;
|
||||
public ShanksConfiguration ShanksConfiguration;
|
||||
|
||||
@@ -27,12 +27,12 @@ namespace CMS_CORE.Demo
|
||||
private DemoEdgesConfiguration DemoEdgesConfiguration = new DemoEdgesConfiguration();
|
||||
|
||||
// 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;
|
||||
private const int MAX_TOOLS_PER_MULTITOOLS = 3;
|
||||
List<MagazineConfigModel> MagazineConfig = new List<MagazineConfigModel>()
|
||||
{
|
||||
new MagazineConfigModel{Id = 1, Type = MAGAZINE_TYPE.CHAIN, LoadingIsActive = true, Name = "MAG1"},
|
||||
new MagazineConfigModel{Id = 2, Type = MAGAZINE_TYPE.BOX_MAGAZINE, LoadingIsActive = true, Name = "MAG2"},
|
||||
new MagazineConfigModel{Id = 3, Type = MAGAZINE_TYPE.BOX_MAGAZINE, LoadingIsActive = false, Name = "MAG3"},
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -1685,18 +1685,12 @@ namespace CMS_CORE.Demo
|
||||
config.EdgesConfiguration.EdgesAdditionalParamsConfiguration.Add(key, tmpNames);
|
||||
}
|
||||
|
||||
config.Magazines = new List<MagazineModel>()
|
||||
{
|
||||
new MagazineModel{Id = 1, Type = MAGAZINE_TYPE.MAGAZINE},
|
||||
new MagazineModel{Id = 2, Type = MAGAZINE_TYPE.MAGAZINE},
|
||||
new MagazineModel{Id = 3, Type = MAGAZINE_TYPE.SPINDLE},
|
||||
};
|
||||
config.Magazines = MagazineConfig;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ManageException(ex);
|
||||
}
|
||||
|
||||
|
||||
return NO_ERROR;
|
||||
}
|
||||
@@ -1716,9 +1710,34 @@ namespace CMS_CORE.Demo
|
||||
|
||||
DemoEdgesConfiguration toolsConfig = new DemoEdgesConfiguration();
|
||||
|
||||
serverService.GetMagazinePositionsWithTools(1.ToString(), out List<DemoMagPosDataModel> mag1);
|
||||
|
||||
// Parse and cast demo model
|
||||
foreach (DemoToolsDataModel demoTool in demoToolsData)
|
||||
{
|
||||
int magazineId = 0;
|
||||
int positionId = 0;
|
||||
|
||||
foreach(var tool in mag1)
|
||||
{
|
||||
if (tool.IsMultiTool)
|
||||
{
|
||||
if (tool.Shank.Id == demoTool.Id)
|
||||
{
|
||||
magazineId = tool.MagazineId;
|
||||
positionId = tool.PositionId;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (tool.ChildTools.Id == demoTool.Id)
|
||||
{
|
||||
magazineId = tool.MagazineId;
|
||||
positionId = tool.PositionId;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var toolData = new SiemensToolModel()
|
||||
{
|
||||
Id = demoTool.Id,
|
||||
@@ -1741,6 +1760,9 @@ namespace CMS_CORE.Demo
|
||||
InChangeTool = demoTool.InChangeTool,
|
||||
IsInUse = demoTool.IsInUse,
|
||||
PreAlarm = demoTool.PreAlarm,
|
||||
MagazineId = magazineId,
|
||||
PositionId = positionId,
|
||||
MultitoolId = 0,
|
||||
EdgesData = new List<EdgeModel>()
|
||||
};
|
||||
|
||||
@@ -1849,13 +1871,11 @@ namespace CMS_CORE.Demo
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
if (tools.Count >= MAX_TOOL_NUMER)
|
||||
return MAX_TOOL_REACHED_ERROR;
|
||||
ToolTableConfiguration config = new ToolTableConfiguration();
|
||||
cmsError = TOOLS_RConfiguration(ref config);
|
||||
|
||||
string family = tool.FamilyName;
|
||||
int toolsWithSameFamily = tools.Where(x => x.FamilyName == family).Count();
|
||||
if (toolsWithSameFamily >= MAX_TOOLS_PER_FAMILY)
|
||||
return MAX_FAMILY_REACHED_ERROR;
|
||||
if (tools.Count >= config.MaxTools)
|
||||
return MAX_TOOL_REACHED_ERROR;
|
||||
|
||||
return NO_ERROR;
|
||||
}
|
||||
@@ -1871,6 +1891,9 @@ namespace CMS_CORE.Demo
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
ToolTableConfiguration config = new ToolTableConfiguration();
|
||||
cmsError = TOOLS_RConfiguration(ref config);
|
||||
|
||||
try
|
||||
{
|
||||
// Get tools data in order to get tool type and its config
|
||||
@@ -1883,7 +1906,7 @@ namespace CMS_CORE.Demo
|
||||
if (demoTool == null)
|
||||
return INCORRECT_PARAMETERS_ERROR;
|
||||
|
||||
if (demoTool.EdgesData.Count >= MAX_EDGES_PER_TOOL)
|
||||
if (demoTool.EdgesData.Count >= config.MaxEdgesPerTools)
|
||||
return MAX_EDGES_PER_TOOL_REACHED_ERROR;
|
||||
|
||||
// Get the configuration of the tool type
|
||||
@@ -2039,7 +2062,12 @@ namespace CMS_CORE.Demo
|
||||
CmsError cmsError = TOOLS_RShanksData(ref shanks);
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
if (shanks.Count >= MAX_MULTITOOLS_NUMBER)
|
||||
|
||||
// Get configuration
|
||||
ToolTableConfiguration config = new ToolTableConfiguration();
|
||||
cmsError = TOOLS_RConfiguration(ref config);
|
||||
|
||||
if (shanks.Count >= config.MaxMultitools)
|
||||
return MAX_MULTITOOL_REACHED_ERROR;
|
||||
|
||||
try
|
||||
@@ -2251,9 +2279,9 @@ namespace CMS_CORE.Demo
|
||||
|
||||
foreach (DemoMagPosDataModel demoPos in demoMagazinePositions)
|
||||
{
|
||||
if(demoPos.IsMultiTool == true)
|
||||
if (demoPos.IsMultiTool == true)
|
||||
{
|
||||
if(demoPos.Shank != null)
|
||||
if (demoPos.Shank != null)
|
||||
{
|
||||
// Create multitool
|
||||
MountedToolModel pos = new MountedToolModel()
|
||||
@@ -2269,7 +2297,7 @@ namespace CMS_CORE.Demo
|
||||
}
|
||||
else
|
||||
{
|
||||
if(demoPos.ChildTools != null)
|
||||
if (demoPos.ChildTools != null)
|
||||
{
|
||||
// Create tool
|
||||
MountedToolModel pos = new MountedToolModel()
|
||||
@@ -2316,16 +2344,25 @@ namespace CMS_CORE.Demo
|
||||
}
|
||||
}
|
||||
|
||||
public override CmsError TOOLS_WLoadToolInMagazine(int magazine, NewToolInMagazineModel newMagazineTool)
|
||||
public override CmsError TOOLS_WLoadToolInMagazine(int magazineId, NewToolInMagazineModel newMagazineTool)
|
||||
{
|
||||
// Check if the NC Demo is Connected
|
||||
CmsError cmsError = CheckConnection();
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
// Get configuration
|
||||
ToolTableConfiguration config = new ToolTableConfiguration();
|
||||
cmsError = TOOLS_RConfiguration(ref config);
|
||||
|
||||
// Get mag config
|
||||
MagazineConfigModel magConfig = config.Magazines.Where(x => x.Id == magazineId).FirstOrDefault();
|
||||
if (magConfig == null || !magConfig.LoadingIsActive)
|
||||
return INCORRECT_PARAMETERS_ERROR;
|
||||
|
||||
try
|
||||
{
|
||||
serverService.UpdateMagazine(magazine.ToString(), new List<NewToolInMagazineModel> { newMagazineTool });
|
||||
serverService.UpdateMagazine(magazineId.ToString(), new List<NewToolInMagazineModel> { newMagazineTool });
|
||||
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
@@ -60,14 +60,14 @@ namespace CMS_CORE.Siemens
|
||||
private static DateTime Last_Static_Read;
|
||||
|
||||
private ushort TimeoutConn;
|
||||
private String Cnc_name;
|
||||
private String Cnc_SftVersion;
|
||||
private String Cnc_SeriesNum;
|
||||
private String Cms_MachNumber;
|
||||
private uint ConfChannelNo;
|
||||
private uint MaxChannelNo;
|
||||
private uint SiemensLanguage;
|
||||
private List<int[]> ChannelAxesId;
|
||||
private static string Cnc_name;
|
||||
private static string Cnc_SftVersion;
|
||||
private static string Cnc_SeriesNum;
|
||||
private static string Cms_MachNumber;
|
||||
private static uint ConfChannelNo;
|
||||
private static uint MaxChannelNo;
|
||||
private static uint SiemensLanguage;
|
||||
private static List<int[]> ChannelAxesId;
|
||||
|
||||
// Alarms Handler
|
||||
private AlarmSvc SiemensAlmSvc = null;
|
||||
@@ -107,6 +107,7 @@ namespace CMS_CORE.Siemens
|
||||
private static List<MountedToolModel> MagazineMountedTools = new List<MountedToolModel>();
|
||||
public static List<FamilyModel> FamiliesData = new List<FamilyModel>();
|
||||
public static MagazineActionModel MagazineAction = new MagazineActionModel();
|
||||
public static List<MagazineConfigModel> MagazineConfig = new List<MagazineConfigModel>();
|
||||
|
||||
public static uint multitoolsNumber = 0;
|
||||
|
||||
@@ -1912,19 +1913,21 @@ namespace CMS_CORE.Siemens
|
||||
// Set config field
|
||||
config.EdgesConfiguration.EdgesAdditionalParamsConfiguration.Add(key, tmpNames);
|
||||
}
|
||||
config.Magazines = new List<MagazineModel>();
|
||||
foreach (PositionModel pos in MagazinePositionsData)
|
||||
{
|
||||
var tmp = config.Magazines.Where(x => x.Id == pos.MagazineId).FirstOrDefault();
|
||||
if (tmp == null)
|
||||
{
|
||||
config.Magazines.Add(new MagazineModel()
|
||||
{
|
||||
Id = pos.MagazineId,
|
||||
Type = MAGAZINE_TYPE.MAGAZINE
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
config.Magazines = MagazineConfig;
|
||||
//config.Magazines = new List<MagazineConfigModel>();
|
||||
//foreach (PositionModel pos in MagazinePositionsData)
|
||||
//{
|
||||
// var tmp = config.Magazines.Where(x => x.Id == pos.MagazineId).FirstOrDefault();
|
||||
// if (tmp == null)
|
||||
// {
|
||||
// config.Magazines.Add(new MagazineConfigModel()
|
||||
// {
|
||||
// Id = pos.MagazineId,
|
||||
// Type = MAGAZINE_TYPE.CHAIN
|
||||
// });
|
||||
// }
|
||||
//}
|
||||
|
||||
return NO_ERROR;
|
||||
}
|
||||
@@ -1933,7 +1936,26 @@ namespace CMS_CORE.Siemens
|
||||
|
||||
public override CmsError TOOLS_RToolsData(ref List<SiemensToolModel> toolTable)
|
||||
{
|
||||
toolTable = ToolTableData;
|
||||
toolTable = new List<SiemensToolModel>(ToolTableData.Select(x =>
|
||||
{
|
||||
// find if is loaded in magazine
|
||||
MountedToolModel tool = MagazineMountedTools.Where(y => y.ToolId == x.Id).FirstOrDefault();
|
||||
if(tool != null)
|
||||
{
|
||||
x.MagazineId = tool.MagazineId;
|
||||
x.PositionId = tool.PositionId;
|
||||
}
|
||||
else
|
||||
{
|
||||
x.MagazineId = 0;
|
||||
x.PositionId = 0;
|
||||
}
|
||||
|
||||
// Update multitool id
|
||||
x.MultitoolId = ToolIsInMultitool(x.Id);
|
||||
return x;
|
||||
})
|
||||
.ToList());
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
@@ -2136,6 +2158,20 @@ namespace CMS_CORE.Siemens
|
||||
|
||||
foreach (ShankModel shank in shanksData)
|
||||
{
|
||||
// Get magazine and position id
|
||||
MountedToolModel mountedTool = MagazineMountedTools.Where(y => y.ToolId == shank.Id).FirstOrDefault();
|
||||
if (mountedTool != null)
|
||||
{
|
||||
shank.MagazineId = mountedTool.MagazineId;
|
||||
shank.PositionId = mountedTool.PositionId;
|
||||
}
|
||||
else
|
||||
{
|
||||
shank.MagazineId = 0;
|
||||
shank.PositionId = 0;
|
||||
}
|
||||
|
||||
// Populate childs
|
||||
foreach (ShankChildModel child in shank.ChildsTools)
|
||||
{
|
||||
// Find tool by id
|
||||
@@ -2511,14 +2547,19 @@ namespace CMS_CORE.Siemens
|
||||
// Check if magazine is occupied
|
||||
if (MagazineAction.Action != MAGAZINE_ACTIONS.NONE)
|
||||
return MAGAZINE_BUSY_ERROR;
|
||||
|
||||
// Get mag config
|
||||
MagazineConfigModel magConfig = MagazineConfig.Where(x => x.Id == magazineId).FirstOrDefault();
|
||||
if (magConfig == null || !magConfig.LoadingIsActive)
|
||||
return INCORRECT_PARAMETERS_ERROR;
|
||||
|
||||
// Get magazine position type
|
||||
PositionModel position = MagazinePositionsData.Where(x => x.PositionId == newMagazineTool.PositionId && x.MagazineId == magazineId).FirstOrDefault();
|
||||
if (position == null)
|
||||
if (position == null || position.Disabled)
|
||||
return INCORRECT_PARAMETERS_ERROR;
|
||||
|
||||
|
||||
// Get tool data
|
||||
var tool = ToolTableData.Where(x => x.Id == newMagazineTool.ToolId).FirstOrDefault();
|
||||
var tool = GetToolOrMultitool(newMagazineTool.ToolId);
|
||||
if (tool == null)
|
||||
return INCORRECT_PARAMETERS_ERROR;
|
||||
|
||||
@@ -2527,14 +2568,36 @@ namespace CMS_CORE.Siemens
|
||||
if (magPos != null)
|
||||
return MAGAZINE_POSITION_OCCUPIED_ERROR;
|
||||
|
||||
// Get position type
|
||||
int newToolPositionType = tool is SiemensToolModel ? (tool as SiemensToolModel).MagazinePositionType : (tool as ShankModel).MagazinePositionType;
|
||||
|
||||
// Check type
|
||||
if (tool.MagazinePositionType != position.Type)
|
||||
if (newToolPositionType != position.Type)
|
||||
return TOOL_AND_POSITION_NOT_MATCHING_ERROR;
|
||||
|
||||
for (int i = 1; i < tool.LeftSize; i++)
|
||||
foreach (var pos in MagazineMountedTools)
|
||||
{
|
||||
int nextPos = (60 - (newMagazineTool.PositionId - i));
|
||||
MagazinePositionsData.FindIndex(x => x.MagazineId == magazineId && x.PositionId == nextPos);
|
||||
// Check if is not the same tool&position
|
||||
if (pos.PositionId != newMagazineTool.PositionId && pos.MagazineId == magazineId)
|
||||
{
|
||||
int toolIndex = ToolTableData.FindIndex(x => x.Id == pos.ToolId);
|
||||
if (toolIndex > 0)
|
||||
{
|
||||
// Right check
|
||||
int decPosition = pos.PositionId < newMagazineTool.PositionId ? pos.PositionId + 60 : pos.PositionId;
|
||||
double leftMounted = decPosition - (ToolTableData[toolIndex].LeftSize / 2.0); // Calculate left space occupied
|
||||
double rightToBeMount = newMagazineTool.PositionId + ((tool as SiemensToolModel).RightSize / 2.0); // Calculate right space needed
|
||||
if (leftMounted < rightToBeMount)
|
||||
return MAGAZINE_POSITION_OCCUPIED_ERROR;
|
||||
|
||||
// Left check
|
||||
int incPosition = pos.PositionId > newMagazineTool.PositionId ? pos.PositionId - 60 : pos.PositionId;
|
||||
double rightMounted = incPosition + (ToolTableData[toolIndex].RightSize / 2.0); // Calculate right space occupied
|
||||
double leftToBeMounted = newMagazineTool.PositionId - ((tool as SiemensToolModel).LeftSize / 2.0); // Calculate left space needed
|
||||
if (rightMounted > leftToBeMounted)
|
||||
return MAGAZINE_POSITION_OCCUPIED_ERROR;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Check if the NC is Connected
|
||||
@@ -2549,7 +2612,7 @@ namespace CMS_CORE.Siemens
|
||||
piArgs[0] = "/NC";
|
||||
piArgs[1] = "401";
|
||||
piArgs[2] = newMagazineTool.ToolId.ToString().PadLeft(5, '0'); //Tool ID (> 00000)
|
||||
piArgs[3] = "00001"; // Manina carico (valore fisso)
|
||||
piArgs[3] = magazineId.ToString().PadLeft(5, '0'); ; // Manina carico (valore fisso)
|
||||
piArgs[4] = "09999"; // Magazzino di carico (valore fisso)
|
||||
piArgs[5] = newMagazineTool.PositionId.ToString().PadLeft(5, '0'); // Manina di destinazione (dove caricare l'utensile)
|
||||
piArgs[6] = magazineId.ToString().PadLeft(5, '0'); // Magazzino di destinazione (dove caricare l'utensile)
|
||||
@@ -2563,6 +2626,8 @@ namespace CMS_CORE.Siemens
|
||||
{
|
||||
return ManageException(ex);
|
||||
}
|
||||
// Mount temporarily till the Siemens notification arrives
|
||||
MountToolToMagazineList(newMagazineTool.ToolId, magazineId, newMagazineTool.PositionId);
|
||||
|
||||
return NO_ERROR;
|
||||
}
|
||||
@@ -2586,7 +2651,7 @@ namespace CMS_CORE.Siemens
|
||||
piArgs[2] = "-0001"; // Tool ID (Fixed, no ID)
|
||||
piArgs[3] = positionId.ToString().PadLeft(5, '0'); // Manina carico (valore fisso)
|
||||
piArgs[4] = magazineId.ToString().PadLeft(5, '0'); // Magazzino di carico (valore fisso)
|
||||
piArgs[5] = "00001"; //Manina carico (valore fisso)
|
||||
piArgs[5] = magazineId.ToString().PadLeft(5, '0'); //Manina carico (valore fisso)
|
||||
piArgs[6] = "09999"; // Magazzino da cui scaricare l'utensile
|
||||
piArgs[7] = "_N_TMMVTL";
|
||||
|
||||
@@ -2599,6 +2664,11 @@ namespace CMS_CORE.Siemens
|
||||
return ManageException(ex);
|
||||
}
|
||||
|
||||
// Smount temporarily till the Siemens notification arrives
|
||||
int magPosIndex = MagazineMountedTools.FindIndex(x => x.MagazineId == magazineId && x.PositionId == positionId);
|
||||
if (magPosIndex >= 0)
|
||||
MagazineMountedTools.Remove(MagazineMountedTools[magPosIndex]);
|
||||
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
@@ -3406,6 +3476,36 @@ namespace CMS_CORE.Siemens
|
||||
MultitoolsData[multitoolIndex].InUse = GetBitValue(toolStatus, 8);
|
||||
}
|
||||
break;
|
||||
case "$TC_MAP1":
|
||||
{
|
||||
// Magazine type
|
||||
MagazineConfigModel mag = MagazineConfig.Where(x => x.Id == firstId).FirstOrDefault();
|
||||
if (mag == null)
|
||||
{
|
||||
bool active = true;
|
||||
MAGAZINE_TYPE type = (MAGAZINE_TYPE)Convert.ToInt32(actualString.Split('=').LastOrDefault());
|
||||
if (type == MAGAZINE_TYPE.MAGAZINE_LOADING_STATION || type == MAGAZINE_TYPE.MAGAZINE_TOOL_BUFFER)
|
||||
active = false;
|
||||
|
||||
MagazineConfig.Add(new MagazineConfigModel()
|
||||
{
|
||||
Id = firstId,
|
||||
Type = (MAGAZINE_TYPE)Convert.ToInt32(actualString.Split('=').LastOrDefault()),
|
||||
LoadingIsActive = active
|
||||
});
|
||||
}
|
||||
else
|
||||
mag.Type = (MAGAZINE_TYPE)Convert.ToInt32(actualString.Split('=').LastOrDefault());
|
||||
}
|
||||
break;
|
||||
case "$TC_MAP2":
|
||||
{
|
||||
// Magazine Name
|
||||
MagazineConfigModel mag = MagazineConfig.Where(x => x.Id == firstId).FirstOrDefault();
|
||||
if (mag != null)
|
||||
mag.Name = actualString.Split('=').LastOrDefault().Replace("\"", "");
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -3614,7 +3714,7 @@ namespace CMS_CORE.Siemens
|
||||
if (toolStatusByte == null)
|
||||
return null;
|
||||
|
||||
byte toolStatus = Convert.ToByte(toolStatusByte.Split('=').LastOrDefault());
|
||||
int toolStatus = Convert.ToInt32(toolStatusByte.Split('=').LastOrDefault());
|
||||
// Find basic info (rotation, cooling ...)
|
||||
var toolInfo = Convert.ToInt32(toolsStrings.FirstOrDefault(X => X.StartsWith("$TC_DP25[" + toolId)).Split('=').LastOrDefault());
|
||||
|
||||
@@ -3699,7 +3799,7 @@ namespace CMS_CORE.Siemens
|
||||
if (toolStatusByte == null)
|
||||
return null;
|
||||
|
||||
byte toolStatus = Convert.ToByte(toolStatusByte.Split('=').LastOrDefault());
|
||||
int toolStatus = Convert.ToInt32(toolStatusByte.Split('=').LastOrDefault());
|
||||
|
||||
// Find shank, in order to get childs
|
||||
ShankModel oldShank = MultitoolsData.Where(x => x.Id == multitoolId).FirstOrDefault();
|
||||
@@ -3820,14 +3920,14 @@ namespace CMS_CORE.Siemens
|
||||
case ToolAction.TOOL_DELETED:
|
||||
{
|
||||
// Find tool
|
||||
SiemensToolModel tool = ToolTableData.SingleOrDefault(t => t.Id == toolInfo.tNo);
|
||||
SiemensToolModel tool = ToolTableData.FirstOrDefault(t => t.Id == toolInfo.tNo);
|
||||
if (tool != null)
|
||||
// Remove
|
||||
ToolTableData.Remove(tool);
|
||||
else if (MULTITOOL_OPTION_ACTIVE)
|
||||
{
|
||||
// if tool not exist, find into shanks
|
||||
ShankModel shank = MultitoolsData.SingleOrDefault(t => t.Id == toolInfo.tNo);
|
||||
ShankModel shank = MultitoolsData.FirstOrDefault(t => t.Id == toolInfo.tNo);
|
||||
if (shank != null)
|
||||
try
|
||||
{
|
||||
@@ -3910,7 +4010,7 @@ namespace CMS_CORE.Siemens
|
||||
if (tool is SiemensToolModel)
|
||||
{
|
||||
// TODO remove when Siemens Library bugs have been fixed
|
||||
if (ToolIsInMultitool((int)toolInfo.tNo))
|
||||
if (ToolIsInMultitool((int)toolInfo.tNo) != 0)
|
||||
return;
|
||||
else
|
||||
{
|
||||
@@ -3927,7 +4027,7 @@ namespace CMS_CORE.Siemens
|
||||
}
|
||||
|
||||
MountToolToMagazineList((int)toolInfo.tNo, magazineId, positionId);
|
||||
|
||||
// moved MULTITOOL handler, add when Siemens Library bugs have been fixed
|
||||
//catch (Exception ex)
|
||||
//{
|
||||
// int shankIdx = MultitoolsData.FindIndex(x => x.Id == toolInfo.tNo);
|
||||
@@ -4100,17 +4200,21 @@ namespace CMS_CORE.Siemens
|
||||
}
|
||||
}
|
||||
|
||||
private bool ToolIsInMultitool(int toolId)
|
||||
private int ToolIsInMultitool(int toolId)
|
||||
{
|
||||
foreach (ShankModel multi in MultitoolsData)
|
||||
{
|
||||
if (multi.ChildsTools.FindIndex(x => x.Id == toolId) >= 0)
|
||||
if (multi.ChildsTools.Count() > 0)
|
||||
{
|
||||
return true;
|
||||
int childIndex = multi.ChildsTools.FindIndex(x => x.Id == toolId);
|
||||
if (childIndex >= 0)
|
||||
{
|
||||
return multi.Id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endregion Tool private functions
|
||||
|
||||
Reference in New Issue
Block a user