From e89dc7c3c101741401e58f601e174bb8673fa10e Mon Sep 17 00:00:00 2001 From: Lucio Maranta Date: Mon, 8 Apr 2019 14:06:06 +0000 Subject: [PATCH] Fix osai axes --- CMS_CORE_Library/Osai/Nc_Osai.cs | 38 ++++++++++++++++++++++---- CMS_CORE_Library/Siemens/Nc_Siemens.cs | 2 +- 2 files changed, 33 insertions(+), 7 deletions(-) diff --git a/CMS_CORE_Library/Osai/Nc_Osai.cs b/CMS_CORE_Library/Osai/Nc_Osai.cs index d7cbc68..0547857 100644 --- a/CMS_CORE_Library/Osai/Nc_Osai.cs +++ b/CMS_CORE_Library/Osai/Nc_Osai.cs @@ -1739,8 +1739,14 @@ namespace CMS_CORE_Library.Osai { if (ax.AxisName > 0 && axesN.Count() > 0) { - AxName = ((char)ax.AxisName).ToString(); - int id = axesN.FirstOrDefault(x => x.Name == AxName).Id; + int id = 0; + //AxName = ((char)ax.AxisName).ToString(); + + // Check if axis exist + var axis = axesN.FirstOrDefault(x => x.Name == AxName); + if (axis != null) + id = axis.Id; + val = Axes.FirstOrDefault(X => X.Key == AxName); if (id > 0) { @@ -1797,8 +1803,14 @@ namespace CMS_CORE_Library.Osai { if (ax.AxisName > 0 && axesN.Count() > 0) { + int id = 0; AxName = ((char)ax.AxisName).ToString(); - int id = axesN.FirstOrDefault(x => x.Name == AxName).Id; + + // Check if axis exist + var axis = axesN.FirstOrDefault(x => x.Name == AxName); + if (axis != null) + id = axis.Id; + val = Axes.FirstOrDefault(X => X.Key == AxName); if (id > 0) { @@ -1855,8 +1867,14 @@ namespace CMS_CORE_Library.Osai { if (ax.AxisName > 0 && axesN.Count() > 0) { + int id = 0; AxName = ((char)ax.AxisName).ToString(); - int id = axesN.FirstOrDefault(x => x.Name == AxName).Id; + + // Check if axis exist + var axis = axesN.FirstOrDefault(x => x.Name == AxName); + if (axis != null) + id = axis.Id; + val = Axes.FirstOrDefault(X => X.Key == AxName); if (id > 0) { @@ -1913,8 +1931,14 @@ namespace CMS_CORE_Library.Osai { if (ax.AxisName > 0 && axesN.Count() > 0) { + int id = 0; AxName = ((char)ax.AxisName).ToString(); - int id = axesN.FirstOrDefault(x => x.Name == AxName).Id; + + // Check if axis exist + var axis = axesN.FirstOrDefault(x => x.Name == AxName); + if (axis != null) + id = axis.Id; + val = Axes.FirstOrDefault(X => X.Key == AxName); if (id > 0) { @@ -2297,6 +2321,8 @@ namespace CMS_CORE_Library.Osai index = 0; MemIndexTemp++; } + else + index++; } } else @@ -2384,7 +2410,7 @@ namespace CMS_CORE_Library.Osai public override CmsError MEM_RWShortList(bool bWrite, int Process, MEMORY_TYPE MemType, int MemIndex, int Number, ref List Value) { List ShortValue = Value.ConvertAll(x => (ushort)x); - CmsError cmsError = MEM_RWWordList(bWrite, Process, MemType, MemIndex, 1, ref ShortValue); + CmsError cmsError = MEM_RWWordList(bWrite, Process, MemType, MemIndex, Number, ref ShortValue); if (cmsError.IsError()) return cmsError; diff --git a/CMS_CORE_Library/Siemens/Nc_Siemens.cs b/CMS_CORE_Library/Siemens/Nc_Siemens.cs index 7250852..b696a67 100644 --- a/CMS_CORE_Library/Siemens/Nc_Siemens.cs +++ b/CMS_CORE_Library/Siemens/Nc_Siemens.cs @@ -4321,7 +4321,7 @@ namespace CMS_CORE_Library.Siemens private void NcLanguageChanged(string language) { SiemensAlmSvc.UnSubscribe(AlarmsChanged); - SiemensAlmSvc.Dispose(); + // SiemensAlmSvc.Dispose(); SiemensAlmSvc = new AlarmSvc(language); SiemensAlmSvc.Subscribe(AlarmsChanged); }