From 9bc6b1cfb50d4df0c2bdf86ba75dfb9cfe3bcb22 Mon Sep 17 00:00:00 2001 From: Lucio Maranta Date: Wed, 11 Jul 2018 15:46:33 +0000 Subject: [PATCH] WIP Osai write file --- CMS_CORE_Application/Form1.Designer.cs | 133 +++++++++++++-------- CMS_CORE_Application/Form1.cs | 39 +++++- CMS_CORE_Library/Demo/Nc_Demo.cs | 15 +++ CMS_CORE_Library/Fanuc/Nc_Fanuc.cs | 14 +++ CMS_CORE_Library/Nc.cs | 8 +- CMS_CORE_Library/Osai/Nc_Osai.cs | 157 +++++++++++++++++++++++-- CMS_CORE_Library/Siemens/Nc_Siemens.cs | 17 ++- CMS_CORE_Library/Utils/Nc_Utils.cs | 11 +- 8 files changed, 326 insertions(+), 68 deletions(-) diff --git a/CMS_CORE_Application/Form1.Designer.cs b/CMS_CORE_Application/Form1.Designer.cs index 6fd7698..7523c00 100644 --- a/CMS_CORE_Application/Form1.Designer.cs +++ b/CMS_CORE_Application/Form1.Designer.cs @@ -30,6 +30,8 @@ { this.Connect = new System.Windows.Forms.Button(); this.panel1 = new System.Windows.Forms.Panel(); + this.writeFileBtn = new System.Windows.Forms.Button(); + this.readFileBtn = new System.Windows.Forms.Button(); this.tableLayoutPanel3 = new System.Windows.Forms.TableLayoutPanel(); this.Disconnect = new System.Windows.Forms.Button(); this.label3 = new System.Windows.Forms.Label(); @@ -69,16 +71,17 @@ this.TXTPPName = new System.Windows.Forms.TextBox(); this.TXTPPLines = new System.Windows.Forms.TextBox(); this.groupBox5 = new System.Windows.Forms.GroupBox(); + this.label13 = new System.Windows.Forms.Label(); + this.lastTime = new System.Windows.Forms.Label(); + this.label12 = new System.Windows.Forms.Label(); + this.totalTimesTXT = new System.Windows.Forms.TextBox(); this.lastTimeDbTXT = new System.Windows.Forms.TextBox(); this.mediaTestDbTXT = new System.Windows.Forms.TextBox(); this.TXTNow = new System.Windows.Forms.TextBox(); this.label7 = new System.Windows.Forms.Label(); this.label10 = new System.Windows.Forms.Label(); this.Error = new System.Windows.Forms.TextBox(); - this.totalTimesTXT = new System.Windows.Forms.TextBox(); - this.label12 = new System.Windows.Forms.Label(); - this.lastTime = new System.Windows.Forms.Label(); - this.label13 = new System.Windows.Forms.Label(); + this.NetworkReadButton = new System.Windows.Forms.Button(); this.panel1.SuspendLayout(); this.tableLayoutPanel3.SuspendLayout(); this.tableLayoutPanel1.SuspendLayout(); @@ -113,6 +116,9 @@ | System.Windows.Forms.AnchorStyles.Right))); this.panel1.BackColor = System.Drawing.Color.White; this.panel1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; + this.panel1.Controls.Add(this.NetworkReadButton); + this.panel1.Controls.Add(this.writeFileBtn); + this.panel1.Controls.Add(this.readFileBtn); this.panel1.Controls.Add(this.tableLayoutPanel3); this.panel1.Controls.Add(this.label3); this.panel1.Controls.Add(this.label2); @@ -126,6 +132,26 @@ this.panel1.TabIndex = 1; this.panel1.Paint += new System.Windows.Forms.PaintEventHandler(this.panel1_Paint); // + // writeFileBtn + // + this.writeFileBtn.Location = new System.Drawing.Point(102, 13); + this.writeFileBtn.Name = "writeFileBtn"; + this.writeFileBtn.Size = new System.Drawing.Size(75, 23); + this.writeFileBtn.TabIndex = 8; + this.writeFileBtn.Text = "scrivi"; + this.writeFileBtn.UseVisualStyleBackColor = true; + this.writeFileBtn.Click += new System.EventHandler(this.writeFileBtn_Click); + // + // readFileBtn + // + this.readFileBtn.Location = new System.Drawing.Point(16, 13); + this.readFileBtn.Name = "readFileBtn"; + this.readFileBtn.Size = new System.Drawing.Size(75, 23); + this.readFileBtn.TabIndex = 7; + this.readFileBtn.Text = "leggi"; + this.readFileBtn.UseVisualStyleBackColor = true; + this.readFileBtn.Click += new System.EventHandler(this.readFileBtn_Click); + // // tableLayoutPanel3 // this.tableLayoutPanel3.ColumnCount = 2; @@ -357,7 +383,7 @@ this.tableLayoutPanel1.ColumnCount = 3; this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50.76253F)); this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 49.23747F)); - this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 289F)); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 292F)); this.tableLayoutPanel1.Controls.Add(this.groupBox2, 1, 0); this.tableLayoutPanel1.Controls.Add(this.groupBox1, 0, 0); this.tableLayoutPanel1.Controls.Add(this.groupBox4, 2, 0); @@ -376,9 +402,9 @@ | System.Windows.Forms.AnchorStyles.Right))); this.groupBox2.Controls.Add(this.TXTMsg); this.groupBox2.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.groupBox2.Location = new System.Drawing.Point(162, 3); + this.groupBox2.Location = new System.Drawing.Point(160, 3); this.groupBox2.Name = "groupBox2"; - this.groupBox2.Size = new System.Drawing.Size(148, 265); + this.groupBox2.Size = new System.Drawing.Size(147, 265); this.groupBox2.TabIndex = 28; this.groupBox2.TabStop = false; this.groupBox2.Text = "Plc"; @@ -392,7 +418,7 @@ this.TXTMsg.Multiline = true; this.TXTMsg.Name = "TXTMsg"; this.TXTMsg.ReadOnly = true; - this.TXTMsg.Size = new System.Drawing.Size(137, 238); + this.TXTMsg.Size = new System.Drawing.Size(136, 238); this.TXTMsg.TabIndex = 18; // // groupBox1 @@ -403,7 +429,7 @@ this.groupBox1.Controls.Add(this.TXTAlmNc); this.groupBox1.Location = new System.Drawing.Point(3, 3); this.groupBox1.Name = "groupBox1"; - this.groupBox1.Size = new System.Drawing.Size(153, 265); + this.groupBox1.Size = new System.Drawing.Size(151, 265); this.groupBox1.TabIndex = 27; this.groupBox1.TabStop = false; this.groupBox1.Text = "Nc"; @@ -417,7 +443,7 @@ this.TXTAlmNc.Multiline = true; this.TXTAlmNc.Name = "TXTAlmNc"; this.TXTAlmNc.ReadOnly = true; - this.TXTAlmNc.Size = new System.Drawing.Size(141, 240); + this.TXTAlmNc.Size = new System.Drawing.Size(139, 240); this.TXTAlmNc.TabIndex = 20; // // groupBox4 @@ -427,9 +453,9 @@ | System.Windows.Forms.AnchorStyles.Right))); this.groupBox4.Controls.Add(this.tabControl1); this.groupBox4.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.groupBox4.Location = new System.Drawing.Point(316, 3); + this.groupBox4.Location = new System.Drawing.Point(313, 3); this.groupBox4.Name = "groupBox4"; - this.groupBox4.Size = new System.Drawing.Size(284, 265); + this.groupBox4.Size = new System.Drawing.Size(287, 265); this.groupBox4.TabIndex = 29; this.groupBox4.TabStop = false; this.groupBox4.Text = "Path"; @@ -443,7 +469,7 @@ this.tabControl1.Location = new System.Drawing.Point(6, 21); this.tabControl1.Name = "tabControl1"; this.tabControl1.SelectedIndex = 0; - this.tabControl1.Size = new System.Drawing.Size(271, 238); + this.tabControl1.Size = new System.Drawing.Size(274, 238); this.tabControl1.TabIndex = 0; // // tabPage1 @@ -452,7 +478,7 @@ this.tabPage1.Location = new System.Drawing.Point(4, 22); this.tabPage1.Name = "tabPage1"; this.tabPage1.Padding = new System.Windows.Forms.Padding(3); - this.tabPage1.Size = new System.Drawing.Size(263, 212); + this.tabPage1.Size = new System.Drawing.Size(266, 212); this.tabPage1.TabIndex = 0; this.tabPage1.Text = "Path 1"; this.tabPage1.UseVisualStyleBackColor = true; @@ -466,7 +492,7 @@ this.TXTAlm.Multiline = true; this.TXTAlm.Name = "TXTAlm"; this.TXTAlm.ReadOnly = true; - this.TXTAlm.Size = new System.Drawing.Size(251, 203); + this.TXTAlm.Size = new System.Drawing.Size(254, 203); this.TXTAlm.TabIndex = 18; // // groupBox3 @@ -595,6 +621,40 @@ this.groupBox5.TabStop = false; this.groupBox5.Text = "Nc Info"; // + // label13 + // + this.label13.AutoSize = true; + this.label13.Location = new System.Drawing.Point(62, 120); + this.label13.Name = "label13"; + this.label13.Size = new System.Drawing.Size(41, 13); + this.label13.TabIndex = 32; + this.label13.Text = "label13"; + // + // lastTime + // + this.lastTime.AutoSize = true; + this.lastTime.Location = new System.Drawing.Point(59, 90); + this.lastTime.Name = "lastTime"; + this.lastTime.Size = new System.Drawing.Size(46, 13); + this.lastTime.TabIndex = 31; + this.lastTime.Text = "lastTime"; + // + // label12 + // + this.label12.AutoSize = true; + this.label12.Location = new System.Drawing.Point(56, 63); + this.label12.Name = "label12"; + this.label12.Size = new System.Drawing.Size(47, 13); + this.label12.TabIndex = 30; + this.label12.Text = "Avarage"; + // + // totalTimesTXT + // + this.totalTimesTXT.Location = new System.Drawing.Point(114, 113); + this.totalTimesTXT.Name = "totalTimesTXT"; + this.totalTimesTXT.Size = new System.Drawing.Size(100, 20); + this.totalTimesTXT.TabIndex = 29; + // // lastTimeDbTXT // this.lastTimeDbTXT.Location = new System.Drawing.Point(114, 87); @@ -646,39 +706,15 @@ this.Error.Size = new System.Drawing.Size(462, 20); this.Error.TabIndex = 27; // - // totalTimesTXT + // NetworkReadButton // - this.totalTimesTXT.Location = new System.Drawing.Point(114, 113); - this.totalTimesTXT.Name = "totalTimesTXT"; - this.totalTimesTXT.Size = new System.Drawing.Size(100, 20); - this.totalTimesTXT.TabIndex = 29; - // - // label12 - // - this.label12.AutoSize = true; - this.label12.Location = new System.Drawing.Point(56, 63); - this.label12.Name = "label12"; - this.label12.Size = new System.Drawing.Size(47, 13); - this.label12.TabIndex = 30; - this.label12.Text = "Avarage"; - // - // lastTime - // - this.lastTime.AutoSize = true; - this.lastTime.Location = new System.Drawing.Point(59, 90); - this.lastTime.Name = "lastTime"; - this.lastTime.Size = new System.Drawing.Size(46, 13); - this.lastTime.TabIndex = 31; - this.lastTime.Text = "lastTime"; - // - // label13 - // - this.label13.AutoSize = true; - this.label13.Location = new System.Drawing.Point(62, 120); - this.label13.Name = "label13"; - this.label13.Size = new System.Drawing.Size(41, 13); - this.label13.TabIndex = 32; - this.label13.Text = "label13"; + this.NetworkReadButton.Location = new System.Drawing.Point(286, 51); + this.NetworkReadButton.Name = "NetworkReadButton"; + this.NetworkReadButton.Size = new System.Drawing.Size(75, 23); + this.NetworkReadButton.TabIndex = 9; + this.NetworkReadButton.Text = "Leggi rete"; + this.NetworkReadButton.UseVisualStyleBackColor = true; + this.NetworkReadButton.Click += new System.EventHandler(this.NetworkReadButton_Click); // // Form1 // @@ -773,6 +809,9 @@ private System.Windows.Forms.Label label12; private System.Windows.Forms.TextBox totalTimesTXT; private System.Windows.Forms.Label label13; + private System.Windows.Forms.Button writeFileBtn; + private System.Windows.Forms.Button readFileBtn; + private System.Windows.Forms.Button NetworkReadButton; } } diff --git a/CMS_CORE_Application/Form1.cs b/CMS_CORE_Application/Form1.cs index 3b1cdae..dd9f1b9 100644 --- a/CMS_CORE_Application/Form1.cs +++ b/CMS_CORE_Application/Form1.cs @@ -7,6 +7,7 @@ using CMS_CORE_Application.ToolDatabase; using System; using System.Collections.Generic; using System.Diagnostics; +using System.IO; using System.Linq; using System.Threading; using System.Windows.Forms; @@ -225,8 +226,10 @@ namespace CMS_CORE_Application //}); // cmsError = N.TOOLS_WUnloadToolInMagazine(1, 53); // cmsError = N.TOOLS_WLoadToolInMagazine(1, new NewToolInMagazineModel() { PositionId = 1, ToolId = 4 }); - cmsError = N.TOOLS_ROffset(1, ref offset); - cmsError = N.TOOLS_WOffset(3, offset); + //cmsError = N.TOOLS_ROffset(1, ref offset); + // cmsError = N.TOOLS_WStartEdit(); + // cmsError = N.TOOLS_WOffset(3, offset); + //cmsError = N.TOOLS_WAddTool(); //cmsError = N.PLC_WRefreshAllMessages(); //cmsError = N.PLC_RHeadsData(headsTest, 1); @@ -309,7 +312,7 @@ namespace CMS_CORE_Application if ((200 - (int)sw.ElapsedMilliseconds) < 0) Debug.WriteLine("Ritardo " + sw.ElapsedMilliseconds); - Thread.Sleep(200); + Thread.Sleep(2000); } } @@ -512,5 +515,35 @@ namespace CMS_CORE_Application Connect.Enabled = true; Disconnect.Enabled = false; } + + private void writeFileBtn_Click(object sender, EventArgs e) + { + using (FileStream fileStream = new FileStream("C:\\test.csv", FileMode.OpenOrCreate)) + { + CmsError cms = N.FILES_WProgramFromFile(@"test\\OEM\\CMS\\SYS\\STEP\\Tools.csv", fileStream); + if (cms.IsError()) + { + MessageBox.Show(cms.localizationKey); + } + } + + } + + private void readFileBtn_Click(object sender, EventArgs e) + { + using (FileStream fileStream = new FileStream("C:\\test.csv", FileMode.OpenOrCreate)) + { + CmsError cms = N.FILES_RProgramToFile(@"test\\OEM\\CMS\\SYS\\STEP\\Tools.csv", fileStream); + if (cms.IsError()) + { + MessageBox.Show(cms.localizationKey); + } + } + } + + private void NetworkReadButton_Click(object sender, EventArgs e) + { + N.TOOLS_WAddTool(); + } } } \ No newline at end of file diff --git a/CMS_CORE_Library/Demo/Nc_Demo.cs b/CMS_CORE_Library/Demo/Nc_Demo.cs index e170403..39fd774 100644 --- a/CMS_CORE_Library/Demo/Nc_Demo.cs +++ b/CMS_CORE_Library/Demo/Nc_Demo.cs @@ -2473,6 +2473,21 @@ namespace CMS_CORE.Demo return NO_ERROR; } + public override CmsError TOOLS_WStartEdit() + { + return NO_ERROR; + } + + public override CmsError TOOLS_WStopEdit() + { + return NO_ERROR; + } + + public override CmsError TOOLS_WAddTool() + { + return NO_ERROR; + } + #endregion Nc Tool Manager /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/CMS_CORE_Library/Fanuc/Nc_Fanuc.cs b/CMS_CORE_Library/Fanuc/Nc_Fanuc.cs index 3f37e44..dc1ca41 100644 --- a/CMS_CORE_Library/Fanuc/Nc_Fanuc.cs +++ b/CMS_CORE_Library/Fanuc/Nc_Fanuc.cs @@ -1807,6 +1807,20 @@ namespace CMS_CORE.Fanuc return NO_ERROR; } + public override CmsError TOOLS_WStartEdit() + { + return NO_ERROR; + } + + public override CmsError TOOLS_WStopEdit() + { + return NO_ERROR; + } + + public override CmsError TOOLS_WAddTool() + { + return NO_ERROR; + } #endregion Nc Tool Manager /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/CMS_CORE_Library/Nc.cs b/CMS_CORE_Library/Nc.cs index fa1a81a..9d020d0 100644 --- a/CMS_CORE_Library/Nc.cs +++ b/CMS_CORE_Library/Nc.cs @@ -1516,11 +1516,17 @@ namespace CMS_CORE /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// #region Nc Tool Manager - + public abstract CmsError TOOLS_ROffset(short offsetId, ref OffsetModel offset); public abstract CmsError TOOLS_WOffset(short offsetId, OffsetModel offset); + public abstract CmsError TOOLS_WStartEdit(); + + public abstract CmsError TOOLS_WStopEdit(); + + public abstract CmsError TOOLS_WAddTool(); + #endregion Nc Tool Manager /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/CMS_CORE_Library/Osai/Nc_Osai.cs b/CMS_CORE_Library/Osai/Nc_Osai.cs index 5525855..b54c9de 100644 --- a/CMS_CORE_Library/Osai/Nc_Osai.cs +++ b/CMS_CORE_Library/Osai/Nc_Osai.cs @@ -22,21 +22,28 @@ namespace CMS_CORE.Osai { public class Nc_Osai : Nc { - private const String ConfigFile = @"Config\OSAI_WIN.INI"; + private const string ConfigFile = @"Config\OSAI_WIN.INI"; private const short MAX_PROC = 64; - private String Url; + private string Url; private OPENcontrolPortTypeClient OpenNC; private ushort CNCPhase; - private String Cnc_SftVersion; - private String Cnc_SeriesNum; - private String Cnc_name; + private string Cnc_SftVersion; + private string Cnc_SeriesNum; + private string Cnc_name; private DateTime Last_Static_Read; - private String OsaiLanguages; + private string OsaiLanguages; private ushort timeOutConn; private EndpointAddress endPointAddress; private BasicHttpBinding HttpBinding; private static Dictionary PlcMessages; + private const string TOOL_MANAGER_DIRECTORY_PATH = @"test\\OEM\\CMS\\SYS\\STEP\\"; + private const string FAMILIES_FILE_NAME = @"Families"; + private const string FAM_SIZE_FILE_NAME = @"Fam_Sizes"; + private const string MAG_POSITION_FILE_NAME = @"Mag_Positions"; + private const string SHANKS_FILE_NAME = @"Shanks"; + private const string TOOLS_FILE_NAME = @"Tools"; + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// #region Contructor & global methods @@ -1911,6 +1918,10 @@ namespace CMS_CORE.Osai { // Get part program file size nReturn = OpenNC.LogFSGetFileSize(partProgramPath, out size, out errorClass, out errorNum); + //If there's an error launch exception + if (errorClass != 0 || errorNum != 0 || nReturn == 0) + return GetNCError(errorClass, errorNum); + // Read part program content nReturn = OpenNC.GetFile(partProgramPath, ref size, out partProgramContent, out errorClass, out errorNum); @@ -2217,9 +2228,8 @@ namespace CMS_CORE.Osai return NO_ERROR; } - public override CmsError TOOLS_WOffset(short offsetId, OffsetModel offset) - { + { //Check if the NC is Connected CmsError cmsError = CheckConnection(); if (cmsError.IsError()) @@ -2252,6 +2262,137 @@ namespace CMS_CORE.Osai return NO_ERROR; } + public override CmsError TOOLS_WStartEdit() + { + //Check if the NC is Connected + CmsError cmsError = CheckConnection(); + if (cmsError.IsError()) + return cmsError; + + try + { + string filePath = TOOL_MANAGER_DIRECTORY_PATH + "{0}.csv"; + string backupFilePath = TOOL_MANAGER_DIRECTORY_PATH + "{0}_bak.csv"; + Stopwatch sw = new Stopwatch(); + sw.Start(); + // Create tool manager file backup + cmsError = FILES_CopyProgram(string.Format(filePath, FAMILIES_FILE_NAME), string.Format(backupFilePath, FAMILIES_FILE_NAME), false); + if (cmsError.IsError()) + return cmsError; + + cmsError = FILES_CopyProgram(string.Format(filePath, FAM_SIZE_FILE_NAME), string.Format(backupFilePath, FAM_SIZE_FILE_NAME), false); + if (cmsError.IsError()) + return cmsError; + + cmsError = FILES_CopyProgram(string.Format(filePath, MAG_POSITION_FILE_NAME), string.Format(backupFilePath, MAG_POSITION_FILE_NAME), false); + if (cmsError.IsError()) + return cmsError; + + cmsError = FILES_CopyProgram(string.Format(filePath, SHANKS_FILE_NAME), string.Format(backupFilePath, SHANKS_FILE_NAME), false); + if (cmsError.IsError()) + return cmsError; + + cmsError = FILES_CopyProgram(string.Format(filePath, TOOLS_FILE_NAME), string.Format(backupFilePath, TOOLS_FILE_NAME), false); + if (cmsError.IsError()) + return cmsError; + + Console.WriteLine(sw.ElapsedMilliseconds); + } + catch (Exception ex) + { + return ManageException(ex); + } + + return NO_ERROR; + } // WIP, NEED Memory control word + + public override CmsError TOOLS_WStopEdit() + { + //Check if the NC is Connected + CmsError cmsError = CheckConnection(); + if (cmsError.IsError()) + return cmsError; + + try + { + return NO_ERROR; + } + catch (Exception ex) + { + return ManageException(ex); + } + } // TODO + + public override CmsError TOOLS_WAddTool() + { + //Check if the NC is Connected + CmsError cmsError = CheckConnection(); + if (cmsError.IsError()) + return cmsError; + + List siemens = new List() {new OffsetModel(){Id = 22, Length = 33, Radius = 44, WearLength = 11, WearRadius =5432 } }; + + // Generate tool data csv string + string csvToolData = GenerateModelCsv(siemens); + + string filePath = TOOL_MANAGER_DIRECTORY_PATH + TOOLS_FILE_NAME + ".csv"; + + try + { + Stopwatch sw = new Stopwatch(); + sw.Start(); + using (FileStream fileStream = new FileStream("C:\\test.csv", FileMode.OpenOrCreate)) + { + // Read tool file + cmsError = FILES_RProgramToFile(filePath, fileStream); + if (cmsError.IsError()) + return cmsError; + } + + using (FileStream fileStream = new FileStream("C:\\test.csv", FileMode.OpenOrCreate)) + { + using (StreamWriter writer = new StreamWriter(fileStream)) + { + // Write local file + writer.WriteLine(csvToolData); + // Write NcFile + cmsError = FILES_WProgramFromFile(filePath, fileStream); + if (cmsError.IsError()) + return cmsError; + } + } + Console.WriteLine("Scrivere tool: " + sw.ElapsedMilliseconds); + } + catch (Exception ex) + { + return ManageException(ex); + } + + return NO_ERROR; + } + + public string GenerateModelCsv(List items) where T : class + { + var output = ""; + var delimiter = ';'; + var properties = typeof(T).GetProperties(); + + using (var sw = new StringWriter()) + { + foreach (var item in items) + { + var row = properties + .Select(n => n.GetValue(item, null)) + .Select(n => n?.ToString()) + .Aggregate((a, b) => a + delimiter + b); + + sw.Write(row); + } + output = sw.ToString(); + } + return output; + } + #endregion Nc Tool Manager /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/CMS_CORE_Library/Siemens/Nc_Siemens.cs b/CMS_CORE_Library/Siemens/Nc_Siemens.cs index e6fc80d..e2a6c2a 100644 --- a/CMS_CORE_Library/Siemens/Nc_Siemens.cs +++ b/CMS_CORE_Library/Siemens/Nc_Siemens.cs @@ -1833,7 +1833,7 @@ namespace CMS_CORE.Siemens FileData.Copy(sourceNode, destNode, true); //Write to local file - Nc_Utils.WriteLocalFile(Nc_Utils.ReadLocalFile(new FileStream(TempFile, FileMode.Open)), ref localFile); + WriteLocalFile(ReadLocalFile(new FileStream(TempFile, FileMode.Open)), ref localFile); //Delete temporary file File.Delete(TempFile); @@ -2884,6 +2884,21 @@ namespace CMS_CORE.Siemens return FUNCTION_NOT_ALLOWED_ERROR; } + public override CmsError TOOLS_WStartEdit() + { + return FUNCTION_NOT_ALLOWED_ERROR; + } + + public override CmsError TOOLS_WStopEdit() + { + return NO_ERROR; + } + + public override CmsError TOOLS_WAddTool() + { + return NO_ERROR; + } + #endregion Nc Tool Manager /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/CMS_CORE_Library/Utils/Nc_Utils.cs b/CMS_CORE_Library/Utils/Nc_Utils.cs index 38e4c61..197163c 100644 --- a/CMS_CORE_Library/Utils/Nc_Utils.cs +++ b/CMS_CORE_Library/Utils/Nc_Utils.cs @@ -139,10 +139,8 @@ namespace CMS_CORE.Utils public static void WriteLocalFile(string fileContent, ref FileStream fileReference) { // Write Part Program - StreamWriter writer = new StreamWriter(fileReference); - writer.Write(fileContent); - // Close file Writer - writer.Close(); + using (StreamWriter writer = new StreamWriter(fileReference)) + writer.Write(fileContent); } public static string ReadLocalFile(FileStream fileReference) @@ -152,8 +150,6 @@ namespace CMS_CORE.Utils string fileContent = reader.ReadToEnd(); - reader.Close(); - return fileContent; } @@ -173,8 +169,7 @@ namespace CMS_CORE.Utils return String.Empty; } - public static IEnumerable DistinctBy -(this IEnumerable source, Func keySelector) + public static IEnumerable DistinctBy (this IEnumerable source, Func keySelector) { HashSet seenKeys = new HashSet(); foreach (TSource element in source)