From f9600956d3c8a96daebe51e2c143763828164f70 Mon Sep 17 00:00:00 2001 From: Lucio Maranta Date: Fri, 31 Aug 2018 11:43:35 +0000 Subject: [PATCH] Fix siemenes --- CMS_CORE_Application/Form1.cs | 14 ++++++++------ CMS_CORE_Library/Siemens/Nc_Siemens.cs | 22 +++++++++++++++------- 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/CMS_CORE_Application/Form1.cs b/CMS_CORE_Application/Form1.cs index 47d709d..9c5f454 100644 --- a/CMS_CORE_Application/Form1.cs +++ b/CMS_CORE_Application/Form1.cs @@ -131,14 +131,16 @@ namespace CMS_CORE_Application error = true; SetError(Lines, cmsError); } + List axes = new List(); + cmsError = N.AXES_RAxesNames(1, ref axes); - N.TOOLS_RStoredData(); - InfoFile f = new InfoFile(); - N.FILES_RGetFileInfo("",ref f); + //N.TOOLS_RStoredData(); + //InfoFile f = new InfoFile(); + //N.FILES_RGetFileInfo("",ref f); - Dictionary statu = new Dictionary(); - Dictionary lives = new Dictionary(); - N.TOOLS_RUpdatedToolsData(ref statu, ref lives); + //Dictionary statu = new Dictionary(); + //Dictionary lives = new Dictionary(); + //N.TOOLS_RUpdatedToolsData(ref statu, ref lives); sw.Stop(); if (!this.IsDisposed && this.InvokeRequired) { diff --git a/CMS_CORE_Library/Siemens/Nc_Siemens.cs b/CMS_CORE_Library/Siemens/Nc_Siemens.cs index e4d980f..4900cda 100644 --- a/CMS_CORE_Library/Siemens/Nc_Siemens.cs +++ b/CMS_CORE_Library/Siemens/Nc_Siemens.cs @@ -3,6 +3,7 @@ using Siemens.Sinumerik.Operate.Services; using System; using System.Collections; using System.Collections.Generic; +using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; @@ -179,7 +180,10 @@ namespace CMS_CORE.Siemens //Set Connected to FALSE and close the session Connected = false; if (SiemensToolSvc != null) + { SiemensToolSvc.UnSubscribe(ToolMngmtSvcHandler); + SiemensToolSvc = null; + } if (MagazinePositionSvc != null) MagazinePositionSvc.UnSubscribe(MagazinePositionEnabled_OnChange); if (MagazineActionsSvc != null) @@ -1294,6 +1298,7 @@ namespace CMS_CORE.Siemens CmsError cmsError = CheckConnection(); if (cmsError.IsError()) return cmsError; + int i = 0; try { XDocument xmlAxesFile = XDocument.Load(AXES_FILE_PATH); @@ -1317,7 +1322,7 @@ namespace CMS_CORE.Siemens bool[] axesAreVisible = new bool[20]; - for (int i = 1; i < 20; i++) + for (i = 1; i < 20; i++) { // Populate static configured axes for the current channel if (ChannelAxesId.Count == 0 || ChannelAxesId[channel - 1] == null) @@ -2047,19 +2052,22 @@ namespace CMS_CORE.Siemens try { // Setup variables - String TempFile = Path.GetTempFileName(); + string tmpFile = Path.GetTempFileName(); FileSvc FileData = new FileSvc(); Node sourceNode = new Node(partProgramPath); - Node destNode = new Node(TempFile); + Node destNode = new Node(tmpFile); //Execute Function FileData.Copy(sourceNode, destNode, true); - //Write to local file - WriteLocalFile(ReadLocalFile(new FileStream(TempFile, FileMode.Open)), ref localFile); + FileStream tmpFileStream = new FileStream(tmpFile, FileMode.Open); + //Write to local file + WriteLocalFile(ReadLocalFile(tmpFileStream), ref localFile); + + tmpFileStream.Close(); //Delete temporary file - File.Delete(TempFile); + File.Delete(tmpFile); } catch (Exception ex) { @@ -4123,7 +4131,7 @@ namespace CMS_CORE.Siemens // Create a configuration file FileStream f = new FileStream(LOCALE_TOOL_FILE_PATH, FileMode.Create); // Read siemens configuration file - FILES_RProgramToFile(NC_TOOL_FILE_PATH, f); + CmsError cmsError = FILES_RProgramToFile(NC_TOOL_FILE_PATH, f); f.Close(); return File.ReadAllLines(LOCALE_TOOL_FILE_PATH); }