From b52047213cb1e610e71b928125a76a7ee2790dc9 Mon Sep 17 00:00:00 2001 From: Lucio Maranta Date: Tue, 24 Sep 2019 14:29:45 +0000 Subject: [PATCH] Added siemens tool mounted data Fix fanuc getFilelist --- CMS_CORE_Application/Form1.cs | 4 +-- CMS_CORE_Library/Fanuc/Nc_Fanuc.cs | 20 +++++++++---- CMS_CORE_Library/Models/DataStructures.cs | 1 + CMS_CORE_Library/Siemens/Nc_Siemens.cs | 36 +++++++++++++++++++++-- 4 files changed, 51 insertions(+), 10 deletions(-) diff --git a/CMS_CORE_Application/Form1.cs b/CMS_CORE_Application/Form1.cs index 55d0a05..4212d84 100644 --- a/CMS_CORE_Application/Form1.cs +++ b/CMS_CORE_Application/Form1.cs @@ -76,7 +76,7 @@ namespace CMS_CORE_Application N = SetNcByType(); CmsError cmsError = N.NC_Connect(); - MessageBox.Show(cmsError.localizationKey); + cmsError = N.NC_RModelName(ref ModelName); List val = new List(); @@ -173,7 +173,7 @@ namespace CMS_CORE_Application TXTPPLines.Text = string.Join(Environment.NewLine, Lines); Connect.Enabled = true; - Disconnect.Enabled = false; + // Disconnect.Enabled = false; }); } } diff --git a/CMS_CORE_Library/Fanuc/Nc_Fanuc.cs b/CMS_CORE_Library/Fanuc/Nc_Fanuc.cs index c6cca78..baebb8a 100644 --- a/CMS_CORE_Library/Fanuc/Nc_Fanuc.cs +++ b/CMS_CORE_Library/Fanuc/Nc_Fanuc.cs @@ -3021,7 +3021,7 @@ namespace CMS_CORE_Library.Fanuc funcInput.size_kind = 1; funcInput.dummy = 0; - maxDir = dataNum.dir_num; + maxDir =(short)(dataNum.file_num + dataNum.dir_num); for (short i = 0; i < dataNum.file_num + dataNum.dir_num; i++) { funcInput.req_num = i; // Update file index @@ -3034,10 +3034,10 @@ namespace CMS_CORE_Library.Fanuc // Add directory to list files.Add(new PreviewFileModel() { - AbsolutePath = FormatPathForHighLevel(absolutePath + fileData.d_f, true), + AbsolutePath = FormatAbsolutePathForHighLevel(absolutePath + fileData.d_f, true), IsDirectory = true, Name = fileData.d_f, - Path = path + fileData.d_f + Path = FormatPathFroHighLevel(path, fileData.d_f) }); } else @@ -3045,10 +3045,10 @@ namespace CMS_CORE_Library.Fanuc // Add file to list files.Add(new PreviewFileModel() { - AbsolutePath = FormatPathForHighLevel(absolutePath + fileData.d_f, false), + AbsolutePath = FormatAbsolutePathForHighLevel(absolutePath + fileData.d_f, false), IsDirectory = false, Name = fileData.d_f, - Path = path + fileData.d_f + Path = FormatPathFroHighLevel(path, fileData.d_f) }); } } @@ -3416,7 +3416,7 @@ namespace CMS_CORE_Library.Fanuc return path; } - private string FormatPathForHighLevel(string path, bool isFolder) + private string FormatAbsolutePathForHighLevel(string path, bool isFolder) { string tmp = path.Replace('\\', '/'); @@ -3426,6 +3426,14 @@ namespace CMS_CORE_Library.Fanuc return tmp; } + private string FormatPathFroHighLevel(string path, string fileName) + { + if (path == "\\\\") + return path + fileName; + + return path + "/" + fileName; + } + #endregion File Management /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/CMS_CORE_Library/Models/DataStructures.cs b/CMS_CORE_Library/Models/DataStructures.cs index 7cabea2..184c5d7 100644 --- a/CMS_CORE_Library/Models/DataStructures.cs +++ b/CMS_CORE_Library/Models/DataStructures.cs @@ -344,6 +344,7 @@ namespace CMS_CORE_Library.Models public int ChildId; public bool Disabled; public bool Measured; + public bool Broken; public double MaxLoad; public double MaxSpeed; public double ResidualLife; diff --git a/CMS_CORE_Library/Siemens/Nc_Siemens.cs b/CMS_CORE_Library/Siemens/Nc_Siemens.cs index a7279d5..135e8d5 100644 --- a/CMS_CORE_Library/Siemens/Nc_Siemens.cs +++ b/CMS_CORE_Library/Siemens/Nc_Siemens.cs @@ -1063,8 +1063,39 @@ namespace CMS_CORE_Library.Siemens // Head address = posizion * size of single head in memory var headOffset = i * headsByte; short toolId = SwapShortEndianFormat(BitConverter.ToInt16(readValues.ToArray(), headOffset + 4)); + + double residualLife = 0; + // Find tool var tool = ToolTableData.Where(x => x.Id == toolId).FirstOrDefault(); + + // Check if process is selected + if (readValues[headOffset] != 0) + { + try + { + // Read selected edge + Item activeEdgeId = new Item { Path = "/Channel/State/actDNumber[u" + readValues[headOffset] + ",1]" }; // OffsetId + DataSvc dataSvc = new DataSvc(); + dataSvc.Read(activeEdgeId); + + if (Convert.ToInt32(activeEdgeId.Value) != 0) + { + // Find edge + var edge = tool.EdgesData + .Where(x => x.Id == Convert.ToInt32(activeEdgeId.Value)) + .FirstOrDefault(); + // Set residual life + if (edge != null) + residualLife = edge.ResidualLife; + } + } + catch(Exception ex) + { + return ManageException(ex); + } + } + heads.Add(new HeadDataModel() { Id = (uint)i + 1, @@ -1083,11 +1114,12 @@ namespace CMS_CORE_Library.Siemens { ChildId = tool == null ? 0 : tool.ChildId, ToolName = tool == null ? "" : tool.FamilyName, - Disabled = tool == null ? false : !tool.IsEnabled, + Disabled = tool == null ? false : !tool.IsActive, Measured = tool == null ? false : tool.IsMeasured, + Broken = tool == null ? false : tool.IsInhibited, MaxLoad = tool == null ? 0 : tool.Load, MaxSpeed = tool == null ? 0 : tool.MaxSpeed, - ResidualLife = tool.EdgesData.FirstOrDefault().ResidualLife + ResidualLife = residualLife } }); }