From 2c8925d2f688f562dc8ce51a60a2db329b6126fb Mon Sep 17 00:00:00 2001 From: Lucio Maranta Date: Mon, 23 Apr 2018 15:46:25 +0000 Subject: [PATCH] Added shanks family magazines to Demo application --- CMS_CORE_Application/Form1.cs | 2 + .../ToolDatabase/ToolDatabaseContext.cs | 2 +- .../ToolDatabase/ToolModels.cs | 4 +- CMS_CORE_Library/CMS_CORE_Library.csproj | 3 +- CMS_CORE_Library/DataStructures.cs | 13 + CMS_CORE_Library/Demo/ILibraryService.cs | 16 + .../Demo/Models/BinaryMemoryModel.cs | 20 +- CMS_CORE_Library/Demo/Models/FamilyModel.cs | 18 + CMS_CORE_Library/Demo/Models/ToolDataModel.cs | 49 ++ CMS_CORE_Library/Demo/Nc_Demo.cs | 36 ++ CMS_CORE_Library/Fanuc/Nc_Fanuc.cs | 5 + CMS_CORE_Library/Nc.cs | 3 + CMS_CORE_Library/Osai/Nc_Osai.cs | 6 + CMS_CORE_Library/Siemens/Nc_Siemens.cs | 6 + .../Siemens/ToolsConfiguration.cs | 447 ++++++++++++++++++ .../CMS_Core_Nc_Demo_Application.csproj | 5 +- .../Nc_Demo_Application/Constants.cs | 7 +- .../Database/DatabaseController.cs | 320 +++++++++---- .../Database/Models/FamilyModel.cs | 22 + .../Database/Models/ToolsDataModel.cs | 49 ++ .../Nc_Demo_Application/Nc_Demo_Db.db | Bin 49152 -> 49152 bytes .../Server/Service/ILibraryService.cs | 18 +- .../Server/Service/LibraryService.cs | 25 + .../Views/DemoApplicationForm.Designer.cs | 318 ++++++++++++- .../Views/DemoApplicationForm.cs | 46 +- .../Views/DemoApplicationForm.resx | 24 + .../Nc_Demo_Application/Views/StartupPanel.cs | 2 +- 27 files changed, 1327 insertions(+), 139 deletions(-) create mode 100644 CMS_CORE_Library/Demo/Models/FamilyModel.cs create mode 100644 CMS_CORE_Library/Demo/Models/ToolDataModel.cs create mode 100644 CMS_CORE_Library/Siemens/ToolsConfiguration.cs create mode 100644 CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/Database/Models/FamilyModel.cs create mode 100644 CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/Database/Models/ToolsDataModel.cs diff --git a/CMS_CORE_Application/Form1.cs b/CMS_CORE_Application/Form1.cs index 87ccd2d..93a48df 100644 --- a/CMS_CORE_Application/Form1.cs +++ b/CMS_CORE_Application/Form1.cs @@ -79,6 +79,7 @@ namespace CMS_CORE_Application ProcessDataModel processData = new ProcessDataModel(); ToolTableConfiguration toolsConfig = new ToolTableConfiguration(); List dataTable = new List(); + List shanks = new List(); byte axisId = 0; @@ -157,6 +158,7 @@ namespace CMS_CORE_Application cmsError = N.PLC_RHeadsData(headsTest, 1); cmsError = N.TOOLS_RToolTable(ref dataTable); + cmsError = N.TOOLS_RShanksData(ref shanks); // 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 f5abb30..49b16d6 100644 --- a/CMS_CORE_Application/ToolDatabase/ToolDatabaseContext.cs +++ b/CMS_CORE_Application/ToolDatabase/ToolDatabaseContext.cs @@ -9,7 +9,7 @@ namespace CMS_CORE_Application.ToolDatabase public class ToolDatabaseContext : DbContext { public DbSet Tools { get; set; } - public DbSet Shanks { get; set; } + public DbSet Shanks { get; set; } public DbSet Family { get; set; } public DbSet Manine { get; set; } diff --git a/CMS_CORE_Application/ToolDatabase/ToolModels.cs b/CMS_CORE_Application/ToolDatabase/ToolModels.cs index d9796c6..6956e85 100644 --- a/CMS_CORE_Application/ToolDatabase/ToolModels.cs +++ b/CMS_CORE_Application/ToolDatabase/ToolModels.cs @@ -22,7 +22,7 @@ namespace CMS_CORE_Application.ToolDatabase [Column("shank")] public int ShankId { get; set; } [ForeignKey("ShankId")] - public ShankModel Shank { get; set; } + public DbShankModel Shank { get; set; } [Column("family")] public int FamilyId { get; set; } [ForeignKey("FamilyId")] @@ -30,7 +30,7 @@ namespace CMS_CORE_Application.ToolDatabase } [Table("shank")] - public class ShankModel + public class DbShankModel { [Key] [Column("id")] diff --git a/CMS_CORE_Library/CMS_CORE_Library.csproj b/CMS_CORE_Library/CMS_CORE_Library.csproj index 602324c..a0ff0cf 100644 --- a/CMS_CORE_Library/CMS_CORE_Library.csproj +++ b/CMS_CORE_Library/CMS_CORE_Library.csproj @@ -132,12 +132,13 @@ + - + diff --git a/CMS_CORE_Library/DataStructures.cs b/CMS_CORE_Library/DataStructures.cs index 0c34450..68428cb 100644 --- a/CMS_CORE_Library/DataStructures.cs +++ b/CMS_CORE_Library/DataStructures.cs @@ -505,6 +505,19 @@ namespace CMS_CORE_Library public List> EdgesData; } + public class ShankModel + { + public int Id; + public List childsTools; + } + + public class ShankChildModel + { + public int ToolId; + public int ChildId; + public string FamilyName; + public int Type; + } #endregion ToolsConfig } diff --git a/CMS_CORE_Library/Demo/ILibraryService.cs b/CMS_CORE_Library/Demo/ILibraryService.cs index 3e10069..677221f 100644 --- a/CMS_CORE_Library/Demo/ILibraryService.cs +++ b/CMS_CORE_Library/Demo/ILibraryService.cs @@ -157,11 +157,27 @@ namespace Nc_Demo_Application.Server.Service void GetTranslations(string language, out Dictionary fileContent); #endregion + #region Family + + [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)] + void PutFamily(FamilyModel familyData); + + #endregion + #region Tools [WebGet(UriTemplate = "tool_table", BodyStyle = WebMessageBodyStyle.Wrapped, ResponseFormat = WebMessageFormat.Json)] void GetTools(out List toolsData); + [WebGet(UriTemplate = "tool_table/shanks", BodyStyle = WebMessageBodyStyle.Wrapped, ResponseFormat = WebMessageFormat.Json)] + void GetShanks(out List shanksData); + + [WebGet(UriTemplate = "tool_table/positions", BodyStyle = WebMessageBodyStyle.Wrapped, ResponseFormat = WebMessageFormat.Json)] + void GetPositions(out List positionsData); + #endregion } } diff --git a/CMS_CORE_Library/Demo/Models/BinaryMemoryModel.cs b/CMS_CORE_Library/Demo/Models/BinaryMemoryModel.cs index dba052b..1680efc 100644 --- a/CMS_CORE_Library/Demo/Models/BinaryMemoryModel.cs +++ b/CMS_CORE_Library/Demo/Models/BinaryMemoryModel.cs @@ -1,36 +1,42 @@ -using System; -using System.Collections.Generic; -using System.Linq; +using System.Collections.Generic; using System.Runtime.Serialization; -using System.Text; -using System.Threading.Tasks; namespace CMS_CORE_Library.Demo.Models { [DataContract] - class BinaryMemoryModel + internal class BinaryMemoryModel { [DataMember] public bool boolean; + [DataMember] public byte binary; + [DataMember] public short word; + [DataMember] public ushort uWord; + [DataMember] public int integer; + [DataMember] public uint dWord; + [DataMember] public List byteList; + [DataMember] public List shortList; + [DataMember] public List wordList; + [DataMember] public List integerList; + [DataMember] public List dWordList; } -} +} \ No newline at end of file diff --git a/CMS_CORE_Library/Demo/Models/FamilyModel.cs b/CMS_CORE_Library/Demo/Models/FamilyModel.cs new file mode 100644 index 0000000..0d7a566 --- /dev/null +++ b/CMS_CORE_Library/Demo/Models/FamilyModel.cs @@ -0,0 +1,18 @@ +using System.Collections.Generic; + +namespace CMS_CORE.Demo.Models +{ + public class FamilyModel + { + public int id; + public string name; + public List childTools; + } + + public class ChildTool + { + 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 new file mode 100644 index 0000000..7420aad --- /dev/null +++ b/CMS_CORE_Library/Demo/Models/ToolDataModel.cs @@ -0,0 +1,49 @@ +using System.Collections.Generic; + +namespace CMS_CORE.Demo.Models +{ + public class ToolsDataModel + { + public int Id; + public int MagazineId; + public string FamilyName; + public int ChildId; + public int MagazinePositionType; + public int ToolType; + public int LeftSize; + public int RightSize; + public int Rotation; + public bool Cooling1; + public bool Cooling2; + public bool IsActive; + public bool FixedPlace; + public bool IsInhibited; + public bool IsMeasured; + public bool ChangeTool; + public bool IsInUse; + public bool PreAlarm; + public int ShanksId; + public List> EdgesData; + } + + public class ShankDataModel + { + public int Id; + public List childsTools; + } + + public class ShankChildDataModel + { + public int ToolId; + public int ChildId; + public string FamilyName; + public int Type; + } + + public class PositionsDataModel + { + public int Id; + public int MagazineId; + public int Type; + } +} \ No newline at end of file diff --git a/CMS_CORE_Library/Demo/Nc_Demo.cs b/CMS_CORE_Library/Demo/Nc_Demo.cs index a339745..9409431 100644 --- a/CMS_CORE_Library/Demo/Nc_Demo.cs +++ b/CMS_CORE_Library/Demo/Nc_Demo.cs @@ -1767,6 +1767,42 @@ namespace CMS_CORE.Demo } } + public override CmsError TOOLS_RShanksData(ref List shanksData) + { + // Check if the NC Demo is Connected + CmsError cmsError = CheckConnection(); + if (cmsError.IsError()) + return cmsError; + + try + { + shanksData = new List(); + // Get tool table data + serverService.GetShanks(out List demoShanksData); + + foreach (ShankDataModel shank in demoShanksData) + { + shanksData.Add(new ShankModel() + { + Id = shank.Id, + childsTools = shank.childsTools.Select(x => new ShankChildModel() + { + ToolId = x.ToolId, + ChildId = x.ChildId, + FamilyName = x.FamilyName, + Type = x.Type + }).ToList() + }); + } + + 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 cf1642a..bf74ffc 100644 --- a/CMS_CORE_Library/Fanuc/Nc_Fanuc.cs +++ b/CMS_CORE_Library/Fanuc/Nc_Fanuc.cs @@ -1675,6 +1675,11 @@ namespace CMS_CORE.Fanuc return NO_ERROR; } + public override CmsError TOOLS_RShanksData(ref List shanksData) + { + return NO_ERROR; + } + #endregion Tools Management /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/CMS_CORE_Library/Nc.cs b/CMS_CORE_Library/Nc.cs index 889c57b..d7cf227 100644 --- a/CMS_CORE_Library/Nc.cs +++ b/CMS_CORE_Library/Nc.cs @@ -1302,6 +1302,9 @@ namespace CMS_CORE public abstract CmsError TOOLS_RToolTable(ref List toolTable); + + public abstract CmsError TOOLS_RShanksData(ref List shanksData); + #endregion File Management (To override) /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/CMS_CORE_Library/Osai/Nc_Osai.cs b/CMS_CORE_Library/Osai/Nc_Osai.cs index ea304c2..e1663b9 100644 --- a/CMS_CORE_Library/Osai/Nc_Osai.cs +++ b/CMS_CORE_Library/Osai/Nc_Osai.cs @@ -2045,6 +2045,12 @@ namespace CMS_CORE.Osai return NO_ERROR; } + public override CmsError TOOLS_RShanksData(ref List shanksData) + { + 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 6fff1aa..e4ece4c 100644 --- a/CMS_CORE_Library/Siemens/Nc_Siemens.cs +++ b/CMS_CORE_Library/Siemens/Nc_Siemens.cs @@ -1866,6 +1866,12 @@ namespace CMS_CORE.Siemens return toolValues; } + public override CmsError TOOLS_RShanksData(ref List shanksData) + { + return NO_ERROR; + } + + #endregion Tool Management /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/CMS_CORE_Library/Siemens/ToolsConfiguration.cs b/CMS_CORE_Library/Siemens/ToolsConfiguration.cs new file mode 100644 index 0000000..5817c73 --- /dev/null +++ b/CMS_CORE_Library/Siemens/ToolsConfiguration.cs @@ -0,0 +1,447 @@ +using System.Collections.Generic; + +namespace CMS_CORE_Library.Siemens +{ + internal class SiemensAdditionalParams + { + public class ToolConfig + { + public string Name; + public string Path; + } + + public Dictionary> ToolsSettings = new Dictionary>() + { + { + 100, new List() + { + new ToolConfig{Name = "CuttingEdge", Path = "$TC_DP2["}, + new ToolConfig{Name = "Lenght", Path = "$TC_DP3["}, + new ToolConfig{Name = "Radius", Path = "$TC_DP6["}, + new ToolConfig{Name = "WearLenght", Path = "$TC_DP12["}, + new ToolConfig{Name = "WearRadius", Path = "$TC_DP15["}, + new ToolConfig{Name = "Teeth", Path = "$TC_DPNT[" } + } + }, + { + 110, new List() + { + new ToolConfig{Name = "CuttingEdge", Path = "$TC_DP2["}, + new ToolConfig{Name = "Lenght", Path = "$TC_DP3["}, + new ToolConfig{Name = "Radius", Path = "$TC_DP6["}, + new ToolConfig{Name = "WearLenght", Path = "$TC_DP12["}, + new ToolConfig{Name = "WearRadius", Path = "$TC_DP15["}, + new ToolConfig{Name = "Teeth", Path = "$TC_DPNT[" } + } + }, + { + 111, new List() + { + new ToolConfig{Name = "CuttingEdge", Path = "$TC_DP2["}, + new ToolConfig{Name = "Lenght", Path = "$TC_DP3["}, + new ToolConfig{Name = "Radius", Path = "$TC_DP6["}, + new ToolConfig{Name = "CornerRadius", Path = "$TC_DP7["}, + new ToolConfig{Name = "WearLenght", Path = "$TC_DP12["}, + new ToolConfig{Name = "WearRadius", Path = "$TC_DP15["}, + new ToolConfig{Name = "Teeth", Path = "$TC_DPNT[" } + } + }, + { + 120, new List() + { + new ToolConfig{Name = "CuttingEdge", Path = "$TC_DP2["}, + new ToolConfig{Name = "Lenght", Path = "$TC_DP3["}, + new ToolConfig{Name = "Radius", Path = "$TC_DP6["}, + new ToolConfig{Name = "WearLenght", Path = "$TC_DP12["}, + new ToolConfig{Name = "WearRadius", Path = "$TC_DP15["}, + new ToolConfig{Name = "Teeth", Path = "$TC_DPNT[" } + } + }, + { + 121, new List() + { + new ToolConfig{Name = "CuttingEdge", Path = "$TC_DP2["}, + new ToolConfig{Name = "Lenght", Path = "$TC_DP3["}, + new ToolConfig{Name = "Radius", Path = "$TC_DP6["}, + new ToolConfig{Name = "WearLenght", Path = "$TC_DP12["}, + new ToolConfig{Name = "WearRadius", Path = "$TC_DP15["}, + new ToolConfig{Name = "Teeth", Path = "$TC_DPNT[" } + } + }, + { + 130, new List() + { + new ToolConfig{Name = "CuttingEdge", Path = "$TC_DP2["}, + new ToolConfig{Name = "GeomLenght1", Path = "$TC_DP3["}, + new ToolConfig{Name = "GeomLenght2", Path = "$TC_DP4["}, + new ToolConfig{Name = "GeomLenght3", Path = "$TC_DP5["}, + new ToolConfig{Name = "Radius", Path = "$TC_DP6["}, + new ToolConfig{Name = "GeomDeltaLenght1", Path = "$TC_DP12["}, + new ToolConfig{Name = "GeomDeltaLenght2", Path = "$TC_DP13["}, + new ToolConfig{Name = "GeomDeltaLenght3", Path = "$TC_DP14["}, + new ToolConfig{Name = "WearRadius", Path = "$TC_DP15["}, + new ToolConfig{Name = "AdapterLenght1", Path = "$TC_DP21["}, + new ToolConfig{Name = "AdapterLenght2", Path = "$TC_DP22["}, + new ToolConfig{Name = "AdapterLenght3", Path = "$TC_DP23["}, + new ToolConfig{Name = "V", Path = "$TC_DPV["}, + new ToolConfig{Name = "Vector1", Path = "$TC_DPV3["}, + new ToolConfig{Name = "Vector2", Path = "$TC_DPV4["}, + new ToolConfig{Name = "Vector3", Path = "$TC_DPV5["}, + new ToolConfig{Name = "Teeth", Path = "$TC_DPNT[" } + } + }, + { + 131, new List() + { + new ToolConfig{Name = "CuttingEdge", Path = "$TC_DP2["}, + new ToolConfig{Name = "GeomLenght1", Path = "$TC_DP3["}, + new ToolConfig{Name = "GeomLenght2", Path = "$TC_DP4["}, + new ToolConfig{Name = "GeomLenght3", Path = "$TC_DP5["}, + new ToolConfig{Name = "Radius", Path = "$TC_DP6["}, + new ToolConfig{Name = "GeomDeltaLenght1", Path = "$TC_DP12["}, + new ToolConfig{Name = "GeomDeltaLenght2", Path = "$TC_DP13["}, + new ToolConfig{Name = "GeomDeltaLenght3", Path = "$TC_DP14["}, + new ToolConfig{Name = "WearRadius", Path = "$TC_DP15["}, + new ToolConfig{Name = "AdapterLenght1", Path = "$TC_DP21["}, + new ToolConfig{Name = "AdapterLenght2", Path = "$TC_DP22["}, + new ToolConfig{Name = "AdapterLenght3", Path = "$TC_DP23["}, + new ToolConfig{Name = "V", Path = "$TC_DPV["}, + new ToolConfig{Name = "Vector1", Path = "$TC_DPV3["}, + new ToolConfig{Name = "Vector2", Path = "$TC_DPV4["}, + new ToolConfig{Name = "Vector3", Path = "$TC_DPV5["}, + new ToolConfig{Name = "Teeth", Path = "$TC_DPNT[" } + } + }, + { + 140, new List() + { + new ToolConfig{Name = "CuttingEdge", Path = "$TC_DP2["}, + new ToolConfig{Name = "Lenght", Path = "$TC_DP3["}, + new ToolConfig{Name = "Radius", Path = "$TC_DP6["}, + new ToolConfig{Name = "OutsideRadius", Path = "$TC_DP17["}, + new ToolConfig{Name = "ToolAngle", Path = "$TC_DP11["}, + new ToolConfig{Name = "Teeth", Path = "$TC_DPNT[" } + } + }, + { + 145, new List() + { + new ToolConfig{Name = "CuttingEdge", Path = "$TC_DP2["}, + new ToolConfig{Name = "Lenght", Path = "$TC_DP3["}, + new ToolConfig{Name = "Radius", Path = "$TC_DP6["}, + new ToolConfig{Name = "WearLenght", Path = "$TC_DP12["}, + new ToolConfig{Name = "WearRadius", Path = "$TC_DP15["}, + new ToolConfig{Name = "Teeth", Path = "$TC_DPNT[" } + } + }, + { + 150, new List() + { + new ToolConfig{Name = "CuttingEdge", Path = "$TC_DP2["}, + new ToolConfig{Name = "Lenght", Path = "$TC_DP3["}, + new ToolConfig{Name = "Radius", Path = "$TC_DP6["}, + new ToolConfig{Name = "Width", Path = "$TC_DP9[" }, + new ToolConfig{Name = "WearLenght", Path = "$TC_DP12["}, + new ToolConfig{Name = "WearRadius", Path = "$TC_DP15[" }, + new ToolConfig{Name = "Teeth", Path = "$TC_DPNT[" } + } + }, + { + 151, new List() + { + new ToolConfig{Name = "CuttingEdge", Path = "$TC_DP2["}, + new ToolConfig{Name = "Lenght", Path = "$TC_DP3["}, + new ToolConfig{Name = "Radius", Path = "$TC_DP6["}, + new ToolConfig{Name = "Width", Path = "$TC_DP9[" }, + new ToolConfig{Name = "WearLenght", Path = "$TC_DP12["}, + new ToolConfig{Name = "WearRadius", Path = "$TC_DP15[" }, + new ToolConfig{Name = "Teeth", Path = "$TC_DPNT[" } + } + }, + { + 155, new List() + { + new ToolConfig{Name = "CuttingEdge", Path = "$TC_DP2["}, + new ToolConfig{Name = "Lenght", Path = "$TC_DP3["}, + new ToolConfig{Name = "Radius", Path = "$TC_DP6["}, + new ToolConfig{Name = "TaperAngle", Path = "$TC_DP11[" }, + new ToolConfig{Name = "WearLenght", Path = "$TC_DP12["}, + new ToolConfig{Name = "WearRadius", Path = "$TC_DP15["}, + new ToolConfig{Name = "Teeth", Path = "$TC_DPNT[" } + } + }, + { + 156, new List() + { + new ToolConfig{Name = "CuttingEdge", Path = "$TC_DP2["}, + new ToolConfig{Name = "Lenght", Path = "$TC_DP3["}, + new ToolConfig{Name = "Radius", Path = "$TC_DP6["}, + new ToolConfig{Name = "CornerRadius", Path = "$TC_DP7["}, + new ToolConfig{Name = "TaperAngle", Path = "$TC_DP11[" }, + new ToolConfig{Name = "WearLenght", Path = "$TC_DP12["}, + new ToolConfig{Name = "WearRadius", Path = "$TC_DP15["}, + new ToolConfig{Name = "Teeth", Path = "$TC_DPNT[" } + } + }, + { + 157, new List() + { + new ToolConfig{Name = "CuttingEdge", Path = "$TC_DP2["}, + new ToolConfig{Name = "Lenght", Path = "$TC_DP3["}, + new ToolConfig{Name = "Radius", Path = "$TC_DP6["}, + new ToolConfig{Name = "TaperAngle", Path = "$TC_DP11[" }, + new ToolConfig{Name = "WearLenght", Path = "$TC_DP12["}, + new ToolConfig{Name = "WearRadius", Path = "$TC_DP15["}, + new ToolConfig{Name = "Teeth", Path = "$TC_DPNT[" } + } + }, + { + 160, new List() + { + new ToolConfig{Name = "CuttingEdge", Path = "$TC_DP2["}, + new ToolConfig{Name = "Lenght", Path = "$TC_DP3["}, + new ToolConfig{Name = "Radius", Path = "$TC_DP6["}, + new ToolConfig{Name = "WearLenght", Path = "$TC_DP12["}, + new ToolConfig{Name = "WearRadius", Path = "$TC_DP15["}, + new ToolConfig{Name = "Teeth", Path = "$TC_DPNT[" } + } + }, + //////// 200 + { + 200, new List() + { + new ToolConfig{ Name = "CuttingEdge", Path = "$TC_DP2["}, + new ToolConfig{ Name = "Lenght", Path = "$TC_DP3["}, + new ToolConfig{ Name = "Radius", Path = "$TC_DP6["}, + new ToolConfig{ Name = "WearLenght", Path = "$TC_DP12"}, + new ToolConfig{ Name = "WearRadius", Path = "$TC_DP15["}, + new ToolConfig{ Name = "TipAngle", Path = "$TC_DP24["} + } + }, + { + 205, new List() + { + new ToolConfig{ Name = "CuttingEdge", Path = "$TC_DP2["}, + new ToolConfig{ Name = "Lenght", Path = "$TC_DP3["}, + new ToolConfig{ Name = "Radius", Path = "$TC_DP6["}, + new ToolConfig{ Name = "WearLenght", Path = "$TC_DP12"}, + new ToolConfig{ Name = "WearRadius", Path = "$TC_DP15["} + } + }, + { + 210, new List() + { + new ToolConfig{ Name = "CuttingEdge", Path = "$TC_DP2["}, + new ToolConfig{ Name = "Lenght", Path = "$TC_DP3["}, + new ToolConfig{ Name = "Radius", Path = "$TC_DP6["}, + new ToolConfig{ Name = "WearLenght", Path = "$TC_DP12"}, + new ToolConfig{ Name = "WearRadius", Path = "$TC_DP15["} + } + }, + { + 220, new List() + { + new ToolConfig{ Name = "CuttingEdge", Path = "$TC_DP2["}, + new ToolConfig{ Name = "Lenght", Path = "$TC_DP3["}, + new ToolConfig{ Name = "Radius", Path = "$TC_DP6["}, + new ToolConfig{ Name = "WearLenght", Path = "$TC_DP12"}, + new ToolConfig{ Name = "WearRadius", Path = "$TC_DP15["}, + new ToolConfig{ Name = "TipAngle", Path = "$TC_DP24["} + } + }, + { + 230, new List() + { + new ToolConfig{ Name = "CuttingEdge", Path = "$TC_DP2["}, + new ToolConfig{ Name = "Lenght", Path = "$TC_DP3["}, + new ToolConfig{ Name = "Radius", Path = "$TC_DP6["}, + new ToolConfig{ Name = "WearLenght", Path = "$TC_DP12"}, + new ToolConfig{ Name = "WearRadius", Path = "$TC_DP15["}, + new ToolConfig{ Name = "TipAngle", Path = "$TC_DP24["} + } + }, + { + 231, new List() + { + new ToolConfig{ Name = "CuttingEdge", Path = "$TC_DP2["}, + new ToolConfig{ Name = "Lenght", Path = "$TC_DP3["}, + new ToolConfig{ Name = "Radius", Path = "$TC_DP6["}, + new ToolConfig{ Name = "WearLenght", Path = "$TC_DP12"}, + new ToolConfig{ Name = "WearRadius", Path = "$TC_DP15["} + } + }, + { + 240, new List() + { + new ToolConfig{ Name = "CuttingEdge", Path = "$TC_DP2["}, + new ToolConfig{ Name = "Lenght", Path = "$TC_DP3["}, + new ToolConfig{ Name = "Radius", Path = "$TC_DP6["}, + new ToolConfig{ Name = "Pitch", Path = "$TC_DP9["}, + new ToolConfig{ Name = "WearLenght", Path = "$TC_DP12"}, + new ToolConfig{ Name = "WearRadius", Path = "$TC_DP15["} + } + }, + { + 241, new List() + { + new ToolConfig{ Name = "CuttingEdge", Path = "$TC_DP2["}, + new ToolConfig{ Name = "Lenght", Path = "$TC_DP3["}, + new ToolConfig{ Name = "Radius", Path = "$TC_DP6["}, + new ToolConfig{ Name = "WearLenght", Path = "$TC_DP12"}, + new ToolConfig{ Name = "WearRadius", Path = "$TC_DP15["} + } + }, + { + 242, new List() + { + new ToolConfig{ Name = "CuttingEdge", Path = "$TC_DP2["}, + new ToolConfig{ Name = "Lenght", Path = "$TC_DP3["}, + new ToolConfig{ Name = "Radius", Path = "$TC_DP6["}, + new ToolConfig{ Name = "Pitch", Path = "$TC_DP9["}, + new ToolConfig{ Name = "WearLenght", Path = "$TC_DP12"}, + new ToolConfig{ Name = "WearRadius", Path = "$TC_DP15["} + } + }, + { + 250, new List() + { + new ToolConfig{ Name = "CuttingEdge", Path = "$TC_DP2["}, + new ToolConfig{ Name = "Lenght", Path = "$TC_DP3["}, + new ToolConfig{ Name = "Radius", Path = "$TC_DP6["}, + new ToolConfig{ Name = "Pitch", Path = "$TC_DP9["}, + new ToolConfig{ Name = "WearLenght", Path = "$TC_DP12"}, + new ToolConfig{ Name = "WearRadius", Path = "$TC_DP15["} + } + }, + ///////// 700 + { + 700, new List() + { + new ToolConfig{Name = "CuttingEdge", Path = "$TC_DP2["}, + new ToolConfig{Name = "GeomLenght1", Path = "$TC_DP3["}, + new ToolConfig{Name = "GeomLenght2", Path = "$TC_DP4["}, + new ToolConfig{Name = "GeomLenght3", Path = "$TC_DP5["}, + //new ToolConfiguration{Name = "Radius", Path = "$TC_DP6["}, + new ToolConfig{Name = "GeomSlotWidth", Path = "$TC_DP7["}, + new ToolConfig{Name = "GeomPrjection", Path = "$TC_DP8["}, + new ToolConfig{Name = "GeomWearLenght1", Path = "$TC_DP12["}, + new ToolConfig{Name = "GeomWearLenght2", Path = "$TC_DP13["}, + new ToolConfig{Name = "GeomWearLenght3", Path = "$TC_DP14["}, + new ToolConfig{Name = "Wear", Path = "$TC_DP15["}, // ? + new ToolConfig{Name = "WearSlotWdth", Path = "$TC_DP16["}, + new ToolConfig{Name = "WearGeomPrjection", Path = "$TC_DP17["}, + new ToolConfig{Name = "AdapterLenght1", Path = "$TC_DP21["}, + new ToolConfig{Name = "AdapterLenght2", Path = "$TC_DP22["}, + new ToolConfig{Name = "AdapterLenght3", Path = "$TC_DP23["} + } + }, + { + 710, new List() + { + new ToolConfig{Name = "CuttingEdge", Path = "$TC_DP2["}, + new ToolConfig{Name = "Lenght", Path = "$TC_DP3["}, + new ToolConfig{Name = "Radius", Path = "$TC_DP6["}, + new ToolConfig{Name = "WearLenght", Path = "$TC_DP12["}, + new ToolConfig{Name = "WearRadius", Path = "$TC_DP15["} + } + }, + { + 711, new List() + { + new ToolConfig{Name = "CuttingEdge", Path = "$TC_DP2["}, + new ToolConfig{Name = "Lenght", Path = "$TC_DP3["}, + new ToolConfig{Name = "Radius", Path = "$TC_DP6["}, + new ToolConfig{Name = "WearLenght", Path = "$TC_DP12["}, + new ToolConfig{Name = "WearRadius", Path = "$TC_DP15["} + } + }, + { + 712, new List() + { + new ToolConfig{Name = "CuttingEdge", Path = "$TC_DP2["}, + new ToolConfig{Name = "Lenght", Path = "$TC_DP3["}, + new ToolConfig{Name = "Radius", Path = "$TC_DP6["}, + new ToolConfig{Name = "CorrAngle", Path = "$TC_DP10["}, + new ToolConfig{Name = "WearLenght", Path = "$TC_DP12["}, + new ToolConfig{Name = "WearRadius", Path = "$TC_DP15["} + } + }, + { + 713, new List() + { + new ToolConfig{Name = "CuttingEdge", Path = "$TC_DP2["}, + new ToolConfig{Name = "GeomLenght1", Path = "$TC_DP3["}, + new ToolConfig{Name = "GeomLenght2", Path = "$TC_DP4["}, + new ToolConfig{Name = "GeomLenght3", Path = "$TC_DP5["}, + new ToolConfig{Name = "Radius", Path = "$TC_DP6["}, + new ToolConfig{Name = "BoomLenght", Path = "$TC_DP7["}, + new ToolConfig{Name = "CorrAngle", Path = "$TC_DP10["}, + new ToolConfig{Name = "GeomWearLenght1", Path = "$TC_DP12["}, + new ToolConfig{Name = "GeomWearLenght2", Path = "$TC_DP13["}, + new ToolConfig{Name = "GeomWearLenght3", Path = "$TC_DP14["}, + new ToolConfig{Name = "WearRadius", Path = "$TC_DP15["}, + new ToolConfig{Name = "AdapterLenght1", Path = "$TC_DP21["}, + new ToolConfig{Name = "AdapterLenght2", Path = "$TC_DP22["}, + new ToolConfig{Name = "AdapterLenght3", Path = "$TC_DP23["} + } + }, + { + 714, new List() + { + new ToolConfig{Name = "CuttingEdge", Path = "$TC_DP2["}, + new ToolConfig{Name = "GeomLenght1", Path = "$TC_DP3["}, + new ToolConfig{Name = "GeomLenght2", Path = "$TC_DP4["}, + new ToolConfig{Name = "GeomLenght3", Path = "$TC_DP5["}, + new ToolConfig{Name = "Radius", Path = "$TC_DP6["}, + new ToolConfig{Name = "BallRadius", Path = "$TC_DP7["}, + new ToolConfig{Name = "CorrAngle", Path = "$TC_DP10["}, + new ToolConfig{Name = "GeomWearLenght1", Path = "$TC_DP12["}, + new ToolConfig{Name = "GeomWearLenght2", Path = "$TC_DP13["}, + new ToolConfig{Name = "GeomWearLenght3", Path = "$TC_DP14["}, + new ToolConfig{Name = "WearRadius", Path = "$TC_DP15["}, + new ToolConfig{Name = "AdapterLenght1", Path = "$TC_DP21["}, + new ToolConfig{Name = "AdapterLenght2", Path = "$TC_DP22["}, + new ToolConfig{Name = "AdapterLenght3", Path = "$TC_DP23["} + } + }, + { + 725, new List() + { + new ToolConfig{Name = "CuttingEdge", Path = "$TC_DP2["}, + new ToolConfig{Name = "GeomLenght1", Path = "$TC_DP3["}, + new ToolConfig{Name = "GeomLenght2", Path = "$TC_DP4["}, + new ToolConfig{Name = "GeomLenght3", Path = "$TC_DP5["}, + new ToolConfig{Name = "Radius", Path = "$TC_DP6["}, + new ToolConfig{Name = "CorrAngle", Path = "$TC_DP10["}, + new ToolConfig{Name = "GeomWearLenght1", Path = "$TC_DP12["}, + new ToolConfig{Name = "GeomWearLenght2", Path = "$TC_DP13["}, + new ToolConfig{Name = "GeomWearLenght3", Path = "$TC_DP14["}, + new ToolConfig{Name = "WearRadius", Path = "$TC_DP15["}, + new ToolConfig{Name = "AdapterLenght1", Path = "$TC_DP21["}, + new ToolConfig{Name = "AdapterLenght2", Path = "$TC_DP22["}, + new ToolConfig{Name = "AdapterLenght3", Path = "$TC_DP23["} + } + }, + { + 730, new List() + { + new ToolConfig{Name = "CuttingEdge", Path = "$TC_DP2["}, + new ToolConfig{Name = "Lenght", Path = "$TC_DP3["}, + new ToolConfig{Name = "Radius", Path = "$TC_DP6["}, + new ToolConfig{Name = "WearLenght", Path = "$TC_DP12["}, + new ToolConfig{Name = "WearRadius", Path = "$TC_DP15["} + } + }, + { + 900, new List() + { + new ToolConfig{Name = "CuttingEdge", Path = "$TC_DP2["}, + new ToolConfig{Name = "Lenght", Path = "$TC_DP3["}, + new ToolConfig{Name = "Radius", Path = "$TC_DP6["}, + new ToolConfig{Name = "WearLenght", Path = "$TC_DP12["}, + new ToolConfig{Name = "WearRadius", Path = "$TC_DP15["} + } + }, + }; + } +} \ No newline at end of file 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 e83036b..afed6e3 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 @@ -114,6 +114,7 @@ + @@ -157,9 +158,9 @@ StartupPanel.cs - + PreserveNewest - + Designer diff --git a/CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/Constants.cs b/CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/Constants.cs index 863226d..bc36c24 100644 --- a/CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/Constants.cs +++ b/CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/Constants.cs @@ -14,8 +14,11 @@ namespace Nc_Demo_Application public const string READ_NC_ALARMS_QUERY = "SELECT * FROM alarm"; public const string READ_NC_AXES_QUERY = "SELECT * FROM axis"; public const string READ_BINARY_MEMORY_QUERY = "SELECT * FROM binary_memory"; - public const string READ_TOOLS_QUERY = "SELECT * FROM tools"; - + public const string READ_TOOLS_QUERY = "SELECT * FROM tool"; + public const string READ_FAMILIES_QUERY = "SELECT * FROM family"; + public const string READ_SHANKS_QUERY = "SELECT * FROM shank"; + public const string READ_MAGAZINES_QUERY = "SELECT * FROM magazine"; + // Server configuration public static string SERVER_PORT = ":8080"; public const string SERVER_IP_ADDRESS = "http://localhost"; 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 c8408be..73aedd1 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 @@ -23,21 +23,30 @@ namespace Nc_Demo_Application.Database private DataTable NcAxesDataTable; private DataTable BinaryMemory; private DataTable ToolsDataTable; + private DataTable FamiliesDataTable; + private DataTable ShanksDataTable; + private DataTable MagazinesDataTable; + + #region Constructor & Private functions private DatabaseController() { SetConnection(); + // Initialize datatables NcDatatable = new DataTable(); NcAlarmDataTable = new DataTable(); NcAxesDataTable = new DataTable(); - + FamiliesDataTable = new DataTable(); + ToolsDataTable = new DataTable(); + ShanksDataTable = new DataTable(); + MagazinesDataTable = new DataTable(); NcProcessDataTable = new DataTable(); + BinaryMemory = new DataTable(); + // Create ncProcess columns NcProcessDataTable.Columns.Add("status", typeof(PROC_STATUS)); NcProcessDataTable.Columns.Add("mode", typeof(PROC_MODE)); - BinaryMemory = new DataTable(); - // Create byte memory dataTable columns and set order DataColumn address = BinaryMemory.Columns.Add("address", typeof(int)); address.SetOrdinal(0); @@ -45,8 +54,6 @@ namespace Nc_Demo_Application.Database BinaryMemory.Columns.Add("binary", typeof(string)).SetOrdinal(2); BinaryMemory.Columns.Add("word", typeof(short)).SetOrdinal(3); BinaryMemory.Columns.Add("integer", typeof(int)).SetOrdinal(4); - - ToolsDataTable = new DataTable(); } public static DatabaseController getInstance() @@ -56,10 +63,10 @@ namespace Nc_Demo_Application.Database return databaseInstance; } - // Setup a new database connection private void SetConnection() { if (sqlConnection == null) + // Setup a new database connection sqlConnection = new SQLiteConnection("Data Source=" + RUNNING_PATH_DIR + DATABASE_FILE_NAME + ";Version=3;New=False;"); } @@ -70,6 +77,9 @@ namespace Nc_Demo_Application.Database NcAlarmDataTable.Dispose(); NcAxesDataTable.Dispose(); ToolsDataTable.Dispose(); + FamiliesDataTable.Dispose(); + ShanksDataTable.Dispose(); + MagazinesDataTable.Dispose(); sqlConnection.Close(); } @@ -90,6 +100,33 @@ namespace Nc_Demo_Application.Database sqlConnection.Close(); } + public void UpdateDatabaseFromGridView(DataTable newDataTable, string readingQuery) + { + 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(readingQuery, sqlConnection); + SQLiteDataAdapter adapter = new SQLiteDataAdapter(sqlCommand); + SQLiteCommandBuilder commandBuilder = new SQLiteCommandBuilder(adapter); + + // Update database with new data + adapter.Update(newDataTable); + + // Close the connection with database + sqlConnection.Close(); + } + catch (Exception ex) + { + Console.WriteLine("Update query: " + readingQuery + "\nException: " + ex.Message); + } + } + + #endregion Constructor & Private functions + #region Nc Data Methods public NcDataModel ReadNcData() @@ -219,27 +256,7 @@ namespace Nc_Demo_Application.Database public void UpdateNcProcess(DataTable ncProcessData) { - 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_NC_PROCESS_QUERY, sqlConnection); - SQLiteDataAdapter adapter = new SQLiteDataAdapter(sqlCommand); - SQLiteCommandBuilder commandBuilder = new SQLiteCommandBuilder(adapter); - - // Update ncData - adapter.Update(ncProcessData); - - // Close the connection with database - sqlConnection.Close(); - } - catch (Exception ex) - { - Console.WriteLine("ReadNcData exception: " + ex.Message); - } + UpdateDatabaseFromGridView(ncProcessData, READ_NC_PROCESS_QUERY); } #endregion Nc Processes Data @@ -256,7 +273,7 @@ namespace Nc_Demo_Application.Database } catch (Exception ex) { - Console.WriteLine("ReadNcData exception: " + ex.Message); + Console.WriteLine("Read alarms exception: " + ex.Message); return null; } } @@ -289,27 +306,7 @@ namespace Nc_Demo_Application.Database public void UpdateNcAlarms(DataTable ncAlarms) { - 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_NC_ALARMS_QUERY, sqlConnection); - SQLiteDataAdapter adapter = new SQLiteDataAdapter(sqlCommand); - SQLiteCommandBuilder commandBuilder = new SQLiteCommandBuilder(adapter); - - // Update ncData - adapter.Update(ncAlarms); - - // Close the connection with database - sqlConnection.Close(); - } - catch (Exception ex) - { - Console.WriteLine("ReadNcData exception: " + ex.Message); - } + UpdateDatabaseFromGridView(ncAlarms, READ_NC_ALARMS_QUERY); } #endregion Nc Alarms Data @@ -361,27 +358,7 @@ namespace Nc_Demo_Application.Database public void UpdateNcAxes(DataTable ncAxes) { - 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_NC_AXES_QUERY, sqlConnection); - SQLiteDataAdapter adapter = new SQLiteDataAdapter(sqlCommand); - SQLiteCommandBuilder commandBuilder = new SQLiteCommandBuilder(adapter); - - // Update ncData - adapter.Update(ncAxes); - - // Close the connection with database - sqlConnection.Close(); - } - catch (Exception ex) - { - Console.WriteLine("ReadNcData exception: " + ex.Message); - } + UpdateDatabaseFromGridView(ncAxes, READ_NC_AXES_QUERY); } #endregion Nc Axes Data @@ -437,27 +414,7 @@ namespace Nc_Demo_Application.Database public void UpdateBinaryMemory(DataTable binaryMemory) { - 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_BINARY_MEMORY_QUERY, sqlConnection); - SQLiteDataAdapter adapter = new SQLiteDataAdapter(sqlCommand); - SQLiteCommandBuilder commandBuilder = new SQLiteCommandBuilder(adapter); - - // Update ncData - adapter.Update(binaryMemory); - - // Close the connection with database - sqlConnection.Close(); - } - catch (Exception ex) - { - Console.WriteLine("ReadNcData exception: " + ex.Message); - } + UpdateDatabaseFromGridView(binaryMemory, READ_BINARY_MEMORY_QUERY); } public byte GetByteValue(int index) @@ -596,6 +553,135 @@ namespace Nc_Demo_Application.Database #endregion Binary Memory + #region Families + + public DataTable ReadFamilies() + { + try + { + ReadDataFromDatabase(READ_FAMILIES_QUERY, ref FamiliesDataTable); + + return FamiliesDataTable; + } + catch (Exception ex) + { + Console.WriteLine("Read Families exception: " + ex.Message); + return null; + } + } + + public List GetFamilies() + { + int lastId = 0; + List Family = new List(); + foreach (DataRow row in FamiliesDataTable.Rows) + { + if (Convert.IsDBNull(row["id"])) + lastId = lastId + 1; + else + lastId = Convert.ToInt32(row["id"]); + + string name = row["name"].ToString(); + List childTools = GetToolsData() + .Where(x => x.FamilyName == name) + .Select(x => new ChildTool() + { + 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 + }; + + Family.Add(tmpFamily); + } + + return Family; + } + + public void UpdateFamilies(DataTable families) + { + UpdateDatabaseFromGridView(families, READ_FAMILIES_QUERY); + } + + public void UpdateFamily(FamilyModel familyData) + { + DataRow row = FamiliesDataTable.AsEnumerable().SingleOrDefault(x => Convert.ToInt32(x["id"]) == familyData.id); + + row["name"] = familyData.name; + + UpdateFamilies(FamiliesDataTable); + } + + #endregion Families + + #region Shanks + + public DataTable ReadShanks() + { + try + { + ReadDataFromDatabase(READ_SHANKS_QUERY, ref ShanksDataTable); + + return ShanksDataTable; + } + catch (Exception ex) + { + Console.WriteLine("Read Shanks exception: " + ex.Message); + return null; + } + } + + public List GetShanks() + { + int lastId = 0; + List shanks = new List(); + foreach (DataRow row in ShanksDataTable.Rows) + { + if (Convert.IsDBNull(row["id"])) + lastId = lastId + 1; + else + lastId = Convert.ToInt32(row["id"]); + // Create&Populate shanks childs + int i = 1; + List childTools = GetToolsData() + .Where(x => x.ShanksId == lastId) + .Select(x => new ShankChildDataModel() + { + ToolId = x.Id, + Type = x.ToolType, + FamilyName = x.FamilyName, + ChildId = i++ + }) + .ToList(); + + // Convert DataTable.row into family model + ShankDataModel tmpShank = new ShankDataModel + { + Id = lastId, + childsTools = childTools + }; + + shanks.Add(tmpShank); + } + + return shanks; + } + + public void UpdateShanks(DataTable shanks) + { + UpdateDatabaseFromGridView(shanks, READ_SHANKS_QUERY); + } + + #endregion Shanks + #region Tools public List ReadTools() @@ -626,11 +712,12 @@ namespace Nc_Demo_Application.Database MagazineId = Convert.ToInt32(row["magazine"]), FamilyName = row["family"].ToString(), ChildId = Convert.ToInt32(row["childId"]), - MagazinePositionType = Convert.ToInt32(row["magazinePositionType"]), + MagazinePositionType = Convert.ToInt32(row["magazinePositionType"]), ToolType = Convert.ToInt32(row["toolType"]), LeftSize = Convert.ToInt32(row["sizeLeft"]), RightSize = Convert.ToInt32(row["sizeRight"]), Rotation = Convert.ToInt32(row["rotation"]), + ShanksId = Convert.ToInt32(row["shankId"]), Cooling1 = Convert.ToInt32(row["cooling1"]) == 1, Cooling2 = Convert.ToInt32(row["cooling2"]) == 1, IsActive = Convert.ToInt32(row["isActive"]) == 1, @@ -665,7 +752,7 @@ namespace Nc_Demo_Application.Database // DataRow row = ToolsDataTable.AsEnumerable().SingleOrDefault(x => Convert.ToInt32(x["id"]) == toolData.Id); DataRow row = ToolsDataTable.NewRow(); toolData.Id = Convert.ToInt32(ToolsDataTable.Rows[ToolsDataTable.Rows.Count - 1]["id"]) + 1; - + // Setup autoincrement Id row["id"] = toolData.Id; row["family"] = toolData.FamilyName; @@ -716,12 +803,13 @@ namespace Nc_Demo_Application.Database // Create new row that must be inserted DataRow row = ToolsDataTable.AsEnumerable().SingleOrDefault(x => Convert.ToInt32(x["id"]) == toolData.Id); - + row["family"] = toolData.FamilyName; row["magazine"] = toolData.MagazineId; row["magazinePositionType"] = toolData.MagazinePositionType; row["childId"] = toolData.ChildId; row["toolType"] = toolData.ToolType; + row["shankId"] = toolData.ShanksId; row["sizeLeft"] = toolData.LeftSize; row["sizeRight"] = toolData.RightSize; row["rotation"] = toolData.Rotation; @@ -777,5 +865,49 @@ namespace Nc_Demo_Application.Database } #endregion Tools + + #region Magazines + + public DataTable ReadMagazines() + { + try + { + ReadDataFromDatabase(READ_MAGAZINES_QUERY, ref MagazinesDataTable); + + return MagazinesDataTable; + } + catch (Exception ex) + { + Console.WriteLine("Read magazines exception: " + ex.Message); + return null; + } + } + + public void UpdateMagazines(DataTable magazines) + { + UpdateDatabaseFromGridView(magazines, READ_MAGAZINES_QUERY); + } + + public List GetPositions() + { + List positions = new List(); + foreach (DataRow row in MagazinesDataTable.Rows) + { + + // Convert DataTable.row into family model + PositionsDataModel tmpPositions = new PositionsDataModel + { + Id = Convert.ToInt32(row["positionId"]), + MagazineId = Convert.ToInt32(row["magazineId"]), + Type = Convert.ToInt32(row["type"]), + }; + + positions.Add(tmpPositions); + } + + return positions; + } + + #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 new file mode 100644 index 0000000..e6c5c6a --- /dev/null +++ b/CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/Database/Models/FamilyModel.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Nc_Demo_Application.Database.Models +{ + public class FamilyModel + { + public int id; + public string name; + public List childTools; + } + + public class ChildTool + { + public int id; + public int type; + public int childId; + } +} diff --git a/CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/Database/Models/ToolsDataModel.cs b/CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/Database/Models/ToolsDataModel.cs new file mode 100644 index 0000000..108e9d5 --- /dev/null +++ b/CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/Database/Models/ToolsDataModel.cs @@ -0,0 +1,49 @@ +using System.Collections.Generic; + +namespace Nc_Demo_Application.Database.Models +{ + public class ToolsDataModel + { + public int Id; + public int MagazineId; + public string FamilyName; + public int ChildId; + public int MagazinePositionType; + public int ToolType; + public int LeftSize; + public int RightSize; + public int Rotation; + public bool Cooling1; + public bool Cooling2; + public bool IsActive; + public bool FixedPlace; + public bool IsInhibited; + public bool IsMeasured; + public bool ChangeTool; + public bool IsInUse; + public bool PreAlarm; + public int ShanksId; + public List> EdgesData; + } + + public class ShankDataModel + { + public int Id; + public List childsTools; + } + + public class ShankChildDataModel + { + public int ToolId; + public int ChildId; + public string FamilyName; + public int Type; + } + + public class PositionsDataModel + { + public int Id; + public int MagazineId; + public int Type; + } +} \ No newline at end of file diff --git a/CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/Nc_Demo_Db.db b/CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/Nc_Demo_Db.db index baa9885720bbbadce61581caaf7e74fe995ad4d0..7ef99dae006128bda96f26f1af7212ba332ddac2 100644 GIT binary patch delta 423 zcmZo@U~Xt&o**q~$H2hA1H@3kXgE>FSl*67PvAE%?>7ccj(<#iU-=gEa`G7PuyfaQ zo#gn(XTMocz@KgNSvEr^?PiY>c5zWr#;#H5_mlKlJ}5axCca&-)GRS0o(@^MvA z0tqQ?j%HuLxcMZP0W+iLwL`mB?G@?3pwPWB{bQBIJ% zH(%5@EnvCFz<+PEV8RuCBLzlb22NE@PDV~3-~b~|PRI20%>1If#FBhNqkLZe?+h&b zry2N9^S|YP!hZ*-Z#TawKO-}PDzZ8@7G?(F()4_GW@ZM_@x0RfvV34< JaEgMw1^`kdb~^w7 delta 277 zcmZo@U~Xt&o**q~%D}+D1I3IC42=2{b&Tar8T1&VczM4uaB%!);`_?Cn3t2sfQOyC zp6evXZ??0W1qJ-sHlJlPWYT6A7Z+!2D=kS(%1JHB&(A3a6Wq>0u8twD3L%b8KCTK% zU@@i5(d-KtH=pD(U}ju9`4_M2WIKL?$xhq~B3wEO32vFGIVq+IoNOg*K*umJY+lTl zEXa49f&VlAZT^e=&-jn?&jniB$v=6nzBXqPvp6T%(9IY1O$%6FGVs6LESPYgUs04% gn1Pd@larAX2sprqlhZICY$T9?Dien&V?b910Cvbi(*OVf 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 b5809d2..080faad 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 @@ -161,11 +161,27 @@ namespace Nc_Demo_Application.Server.Service #endregion + #region Family + + [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)] + void PutFamily(FamilyModel familyData); + + #endregion + #region Tools [WebGet(UriTemplate = "tool_table", BodyStyle = WebMessageBodyStyle.Wrapped, ResponseFormat = WebMessageFormat.Json)] void GetTools(out List toolsData); - + + [WebGet(UriTemplate = "tool_table/shanks", BodyStyle = WebMessageBodyStyle.Wrapped, ResponseFormat = WebMessageFormat.Json)] + void GetShanks(out List shanksData); + + [WebGet(UriTemplate = "tool_table/positions", BodyStyle = WebMessageBodyStyle.Wrapped, ResponseFormat = WebMessageFormat.Json)] + void GetPositions(out List positionsData); + #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 82fd758..4eb3a5f 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,8 +452,23 @@ namespace Nc_Demo_Application.Server.Service .ToDictionary(y => i++, y => y[0]); } + #endregion File Management + #region Family + + public void GetFamilies(out List families) + { + families = DatabaseController.getInstance().GetFamilies(); + } + + public void PutFamily(FamilyModel familyData) + { + DatabaseController.getInstance().UpdateFamily(familyData); + } + + #endregion + #region Tools public void GetTools(out List toolsData) @@ -461,6 +476,16 @@ namespace Nc_Demo_Application.Server.Service toolsData = DatabaseController.getInstance().ReadTools(); } + public void GetShanks(out List shanksData) + { + shanksData = DatabaseController.getInstance().GetShanks(); + } + + public void GetPositions(out List positionsData) + { + positionsData = DatabaseController.getInstance().GetPositions(); + } + #endregion } } \ 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 0c5aaa1..1f89cec 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 @@ -30,6 +30,11 @@ namespace Nc_Demo_Application /// private void InitializeComponent() { + 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(); this.serverStatusLabel = new System.Windows.Forms.Label(); this.ncDataPage = new System.Windows.Forms.TabPage(); this.toolStrip5 = new Nc_Demo_Application.Views.ToolStripEx(); @@ -132,11 +137,30 @@ namespace Nc_Demo_Application this.FamilyTxt = new System.Windows.Forms.TextBox(); this.toolsIdLlb = new System.Windows.Forms.Label(); this.toolNameTxt = new System.Windows.Forms.TextBox(); + this.toolsTreeView = new System.Windows.Forms.TreeView(); this.toolStrip7 = new Nc_Demo_Application.Views.ToolStripEx(); this.removeTool = new System.Windows.Forms.ToolStripButton(); this.addTool = new System.Windows.Forms.ToolStripButton(); - this.toolsTreeView = new System.Windows.Forms.TreeView(); + 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(); @@ -156,6 +180,13 @@ namespace Nc_Demo_Application this.toolStrip6.SuspendLayout(); this.toolsPage.SuspendLayout(); this.toolStrip7.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.SuspendLayout(); // // serverStatusLabel @@ -366,6 +397,8 @@ namespace Nc_Demo_Application this.ncTabControl.Controls.Add(this.ncAxesPage); this.ncTabControl.Controls.Add(this.byteMemoryPage); this.ncTabControl.Controls.Add(this.partProgramPage); + this.ncTabControl.Controls.Add(this.magazinesTab); + this.ncTabControl.Controls.Add(this.familiesTab); this.ncTabControl.Controls.Add(this.toolsPage); this.ncTabControl.Location = new System.Drawing.Point(11, 14); this.ncTabControl.Name = "ncTabControl"; @@ -429,6 +462,10 @@ namespace Nc_Demo_Application // ncProcessIdColumn // this.ncProcessIdColumn.DataPropertyName = "id"; + dataGridViewCellStyle1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(224)))), ((int)(((byte)(224)))), ((int)(((byte)(224))))); + dataGridViewCellStyle1.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(224)))), ((int)(((byte)(224)))), ((int)(((byte)(224))))); + dataGridViewCellStyle1.SelectionForeColor = System.Drawing.Color.Black; + this.ncProcessIdColumn.DefaultCellStyle = dataGridViewCellStyle1; this.ncProcessIdColumn.HeaderText = "Process Id"; this.ncProcessIdColumn.Name = "ncProcessIdColumn"; this.ncProcessIdColumn.ReadOnly = true; @@ -692,6 +729,10 @@ namespace Nc_Demo_Application // BinaryMemoryAddressColumn // this.BinaryMemoryAddressColumn.DataPropertyName = "address"; + dataGridViewCellStyle2.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(224)))), ((int)(((byte)(224)))), ((int)(((byte)(224))))); + dataGridViewCellStyle2.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(224)))), ((int)(((byte)(224)))), ((int)(((byte)(224))))); + dataGridViewCellStyle2.SelectionForeColor = System.Drawing.Color.Black; + this.BinaryMemoryAddressColumn.DefaultCellStyle = dataGridViewCellStyle2; this.BinaryMemoryAddressColumn.HeaderText = "Byte Address"; this.BinaryMemoryAddressColumn.Name = "BinaryMemoryAddressColumn"; this.BinaryMemoryAddressColumn.ReadOnly = true; @@ -852,6 +893,8 @@ namespace Nc_Demo_Application // // toolsPage // + this.toolsPage.Controls.Add(this.label19); + this.toolsPage.Controls.Add(this.shankIdTextBox); this.toolsPage.Controls.Add(this.label16); this.toolsPage.Controls.Add(this.magazinePositionTypeTxt); this.toolsPage.Controls.Add(this.label15); @@ -882,8 +925,8 @@ namespace Nc_Demo_Application this.toolsPage.Controls.Add(this.FamilyTxt); this.toolsPage.Controls.Add(this.toolsIdLlb); this.toolsPage.Controls.Add(this.toolNameTxt); - this.toolsPage.Controls.Add(this.toolStrip7); this.toolsPage.Controls.Add(this.toolsTreeView); + this.toolsPage.Controls.Add(this.toolStrip7); this.toolsPage.Location = new System.Drawing.Point(4, 22); this.toolsPage.Name = "toolsPage"; this.toolsPage.Padding = new System.Windows.Forms.Padding(3); @@ -1115,7 +1158,7 @@ namespace Nc_Demo_Application // label8 // this.label8.AutoSize = true; - this.label8.Location = new System.Drawing.Point(818, 93); + this.label8.Location = new System.Drawing.Point(739, 92); this.label8.Name = "label8"; this.label8.Size = new System.Drawing.Size(45, 13); this.label8.TabIndex = 7; @@ -1123,7 +1166,7 @@ namespace Nc_Demo_Application // // childIdTxt // - this.childIdTxt.Location = new System.Drawing.Point(869, 90); + this.childIdTxt.Location = new System.Drawing.Point(790, 89); this.childIdTxt.Name = "childIdTxt"; this.childIdTxt.Size = new System.Drawing.Size(49, 20); this.childIdTxt.TabIndex = 6; @@ -1131,7 +1174,7 @@ namespace Nc_Demo_Application // label7 // this.label7.AutoSize = true; - this.label7.Location = new System.Drawing.Point(629, 93); + this.label7.Location = new System.Drawing.Point(577, 92); this.label7.Name = "label7"; this.label7.Size = new System.Drawing.Size(39, 13); this.label7.TabIndex = 5; @@ -1139,7 +1182,7 @@ namespace Nc_Demo_Application // // FamilyTxt // - this.FamilyTxt.Location = new System.Drawing.Point(674, 90); + this.FamilyTxt.Location = new System.Drawing.Point(622, 89); this.FamilyTxt.Name = "FamilyTxt"; this.FamilyTxt.Size = new System.Drawing.Size(102, 20); this.FamilyTxt.TabIndex = 4; @@ -1161,6 +1204,17 @@ namespace Nc_Demo_Application this.toolNameTxt.Size = new System.Drawing.Size(100, 20); this.toolNameTxt.TabIndex = 2; // + // toolsTreeView + // + this.toolsTreeView.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.toolsTreeView.Location = new System.Drawing.Point(3, 31); + this.toolsTreeView.Name = "toolsTreeView"; + this.toolsTreeView.Size = new System.Drawing.Size(163, 604); + this.toolsTreeView.TabIndex = 0; + this.toolsTreeView.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.ToolsTreeView_AfterSelect); + // // toolStrip7 // this.toolStrip7.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { @@ -1192,16 +1246,184 @@ namespace Nc_Demo_Application this.addTool.Text = "toolStripButton1"; this.addTool.Click += new System.EventHandler(this.AddTool_Click); // - // toolsTreeView + // familiesTab // - this.toolsTreeView.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.toolsTreeView.Location = new System.Drawing.Point(3, 31); - this.toolsTreeView.Name = "toolsTreeView"; - this.toolsTreeView.Size = new System.Drawing.Size(163, 604); - this.toolsTreeView.TabIndex = 0; - this.toolsTreeView.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.ToolsTreeView_AfterSelect); + 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 // @@ -1214,6 +1436,22 @@ namespace Nc_Demo_Application 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); @@ -1260,6 +1498,17 @@ namespace Nc_Demo_Application this.toolsPage.PerformLayout(); this.toolStrip7.ResumeLayout(false); this.toolStrip7.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.ResumeLayout(false); this.PerformLayout(); @@ -1315,11 +1564,6 @@ namespace Nc_Demo_Application private System.Windows.Forms.ToolStripButton addRowsBinaryMemory; private System.Windows.Forms.ToolStripButton deleteRowsBinaryMemory; private System.Windows.Forms.DataGridView binaryMemoryGridView; - private System.Windows.Forms.DataGridViewTextBoxColumn BinaryMemoryAddressColumn; - private System.Windows.Forms.DataGridViewTextBoxColumn BinaryMemoryDecimalColumn; - private System.Windows.Forms.DataGridViewTextBoxColumn BinaryMemoryBinaryColumn; - private System.Windows.Forms.DataGridViewTextBoxColumn BinaryMemoryWordColumn; - private System.Windows.Forms.DataGridViewTextBoxColumn BinaryMemoryIntegerColumn; private System.Windows.Forms.TabPage partProgramPage; private System.Windows.Forms.TextBox fileContentTextBox; private System.Windows.Forms.ToolStripButton saveFileButton; @@ -1328,11 +1572,6 @@ namespace Nc_Demo_Application private System.Windows.Forms.ToolStripTextBox newFileNameTextBox; private System.Windows.Forms.TreeView fileTreeView; private System.Windows.Forms.Button stopServer; - private System.Windows.Forms.DataGridViewTextBoxColumn ncProcessIdColumn; - private System.Windows.Forms.DataGridViewTextBoxColumn ProcessPartProgram; - private System.Windows.Forms.DataGridViewTextBoxColumn ncProcessNameColumn; - private System.Windows.Forms.DataGridViewComboBoxColumn ncProcessStatusColumn; - private System.Windows.Forms.DataGridViewComboBoxColumn ncProcessModeColumn; private System.Windows.Forms.LinkLabel openDoc; private System.Windows.Forms.TabPage toolsPage; private ToolStripEx toolStrip7; @@ -1374,6 +1613,35 @@ namespace Nc_Demo_Application private System.Windows.Forms.Label label15; private System.Windows.Forms.Label label16; private System.Windows.Forms.TextBox magazinePositionTypeTxt; + private System.Windows.Forms.TabPage familiesTab; + private System.Windows.Forms.DataGridView familiesDataGridView; + private ToolStripEx toolStripEx1; + private System.Windows.Forms.ToolStripButton saveFamiliesButton; + private System.Windows.Forms.DataGridView shanksDataGridView; + private System.Windows.Forms.DataGridViewTextBoxColumn shanksId; + private System.Windows.Forms.Label label17; + 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; + private System.Windows.Forms.DataGridViewTextBoxColumn BinaryMemoryDecimalColumn; + private System.Windows.Forms.DataGridViewTextBoxColumn BinaryMemoryBinaryColumn; + private System.Windows.Forms.DataGridViewTextBoxColumn BinaryMemoryWordColumn; + private System.Windows.Forms.DataGridViewTextBoxColumn BinaryMemoryIntegerColumn; + private System.Windows.Forms.DataGridViewTextBoxColumn ncProcessIdColumn; + private System.Windows.Forms.DataGridViewTextBoxColumn ProcessPartProgram; + private System.Windows.Forms.DataGridViewTextBoxColumn ncProcessNameColumn; + private System.Windows.Forms.DataGridViewComboBoxColumn ncProcessStatusColumn; + private System.Windows.Forms.DataGridViewComboBoxColumn ncProcessModeColumn; + private ToolStripEx toolStripEx2; + private System.Windows.Forms.ToolStripButton saveMagazinesButton; + private System.Windows.Forms.Label label19; + private System.Windows.Forms.TextBox shankIdTextBox; } } 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 b0cfde4..34f4ce5 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 @@ -43,7 +43,7 @@ namespace Nc_Demo_Application startupPanel.Visible = !visible; } - public void startServer(int port) + public void StartServer(int port) { SERVER_PORT = port.ToString(); try @@ -66,6 +66,8 @@ namespace Nc_Demo_Application FillNcAlarmsInput(); FillNAxisInput(); FillBinaryMemoryInput(); + FillFamilyInput(); + FillMagazineInput(); ReadPartProgramDirectory("./part_program"); FillToolsInput(); @@ -139,6 +141,24 @@ namespace Nc_Demo_Application binaryMemoryGridView.DataSource = binaryMemoryData; } + private void FillFamilyInput() + { + // 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; + } + + private void FillMagazineInput() + { + // Insert magazines data into grid view + DataTable magazines = DatabaseController.getInstance().ReadMagazines(); + magazinesGridView.DataSource = magazines; + } + private void FillToolsInput() { List toolsData = DatabaseController.getInstance().ReadTools(); @@ -174,6 +194,7 @@ namespace Nc_Demo_Application private void SaveNcAlarmsButton_Click(object sender, EventArgs e) { DatabaseController.getInstance().UpdateNcAlarms((DataTable)ncAlarmsGridView.DataSource); + FillNcAlarmsInput(); } private void SaveNcAxesButton_Click(object sender, EventArgs e) @@ -512,6 +533,7 @@ namespace Nc_Demo_Application ChildId = 1, MagazinePositionType = 1, ToolType = 100, + ShanksId = 0, LeftSize = 1, RightSize = 1, Cooling1 = false, @@ -523,9 +545,9 @@ namespace Nc_Demo_Application ChangeTool = false, PreAlarm = false, IsInUse = false, - IsInhibited = false, - + IsInhibited = false }; + // Add to database DatabaseController.getInstance().AddToolToDatabase(ref newTool); // Add to treeView @@ -584,6 +606,7 @@ namespace Nc_Demo_Application leftSizeTxt.Text = toolInfo.LeftSize.ToString(); cooling1CheckBox.Checked = toolInfo.Cooling1; cooling2CheckBox.Checked = toolInfo.Cooling2; + shankIdTextBox.Text = toolInfo.ShanksId.ToString(); isActiveCheckBox.Checked = toolInfo.IsActive; fixedPlaceCheckBox.Checked = toolInfo.FixedPlace; @@ -622,6 +645,7 @@ namespace Nc_Demo_Application toolInfo.LeftSize = Convert.ToInt32(leftSizeTxt.Text); toolInfo.Cooling1 = cooling1CheckBox.Checked; toolInfo.Cooling2 = cooling2CheckBox.Checked; + toolInfo.ShanksId = Convert.ToInt32(shankIdTextBox.Text); toolInfo.IsActive = isActiveCheckBox.Checked; toolInfo.FixedPlace = fixedPlaceCheckBox.Checked; @@ -636,5 +660,21 @@ namespace Nc_Demo_Application DatabaseController.getInstance().UpdateToolData(toolInfo); } + + private void SaveFamiliesButton_Click(object sender, EventArgs e) + { + // Save families + DatabaseController.getInstance().UpdateFamilies((DataTable)familiesDataGridView.DataSource); + // Save shanks + DatabaseController.getInstance().UpdateShanks((DataTable)shanksDataGridView.DataSource); + // Update UI + FillFamilyInput(); + } + + private void SaveMagazinesButton_Click(object sender, EventArgs e) + { + DatabaseController.getInstance().UpdateMagazines((DataTable)magazinesGridView.DataSource); + } + } } \ 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 1bd053d..c7b5ef4 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 @@ -135,6 +135,30 @@ 542, 17 + + True + + + True + + + True + + + 869, 17 + + + True + + + True + + + True + + + 752, 17 + 647, 17 diff --git a/CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/Views/StartupPanel.cs b/CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/Views/StartupPanel.cs index 39776cd..ba52959 100644 --- a/CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/Views/StartupPanel.cs +++ b/CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/Views/StartupPanel.cs @@ -19,7 +19,7 @@ namespace Nc_Demo_Application.Views private void startupButton_Click(object sender, EventArgs e) { - ((DemoApplicationForm)Parent).startServer(Convert.ToInt32(portTextBox.Text)); + ((DemoApplicationForm)Parent).StartServer(Convert.ToInt32(portTextBox.Text)); } } }