From 13cbb12d0ea4a85748e4ba2a95840cd460c65e33 Mon Sep 17 00:00:00 2001 From: Lucio Maranta Date: Fri, 20 Jul 2018 11:36:19 +0000 Subject: [PATCH] Fix osai tool manager --- CMS_CORE_Application/Form1.Designer.cs | 44 ++++--- CMS_CORE_Application/Form1.cs | 18 ++- CMS_CORE_Library/DataStructures.cs | 14 ++- CMS_CORE_Library/Osai/Nc_Osai.cs | 160 ++++++++++--------------- CMS_CORE_Library/Siemens/Nc_Siemens.cs | 32 +++-- 5 files changed, 136 insertions(+), 132 deletions(-) diff --git a/CMS_CORE_Application/Form1.Designer.cs b/CMS_CORE_Application/Form1.Designer.cs index d6f04f7..892cf86 100644 --- a/CMS_CORE_Application/Form1.Designer.cs +++ b/CMS_CORE_Application/Form1.Designer.cs @@ -30,6 +30,7 @@ { this.Connect = new System.Windows.Forms.Button(); this.panel1 = new System.Windows.Forms.Panel(); + this.NetworkReadButton = new System.Windows.Forms.Button(); this.writeFileBtn = new System.Windows.Forms.Button(); this.readFileBtn = new System.Windows.Forms.Button(); this.tableLayoutPanel3 = new System.Windows.Forms.TableLayoutPanel(); @@ -81,7 +82,7 @@ this.label7 = new System.Windows.Forms.Label(); this.label10 = new System.Windows.Forms.Label(); this.Error = new System.Windows.Forms.TextBox(); - this.NetworkReadButton = new System.Windows.Forms.Button(); + this.pathTextBox = new System.Windows.Forms.TextBox(); this.panel1.SuspendLayout(); this.tableLayoutPanel3.SuspendLayout(); this.tableLayoutPanel1.SuspendLayout(); @@ -116,6 +117,7 @@ | 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.pathTextBox); this.panel1.Controls.Add(this.NetworkReadButton); this.panel1.Controls.Add(this.writeFileBtn); this.panel1.Controls.Add(this.readFileBtn); @@ -131,6 +133,16 @@ this.panel1.Size = new System.Drawing.Size(650, 128); this.panel1.TabIndex = 1; // + // NetworkReadButton + // + this.NetworkReadButton.Location = new System.Drawing.Point(188, 13); + 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); + // // writeFileBtn // this.writeFileBtn.Location = new System.Drawing.Point(102, 13); @@ -382,7 +394,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, 292F)); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 293F)); this.tableLayoutPanel1.Controls.Add(this.groupBox2, 1, 0); this.tableLayoutPanel1.Controls.Add(this.groupBox1, 0, 0); this.tableLayoutPanel1.Controls.Add(this.groupBox4, 2, 0); @@ -403,7 +415,7 @@ this.groupBox2.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.groupBox2.Location = new System.Drawing.Point(160, 3); this.groupBox2.Name = "groupBox2"; - this.groupBox2.Size = new System.Drawing.Size(147, 265); + this.groupBox2.Size = new System.Drawing.Size(146, 265); this.groupBox2.TabIndex = 28; this.groupBox2.TabStop = false; this.groupBox2.Text = "Plc"; @@ -417,7 +429,7 @@ this.TXTMsg.Multiline = true; this.TXTMsg.Name = "TXTMsg"; this.TXTMsg.ReadOnly = true; - this.TXTMsg.Size = new System.Drawing.Size(136, 238); + this.TXTMsg.Size = new System.Drawing.Size(135, 238); this.TXTMsg.TabIndex = 18; // // groupBox1 @@ -452,9 +464,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(313, 3); + this.groupBox4.Location = new System.Drawing.Point(312, 3); this.groupBox4.Name = "groupBox4"; - this.groupBox4.Size = new System.Drawing.Size(287, 265); + this.groupBox4.Size = new System.Drawing.Size(288, 265); this.groupBox4.TabIndex = 29; this.groupBox4.TabStop = false; this.groupBox4.Text = "Path"; @@ -468,7 +480,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(274, 238); + this.tabControl1.Size = new System.Drawing.Size(275, 238); this.tabControl1.TabIndex = 0; // // tabPage1 @@ -477,7 +489,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(266, 212); + this.tabPage1.Size = new System.Drawing.Size(267, 212); this.tabPage1.TabIndex = 0; this.tabPage1.Text = "Path 1"; this.tabPage1.UseVisualStyleBackColor = true; @@ -491,7 +503,7 @@ this.TXTAlm.Multiline = true; this.TXTAlm.Name = "TXTAlm"; this.TXTAlm.ReadOnly = true; - this.TXTAlm.Size = new System.Drawing.Size(254, 203); + this.TXTAlm.Size = new System.Drawing.Size(255, 203); this.TXTAlm.TabIndex = 18; // // groupBox3 @@ -705,15 +717,12 @@ this.Error.Size = new System.Drawing.Size(462, 20); this.Error.TabIndex = 27; // - // NetworkReadButton + // pathTextBox // - 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); + this.pathTextBox.Location = new System.Drawing.Point(19, 51); + this.pathTextBox.Name = "pathTextBox"; + this.pathTextBox.Size = new System.Drawing.Size(244, 20); + this.pathTextBox.TabIndex = 10; // // Form1 // @@ -811,6 +820,7 @@ private System.Windows.Forms.Button writeFileBtn; private System.Windows.Forms.Button readFileBtn; private System.Windows.Forms.Button NetworkReadButton; + private System.Windows.Forms.TextBox pathTextBox; } } diff --git a/CMS_CORE_Application/Form1.cs b/CMS_CORE_Application/Form1.cs index 98ebbf6..0f6b34c 100644 --- a/CMS_CORE_Application/Form1.cs +++ b/CMS_CORE_Application/Form1.cs @@ -208,10 +208,10 @@ namespace CMS_CORE_Application error = true; SetError(Lines, cmsError); } - N.TOOLS_WStartEditData(); - cmsError = N.TOOLS_WStartEditTooling(1); - cmsError = N.TOOLS_WRestoreBackup(); - cmsError = N.FILES_CopyProgram("C:\\TO_INI.INI", @"test\\OEM\\CMS\\SYS\\STEP\\testLocal", true); + // N.TOOLS_WStartEditData(); + // cmsError = N.TOOLS_WStartEditTooling(1); + // cmsError = N.TOOLS_WRestoreBackup(); + // cmsError = N.FILES_CopyProgram("C:\\TO_INI.INI", @"test\\OEM\\CMS\\SYS\\STEP\\testLocal", true); //cmsError = N.TOOLS_WStopEditTooling(1); // cmsError = N.TOOLS_WAddShank(ref newShank); // List a = new List() ; @@ -473,7 +473,8 @@ namespace CMS_CORE_Application { TXTip.Enabled = true; TXTport.Enabled = true; - TXTip.Text = "192.168.157.2"; + TXTip.Text = "192.168.139.1"; + // TXTip.Text = "192.168.157.2"; TXTport.Text = "8080"; } else if (NcCombo.SelectedItem.ToString().Equals("Demo")) @@ -534,11 +535,16 @@ namespace CMS_CORE_Application { using (FileStream fileStream = new FileStream("C:\\test.csv", FileMode.OpenOrCreate)) { - CmsError cms = N.FILES_RProgramToFile(@"test\\OEM\\CMS\\SYS\\STEP\\Tools.csv", fileStream); + CmsError cms = N.FILES_RProgramToFile(pathTextBox.Text, fileStream); if (cms.IsError()) { MessageBox.Show(cms.localizationKey); } + else + { + string text = File.ReadAllText("C:\\test.csv"); + MessageBox.Show(text); + } } } diff --git a/CMS_CORE_Library/DataStructures.cs b/CMS_CORE_Library/DataStructures.cs index 82b9a9c..1ef0a95 100644 --- a/CMS_CORE_Library/DataStructures.cs +++ b/CMS_CORE_Library/DataStructures.cs @@ -703,21 +703,23 @@ namespace CMS_CORE_Library { public ushort Id { get; set; } - public ushort OffsetLength { get; set; } - - public ushort ResidualLife { get; set; } - - public ushort ResidualRevive { get; set; } - public int FamilyId { get; set; } public int ShankId { get; set; } + public byte Status { get; set; } + + public ushort OffsetLength { get; set; } + + public ushort ResidualLife { get; set; } + public int OffsetId1 { get; set; } public int OffsetId2 { get; set; } public int OffsetId3 { get; set; } + + public ushort ResidualRevive { get; set; } } public class NcShankModel diff --git a/CMS_CORE_Library/Osai/Nc_Osai.cs b/CMS_CORE_Library/Osai/Nc_Osai.cs index 9c18976..d07ac64 100644 --- a/CMS_CORE_Library/Osai/Nc_Osai.cs +++ b/CMS_CORE_Library/Osai/Nc_Osai.cs @@ -37,7 +37,7 @@ namespace CMS_CORE.Osai private BasicHttpBinding HttpBinding; private static Dictionary PlcMessages; - private const string TOOL_MANAGER_DIRECTORY_PATH = @"test\\OEM\\CMS\\SYS\\STEP\\"; + private const string TOOL_MANAGER_DIRECTORY_PATH = @"TEST\\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"; @@ -2136,6 +2136,7 @@ namespace CMS_CORE.Osai CmsError cmsError = CheckConnection(); if (cmsError.IsError()) return cmsError; + ushort status = 0; // Read tool manager status cmsError = MEM_RWWord(R, 0, TOOL_MANAGER_STATUS.MemType, TOOL_MANAGER_STATUS.Address, ref status); @@ -2156,21 +2157,14 @@ namespace CMS_CORE.Osai if (cmsError.IsError()) return cmsError; - try - { - Stopwatch sw = new Stopwatch(); - sw.Start(); + Stopwatch sw = new Stopwatch(); + sw.Start(); - cmsError = CreateBackup(); - if (cmsError.IsError()) - return cmsError; + cmsError = CreateBackup(); + if (cmsError.IsError()) + return cmsError; - Console.WriteLine("Backup" + sw.ElapsedMilliseconds); - } - catch (Exception ex) - { - return ManageException(ex); - } + Console.WriteLine("Backup" + sw.ElapsedMilliseconds); return NO_ERROR; } @@ -2182,24 +2176,17 @@ namespace CMS_CORE.Osai if (cmsError.IsError()) return cmsError; - try - { - // Write busy tool manager status - bool write = true; - cmsError = MEM_RWBoolean(W, 0, TOOL_MANAGER_COMMAND.MemType, TOOL_MANAGER_COMMAND.Address, 0, ref write); - if (cmsError.IsError()) - return cmsError; + // Set reload command to 1 + bool write = true; + cmsError = MEM_RWBoolean(W, 0, TOOL_MANAGER_COMMAND.MemType, TOOL_MANAGER_COMMAND.Address, 0, ref write); + if (cmsError.IsError()) + return cmsError; - cmsError = DeleteBackup(); - if (cmsError.IsError()) - return cmsError; + cmsError = DeleteBackup(); + if (cmsError.IsError()) + return cmsError; - return NO_ERROR; - } - catch (Exception ex) - { - return ManageException(ex); - } + return NO_ERROR; } public override CmsError TOOLS_WStartEditTooling(int magazineId) @@ -2209,31 +2196,25 @@ namespace CMS_CORE.Osai if (cmsError.IsError()) return cmsError; - bool status = false; // Read tool manager status + bool status = false; cmsError = MEM_RWBoolean(R, 0, MAGAZINES_ENABLED_COMMAND.MemType, MAGAZINES_ENABLED_COMMAND.Address, magazineId - 1, ref status); if (cmsError.IsError()) return cmsError; - + // If magazine is busy if (!status) return MAGAZINE_BUSY_ERROR; - // Write busy + // Write busy bool write = true; cmsError = MEM_RWBoolean(W, 0, MAGAZINES_TOOLING_COMMAND.MemType, MAGAZINES_TOOLING_COMMAND.Address, magazineId - 1, ref write); if (cmsError.IsError()) return cmsError; - try - { - cmsError = CreateBackup(); - if (cmsError.IsError()) - return cmsError; - } - catch (Exception ex) - { - return ManageException(ex); - } + // Create backup files + cmsError = CreateBackup(); + if (cmsError.IsError()) + return cmsError; return NO_ERROR; } @@ -2245,56 +2226,49 @@ namespace CMS_CORE.Osai if (cmsError.IsError()) return cmsError; - // Write busy + // Write busy bool write = false; cmsError = MEM_RWBoolean(W, 0, MAGAZINES_TOOLING_COMMAND.MemType, MAGAZINES_TOOLING_COMMAND.Address, magazineId - 1, ref write); if (cmsError.IsError()) return cmsError; - try - { - cmsError = DeleteBackup(); - if(cmsError.IsError()) - return cmsError; - } - catch (Exception ex) - { - return ManageException(ex); - } + // Delete backup files + cmsError = DeleteBackup(); + if (cmsError.IsError()) + return cmsError; + + // Set reload command to 1 + write = true; + cmsError = MEM_RWBoolean(W, 0, TOOL_MANAGER_COMMAND.MemType, TOOL_MANAGER_COMMAND.Address, 0, ref write); + if (cmsError.IsError()) + return cmsError; return NO_ERROR; } private CmsError CreateBackup() { - try - { - string filePath = TOOL_MANAGER_DIRECTORY_PATH + "{0}.csv"; - string backupFilePath = TOOL_MANAGER_DIRECTORY_PATH + "{0}_bak.csv"; + string filePath = TOOL_MANAGER_DIRECTORY_PATH + "{0}.csv"; + string backupFilePath = TOOL_MANAGER_DIRECTORY_PATH + "{0}_bak.csv"; - // Create tool manager backup file - CmsError cmsError = FILES_CopyProgram(string.Format(filePath, FAMILIES_FILE_NAME), string.Format(backupFilePath, FAMILIES_FILE_NAME), false); - if (cmsError.IsError()) - return cmsError; + // Create tool manager backup file + CmsError 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, 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, 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, SHANKS_FILE_NAME), string.Format(backupFilePath, SHANKS_FILE_NAME), false); + if (cmsError.IsError()) + return cmsError; - return FILES_CopyProgram(string.Format(filePath, TOOLS_FILE_NAME), string.Format(backupFilePath, TOOLS_FILE_NAME), false); - } - catch (Exception ex) - { - return ManageException(ex); - } + return FILES_CopyProgram(string.Format(filePath, TOOLS_FILE_NAME), string.Format(backupFilePath, TOOLS_FILE_NAME), false); } private CmsError DeleteBackup() @@ -2302,8 +2276,8 @@ namespace CMS_CORE.Osai try { string backupFilePath = "{0}_bak.csv"; - - // Delete tool manager backup file + + // Delete tool manager backup file CmsError cmsError = FILES_DeleteProgram(TOOL_MANAGER_DIRECTORY_PATH, string.Format(backupFilePath, FAMILIES_FILE_NAME)); if (cmsError.IsError()) return cmsError; @@ -2319,7 +2293,7 @@ namespace CMS_CORE.Osai cmsError = FILES_DeleteProgram(TOOL_MANAGER_DIRECTORY_PATH, string.Format(backupFilePath, SHANKS_FILE_NAME)); if (cmsError.IsError()) return cmsError; - + return FILES_DeleteProgram(TOOL_MANAGER_DIRECTORY_PATH, string.Format(backupFilePath, TOOLS_FILE_NAME)); } catch (Exception ex) @@ -2329,7 +2303,7 @@ namespace CMS_CORE.Osai } public override CmsError TOOLS_WRestoreBackup() - { + { //Check if the NC is Connected CmsError cmsError = CheckConnection(); if (cmsError.IsError()) @@ -2339,8 +2313,8 @@ namespace CMS_CORE.Osai string filePath = TOOL_MANAGER_DIRECTORY_PATH + "{0}.csv"; string backupFilePath = TOOL_MANAGER_DIRECTORY_PATH + "{0}_bak.csv"; - // Create tool manager backup file - cmsError = FILES_CopyProgram( string.Format(backupFilePath, FAMILIES_FILE_NAME), string.Format(filePath, FAMILIES_FILE_NAME), false); + // Create tool manager backup file + cmsError = FILES_CopyProgram(string.Format(backupFilePath, FAMILIES_FILE_NAME), string.Format(filePath, FAMILIES_FILE_NAME), false); if (cmsError.IsError()) return cmsError; // FamilySize @@ -2348,7 +2322,7 @@ namespace CMS_CORE.Osai if (cmsError.IsError()) return cmsError; // Mag positions - cmsError = FILES_CopyProgram( string.Format(backupFilePath, MAG_POSITION_FILE_NAME), string.Format(filePath, MAG_POSITION_FILE_NAME), false); + cmsError = FILES_CopyProgram(string.Format(backupFilePath, MAG_POSITION_FILE_NAME), string.Format(filePath, MAG_POSITION_FILE_NAME), false); if (cmsError.IsError()) return cmsError; // Shanks @@ -2391,14 +2365,14 @@ namespace CMS_CORE.Osai return NO_ERROR; } - + public override CmsError TOOLS_WUpdateFamilies(List families) { //Check if the NC is Connected CmsError cmsError = CheckConnection(); if (cmsError.IsError()) return cmsError; - + string filePath = TOOL_MANAGER_DIRECTORY_PATH + FAMILIES_FILE_NAME + ".csv"; try @@ -2416,7 +2390,6 @@ namespace CMS_CORE.Osai cmsError = UpdateToolManagerFile(filePath, familiesSizeData); if (cmsError.IsError()) return cmsError; - } catch (Exception ex) { @@ -2449,14 +2422,14 @@ namespace CMS_CORE.Osai return NO_ERROR; } - - public override CmsError TOOLS_WUpdateMagazinePositions(List positions) + + public override CmsError TOOLS_WUpdateMagazinePositions(List positions) { //Check if the NC is Connected CmsError cmsError = CheckConnection(); if (cmsError.IsError()) return cmsError; - + string filePath = TOOL_MANAGER_DIRECTORY_PATH + MAG_POSITION_FILE_NAME + ".csv"; try @@ -2465,7 +2438,6 @@ namespace CMS_CORE.Osai cmsError = UpdateToolManagerFile(filePath, positions); if (cmsError.IsError()) return cmsError; - } catch (Exception ex) { @@ -2484,7 +2456,7 @@ namespace CMS_CORE.Osai try { - Stopwatch sw = new Stopwatch();sw.Start(); + Stopwatch sw = new Stopwatch(); sw.Start(); List lines = new List(); @@ -2495,7 +2467,7 @@ namespace CMS_CORE.Osai // Write into local file File.WriteAllLines("C:\\test.csv", lines); - // Update file + // Update file using (FileStream fileStream = new FileStream("C:\\test.csv", FileMode.OpenOrCreate)) { // Write NcFile @@ -2535,7 +2507,7 @@ namespace CMS_CORE.Osai } return output; } - + public override CmsError TOOLS_ROffset(short offsetId, ref OffsetModel offset) { //Check if the NC is Connected diff --git a/CMS_CORE_Library/Siemens/Nc_Siemens.cs b/CMS_CORE_Library/Siemens/Nc_Siemens.cs index 725c477..a6da400 100644 --- a/CMS_CORE_Library/Siemens/Nc_Siemens.cs +++ b/CMS_CORE_Library/Siemens/Nc_Siemens.cs @@ -1,5 +1,4 @@ -using CMS_CORE.Utils; -using CMS_CORE_Library.Siemens; +using CMS_CORE_Library.Siemens; using Siemens.Sinumerik.Operate.Services; using System; using System.Collections; @@ -2888,11 +2887,12 @@ namespace CMS_CORE.Siemens { return FUNCTION_NOT_ALLOWED_ERROR; } - + public override CmsError TOOLS_WStopEditData() { return FUNCTION_NOT_ALLOWED_ERROR; } + public override CmsError TOOLS_WUpdateTools(List list) { return FUNCTION_NOT_ALLOWED_ERROR; @@ -2903,7 +2903,6 @@ namespace CMS_CORE.Siemens return FUNCTION_NOT_ALLOWED_ERROR; } - public override CmsError TOOLS_WUpdateShanks(List list) { return FUNCTION_NOT_ALLOWED_ERROR; @@ -2913,6 +2912,7 @@ namespace CMS_CORE.Siemens { return FUNCTION_NOT_ALLOWED_ERROR; } + public override CmsError TOOLS_WStartEditTooling(int magazineId) { return FUNCTION_NOT_ALLOWED_ERROR; @@ -2927,6 +2927,7 @@ namespace CMS_CORE.Siemens { return FUNCTION_NOT_ALLOWED_ERROR; } + #endregion Nc Tool Manager /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -3307,6 +3308,7 @@ namespace CMS_CORE.Siemens }; } break; + case 2: case 3: { @@ -3356,14 +3358,27 @@ namespace CMS_CORE.Siemens { // Read tool id dataSvc = new DataSvc(); - readedItem = new Item("$AC_TC_TNO"); + readedItem = new Item("/Channel/State/aTcTno"); dataSvc.Read(readedItem); toolId = Convert.ToInt32(readedItem.Value); - // Set destination indexes - destinationMagIndex = 4; - destinationPosIndex = 5; + if (magAction == MAGAZINE_ACTIONS.UNLOADING) + { + // Set source indexes + sourceMagIndex = 2; + sourcePosIndex = 3; + + // Set destination indexes + destinationMagIndex = 0; + destinationPosIndex = 1; + } + else + { + // Set destination indexes + destinationMagIndex = 4; + destinationPosIndex = 5; + } } // Read position and tool data @@ -3394,7 +3409,6 @@ namespace CMS_CORE.Siemens // IsMultitool = false // }).FirstOrDefault(); - // // If not found in the tools list, check in the multitools list // if (tool == null) // tool = MultitoolsData.Where(x => x.Id == toolId)?.Select(x => new MagazineActionToolModel