From b00ae40d2e8d3b80a7394110eabbf9bc6a25821f Mon Sep 17 00:00:00 2001 From: Lucio Maranta Date: Tue, 24 Apr 2018 16:37:04 +0000 Subject: [PATCH] Added "add" tool shank, family functions --- CMS_CORE_Application/Form1.cs | 34 + .../ToolDatabase/ToolDatabaseContext.cs | 2 +- .../ToolDatabase/ToolModels.cs | 6 +- CMS_CORE_Library/DataStructures.cs | 21 + CMS_CORE_Library/Demo/ILibraryService.cs | 22 +- CMS_CORE_Library/Demo/Models/FamilyModel.cs | 16 +- CMS_CORE_Library/Demo/Models/ToolDataModel.cs | 6 +- CMS_CORE_Library/Demo/Nc_Demo.cs | 130 +++- CMS_CORE_Library/Fanuc/Nc_Fanuc.cs | 25 + CMS_CORE_Library/Nc.cs | 10 + CMS_CORE_Library/Osai/Nc_Osai.cs | 23 + CMS_CORE_Library/Siemens/Nc_Siemens.cs | 24 + .../CMS_Core_Nc_Demo_Application.csproj | 1 + .../Database/DatabaseController.cs | 157 +++- .../Database/Models/FamilyModel.cs | 12 +- .../Properties/Resources.Designer.cs | 10 + .../Properties/Resources.resx | 10 +- .../Nc_Demo_Application/Resources/refresh.png | Bin 0 -> 378 bytes .../Server/Service/ILibraryService.cs | 14 +- .../Server/Service/LibraryService.cs | 25 +- .../Views/DemoApplicationForm.Designer.cs | 735 +++++++++--------- .../Views/DemoApplicationForm.cs | 73 +- 22 files changed, 897 insertions(+), 459 deletions(-) create mode 100644 CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/Resources/refresh.png diff --git a/CMS_CORE_Application/Form1.cs b/CMS_CORE_Application/Form1.cs index 93a48df..8f375f2 100644 --- a/CMS_CORE_Application/Form1.cs +++ b/CMS_CORE_Application/Form1.cs @@ -80,6 +80,29 @@ namespace CMS_CORE_Application ToolTableConfiguration toolsConfig = new ToolTableConfiguration(); List dataTable = new List(); List shanks = new List(); + List famiies = new List(); + List positions = new List(); + SiemensToolModel newTool = new SiemensToolModel() + { + FamilyName = "nuovo nome", + ChildId = 1, + MagazinePositionType = 1, + ToolType = 110, + LeftSize = 1, + RightSize = 1, + Rotation = (ROTATION)0, + Cooling1 = false, + Cooling2 = true, + IsActive = true, + FixedPlace = true, + IsInhibited = true, + IsMeasured = true, + ChangeTool = true, + IsInUse = false, + PreAlarm = false, + EdgesData = null + }; + byte axisId = 0; @@ -159,6 +182,17 @@ namespace CMS_CORE_Application cmsError = N.TOOLS_RToolTable(ref dataTable); cmsError = N.TOOLS_RShanksData(ref shanks); + cmsError = N.TOOLS_RFamilyData(ref famiies); + cmsError = N.TOOLS_RMagazinePositions(ref positions); + cmsError = N.TOOLS_WAddTool(ref newTool); + + ShankModel shank = new ShankModel(); + cmsError = N.TOOLS_WAddShank(ref shank); + FamilyModel family = new FamilyModel + { + Name = "Da demo" + }; + cmsError = N.TOOLS_WAddFamily(ref family); // N.PLC_WPowerOnData(6, true); //N.PLC_RFunctionAccess(ref functionality); diff --git a/CMS_CORE_Application/ToolDatabase/ToolDatabaseContext.cs b/CMS_CORE_Application/ToolDatabase/ToolDatabaseContext.cs index 49b16d6..7c72eb7 100644 --- a/CMS_CORE_Application/ToolDatabase/ToolDatabaseContext.cs +++ b/CMS_CORE_Application/ToolDatabase/ToolDatabaseContext.cs @@ -10,7 +10,7 @@ namespace CMS_CORE_Application.ToolDatabase { public DbSet Tools { get; set; } public DbSet Shanks { get; set; } - public DbSet Family { get; set; } + public DbSet Family { get; set; } public DbSet Manine { get; set; } public ToolDatabaseContext() : base("mySQLDatabaseConnection") diff --git a/CMS_CORE_Application/ToolDatabase/ToolModels.cs b/CMS_CORE_Application/ToolDatabase/ToolModels.cs index 6956e85..d8248ea 100644 --- a/CMS_CORE_Application/ToolDatabase/ToolModels.cs +++ b/CMS_CORE_Application/ToolDatabase/ToolModels.cs @@ -26,7 +26,7 @@ namespace CMS_CORE_Application.ToolDatabase [Column("family")] public int FamilyId { get; set; } [ForeignKey("FamilyId")] - public FamilyModel Family { get; set; } + public DbFamilyModel Family { get; set; } } [Table("shank")] @@ -38,13 +38,13 @@ namespace CMS_CORE_Application.ToolDatabase [Column("manina")] public int? ManinaId { get; set; } [ForeignKey("ManinaId")] - public FamilyModel Manina { get; set; } + public DbFamilyModel Manina { get; set; } [Column("tablet_id")] public int TabletId { get; set; } } [Table("family")] - public class FamilyModel + public class DbFamilyModel { [Key] [Column("id")] diff --git a/CMS_CORE_Library/DataStructures.cs b/CMS_CORE_Library/DataStructures.cs index 68428cb..a12a5a6 100644 --- a/CMS_CORE_Library/DataStructures.cs +++ b/CMS_CORE_Library/DataStructures.cs @@ -519,6 +519,27 @@ namespace CMS_CORE_Library public int Type; } + public class FamilyModel + { + public int Id; + public string Name; + public List ChildTools; + } + + public class FamilyChildModel + { + public int Id; + public int Type; + public int ChildId; + } + + public class MagazinePositionsModel + { + public int Id; + public int MagazineId; + public int Type; + } + #endregion ToolsConfig } } \ No newline at end of file diff --git a/CMS_CORE_Library/Demo/ILibraryService.cs b/CMS_CORE_Library/Demo/ILibraryService.cs index 677221f..1ae624e 100644 --- a/CMS_CORE_Library/Demo/ILibraryService.cs +++ b/CMS_CORE_Library/Demo/ILibraryService.cs @@ -4,6 +4,7 @@ using System.ServiceModel.Web; using System.Collections.Generic; using CMS_CORE.Demo.Models; using CMS_CORE_Library.Demo.Models; +using static CMS_CORE_Library.DataStructures; namespace Nc_Demo_Application.Server.Service { @@ -160,10 +161,13 @@ namespace Nc_Demo_Application.Server.Service #region Family [WebGet(UriTemplate = "tool_table/families", BodyStyle = WebMessageBodyStyle.Wrapped, ResponseFormat = WebMessageFormat.Json)] - void GetFamilies(out List families); + void GetFamilies(out List families); - [WebInvoke(Method = "PUT", UriTemplate = "tool_table/families", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped)] - void PutFamily(FamilyModel familyData); + [WebInvoke(Method = "PUT", UriTemplate = "tool_table/family", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped)] + void PutFamily(DemoFamilyModel familyData); + + [WebInvoke(Method = "POST", UriTemplate = "tool_table/family", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped)] + void AddFamily(ref FamilyModel family); #endregion @@ -172,12 +176,22 @@ namespace Nc_Demo_Application.Server.Service [WebGet(UriTemplate = "tool_table", BodyStyle = WebMessageBodyStyle.Wrapped, ResponseFormat = WebMessageFormat.Json)] void GetTools(out List toolsData); + [WebInvoke(Method = "POST", UriTemplate = "tool_table/tool", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped)] + void AddTool(ref SiemensToolModel tool); + [WebGet(UriTemplate = "tool_table/shanks", BodyStyle = WebMessageBodyStyle.Wrapped, ResponseFormat = WebMessageFormat.Json)] void GetShanks(out List shanksData); + [WebInvoke(Method = "POST", UriTemplate = "tool_table/shank", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped)] + void AddShank(out ShankModel shankData); + [WebGet(UriTemplate = "tool_table/positions", BodyStyle = WebMessageBodyStyle.Wrapped, ResponseFormat = WebMessageFormat.Json)] - void GetPositions(out List positionsData); + void GetPositions(out List positionsData); + + [WebInvoke(Method = "PUT", UriTemplate = "tool_table/position", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped)] + void PutPosition(DemoPositionsModel position); #endregion + } } diff --git a/CMS_CORE_Library/Demo/Models/FamilyModel.cs b/CMS_CORE_Library/Demo/Models/FamilyModel.cs index 0d7a566..4f28c61 100644 --- a/CMS_CORE_Library/Demo/Models/FamilyModel.cs +++ b/CMS_CORE_Library/Demo/Models/FamilyModel.cs @@ -2,17 +2,17 @@ namespace CMS_CORE.Demo.Models { - public class FamilyModel + public class DemoFamilyModel { - public int id; - public string name; - public List childTools; + public int Id; + public string Name; + public List ChildTools; } - public class ChildTool + public class DemoChildTool { - public int id; - public int type; - public int childId; + public int Id; + public int Type; + public int ChildId; } } \ No newline at end of file diff --git a/CMS_CORE_Library/Demo/Models/ToolDataModel.cs b/CMS_CORE_Library/Demo/Models/ToolDataModel.cs index 7420aad..e3667e1 100644 --- a/CMS_CORE_Library/Demo/Models/ToolDataModel.cs +++ b/CMS_CORE_Library/Demo/Models/ToolDataModel.cs @@ -29,10 +29,10 @@ namespace CMS_CORE.Demo.Models public class ShankDataModel { public int Id; - public List childsTools; + public List childsTools; } - public class ShankChildDataModel + public class DemoShankChildModel { public int ToolId; public int ChildId; @@ -40,7 +40,7 @@ namespace CMS_CORE.Demo.Models public int Type; } - public class PositionsDataModel + public class DemoPositionsModel { public int Id; public int MagazineId; diff --git a/CMS_CORE_Library/Demo/Nc_Demo.cs b/CMS_CORE_Library/Demo/Nc_Demo.cs index 9409431..faf42f6 100644 --- a/CMS_CORE_Library/Demo/Nc_Demo.cs +++ b/CMS_CORE_Library/Demo/Nc_Demo.cs @@ -1767,7 +1767,7 @@ namespace CMS_CORE.Demo } } - public override CmsError TOOLS_RShanksData(ref List shanksData) + public override CmsError TOOLS_WAddTool(ref SiemensToolModel tool) { // Check if the NC Demo is Connected CmsError cmsError = CheckConnection(); @@ -1776,13 +1776,32 @@ namespace CMS_CORE.Demo try { - shanksData = new List(); + serverService.AddTool(ref tool); + + return NO_ERROR; + } + catch (Exception ex) + { + return ManageException(ex); + } + } + + public override CmsError TOOLS_RShanksData(ref List shanks) + { + // Check if the NC Demo is Connected + CmsError cmsError = CheckConnection(); + if (cmsError.IsError()) + return cmsError; + + try + { + shanks = new List(); // Get tool table data serverService.GetShanks(out List demoShanksData); foreach (ShankDataModel shank in demoShanksData) { - shanksData.Add(new ShankModel() + shanks.Add(new ShankModel() { Id = shank.Id, childsTools = shank.childsTools.Select(x => new ShankChildModel() @@ -1803,6 +1822,111 @@ namespace CMS_CORE.Demo } } + public override CmsError TOOLS_WAddShank(ref ShankModel shank) + { + // Check if the NC Demo is Connected + CmsError cmsError = CheckConnection(); + if (cmsError.IsError()) + return cmsError; + + try + { + serverService.AddShank(out shank); + + return NO_ERROR; + } + catch (Exception ex) + { + return ManageException(ex); + } + } + + public override CmsError TOOLS_RFamilyData(ref List families) + { + // Check if the NC Demo is Connected + CmsError cmsError = CheckConnection(); + if (cmsError.IsError()) + return cmsError; + families = new List(); + try + { + // Get families data + serverService.GetFamilies(out List demoFamilies); + // Populate output model + foreach (DemoFamilyModel family in demoFamilies) + { + families.Add(new FamilyModel() + { + Id = family.Id, + Name = family.Name, + ChildTools = family.ChildTools.Select(x => new FamilyChildModel() + { + Id = x.Id, + ChildId = x.ChildId, + Type = x.Type + }).ToList() + }); + } + + return NO_ERROR; + } + catch (Exception ex) + { + return ManageException(ex); + } + } + + + public override CmsError TOOLS_WAddFamily(ref FamilyModel family) + { + // Check if the NC Demo is Connected + CmsError cmsError = CheckConnection(); + if (cmsError.IsError()) + return cmsError; + + try + { + serverService.AddFamily(ref family); + + return NO_ERROR; + } + catch (Exception ex) + { + return ManageException(ex); + } + } + + public override CmsError TOOLS_RMagazinePositions(ref List positions) + { + // Check if the NC Demo is Connected + CmsError cmsError = CheckConnection(); + if (cmsError.IsError()) + return cmsError; + + positions = new List(); + try + { + // Get position data from demo + serverService.GetPositions(out List demoPositions); + // Populate output model + foreach (DemoPositionsModel position in demoPositions) + { + positions.Add(new MagazinePositionsModel() + { + Id = position.Id, + MagazineId = position.MagazineId, + Type = position.Type + }); + } + + return NO_ERROR; + } + catch (Exception ex) + { + return ManageException(ex); + } + } + #endregion Tools Management /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/CMS_CORE_Library/Fanuc/Nc_Fanuc.cs b/CMS_CORE_Library/Fanuc/Nc_Fanuc.cs index bf74ffc..9b259da 100644 --- a/CMS_CORE_Library/Fanuc/Nc_Fanuc.cs +++ b/CMS_CORE_Library/Fanuc/Nc_Fanuc.cs @@ -1680,6 +1680,31 @@ namespace CMS_CORE.Fanuc return NO_ERROR; } + public override CmsError TOOLS_RFamilyData(ref List families) + { + return NO_ERROR; + } + + public override CmsError TOOLS_RMagazinePositions(ref List positions) + { + return NO_ERROR; + } + + public override CmsError TOOLS_WAddTool(ref SiemensToolModel tool) + { + return NO_ERROR; + } + + public override CmsError TOOLS_WAddFamily(ref FamilyModel family) + { + return NO_ERROR; + } + + public override CmsError TOOLS_WAddShank(ref ShankModel shank) + { + return NO_ERROR; + } + #endregion Tools Management /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/CMS_CORE_Library/Nc.cs b/CMS_CORE_Library/Nc.cs index d7cf227..79da1d6 100644 --- a/CMS_CORE_Library/Nc.cs +++ b/CMS_CORE_Library/Nc.cs @@ -1305,6 +1305,16 @@ namespace CMS_CORE public abstract CmsError TOOLS_RShanksData(ref List shanksData); + public abstract CmsError TOOLS_RFamilyData(ref List families); + + public abstract CmsError TOOLS_RMagazinePositions(ref List positions); + + public abstract CmsError TOOLS_WAddTool(ref SiemensToolModel tool); + + public abstract CmsError TOOLS_WAddFamily(ref FamilyModel family); + + public abstract CmsError TOOLS_WAddShank(ref ShankModel shank); + #endregion File Management (To override) /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/CMS_CORE_Library/Osai/Nc_Osai.cs b/CMS_CORE_Library/Osai/Nc_Osai.cs index e1663b9..9240866 100644 --- a/CMS_CORE_Library/Osai/Nc_Osai.cs +++ b/CMS_CORE_Library/Osai/Nc_Osai.cs @@ -2050,7 +2050,30 @@ namespace CMS_CORE.Osai return NO_ERROR; } + public override CmsError TOOLS_RFamilyData(ref List families) + { + return NO_ERROR; + } + public override CmsError TOOLS_RMagazinePositions(ref List positions) + { + return NO_ERROR; + } + + public override CmsError TOOLS_WAddTool(ref SiemensToolModel tool) + { + return NO_ERROR; + } + + public override CmsError TOOLS_WAddFamily(ref FamilyModel family) + { + return NO_ERROR; + } + + public override CmsError TOOLS_WAddShank(ref ShankModel shank) + { + return NO_ERROR; + } #endregion Tools Management /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/CMS_CORE_Library/Siemens/Nc_Siemens.cs b/CMS_CORE_Library/Siemens/Nc_Siemens.cs index e4ece4c..aa727b3 100644 --- a/CMS_CORE_Library/Siemens/Nc_Siemens.cs +++ b/CMS_CORE_Library/Siemens/Nc_Siemens.cs @@ -1871,6 +1871,30 @@ namespace CMS_CORE.Siemens return NO_ERROR; } + public override CmsError TOOLS_RFamilyData(ref List families) + { + return NO_ERROR; + } + + public override CmsError TOOLS_RMagazinePositions(ref List positions) + { + return NO_ERROR; + } + + public override CmsError TOOLS_WAddTool(ref SiemensToolModel tool) + { + return NO_ERROR; + } + + public override CmsError TOOLS_WAddFamily(ref FamilyModel family) + { + return NO_ERROR; + } + + public override CmsError TOOLS_WAddShank(ref ShankModel shank) + { + return NO_ERROR; + } #endregion Tool Management 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 afed6e3..4402eb7 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 @@ -184,6 +184,7 @@ + Always diff --git a/CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/Database/DatabaseController.cs b/CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/Database/DatabaseController.cs index 73aedd1..12dbb8b 100644 --- a/CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/Database/DatabaseController.cs +++ b/CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/Database/DatabaseController.cs @@ -25,7 +25,7 @@ namespace Nc_Demo_Application.Database private DataTable ToolsDataTable; private DataTable FamiliesDataTable; private DataTable ShanksDataTable; - private DataTable MagazinesDataTable; + private DataTable MagazinesPositionDataTable; #region Constructor & Private functions @@ -39,7 +39,7 @@ namespace Nc_Demo_Application.Database FamiliesDataTable = new DataTable(); ToolsDataTable = new DataTable(); ShanksDataTable = new DataTable(); - MagazinesDataTable = new DataTable(); + MagazinesPositionDataTable = new DataTable(); NcProcessDataTable = new DataTable(); BinaryMemory = new DataTable(); @@ -79,7 +79,7 @@ namespace Nc_Demo_Application.Database ToolsDataTable.Dispose(); FamiliesDataTable.Dispose(); ShanksDataTable.Dispose(); - MagazinesDataTable.Dispose(); + MagazinesPositionDataTable.Dispose(); sqlConnection.Close(); } @@ -582,22 +582,23 @@ namespace Nc_Demo_Application.Database lastId = Convert.ToInt32(row["id"]); string name = row["name"].ToString(); - List childTools = GetToolsData() + List childTools = new List(); + childTools = GetToolsData() .Where(x => x.FamilyName == name) .Select(x => new ChildTool() { - id = x.Id, - childId = x.ChildId, - type = x.ToolType + Id = x.Id, + ChildId = x.ChildId, + Type = x.ToolType }) .ToList(); // Convert DataTable.row into family model FamilyModel tmpFamily = new FamilyModel { - id = lastId, - name = name, - //childTools = childTools + Id = lastId, + Name = name, + ChildTools = childTools }; Family.Add(tmpFamily); @@ -613,13 +614,54 @@ namespace Nc_Demo_Application.Database public void UpdateFamily(FamilyModel familyData) { - DataRow row = FamiliesDataTable.AsEnumerable().SingleOrDefault(x => Convert.ToInt32(x["id"]) == familyData.id); + DataRow row = FamiliesDataTable.AsEnumerable().SingleOrDefault(x => Convert.ToInt32(x["id"]) == familyData.Id); - row["name"] = familyData.name; + row["name"] = familyData.Name; UpdateFamilies(FamiliesDataTable); } + public FamilyModel AddFamily(FamilyModel family) + { + try + { + SetConnection(); + + // Open the connection with database + sqlConnection.Open(); + // Create a SQLite command with query, adapter and commandbuilder in order to update. + sqlCommand = new SQLiteCommand(READ_FAMILIES_QUERY, sqlConnection); + SQLiteDataAdapter adapter = new SQLiteDataAdapter(sqlCommand); + SQLiteCommandBuilder commandBuilder = new SQLiteCommandBuilder(adapter); + + // Create new row that must be inserted + DataRow row = FamiliesDataTable.NewRow(); + int id = Convert.ToInt32(FamiliesDataTable.Rows[FamiliesDataTable.Rows.Count - 1]["id"]) + 1; + family.Id = id; + family.ChildTools = new List(); + + // Setup autoincrement Id + row["id"] = id; + row["name"] = family.Name; + + // Add the new row + FamiliesDataTable.Rows.Add(row); + + // Update database + adapter.Update(FamiliesDataTable); + + // Close the connection with database + sqlConnection.Close(); + + return family; + } + catch (Exception ex) + { + Console.WriteLine("Add family exception: " + ex.Message); + return null; + } + } + #endregion Families #region Shanks @@ -657,7 +699,7 @@ namespace Nc_Demo_Application.Database { ToolId = x.Id, Type = x.ToolType, - FamilyName = x.FamilyName, + FamilyName = x.FamilyName, ChildId = i++ }) .ToList(); @@ -680,6 +722,48 @@ namespace Nc_Demo_Application.Database UpdateDatabaseFromGridView(shanks, READ_SHANKS_QUERY); } + public ShankDataModel AddShank() + { + try + { + SetConnection(); + + // Open the connection with database + sqlConnection.Open(); + // Create a SQLite command with query, adapter and commandbuilder in order to update. + sqlCommand = new SQLiteCommand(READ_SHANKS_QUERY, sqlConnection); + SQLiteDataAdapter adapter = new SQLiteDataAdapter(sqlCommand); + SQLiteCommandBuilder commandBuilder = new SQLiteCommandBuilder(adapter); + + // Create new row that must be inserted + DataRow row = ShanksDataTable.NewRow(); + int id = Convert.ToInt32(ShanksDataTable.Rows[ShanksDataTable.Rows.Count - 1]["id"]) + 1; + + // Setup autoincrement Id + row["id"] = id; + + // Add the new row + ShanksDataTable.Rows.Add(row); + + // Update database + adapter.Update(ShanksDataTable); + + // Close the connection with database + sqlConnection.Close(); + + return new ShankDataModel() + { + Id = id, + childsTools = new List() + }; + } + catch (Exception ex) + { + Console.WriteLine("Add shanks exception: " + ex.Message); + return null; + } + } + #endregion Shanks #region Tools @@ -735,7 +819,7 @@ namespace Nc_Demo_Application.Database return toolsDataModel; } - public void AddToolToDatabase(ref ToolsDataModel toolData) + public ToolsDataModel AddToolToDatabase(ToolsDataModel toolData) { try { @@ -749,15 +833,26 @@ namespace Nc_Demo_Application.Database SQLiteCommandBuilder commandBuilder = new SQLiteCommandBuilder(adapter); // Create new row that must be inserted - // DataRow row = ToolsDataTable.AsEnumerable().SingleOrDefault(x => Convert.ToInt32(x["id"]) == toolData.Id); DataRow row = ToolsDataTable.NewRow(); + // Find & set new item Id toolData.Id = Convert.ToInt32(ToolsDataTable.Rows[ToolsDataTable.Rows.Count - 1]["id"]) + 1; + + var family = toolData.FamilyName; + // Find next child id + var childs = ToolsDataTable.AsEnumerable() + .Where(x => x["family"].ToString() == family)? + .Select(x => Convert.ToInt32(x["childId"])).ToList(); + + int newChildId = 1; + if (childs.Count != 0) + newChildId = childs.Max() + 1; + toolData.ChildId = newChildId; // Setup autoincrement Id row["id"] = toolData.Id; row["family"] = toolData.FamilyName; row["magazine"] = toolData.MagazineId; - row["childId"] = toolData.ChildId; + row["childId"] = newChildId; row["magazinePositionType"] = toolData.MagazinePositionType; row["toolType"] = toolData.ToolType; row["sizeLeft"] = toolData.LeftSize; @@ -772,6 +867,7 @@ namespace Nc_Demo_Application.Database row["changeTool"] = toolData.ChangeTool; row["isInUse"] = toolData.IsInUse; row["preAlarm"] = toolData.PreAlarm; + row["shankId"] = toolData.ShanksId; // Add the new row ToolsDataTable.Rows.Add(row); @@ -781,10 +877,13 @@ namespace Nc_Demo_Application.Database // Close the connection with database sqlConnection.Close(); + + return toolData; } catch (Exception ex) { Console.WriteLine("Add tool exception: " + ex.Message); + return null; } } @@ -872,9 +971,9 @@ namespace Nc_Demo_Application.Database { try { - ReadDataFromDatabase(READ_MAGAZINES_QUERY, ref MagazinesDataTable); + ReadDataFromDatabase(READ_MAGAZINES_QUERY, ref MagazinesPositionDataTable); - return MagazinesDataTable; + return MagazinesPositionDataTable; } catch (Exception ex) { @@ -891,10 +990,9 @@ namespace Nc_Demo_Application.Database public List GetPositions() { List positions = new List(); - foreach (DataRow row in MagazinesDataTable.Rows) + foreach (DataRow row in MagazinesPositionDataTable.Rows) { - - // Convert DataTable.row into family model + // Convert DataTable.row into positions model PositionsDataModel tmpPositions = new PositionsDataModel { Id = Convert.ToInt32(row["positionId"]), @@ -908,6 +1006,23 @@ namespace Nc_Demo_Application.Database return positions; } + public void UpdatePosition(PositionsDataModel position) + { + // Find position to be updated + DataRow row = MagazinesPositionDataTable + .AsEnumerable() + .SingleOrDefault(x => Convert.ToInt32(x["positionId"]) == position.Id && Convert.ToInt32(x["magazineId"]) == position.MagazineId); + + // Update positions type + row["type"] = position.Type; + // Save + UpdatePositions(MagazinesPositionDataTable); + } + + public void UpdatePositions(DataTable positions) + { + UpdateDatabaseFromGridView(positions, READ_MAGAZINES_QUERY); + } #endregion Magazines } } \ No newline at end of file diff --git a/CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/Database/Models/FamilyModel.cs b/CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/Database/Models/FamilyModel.cs index e6c5c6a..c430b8c 100644 --- a/CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/Database/Models/FamilyModel.cs +++ b/CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/Database/Models/FamilyModel.cs @@ -8,15 +8,15 @@ namespace Nc_Demo_Application.Database.Models { public class FamilyModel { - public int id; - public string name; - public List childTools; + public int Id; + public string Name; + public List ChildTools; } public class ChildTool { - public int id; - public int type; - public int childId; + public int Id; + public int Type; + public int ChildId; } } diff --git a/CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/Properties/Resources.Designer.cs b/CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/Properties/Resources.Designer.cs index d447c77..8f3889c 100644 --- a/CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/Properties/Resources.Designer.cs +++ b/CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/Properties/Resources.Designer.cs @@ -70,6 +70,16 @@ namespace Nc_Demo_Application.Properties { } } + /// + /// Cerca una risorsa localizzata di tipo System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap refresh { + get { + object obj = ResourceManager.GetObject("refresh", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + /// /// Cerca una risorsa localizzata di tipo System.Drawing.Bitmap. /// diff --git a/CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/Properties/Resources.resx b/CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/Properties/Resources.resx index e998711..5eba359 100644 --- a/CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/Properties/Resources.resx +++ b/CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/Properties/Resources.resx @@ -121,21 +121,25 @@ iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 - YQUAAAAJcEhZcwAADsIAAA7CARUoSoAAAABISURBVDhPY8AGvn379h8bhkoTBiDFFl0mKHg4GwCSwIax + YQUAAAAJcEhZcwAADsEAAA7BAbiRa+0AAABISURBVDhPY8AGvn379h8bhkoTBiDFFl0mKHg4GwCSwIax GYANY7WNWDycDMCGsSnGhqFxgQpAEtgMgEoTBsPEAGwYKo0EGBgAMACkrMWZPQwAAAAASUVORK5CYII= + + + ..\Resources\refresh.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 - YQUAAAAJcEhZcwAADsIAAA7CARUoSoAAAAAmSURBVDhPYxgFVADfvn37TwkGG+Dk5EQWHk4GUIKhcTEK + YQUAAAAJcEhZcwAADsEAAA7BAbiRa+0AAAAmSURBVDhPYxgFVADfvn37TwkGG+Dk5EQWHk4GUIKhcTEK yAcMDABULP5BZjjimQAAAABJRU5ErkJggg== iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 - YQUAAAAJcEhZcwAADsIAAA7CARUoSoAAAABRSURBVDhPY6AK+Pbt239S8NevX+dDtUIASJAheA4cf3j/ + YQUAAAAJcEhZcwAADsEAAA7BAbiRa+0AAABRSURBVDhPY6AK+Pbt239S8NevX+dDtUIASJAheA4cf3j/ EY6RxUB0zIR9mIaQYgAIwwyBaifdABAm2gBkjKyGtgYQg0cNGJQGkIOh2ikBDAwAR/4LjdUkCHIAAAAA SUVORK5CYII= diff --git a/CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/Resources/refresh.png b/CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/Resources/refresh.png new file mode 100644 index 0000000000000000000000000000000000000000..a214ed9867acaedf28633513d4dd332666b1e981 GIT binary patch literal 378 zcmV-=0fqjFP)wv>3qWhliRxC_sTTky^+8|4_u3RF?SL>}RNQJ{)<|FjzOIK>mb>I7;}veg*Ic?`M4CYGBBd}236_$?l> z(9l;Oeu2rX!{IE3k2LA4;tne*f?+O(G=6!FZ49Iehht&SbK^lca7k#TX2+vMZUTf0 zr(M?Yk%hoBraBOq7A~u<1+K8sfxvp4+cmTJ#$p?D%0lUuvJik1ykNA2v153}VOHTV zgq!%{r9Z}%@rG**W+_mUIP&|)+YwIsYHU}8tvW~%UQY@8xEIRoBewT2lQOuVprAMT Y0V2LXKUwY73jhEB07*qoM6N<$f@zbVqW}N^ literal 0 HcmV?d00001 diff --git a/CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/Server/Service/ILibraryService.cs b/CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/Server/Service/ILibraryService.cs index 080faad..321ced4 100644 --- a/CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/Server/Service/ILibraryService.cs +++ b/CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/Server/Service/ILibraryService.cs @@ -166,9 +166,12 @@ namespace Nc_Demo_Application.Server.Service [WebGet(UriTemplate = "tool_table/families", BodyStyle = WebMessageBodyStyle.Wrapped, ResponseFormat = WebMessageFormat.Json)] void GetFamilies(out List families); - [WebInvoke(Method = "PUT", UriTemplate = "tool_table/families", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped)] + [WebInvoke(Method = "PUT", UriTemplate = "tool_table/family", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped)] void PutFamily(FamilyModel familyData); + [WebInvoke(Method = "POST", UriTemplate = "tool_table/family", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped)] + void AddFamily(ref FamilyModel family); + #endregion #region Tools @@ -176,12 +179,21 @@ namespace Nc_Demo_Application.Server.Service [WebGet(UriTemplate = "tool_table", BodyStyle = WebMessageBodyStyle.Wrapped, ResponseFormat = WebMessageFormat.Json)] void GetTools(out List toolsData); + [WebInvoke(Method = "POST", UriTemplate = "tool_table/tool", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped)] + void AddTool(ref ToolsDataModel tool); + [WebGet(UriTemplate = "tool_table/shanks", BodyStyle = WebMessageBodyStyle.Wrapped, ResponseFormat = WebMessageFormat.Json)] void GetShanks(out List shanksData); + [WebInvoke(Method = "POST", UriTemplate = "tool_table/shank", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped)] + void AddShank(out ShankDataModel shankData); + [WebGet(UriTemplate = "tool_table/positions", BodyStyle = WebMessageBodyStyle.Wrapped, ResponseFormat = WebMessageFormat.Json)] void GetPositions(out List positionsData); + [WebInvoke(Method = "PUT", UriTemplate = "tool_table/position", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped)] + void PutPosition(PositionsDataModel position); + #endregion } } diff --git a/CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/Server/Service/LibraryService.cs b/CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/Server/Service/LibraryService.cs index 4eb3a5f..b11f837 100644 --- a/CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/Server/Service/LibraryService.cs +++ b/CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/Server/Service/LibraryService.cs @@ -452,7 +452,6 @@ namespace Nc_Demo_Application.Server.Service .ToDictionary(y => i++, y => y[0]); } - #endregion File Management #region Family @@ -467,7 +466,12 @@ namespace Nc_Demo_Application.Server.Service DatabaseController.getInstance().UpdateFamily(familyData); } - #endregion + public void AddFamily(ref FamilyModel family) + { + family = DatabaseController.getInstance().AddFamily(family); + } + + #endregion Family #region Tools @@ -476,16 +480,31 @@ namespace Nc_Demo_Application.Server.Service toolsData = DatabaseController.getInstance().ReadTools(); } + public void AddTool(ref ToolsDataModel tool) + { + tool = DatabaseController.getInstance(). AddToolToDatabase(tool); + } + public void GetShanks(out List shanksData) { shanksData = DatabaseController.getInstance().GetShanks(); } + public void AddShank(out ShankDataModel shankData) + { + shankData = DatabaseController.getInstance().AddShank(); + } + public void GetPositions(out List positionsData) { positionsData = DatabaseController.getInstance().GetPositions(); } - #endregion + public void PutPosition(PositionsDataModel position) + { + DatabaseController.getInstance().UpdatePosition(position); + } + + #endregion Tools } } \ No newline at end of file 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 1f89cec..84e6099 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 @@ -32,13 +32,12 @@ namespace Nc_Demo_Application { System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle5 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle5 = new System.Windows.Forms.DataGridViewCellStyle(); this.serverStatusLabel = new System.Windows.Forms.Label(); this.ncDataPage = new System.Windows.Forms.TabPage(); this.toolStrip5 = new Nc_Demo_Application.Views.ToolStripEx(); - this.saveNcDataButton = new System.Windows.Forms.ToolStripButton(); this.label6 = new System.Windows.Forms.Label(); this.label5 = new System.Windows.Forms.Label(); this.label4 = new System.Windows.Forms.Label(); @@ -59,7 +58,6 @@ namespace Nc_Demo_Application this.ncTabControl = new System.Windows.Forms.TabControl(); this.processPage = new System.Windows.Forms.TabPage(); this.toolStrip1 = new Nc_Demo_Application.Views.ToolStripEx(); - this.saveNcProcessData = new System.Windows.Forms.ToolStripButton(); this.ncProcessGridView = new System.Windows.Forms.DataGridView(); this.ncProcessIdColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.ProcessPartProgram = new System.Windows.Forms.DataGridViewTextBoxColumn(); @@ -68,7 +66,6 @@ namespace Nc_Demo_Application this.ncProcessModeColumn = new System.Windows.Forms.DataGridViewComboBoxColumn(); this.alarms = new System.Windows.Forms.TabPage(); this.toolStrip3 = new Nc_Demo_Application.Views.ToolStripEx(); - this.saveNcAlarmsButton = new System.Windows.Forms.ToolStripButton(); this.ncAlarmsGridView = new System.Windows.Forms.DataGridView(); this.ncAlarmCodeColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.ncAlarmProcessIdColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); @@ -76,7 +73,6 @@ namespace Nc_Demo_Application this.ncAlarmIdColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.ncAxesPage = new System.Windows.Forms.TabPage(); this.toolStrip4 = new Nc_Demo_Application.Views.ToolStripEx(); - this.saveNcAxesButton = new System.Windows.Forms.ToolStripButton(); this.ncAxisGridView = new System.Windows.Forms.DataGridView(); this.axisIdColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.axisNameColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); @@ -95,18 +91,29 @@ namespace Nc_Demo_Application this.BinaryMemoryWordColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.BinaryMemoryIntegerColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.toolStrip2 = new Nc_Demo_Application.Views.ToolStripEx(); - this.saveBinaryMemoryButton = new System.Windows.Forms.ToolStripButton(); - this.addRowsBinaryMemory = new System.Windows.Forms.ToolStripButton(); - this.deleteRowsBinaryMemory = new System.Windows.Forms.ToolStripButton(); this.partProgramPage = new System.Windows.Forms.TabPage(); this.fileContentTextBox = new System.Windows.Forms.TextBox(); this.fileTreeView = new System.Windows.Forms.TreeView(); this.toolStrip6 = new Nc_Demo_Application.Views.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.magazinesTab = new System.Windows.Forms.TabPage(); + this.magazinesGridView = new System.Windows.Forms.DataGridView(); + this.magazineId = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.positionId = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.positionType = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.toolStripEx2 = new Nc_Demo_Application.Views.ToolStripEx(); + this.familiesTab = new System.Windows.Forms.TabPage(); + this.label18 = new System.Windows.Forms.Label(); + this.shanksDataGridView = new System.Windows.Forms.DataGridView(); + this.shanksId = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.label17 = new System.Windows.Forms.Label(); + this.familiesDataGridView = new System.Windows.Forms.DataGridView(); + this.id = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.name = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.toolStripEx1 = new Nc_Demo_Application.Views.ToolStripEx(); this.toolsPage = new System.Windows.Forms.TabPage(); + this.label19 = new System.Windows.Forms.Label(); + this.shankIdTextBox = new System.Windows.Forms.TextBox(); this.label16 = new System.Windows.Forms.Label(); this.magazinePositionTypeTxt = new System.Windows.Forms.TextBox(); this.label15 = new System.Windows.Forms.Label(); @@ -139,28 +146,22 @@ namespace Nc_Demo_Application this.toolNameTxt = new System.Windows.Forms.TextBox(); this.toolsTreeView = new System.Windows.Forms.TreeView(); this.toolStrip7 = new Nc_Demo_Application.Views.ToolStripEx(); + this.refreshToolUI = new System.Windows.Forms.ToolStripButton(); + this.stopServer = new System.Windows.Forms.Button(); + this.saveNcDataButton = new System.Windows.Forms.ToolStripButton(); + this.saveNcProcessData = new System.Windows.Forms.ToolStripButton(); + this.saveNcAlarmsButton = new System.Windows.Forms.ToolStripButton(); + this.saveNcAxesButton = new System.Windows.Forms.ToolStripButton(); + this.saveBinaryMemoryButton = new System.Windows.Forms.ToolStripButton(); + this.addRowsBinaryMemory = new System.Windows.Forms.ToolStripButton(); + this.deleteRowsBinaryMemory = new System.Windows.Forms.ToolStripButton(); + this.saveFileButton = new System.Windows.Forms.ToolStripButton(); + this.deleteFileButton = new System.Windows.Forms.ToolStripButton(); + this.addFileButton = new System.Windows.Forms.ToolStripButton(); + this.saveMagazinesButton = new System.Windows.Forms.ToolStripButton(); + this.saveFamiliesButton = new System.Windows.Forms.ToolStripButton(); this.removeTool = new System.Windows.Forms.ToolStripButton(); this.addTool = new System.Windows.Forms.ToolStripButton(); - this.familiesTab = new System.Windows.Forms.TabPage(); - this.label18 = new System.Windows.Forms.Label(); - this.shanksDataGridView = new System.Windows.Forms.DataGridView(); - this.shanksId = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.label17 = new System.Windows.Forms.Label(); - this.familiesDataGridView = new System.Windows.Forms.DataGridView(); - this.id = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.name = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.toolStripEx1 = new Nc_Demo_Application.Views.ToolStripEx(); - this.saveFamiliesButton = new System.Windows.Forms.ToolStripButton(); - this.magazinesTab = new System.Windows.Forms.TabPage(); - this.magazinesGridView = new System.Windows.Forms.DataGridView(); - this.magazineId = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.positionId = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.positionType = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.toolStripEx2 = new Nc_Demo_Application.Views.ToolStripEx(); - this.saveMagazinesButton = new System.Windows.Forms.ToolStripButton(); - this.stopServer = new System.Windows.Forms.Button(); - this.label19 = new System.Windows.Forms.Label(); - this.shankIdTextBox = new System.Windows.Forms.TextBox(); this.ncDataPage.SuspendLayout(); this.toolStrip5.SuspendLayout(); this.ncTabControl.SuspendLayout(); @@ -178,15 +179,15 @@ namespace Nc_Demo_Application this.toolStrip2.SuspendLayout(); this.partProgramPage.SuspendLayout(); this.toolStrip6.SuspendLayout(); - this.toolsPage.SuspendLayout(); - this.toolStrip7.SuspendLayout(); + this.magazinesTab.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.magazinesGridView)).BeginInit(); + this.toolStripEx2.SuspendLayout(); this.familiesTab.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.shanksDataGridView)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.familiesDataGridView)).BeginInit(); this.toolStripEx1.SuspendLayout(); - this.magazinesTab.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.magazinesGridView)).BeginInit(); - this.toolStripEx2.SuspendLayout(); + this.toolsPage.SuspendLayout(); + this.toolStrip7.SuspendLayout(); this.SuspendLayout(); // // serverStatusLabel @@ -238,16 +239,6 @@ namespace Nc_Demo_Application this.toolStrip5.TabIndex = 53; this.toolStrip5.Text = "toolStrip5"; // - // saveNcDataButton - // - this.saveNcDataButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; - this.saveNcDataButton.Image = global::Nc_Demo_Application.Properties.Resources.saveButton; - this.saveNcDataButton.ImageTransparentColor = System.Drawing.Color.Magenta; - this.saveNcDataButton.Name = "saveNcDataButton"; - this.saveNcDataButton.Size = new System.Drawing.Size(23, 22); - this.saveNcDataButton.Text = "toolStripButton1"; - this.saveNcDataButton.Click += new System.EventHandler(this.SaveCnDataButton_Click); - // // label6 // this.label6.AutoSize = true; @@ -430,16 +421,6 @@ namespace Nc_Demo_Application this.toolStrip1.Text = "toolStrip1"; this.toolStrip1.Click += new System.EventHandler(this.SaveNcProcessData_Click); // - // saveNcProcessData - // - this.saveNcProcessData.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; - this.saveNcProcessData.Image = global::Nc_Demo_Application.Properties.Resources.saveButton; - this.saveNcProcessData.ImageTransparentColor = System.Drawing.Color.Magenta; - this.saveNcProcessData.Name = "saveNcProcessData"; - this.saveNcProcessData.Size = new System.Drawing.Size(23, 22); - this.saveNcProcessData.Text = "Save"; - this.saveNcProcessData.Click += new System.EventHandler(this.SaveNcProcessData_Click); - // // ncProcessGridView // this.ncProcessGridView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) @@ -523,16 +504,6 @@ namespace Nc_Demo_Application this.toolStrip3.Text = "toolStrip3"; this.toolStrip3.Click += new System.EventHandler(this.SaveNcAlarmsButton_Click); // - // saveNcAlarmsButton - // - this.saveNcAlarmsButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; - this.saveNcAlarmsButton.Image = global::Nc_Demo_Application.Properties.Resources.saveButton; - this.saveNcAlarmsButton.ImageTransparentColor = System.Drawing.Color.Magenta; - this.saveNcAlarmsButton.Name = "saveNcAlarmsButton"; - this.saveNcAlarmsButton.Size = new System.Drawing.Size(23, 22); - this.saveNcAlarmsButton.Text = "Save"; - this.saveNcAlarmsButton.Click += new System.EventHandler(this.SaveNcAlarmsButton_Click); - // // ncAlarmsGridView // this.ncAlarmsGridView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) @@ -600,21 +571,8 @@ namespace Nc_Demo_Application this.toolStrip4.TabIndex = 53; this.toolStrip4.Text = "toolStrip4"; // - // saveNcAxesButton - // - this.saveNcAxesButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; - this.saveNcAxesButton.Image = global::Nc_Demo_Application.Properties.Resources.saveButton; - this.saveNcAxesButton.ImageTransparentColor = System.Drawing.Color.Magenta; - this.saveNcAxesButton.Name = "saveNcAxesButton"; - this.saveNcAxesButton.Size = new System.Drawing.Size(23, 22); - this.saveNcAxesButton.Text = "Save"; - this.saveNcAxesButton.Click += new System.EventHandler(this.SaveNcAxesButton_Click); - // // ncAxisGridView // - this.ncAxisGridView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); this.ncAxisGridView.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; this.ncAxisGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.ncAxisGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { @@ -708,9 +666,6 @@ namespace Nc_Demo_Application // this.binaryMemoryGridView.AllowUserToAddRows = false; this.binaryMemoryGridView.AllowUserToDeleteRows = false; - this.binaryMemoryGridView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); this.binaryMemoryGridView.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; this.binaryMemoryGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.binaryMemoryGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { @@ -774,37 +729,6 @@ namespace Nc_Demo_Application this.toolStrip2.TabIndex = 1; this.toolStrip2.Text = "toolStrip2"; // - // saveBinaryMemoryButton - // - this.saveBinaryMemoryButton.CheckOnClick = true; - this.saveBinaryMemoryButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; - this.saveBinaryMemoryButton.Image = global::Nc_Demo_Application.Properties.Resources.saveButton; - this.saveBinaryMemoryButton.ImageTransparentColor = System.Drawing.Color.Magenta; - this.saveBinaryMemoryButton.Name = "saveBinaryMemoryButton"; - this.saveBinaryMemoryButton.Size = new System.Drawing.Size(23, 22); - this.saveBinaryMemoryButton.Text = "Save"; - this.saveBinaryMemoryButton.Click += new System.EventHandler(this.SaveBinaryMemory_Click); - // - // addRowsBinaryMemory - // - this.addRowsBinaryMemory.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; - this.addRowsBinaryMemory.Image = global::Nc_Demo_Application.Properties.Resources.addButton; - this.addRowsBinaryMemory.ImageTransparentColor = System.Drawing.Color.Magenta; - this.addRowsBinaryMemory.Name = "addRowsBinaryMemory"; - this.addRowsBinaryMemory.Size = new System.Drawing.Size(23, 22); - this.addRowsBinaryMemory.Text = "Add 4 Rows"; - this.addRowsBinaryMemory.Click += new System.EventHandler(this.addRowsBinaryMemory_Click); - // - // deleteRowsBinaryMemory - // - this.deleteRowsBinaryMemory.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; - this.deleteRowsBinaryMemory.Image = global::Nc_Demo_Application.Properties.Resources.removeButton; - this.deleteRowsBinaryMemory.ImageTransparentColor = System.Drawing.Color.Magenta; - this.deleteRowsBinaryMemory.Name = "deleteRowsBinaryMemory"; - this.deleteRowsBinaryMemory.Size = new System.Drawing.Size(23, 22); - this.deleteRowsBinaryMemory.Text = "Remove 4 rows"; - this.deleteRowsBinaryMemory.Click += new System.EventHandler(this.deleteRowsBinaryMemory_Click); - // // partProgramPage // this.partProgramPage.Controls.Add(this.fileContentTextBox); @@ -855,42 +779,171 @@ namespace Nc_Demo_Application this.toolStrip6.TabIndex = 1; this.toolStrip6.Text = "toolStrip6"; // - // saveFileButton - // - this.saveFileButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; - this.saveFileButton.Enabled = false; - this.saveFileButton.Image = global::Nc_Demo_Application.Properties.Resources.saveButton; - this.saveFileButton.ImageTransparentColor = System.Drawing.Color.Magenta; - this.saveFileButton.Name = "saveFileButton"; - this.saveFileButton.Size = new System.Drawing.Size(23, 22); - this.saveFileButton.Text = "Save file"; - this.saveFileButton.Click += new System.EventHandler(this.SaveFileButton_Click); - // - // deleteFileButton - // - this.deleteFileButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; - this.deleteFileButton.Image = global::Nc_Demo_Application.Properties.Resources.removeButton; - this.deleteFileButton.ImageTransparentColor = System.Drawing.Color.Magenta; - this.deleteFileButton.Name = "deleteFileButton"; - this.deleteFileButton.Size = new System.Drawing.Size(23, 22); - this.deleteFileButton.Text = "Delete file"; - this.deleteFileButton.Click += new System.EventHandler(this.DeleteFile_Click); - // - // addFileButton - // - this.addFileButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; - this.addFileButton.Image = global::Nc_Demo_Application.Properties.Resources.addButton; - this.addFileButton.ImageTransparentColor = System.Drawing.Color.Magenta; - this.addFileButton.Name = "addFileButton"; - this.addFileButton.Size = new System.Drawing.Size(23, 22); - this.addFileButton.Text = "Add file"; - this.addFileButton.Click += new System.EventHandler(this.AddFile_Click); - // // newFileNameTextBox // this.newFileNameTextBox.Name = "newFileNameTextBox"; this.newFileNameTextBox.Size = new System.Drawing.Size(100, 25); // + // magazinesTab + // + this.magazinesTab.Controls.Add(this.magazinesGridView); + this.magazinesTab.Controls.Add(this.toolStripEx2); + this.magazinesTab.Location = new System.Drawing.Point(4, 22); + this.magazinesTab.Name = "magazinesTab"; + this.magazinesTab.Padding = new System.Windows.Forms.Padding(3); + this.magazinesTab.Size = new System.Drawing.Size(978, 641); + this.magazinesTab.TabIndex = 8; + this.magazinesTab.Text = "Magazines"; + this.magazinesTab.UseVisualStyleBackColor = true; + // + // magazinesGridView + // + this.magazinesGridView.AllowUserToAddRows = false; + this.magazinesGridView.AllowUserToDeleteRows = false; + this.magazinesGridView.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; + this.magazinesGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.magazinesGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { + this.magazineId, + this.positionId, + this.positionType}); + this.magazinesGridView.Location = new System.Drawing.Point(0, 31); + this.magazinesGridView.Name = "magazinesGridView"; + this.magazinesGridView.Size = new System.Drawing.Size(978, 607); + this.magazinesGridView.TabIndex = 0; + // + // magazineId + // + this.magazineId.DataPropertyName = "magazineId"; + dataGridViewCellStyle3.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(224)))), ((int)(((byte)(224)))), ((int)(((byte)(224))))); + dataGridViewCellStyle3.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(224)))), ((int)(((byte)(224)))), ((int)(((byte)(224))))); + dataGridViewCellStyle3.SelectionForeColor = System.Drawing.Color.Black; + this.magazineId.DefaultCellStyle = dataGridViewCellStyle3; + this.magazineId.FillWeight = 105.2829F; + this.magazineId.HeaderText = "Magazine Id"; + this.magazineId.Name = "magazineId"; + this.magazineId.ReadOnly = true; + this.magazineId.Resizable = System.Windows.Forms.DataGridViewTriState.False; + // + // positionId + // + this.positionId.DataPropertyName = "positionId"; + dataGridViewCellStyle4.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(224)))), ((int)(((byte)(224)))), ((int)(((byte)(224))))); + dataGridViewCellStyle4.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(224)))), ((int)(((byte)(224)))), ((int)(((byte)(224))))); + dataGridViewCellStyle4.SelectionForeColor = System.Drawing.Color.Black; + this.positionId.DefaultCellStyle = dataGridViewCellStyle4; + this.positionId.FillWeight = 94.61015F; + this.positionId.HeaderText = "Position Id"; + this.positionId.Name = "positionId"; + this.positionId.ReadOnly = true; + // + // positionType + // + this.positionType.DataPropertyName = "type"; + this.positionType.FillWeight = 100.1069F; + this.positionType.HeaderText = "Type"; + this.positionType.Name = "positionType"; + // + // toolStripEx2 + // + this.toolStripEx2.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.saveMagazinesButton}); + this.toolStripEx2.Location = new System.Drawing.Point(3, 3); + this.toolStripEx2.Name = "toolStripEx2"; + this.toolStripEx2.Size = new System.Drawing.Size(972, 25); + this.toolStripEx2.TabIndex = 1; + this.toolStripEx2.Text = "toolStripEx2"; + // + // familiesTab + // + this.familiesTab.Controls.Add(this.label18); + this.familiesTab.Controls.Add(this.shanksDataGridView); + this.familiesTab.Controls.Add(this.label17); + this.familiesTab.Controls.Add(this.familiesDataGridView); + this.familiesTab.Controls.Add(this.toolStripEx1); + this.familiesTab.Location = new System.Drawing.Point(4, 22); + this.familiesTab.Name = "familiesTab"; + this.familiesTab.Padding = new System.Windows.Forms.Padding(3); + this.familiesTab.Size = new System.Drawing.Size(978, 641); + this.familiesTab.TabIndex = 7; + this.familiesTab.Text = "Families & Shanks"; + this.familiesTab.UseVisualStyleBackColor = true; + // + // label18 + // + this.label18.AutoSize = true; + this.label18.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F); + this.label18.Location = new System.Drawing.Point(627, 34); + this.label18.Name = "label18"; + this.label18.Size = new System.Drawing.Size(67, 20); + this.label18.TabIndex = 4; + this.label18.Text = "Shanks:"; + // + // shanksDataGridView + // + this.shanksDataGridView.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; + this.shanksDataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.shanksDataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { + this.shanksId}); + this.shanksDataGridView.Location = new System.Drawing.Point(624, 61); + this.shanksDataGridView.Name = "shanksDataGridView"; + this.shanksDataGridView.Size = new System.Drawing.Size(291, 577); + this.shanksDataGridView.TabIndex = 3; + // + // shanksId + // + this.shanksId.DataPropertyName = "id"; + this.shanksId.HeaderText = "Id"; + this.shanksId.Name = "shanksId"; + // + // label17 + // + this.label17.AutoSize = true; + this.label17.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F); + this.label17.Location = new System.Drawing.Point(6, 34); + this.label17.Name = "label17"; + this.label17.Size = new System.Drawing.Size(110, 20); + this.label17.TabIndex = 2; + this.label17.Text = "Families Data:"; + // + // familiesDataGridView + // + this.familiesDataGridView.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; + this.familiesDataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.familiesDataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { + this.id, + this.name}); + this.familiesDataGridView.Location = new System.Drawing.Point(3, 61); + this.familiesDataGridView.Name = "familiesDataGridView"; + this.familiesDataGridView.Size = new System.Drawing.Size(457, 584); + this.familiesDataGridView.TabIndex = 1; + // + // id + // + this.id.DataPropertyName = "id"; + dataGridViewCellStyle5.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(224)))), ((int)(((byte)(224)))), ((int)(((byte)(224))))); + dataGridViewCellStyle5.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(224)))), ((int)(((byte)(224)))), ((int)(((byte)(224))))); + dataGridViewCellStyle5.SelectionForeColor = System.Drawing.Color.Black; + this.id.DefaultCellStyle = dataGridViewCellStyle5; + this.id.HeaderText = "Id"; + this.id.Name = "id"; + this.id.ReadOnly = true; + // + // name + // + this.name.DataPropertyName = "name"; + this.name.HeaderText = "Name"; + this.name.Name = "name"; + // + // toolStripEx1 + // + this.toolStripEx1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.saveFamiliesButton}); + this.toolStripEx1.Location = new System.Drawing.Point(3, 3); + this.toolStripEx1.Name = "toolStripEx1"; + this.toolStripEx1.Size = new System.Drawing.Size(972, 25); + this.toolStripEx1.TabIndex = 0; + this.toolStripEx1.Text = "toolStripEx1"; + // // toolsPage // this.toolsPage.Controls.Add(this.label19); @@ -935,6 +988,22 @@ namespace Nc_Demo_Application this.toolsPage.Text = "Tools"; this.toolsPage.UseVisualStyleBackColor = true; // + // label19 + // + this.label19.AutoSize = true; + this.label19.Location = new System.Drawing.Point(845, 92); + this.label19.Name = "label19"; + this.label19.Size = new System.Drawing.Size(53, 13); + this.label19.TabIndex = 33; + this.label19.Text = "Shank Id:"; + // + // shankIdTextBox + // + this.shankIdTextBox.Location = new System.Drawing.Point(904, 89); + this.shankIdTextBox.Name = "shankIdTextBox"; + this.shankIdTextBox.Size = new System.Drawing.Size(49, 20); + this.shankIdTextBox.TabIndex = 32; + // // label16 // this.label16.AutoSize = true; @@ -954,7 +1023,7 @@ namespace Nc_Demo_Application // label15 // this.label15.AutoSize = true; - this.label15.Location = new System.Drawing.Point(89, 7); + this.label15.Location = new System.Drawing.Point(107, 8); this.label15.Name = "label15"; this.label15.Size = new System.Drawing.Size(62, 13); this.label15.TabIndex = 29; @@ -1199,7 +1268,7 @@ namespace Nc_Demo_Application // // toolNameTxt // - this.toolNameTxt.Location = new System.Drawing.Point(157, 4); + this.toolNameTxt.Location = new System.Drawing.Point(175, 5); this.toolNameTxt.Name = "toolNameTxt"; this.toolNameTxt.Size = new System.Drawing.Size(100, 20); this.toolNameTxt.TabIndex = 2; @@ -1218,6 +1287,7 @@ namespace Nc_Demo_Application // toolStrip7 // this.toolStrip7.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.refreshToolUI, this.removeTool, this.addTool}); this.toolStrip7.Location = new System.Drawing.Point(3, 3); @@ -1226,6 +1296,148 @@ namespace Nc_Demo_Application this.toolStrip7.TabIndex = 1; this.toolStrip7.Text = "toolStrip7"; // + // refreshToolUI + // + this.refreshToolUI.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; + this.refreshToolUI.Image = global::Nc_Demo_Application.Properties.Resources.refresh; + this.refreshToolUI.ImageTransparentColor = System.Drawing.Color.Magenta; + this.refreshToolUI.Name = "refreshToolUI"; + this.refreshToolUI.Size = new System.Drawing.Size(23, 22); + this.refreshToolUI.Text = "Refresh"; + this.refreshToolUI.Click += new System.EventHandler(this.refreshToolUI_Click); + // + // stopServer + // + this.stopServer.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.stopServer.Location = new System.Drawing.Point(906, 687); + this.stopServer.Name = "stopServer"; + this.stopServer.Size = new System.Drawing.Size(91, 30); + this.stopServer.TabIndex = 8; + this.stopServer.Text = "Stop"; + this.stopServer.UseVisualStyleBackColor = true; + this.stopServer.Click += new System.EventHandler(this.StopServer_Click); + // + // saveNcDataButton + // + this.saveNcDataButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; + this.saveNcDataButton.Image = global::Nc_Demo_Application.Properties.Resources.saveButton; + this.saveNcDataButton.ImageTransparentColor = System.Drawing.Color.Magenta; + this.saveNcDataButton.Name = "saveNcDataButton"; + this.saveNcDataButton.Size = new System.Drawing.Size(23, 22); + this.saveNcDataButton.Text = "toolStripButton1"; + this.saveNcDataButton.Click += new System.EventHandler(this.SaveCnDataButton_Click); + // + // saveNcProcessData + // + this.saveNcProcessData.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; + this.saveNcProcessData.Image = global::Nc_Demo_Application.Properties.Resources.saveButton; + this.saveNcProcessData.ImageTransparentColor = System.Drawing.Color.Magenta; + this.saveNcProcessData.Name = "saveNcProcessData"; + this.saveNcProcessData.Size = new System.Drawing.Size(23, 22); + this.saveNcProcessData.Text = "Save"; + this.saveNcProcessData.Click += new System.EventHandler(this.SaveNcProcessData_Click); + // + // saveNcAlarmsButton + // + this.saveNcAlarmsButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; + this.saveNcAlarmsButton.Image = global::Nc_Demo_Application.Properties.Resources.saveButton; + this.saveNcAlarmsButton.ImageTransparentColor = System.Drawing.Color.Magenta; + this.saveNcAlarmsButton.Name = "saveNcAlarmsButton"; + this.saveNcAlarmsButton.Size = new System.Drawing.Size(23, 22); + this.saveNcAlarmsButton.Text = "Save"; + this.saveNcAlarmsButton.Click += new System.EventHandler(this.SaveNcAlarmsButton_Click); + // + // saveNcAxesButton + // + this.saveNcAxesButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; + this.saveNcAxesButton.Image = global::Nc_Demo_Application.Properties.Resources.saveButton; + this.saveNcAxesButton.ImageTransparentColor = System.Drawing.Color.Magenta; + this.saveNcAxesButton.Name = "saveNcAxesButton"; + this.saveNcAxesButton.Size = new System.Drawing.Size(23, 22); + this.saveNcAxesButton.Text = "Save"; + this.saveNcAxesButton.Click += new System.EventHandler(this.SaveNcAxesButton_Click); + // + // saveBinaryMemoryButton + // + this.saveBinaryMemoryButton.CheckOnClick = true; + this.saveBinaryMemoryButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; + this.saveBinaryMemoryButton.Image = global::Nc_Demo_Application.Properties.Resources.saveButton; + this.saveBinaryMemoryButton.ImageTransparentColor = System.Drawing.Color.Magenta; + this.saveBinaryMemoryButton.Name = "saveBinaryMemoryButton"; + this.saveBinaryMemoryButton.Size = new System.Drawing.Size(23, 22); + this.saveBinaryMemoryButton.Text = "Save"; + this.saveBinaryMemoryButton.Click += new System.EventHandler(this.SaveBinaryMemory_Click); + // + // addRowsBinaryMemory + // + this.addRowsBinaryMemory.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; + this.addRowsBinaryMemory.Image = global::Nc_Demo_Application.Properties.Resources.addButton; + this.addRowsBinaryMemory.ImageTransparentColor = System.Drawing.Color.Magenta; + this.addRowsBinaryMemory.Name = "addRowsBinaryMemory"; + this.addRowsBinaryMemory.Size = new System.Drawing.Size(23, 22); + this.addRowsBinaryMemory.Text = "Add 4 Rows"; + this.addRowsBinaryMemory.Click += new System.EventHandler(this.addRowsBinaryMemory_Click); + // + // deleteRowsBinaryMemory + // + this.deleteRowsBinaryMemory.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; + this.deleteRowsBinaryMemory.Image = global::Nc_Demo_Application.Properties.Resources.removeButton; + this.deleteRowsBinaryMemory.ImageTransparentColor = System.Drawing.Color.Magenta; + this.deleteRowsBinaryMemory.Name = "deleteRowsBinaryMemory"; + this.deleteRowsBinaryMemory.Size = new System.Drawing.Size(23, 22); + this.deleteRowsBinaryMemory.Text = "Remove 4 rows"; + this.deleteRowsBinaryMemory.Click += new System.EventHandler(this.deleteRowsBinaryMemory_Click); + // + // saveFileButton + // + this.saveFileButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; + this.saveFileButton.Enabled = false; + this.saveFileButton.Image = global::Nc_Demo_Application.Properties.Resources.saveButton; + this.saveFileButton.ImageTransparentColor = System.Drawing.Color.Magenta; + this.saveFileButton.Name = "saveFileButton"; + this.saveFileButton.Size = new System.Drawing.Size(23, 22); + this.saveFileButton.Text = "Save file"; + this.saveFileButton.Click += new System.EventHandler(this.SaveFileButton_Click); + // + // deleteFileButton + // + this.deleteFileButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; + this.deleteFileButton.Image = global::Nc_Demo_Application.Properties.Resources.removeButton; + this.deleteFileButton.ImageTransparentColor = System.Drawing.Color.Magenta; + this.deleteFileButton.Name = "deleteFileButton"; + this.deleteFileButton.Size = new System.Drawing.Size(23, 22); + this.deleteFileButton.Text = "Delete file"; + this.deleteFileButton.Click += new System.EventHandler(this.DeleteFile_Click); + // + // addFileButton + // + this.addFileButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; + this.addFileButton.Image = global::Nc_Demo_Application.Properties.Resources.addButton; + this.addFileButton.ImageTransparentColor = System.Drawing.Color.Magenta; + this.addFileButton.Name = "addFileButton"; + this.addFileButton.Size = new System.Drawing.Size(23, 22); + this.addFileButton.Text = "Add file"; + this.addFileButton.Click += new System.EventHandler(this.AddFile_Click); + // + // saveMagazinesButton + // + this.saveMagazinesButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; + this.saveMagazinesButton.Image = global::Nc_Demo_Application.Properties.Resources.saveButton; + this.saveMagazinesButton.ImageTransparentColor = System.Drawing.Color.Magenta; + this.saveMagazinesButton.Name = "saveMagazinesButton"; + this.saveMagazinesButton.Size = new System.Drawing.Size(23, 22); + this.saveMagazinesButton.Text = "Save"; + this.saveMagazinesButton.Click += new System.EventHandler(this.SaveMagazinesButton_Click); + // + // saveFamiliesButton + // + this.saveFamiliesButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; + this.saveFamiliesButton.Image = global::Nc_Demo_Application.Properties.Resources.saveButton; + this.saveFamiliesButton.ImageTransparentColor = System.Drawing.Color.Magenta; + this.saveFamiliesButton.Name = "saveFamiliesButton"; + this.saveFamiliesButton.Size = new System.Drawing.Size(23, 22); + this.saveFamiliesButton.Click += new System.EventHandler(this.SaveFamiliesButton_Click); + // // removeTool // this.removeTool.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; @@ -1246,212 +1458,6 @@ namespace Nc_Demo_Application this.addTool.Text = "toolStripButton1"; this.addTool.Click += new System.EventHandler(this.AddTool_Click); // - // familiesTab - // - this.familiesTab.Controls.Add(this.label18); - this.familiesTab.Controls.Add(this.shanksDataGridView); - this.familiesTab.Controls.Add(this.label17); - this.familiesTab.Controls.Add(this.familiesDataGridView); - this.familiesTab.Controls.Add(this.toolStripEx1); - this.familiesTab.Location = new System.Drawing.Point(4, 22); - this.familiesTab.Name = "familiesTab"; - this.familiesTab.Padding = new System.Windows.Forms.Padding(3); - this.familiesTab.Size = new System.Drawing.Size(978, 641); - this.familiesTab.TabIndex = 7; - this.familiesTab.Text = "Families & Shanks"; - this.familiesTab.UseVisualStyleBackColor = true; - // - // label18 - // - this.label18.AutoSize = true; - this.label18.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F); - this.label18.Location = new System.Drawing.Point(627, 34); - this.label18.Name = "label18"; - this.label18.Size = new System.Drawing.Size(67, 20); - this.label18.TabIndex = 4; - this.label18.Text = "Shanks:"; - // - // shanksDataGridView - // - this.shanksDataGridView.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; - this.shanksDataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; - this.shanksDataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { - this.shanksId}); - this.shanksDataGridView.Location = new System.Drawing.Point(624, 61); - this.shanksDataGridView.Name = "shanksDataGridView"; - this.shanksDataGridView.Size = new System.Drawing.Size(291, 577); - this.shanksDataGridView.TabIndex = 3; - // - // shanksId - // - this.shanksId.DataPropertyName = "id"; - this.shanksId.HeaderText = "Id"; - this.shanksId.Name = "shanksId"; - // - // label17 - // - this.label17.AutoSize = true; - this.label17.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F); - this.label17.Location = new System.Drawing.Point(6, 34); - this.label17.Name = "label17"; - this.label17.Size = new System.Drawing.Size(110, 20); - this.label17.TabIndex = 2; - this.label17.Text = "Families Data:"; - // - // familiesDataGridView - // - this.familiesDataGridView.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; - this.familiesDataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; - this.familiesDataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { - this.id, - this.name}); - this.familiesDataGridView.Location = new System.Drawing.Point(3, 61); - this.familiesDataGridView.Name = "familiesDataGridView"; - this.familiesDataGridView.Size = new System.Drawing.Size(457, 584); - this.familiesDataGridView.TabIndex = 1; - // - // id - // - this.id.DataPropertyName = "id"; - dataGridViewCellStyle5.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(224)))), ((int)(((byte)(224)))), ((int)(((byte)(224))))); - dataGridViewCellStyle5.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(224)))), ((int)(((byte)(224)))), ((int)(((byte)(224))))); - dataGridViewCellStyle5.SelectionForeColor = System.Drawing.Color.Black; - this.id.DefaultCellStyle = dataGridViewCellStyle5; - this.id.HeaderText = "Id"; - this.id.Name = "id"; - this.id.ReadOnly = true; - // - // name - // - this.name.DataPropertyName = "name"; - this.name.HeaderText = "Name"; - this.name.Name = "name"; - // - // toolStripEx1 - // - this.toolStripEx1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.saveFamiliesButton}); - this.toolStripEx1.Location = new System.Drawing.Point(3, 3); - this.toolStripEx1.Name = "toolStripEx1"; - this.toolStripEx1.Size = new System.Drawing.Size(972, 25); - this.toolStripEx1.TabIndex = 0; - this.toolStripEx1.Text = "toolStripEx1"; - // - // saveFamiliesButton - // - this.saveFamiliesButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; - this.saveFamiliesButton.Image = global::Nc_Demo_Application.Properties.Resources.saveButton; - this.saveFamiliesButton.ImageTransparentColor = System.Drawing.Color.Magenta; - this.saveFamiliesButton.Name = "saveFamiliesButton"; - this.saveFamiliesButton.Size = new System.Drawing.Size(23, 22); - this.saveFamiliesButton.Click += new System.EventHandler(this.SaveFamiliesButton_Click); - // - // magazinesTab - // - this.magazinesTab.Controls.Add(this.magazinesGridView); - this.magazinesTab.Controls.Add(this.toolStripEx2); - this.magazinesTab.Location = new System.Drawing.Point(4, 22); - this.magazinesTab.Name = "magazinesTab"; - this.magazinesTab.Padding = new System.Windows.Forms.Padding(3); - this.magazinesTab.Size = new System.Drawing.Size(978, 641); - this.magazinesTab.TabIndex = 8; - this.magazinesTab.Text = "Magazines"; - this.magazinesTab.UseVisualStyleBackColor = true; - // - // magazinesGridView - // - this.magazinesGridView.AllowUserToAddRows = false; - this.magazinesGridView.AllowUserToDeleteRows = false; - this.magazinesGridView.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; - this.magazinesGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; - this.magazinesGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { - this.magazineId, - this.positionId, - this.positionType}); - this.magazinesGridView.Location = new System.Drawing.Point(0, 31); - this.magazinesGridView.Name = "magazinesGridView"; - this.magazinesGridView.Size = new System.Drawing.Size(978, 607); - this.magazinesGridView.TabIndex = 0; - // - // magazineId - // - this.magazineId.DataPropertyName = "magazineId"; - dataGridViewCellStyle3.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(224)))), ((int)(((byte)(224)))), ((int)(((byte)(224))))); - dataGridViewCellStyle3.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(224)))), ((int)(((byte)(224)))), ((int)(((byte)(224))))); - dataGridViewCellStyle3.SelectionForeColor = System.Drawing.Color.Black; - this.magazineId.DefaultCellStyle = dataGridViewCellStyle3; - this.magazineId.FillWeight = 105.2829F; - this.magazineId.HeaderText = "Magazine Id"; - this.magazineId.Name = "magazineId"; - this.magazineId.ReadOnly = true; - this.magazineId.Resizable = System.Windows.Forms.DataGridViewTriState.False; - // - // positionId - // - this.positionId.DataPropertyName = "positionId"; - dataGridViewCellStyle4.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(224)))), ((int)(((byte)(224)))), ((int)(((byte)(224))))); - dataGridViewCellStyle4.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(224)))), ((int)(((byte)(224)))), ((int)(((byte)(224))))); - dataGridViewCellStyle4.SelectionForeColor = System.Drawing.Color.Black; - this.positionId.DefaultCellStyle = dataGridViewCellStyle4; - this.positionId.FillWeight = 94.61015F; - this.positionId.HeaderText = "Position Id"; - this.positionId.Name = "positionId"; - this.positionId.ReadOnly = true; - // - // positionType - // - this.positionType.DataPropertyName = "type"; - this.positionType.FillWeight = 100.1069F; - this.positionType.HeaderText = "Type"; - this.positionType.Name = "positionType"; - // - // toolStripEx2 - // - this.toolStripEx2.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.saveMagazinesButton}); - this.toolStripEx2.Location = new System.Drawing.Point(3, 3); - this.toolStripEx2.Name = "toolStripEx2"; - this.toolStripEx2.Size = new System.Drawing.Size(972, 25); - this.toolStripEx2.TabIndex = 1; - this.toolStripEx2.Text = "toolStripEx2"; - // - // saveMagazinesButton - // - this.saveMagazinesButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; - this.saveMagazinesButton.Image = global::Nc_Demo_Application.Properties.Resources.saveButton; - this.saveMagazinesButton.ImageTransparentColor = System.Drawing.Color.Magenta; - this.saveMagazinesButton.Name = "saveMagazinesButton"; - this.saveMagazinesButton.Size = new System.Drawing.Size(23, 22); - this.saveMagazinesButton.Text = "Save"; - this.saveMagazinesButton.Click += new System.EventHandler(this.SaveMagazinesButton_Click); - // - // stopServer - // - this.stopServer.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.stopServer.Location = new System.Drawing.Point(906, 687); - this.stopServer.Name = "stopServer"; - this.stopServer.Size = new System.Drawing.Size(91, 30); - this.stopServer.TabIndex = 8; - this.stopServer.Text = "Stop"; - this.stopServer.UseVisualStyleBackColor = true; - this.stopServer.Click += new System.EventHandler(this.StopServer_Click); - // - // label19 - // - this.label19.AutoSize = true; - this.label19.Location = new System.Drawing.Point(845, 92); - this.label19.Name = "label19"; - this.label19.Size = new System.Drawing.Size(53, 13); - this.label19.TabIndex = 33; - this.label19.Text = "Shank Id:"; - // - // shankIdTextBox - // - this.shankIdTextBox.Location = new System.Drawing.Point(904, 89); - this.shankIdTextBox.Name = "shankIdTextBox"; - this.shankIdTextBox.Size = new System.Drawing.Size(49, 20); - this.shankIdTextBox.TabIndex = 32; - // // DemoApplicationForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -1494,21 +1500,21 @@ namespace Nc_Demo_Application this.partProgramPage.PerformLayout(); this.toolStrip6.ResumeLayout(false); this.toolStrip6.PerformLayout(); - this.toolsPage.ResumeLayout(false); - this.toolsPage.PerformLayout(); - this.toolStrip7.ResumeLayout(false); - this.toolStrip7.PerformLayout(); + this.magazinesTab.ResumeLayout(false); + this.magazinesTab.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.magazinesGridView)).EndInit(); + this.toolStripEx2.ResumeLayout(false); + this.toolStripEx2.PerformLayout(); this.familiesTab.ResumeLayout(false); this.familiesTab.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.shanksDataGridView)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.familiesDataGridView)).EndInit(); this.toolStripEx1.ResumeLayout(false); this.toolStripEx1.PerformLayout(); - this.magazinesTab.ResumeLayout(false); - this.magazinesTab.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.magazinesGridView)).EndInit(); - this.toolStripEx2.ResumeLayout(false); - this.toolStripEx2.PerformLayout(); + this.toolsPage.ResumeLayout(false); + this.toolsPage.PerformLayout(); + this.toolStrip7.ResumeLayout(false); + this.toolStrip7.PerformLayout(); this.ResumeLayout(false); this.PerformLayout(); @@ -1623,9 +1629,6 @@ namespace Nc_Demo_Application private System.Windows.Forms.Label label18; private System.Windows.Forms.TabPage magazinesTab; private System.Windows.Forms.DataGridView magazinesGridView; - private System.Windows.Forms.DataGridViewTextBoxColumn magazineId; - private System.Windows.Forms.DataGridViewTextBoxColumn positionId; - private System.Windows.Forms.DataGridViewTextBoxColumn positionType; private System.Windows.Forms.DataGridViewTextBoxColumn id; private System.Windows.Forms.DataGridViewTextBoxColumn name; private System.Windows.Forms.DataGridViewTextBoxColumn BinaryMemoryAddressColumn; @@ -1642,6 +1645,10 @@ namespace Nc_Demo_Application private System.Windows.Forms.ToolStripButton saveMagazinesButton; private System.Windows.Forms.Label label19; private System.Windows.Forms.TextBox shankIdTextBox; + private System.Windows.Forms.DataGridViewTextBoxColumn magazineId; + private System.Windows.Forms.DataGridViewTextBoxColumn positionId; + private System.Windows.Forms.DataGridViewTextBoxColumn positionType; + private System.Windows.Forms.ToolStripButton refreshToolUI; } } 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 34f4ce5..54d21ca 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 @@ -57,7 +57,7 @@ namespace Nc_Demo_Application rotationSelect.DataSource = Enum.GetValues(typeof(ROTATION)); toolTypeSelect.DataSource = Enum.GetValues(typeof(TOOLS_TYPE)); magazineComboBox.DataSource = Enum.GetValues(typeof(MAGAZINES)); - + ShowServer(true); // Read data from database @@ -146,7 +146,7 @@ namespace Nc_Demo_Application // Insert families data into grid view DataTable families = DatabaseController.getInstance().ReadFamilies(); familiesDataGridView.DataSource = families; - + // Insert shanks data into grid View DataTable shanks = DatabaseController.getInstance().ReadShanks(); shanksDataGridView.DataSource = shanks; @@ -169,7 +169,6 @@ namespace Nc_Demo_Application { NcDataModel ncData = new NcDataModel { - // Read data from user NcData input name = ncNameTxb.Text, model = modelTxb.Text, @@ -485,40 +484,33 @@ namespace Nc_Demo_Application private void SetupToolData(List toolsList) { - try + toolsTreeView.Nodes.Clear(); + // Create root and push it + var stack = new Stack(); + + // Push + var node = new TreeNode("ToolTable") { Tag = "ToolTable" }; + node.Expand(); + stack.Push(node); + + while (stack.Count > 0) { + // Get new node from tree + var currentNode = stack.Pop(); - // Create root and push it - var stack = new Stack(); - - // Push - var node = new TreeNode("ToolTable") { Tag = "ToolTable" }; - stack.Push(node); - - - while (stack.Count > 0) + // Add node to Treeview + foreach (ToolsDataModel tool in toolsList) { - // Get new node from tree - var currentNode = stack.Pop(); - - // Add node to Treeview - foreach (ToolsDataModel tool in toolsList) + var tmpNode = new TreeNode { - var tmpNode = new TreeNode - { - Tag = tool.Id, - Text = tool.FamilyName - }; - currentNode.Nodes.Add(tmpNode); - } + Tag = tool.Id, + Text = tool.FamilyName + }; + currentNode.Nodes.Add(tmpNode); } - - toolsTreeView.Nodes.Add(node); } - catch(Exception ex) - { - } + toolsTreeView.Nodes.Add(node); } private void AddTool_Click(object sender, EventArgs e) @@ -534,22 +526,22 @@ namespace Nc_Demo_Application MagazinePositionType = 1, ToolType = 100, ShanksId = 0, - LeftSize = 1, + LeftSize = 1, RightSize = 1, Cooling1 = false, Cooling2 = false, - Rotation= 0, + Rotation = 0, IsActive = false, FixedPlace = false, IsMeasured = false, ChangeTool = false, PreAlarm = false, - IsInUse = false, + IsInUse = false, IsInhibited = false }; // Add to database - DatabaseController.getInstance().AddToolToDatabase(ref newTool); + newTool = DatabaseController.getInstance().AddToolToDatabase(newTool); // Add to treeView toolsTreeView.Nodes[0].Nodes.Add(new TreeNode { @@ -591,11 +583,11 @@ namespace Nc_Demo_Application if (selectedTool.Level == 0) return; - // Find selected tools data from database + // Find selected tools data from database List toolsInfo = DatabaseController.getInstance().ReadTools(); ToolsDataModel toolInfo = toolsInfo.Where(x => x.Id == Convert.ToInt32(selectedTool.Tag)).SingleOrDefault(); - - if(toolInfo != null) + + if (toolInfo != null) { // Update form inputs toolsIdLlb.Text = toolInfo.Id.ToString(); @@ -620,7 +612,6 @@ namespace Nc_Demo_Application rotationSelect.SelectedItem = (ROTATION)toolInfo.Rotation; magazineComboBox.SelectedItem = (MAGAZINES)toolInfo.MagazineId; } - } private void SaveToolButton_Click(object sender, EventArgs e) @@ -631,7 +622,7 @@ namespace Nc_Demo_Application if (selectedTool.Level == 0) return; - // Find selected tools data from database + // Find selected tools data from database List toolsInfo = DatabaseController.getInstance().ReadTools(); ToolsDataModel toolInfo = new ToolsDataModel(); @@ -676,5 +667,9 @@ namespace Nc_Demo_Application DatabaseController.getInstance().UpdateMagazines((DataTable)magazinesGridView.DataSource); } + private void refreshToolUI_Click(object sender, EventArgs e) + { + FillToolsInput(); + } } } \ No newline at end of file