diff --git a/CMS_CORE_Library/DataStructures.cs b/CMS_CORE_Library/DataStructures.cs index 4c844e8..d9d63ea 100644 --- a/CMS_CORE_Library/DataStructures.cs +++ b/CMS_CORE_Library/DataStructures.cs @@ -199,32 +199,6 @@ namespace CMS_CORE_Library public string Status; public bool Visible; public byte Reps; - - public override bool Equals(object obj) - { - var item = obj as ProcessDataModel; - - if (item == null) - return false; - - if (Id != item.Id) - return false; - - if (Type != item.Type || - IsInAlarm != item.IsInAlarm || - PartProgramName != item.PartProgramName || - Status != item.Status || - Visible != item.Visible || - Reps != item.Reps) - return false; - - return true; - } - - public override int GetHashCode() - { - return base.GetHashCode(); - } } public struct FunctionalityModel @@ -286,10 +260,10 @@ namespace CMS_CORE_Library public byte Override; public ushort Load_Abrasive; public int ActualSpeed_Pressure; - public ushort MountedTool_Vacum; + public short MountedTool_Vacum; - public bool isActive; - public bool isSelected; + public bool IsActive; + public bool IsSelected; public bool OverrideEditable; } diff --git a/CMS_CORE_Library/Demo/Nc_Demo.cs b/CMS_CORE_Library/Demo/Nc_Demo.cs index cc51b6a..9205240 100644 --- a/CMS_CORE_Library/Demo/Nc_Demo.cs +++ b/CMS_CORE_Library/Demo/Nc_Demo.cs @@ -638,7 +638,7 @@ namespace CMS_CORE.Demo { softKeys.Add(new SoftKeysModel() { - Id = i, + Id = (uint)i + 1, Value = bits[i], Active = bits[i + offset] }); @@ -726,14 +726,17 @@ namespace CMS_CORE.Demo return INCORRECT_PARAMETERS_ERROR; heads.Clear(); + List readInts = new List(); List readValues = new List(); // Find the size of a single head int headsByte = (MEMORY_ADDRESS.HEADS_DATA.Size / HEADS_NUMBER); + double headsInts = Math.Ceiling((double)(headsByte / 4 ) + 1); // Read data for N heads - CmsError cmsError = MEM_RWByteList(R, 0, MEMORY_ADDRESS.HEADS_DATA.MemType, MEMORY_ADDRESS.HEADS_DATA.Address, 0, headsByte * number, ref readValues); + CmsError cmsError = MEM_RWIntegerList(R, 0, MEMORY_ADDRESS.HEADS_DATA.MemType, 0,MEMORY_ADDRESS.HEADS_DATA.Address, (int)headsInts * number, ref readInts); if (cmsError.IsError()) return cmsError; + readValues = readInts.SelectMany(BitConverter.GetBytes).ToList(); // Parse and format readed data for (int i = 0; i < number; i++) @@ -742,15 +745,15 @@ namespace CMS_CORE.Demo var headOffset = i * headsByte; heads.Add(new HeadDataModel() { - Id = (uint)i, + Id = (uint)i + 1, Process = readValues[headOffset], Override = readValues[headOffset + 1], - Load_Abrasive = readValues[headOffset + 2], - ActualSpeed_Pressure = BitConverter.ToInt32(readValues.ToArray(), headOffset + 3), // Int32 = 4byte - MountedTool_Vacum = BitConverter.ToUInt16(readValues.ToArray(), headOffset + 7), // Uint 16 = 2byte - isActive = (readValues[headOffset + 9] & 1) != 0, // bit 0 - isSelected = (readValues[headOffset + 9] & 2) != 0, // bit 1 - OverrideEditable = (readValues[headOffset + 9] & 4) != 0 // bit 2 + Load_Abrasive = BitConverter.ToUInt16(readValues.ToArray(), headOffset + 2), // Uint16 = 2 byte + ActualSpeed_Pressure = BitConverter.ToInt32(readValues.ToArray(), headOffset + 4), // Int32 = 4byte + MountedTool_Vacum = BitConverter.ToInt16(readValues.ToArray(), headOffset + 8), // Uint 16 = 2byte + IsActive = (readValues[headOffset + 10] & 1) != 0, // bit 0 + IsSelected = (readValues[headOffset + 10] & 2) != 0, // bit 1 + OverrideEditable = (readValues[headOffset + 10] & 4) != 0 // bit 2 }); } @@ -931,7 +934,7 @@ namespace CMS_CORE.Demo BitArray bits = new BitArray(new byte[] { bytes[0] }); //1st byte -> 0 : Proccess type (AUX-WORK), 1: Process in alarm status, 2: Run, 3: Hold, 4: Read, 5: PartProgramVisible // Populate response structure - processData.Type = bits[0] ? "WORK" : "AUX"; + processData.Type = bits[0] ? "AUX" : "WORK"; processData.IsInAlarm = bits[1]; // Choose process status @@ -1808,11 +1811,11 @@ namespace CMS_CORE.Demo internal static MEMORY_CELL ALARM_ACK = new MEMORY_CELL(MEMORY_TYPE.Demo, 201, 4); internal static MEMORY_CELL ALARM_REFRESH_STROBE = new MEMORY_CELL(MEMORY_TYPE.Demo, 205, 4); - internal static MEMORY_CELL HEADS_DATA = new MEMORY_CELL(MEMORY_TYPE.Demo, 209, 240); + internal static MEMORY_CELL HEADS_DATA = new MEMORY_CELL(MEMORY_TYPE.Demo, 209, 220); - internal static MEMORY_CELL HEADS_ACK = new MEMORY_CELL(MEMORY_TYPE.Demo, 449, 4); - internal static MEMORY_CELL HEADS_STROBE_INCREMENT = new MEMORY_CELL(MEMORY_TYPE.Demo, 453, 4); - internal static MEMORY_CELL HEADS_STROBE_DECREMENT = new MEMORY_CELL(MEMORY_TYPE.Demo, 457, 4); + internal static MEMORY_CELL HEADS_ACK = new MEMORY_CELL(MEMORY_TYPE.Demo, 429, 4); + internal static MEMORY_CELL HEADS_STROBE_INCREMENT = new MEMORY_CELL(MEMORY_TYPE.Demo, 432, 4); + internal static MEMORY_CELL HEADS_STROBE_DECREMENT = new MEMORY_CELL(MEMORY_TYPE.Demo, 436, 4); } #endregion Memory addresses diff --git a/CMS_CORE_Library/Osai/Nc_Osai.cs b/CMS_CORE_Library/Osai/Nc_Osai.cs index 9af83c1..5d2a318 100644 --- a/CMS_CORE_Library/Osai/Nc_Osai.cs +++ b/CMS_CORE_Library/Osai/Nc_Osai.cs @@ -756,9 +756,9 @@ namespace CMS_CORE.Osai Override = readValues[headOffset + 1], Load_Abrasive = BitConverter.ToUInt16(readValues.ToArray(), headOffset + 2), // Uint 16 = 2byte ActualSpeed_Pressure = BitConverter.ToInt32(readValues.ToArray(), headOffset + 4), // Int32 = 4byte - MountedTool_Vacum = BitConverter.ToUInt16(readValues.ToArray(), headOffset + 8), // Uint 16 = 2byte - isActive = (readValues[headOffset + 10] & 1) != 0, // bit 0 - isSelected = (readValues[headOffset + 10] & 2) != 0, // bit 1 + MountedTool_Vacum = BitConverter.ToInt16(readValues.ToArray(), headOffset + 8), // Uint 16 = 2byte + IsActive = (readValues[headOffset + 10] & 1) != 0, // bit 0 + IsSelected = (readValues[headOffset + 10] & 2) != 0, // bit 1 OverrideEditable = (readValues[headOffset + 10] & 4) != 0 // bit 2 }); } diff --git a/CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/CMS_Core_Nc_Demo_Application.csproj b/CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/CMS_Core_Nc_Demo_Application.csproj index b395e08..d03ecde 100644 --- a/CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/CMS_Core_Nc_Demo_Application.csproj +++ b/CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/CMS_Core_Nc_Demo_Application.csproj @@ -137,6 +137,9 @@ StartupPanel.cs + + Component + DemoApplicationForm.cs @@ -183,7 +186,9 @@ Always - + + + diff --git a/CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/Views/DemoApplicationForm.Designer.cs b/CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/Views/DemoApplicationForm.Designer.cs index 3b02a49..b07f26b 100644 --- a/CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/Views/DemoApplicationForm.Designer.cs +++ b/CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/Views/DemoApplicationForm.Designer.cs @@ -1,4 +1,6 @@ -namespace Nc_Demo_Application +using Nc_Demo_Application.Views; + +namespace Nc_Demo_Application { partial class DemoApplicationForm { @@ -31,7 +33,7 @@ System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(DemoApplicationForm)); this.serverStatusLabel = new System.Windows.Forms.Label(); this.ncDataPage = new System.Windows.Forms.TabPage(); - this.toolStrip5 = new System.Windows.Forms.ToolStrip(); + this.toolStrip5 = new ToolStripEx(); this.saveNcDataButton = new System.Windows.Forms.ToolStripButton(); this.label6 = new System.Windows.Forms.Label(); this.label5 = new System.Windows.Forms.Label(); @@ -52,7 +54,7 @@ this.NCNameLabel = new System.Windows.Forms.Label(); this.ncTabControl = new System.Windows.Forms.TabControl(); this.processPage = new System.Windows.Forms.TabPage(); - this.toolStrip1 = new System.Windows.Forms.ToolStrip(); + this.toolStrip1 = new ToolStripEx(); this.saveNcProcessData = new System.Windows.Forms.ToolStripButton(); this.ncProcessGridView = new System.Windows.Forms.DataGridView(); this.ncProcessIdColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); @@ -61,7 +63,7 @@ this.ncProcessStatusColumn = new System.Windows.Forms.DataGridViewComboBoxColumn(); this.ncProcessModeColumn = new System.Windows.Forms.DataGridViewComboBoxColumn(); this.alarms = new System.Windows.Forms.TabPage(); - this.toolStrip3 = new System.Windows.Forms.ToolStrip(); + this.toolStrip3 = new ToolStripEx(); this.saveNcAlarmsButton = new System.Windows.Forms.ToolStripButton(); this.ncAlarmsGridView = new System.Windows.Forms.DataGridView(); this.ncAlarmCodeColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); @@ -69,7 +71,7 @@ this.ncAlarmTextColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.ncAlarmIdColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.ncAxesPage = new System.Windows.Forms.TabPage(); - this.toolStrip4 = new System.Windows.Forms.ToolStrip(); + this.toolStrip4 = new ToolStripEx(); this.saveNcAxesButton = new System.Windows.Forms.ToolStripButton(); this.ncAxisGridView = new System.Windows.Forms.DataGridView(); this.axisIdColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); @@ -81,7 +83,8 @@ this.axisProcessColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.followErrorProcessColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.byteMemoryPage = new System.Windows.Forms.TabPage(); - this.toolStrip2 = new System.Windows.Forms.ToolStrip(); + this.openDoc = new System.Windows.Forms.LinkLabel(); + this.toolStrip2 = new ToolStripEx(); this.saveBinaryMemoryButton = new System.Windows.Forms.ToolStripButton(); this.addRowsBinaryMemory = new System.Windows.Forms.ToolStripButton(); this.deleteRowsBinaryMemory = new System.Windows.Forms.ToolStripButton(); @@ -93,14 +96,13 @@ this.BinaryMemoryIntegerColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.partProgramPage = new System.Windows.Forms.TabPage(); this.fileContentTextBox = new System.Windows.Forms.TextBox(); - this.toolStrip6 = new System.Windows.Forms.ToolStrip(); + this.toolStrip6 = new ToolStripEx(); this.saveFileButton = new System.Windows.Forms.ToolStripButton(); this.deleteFileButton = new System.Windows.Forms.ToolStripButton(); this.addFileButton = new System.Windows.Forms.ToolStripButton(); this.newFileNameTextBox = new System.Windows.Forms.ToolStripTextBox(); this.fileTreeView = new System.Windows.Forms.TreeView(); this.stopServer = new System.Windows.Forms.Button(); - this.openDoc = new System.Windows.Forms.LinkLabel(); this.ncDataPage.SuspendLayout(); this.toolStrip5.SuspendLayout(); this.ncTabControl.SuspendLayout(); @@ -617,6 +619,17 @@ this.byteMemoryPage.Text = "Byte Memory"; this.byteMemoryPage.UseVisualStyleBackColor = true; // + // openDoc + // + this.openDoc.AutoSize = true; + this.openDoc.Location = new System.Drawing.Point(79, 4); + this.openDoc.Name = "openDoc"; + this.openDoc.Size = new System.Drawing.Size(75, 13); + this.openDoc.TabIndex = 2; + this.openDoc.TabStop = true; + this.openDoc.Text = "Open Schema"; + this.openDoc.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.openDoc_LinkClicked); + // // toolStrip2 // this.toolStrip2.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { @@ -631,6 +644,7 @@ // // saveBinaryMemoryButton // + this.saveBinaryMemoryButton.CheckOnClick = true; this.saveBinaryMemoryButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; this.saveBinaryMemoryButton.Image = ((System.Drawing.Image)(resources.GetObject("saveBinaryMemoryButton.Image"))); this.saveBinaryMemoryButton.ImageTransparentColor = System.Drawing.Color.Magenta; @@ -809,17 +823,6 @@ this.stopServer.UseVisualStyleBackColor = true; this.stopServer.Click += new System.EventHandler(this.StopServer_Click); // - // openDoc - // - this.openDoc.AutoSize = true; - this.openDoc.Location = new System.Drawing.Point(79, 4); - this.openDoc.Name = "openDoc"; - this.openDoc.Size = new System.Drawing.Size(75, 13); - this.openDoc.TabIndex = 2; - this.openDoc.TabStop = true; - this.openDoc.Text = "Open Schema"; - this.openDoc.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.openDoc_LinkClicked); - // // DemoApplicationForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -916,7 +919,7 @@ private System.Windows.Forms.DataGridViewTextBoxColumn axisProcessColumn; private System.Windows.Forms.DataGridViewTextBoxColumn followErrorProcessColumn; private System.Windows.Forms.TabPage byteMemoryPage; - private System.Windows.Forms.ToolStrip toolStrip2; + private ToolStripEx toolStrip2; private System.Windows.Forms.ToolStripButton saveBinaryMemoryButton; private System.Windows.Forms.ToolStripButton addRowsBinaryMemory; private System.Windows.Forms.ToolStripButton deleteRowsBinaryMemory; diff --git a/CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/Views/DemoApplicationForm.cs b/CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/Views/DemoApplicationForm.cs index e9dac31..2db6547 100644 --- a/CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/Views/DemoApplicationForm.cs +++ b/CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/Views/DemoApplicationForm.cs @@ -227,11 +227,12 @@ namespace Nc_Demo_Application binaryIntegerCellValue = binaryIntegerCellValue.Remove(stringIndexToReplace, 8).Insert(stringIndexToReplace, binaryValue); // Update cell integerCell.Value = Convert.ToInt32(binaryIntegerCellValue, 2).ToString(); - } - if(e.RowIndex == 27 && (int)decimalCell.Value == 0 && !axisResetRunning) - { - axisResetRunning = true; - Task.Run(() => AxisResetProcedureAsync(binaryMemoryGridView.Rows[e.RowIndex])); + + if (e.RowIndex == 27 && (int)decimalCell.Value == 0 && !axisResetRunning) + { + axisResetRunning = true; + Task.Run(() => AxisResetProcedureAsync(binaryMemoryGridView.Rows[e.RowIndex])); + } } } } @@ -376,6 +377,9 @@ namespace Nc_Demo_Application private void DeleteFile_Click(object sender, EventArgs e) { + if (fileTreeView.SelectedNode == null) + return; + string selectedFile = fileTreeView.SelectedNode.Text; try @@ -445,4 +449,6 @@ namespace Nc_Demo_Application System.Diagnostics.Process.Start("https://docs.google.com/spreadsheets/d/17AHl_qwPTGupYdWCmFYV3ubXmJykQpy1ciSTk8AgNek/edit?usp=sharing"); } } + + } \ No newline at end of file diff --git a/CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/Views/DemoApplicationForm.resx b/CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/Views/DemoApplicationForm.resx index 5a9ff96..08462a0 100644 --- a/CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/Views/DemoApplicationForm.resx +++ b/CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/Views/DemoApplicationForm.resx @@ -120,6 +120,9 @@ 437, 56 + + 437, 56 + @@ -132,6 +135,52 @@ 542, 56 + + 647, 56 + + + 752, 56 + + + 17, 95 + + + + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAABRSURBVDhPY6AK+Pbt239S8NevX+dDtUIASJAheA4cf3j/ + EY6RxUB0zIR9mIaQYgAIwwyBaifdABAm2gBkjKyGtgYQg0cNGJQGkIOh2ikBDAwAR/4LjdUkCHIAAAAA + SUVORK5CYII= + + + + + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAABISURBVDhPY8AGvn379h8bhkoTBiDFFl0mKHg4GwCSwIax + GYANY7WNWDycDMCGsSnGhqFxgQpAEtgMgEoTBsPEAGwYKo0EGBgAMACkrMWZPQwAAAAASUVORK5CYII= + + + + + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAmSURBVDhPYxgFVADfvn37TwkGG+Dk5EQWHk4GUIKhcTEK + yAcMDABULP5BZjjimQAAAABJRU5ErkJggg== + + + + True + + + True + + + True + + + 122, 95 + + + 542, 56 + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 @@ -155,6 +204,21 @@ True + + True + + + True + + + True + + + True + + + True + 647, 56 @@ -178,6 +242,18 @@ True + + True + + + True + + + True + + + True + 752, 56 @@ -213,31 +289,30 @@ True - - 17, 95 + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True - - - iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 - YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAABRSURBVDhPY6AK+Pbt239S8NevX+dDtUIASJAheA4cf3j/ - EY6RxUB0zIR9mIaQYgAIwwyBaifdABAm2gBkjKyGtgYQg0cNGJQGkIOh2ikBDAwAR/4LjdUkCHIAAAAA - SUVORK5CYII= - - - - - iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 - YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAABISURBVDhPY8AGvn379h8bhkoTBiDFFl0mKHg4GwCSwIax - GYANY7WNWDycDMCGsSnGhqFxgQpAEtgMgEoTBsPEAGwYKo0EGBgAMACkrMWZPQwAAAAASUVORK5CYII= - - - - - iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 - YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAmSURBVDhPYxgFVADfvn37TwkGG+Dk5EQWHk4GUIKhcTEK - yAcMDABULP5BZjjimQAAAABJRU5ErkJggg== - - True diff --git a/CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/Views/ToolStripEx.cs b/CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/Views/ToolStripEx.cs new file mode 100644 index 0000000..ac911a9 --- /dev/null +++ b/CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/Views/ToolStripEx.cs @@ -0,0 +1,38 @@ +using System; +using System.Windows.Forms; + +namespace Nc_Demo_Application.Views +{ + public class ToolStripEx : ToolStrip + + { + protected override void WndProc(ref Message m) + + { + base.WndProc(ref m); + + if (m.Msg == NativeConstants.WM_MOUSEACTIVATE && m.Result == (IntPtr)NativeConstants.MA_ACTIVATEANDEAT) + { + m.Result = (IntPtr)NativeConstants.MA_ACTIVATE; + } + } + } + + internal sealed class NativeConstants + + { + private NativeConstants() + { + } + + internal const uint WM_MOUSEACTIVATE = 0x21; + + internal const uint MA_ACTIVATE = 1; + + internal const uint MA_ACTIVATEANDEAT = 2; + + internal const uint MA_NOACTIVATE = 3; + + internal const uint MA_NOACTIVATEANDEAT = 4; + } +} \ No newline at end of file