diff --git a/CMS_CORE_Library/Demo/ILibraryService.cs b/CMS_CORE_Library/Demo/ILibraryService.cs index 50f3cd8..865e22e 100644 --- a/CMS_CORE_Library/Demo/ILibraryService.cs +++ b/CMS_CORE_Library/Demo/ILibraryService.cs @@ -151,6 +151,9 @@ namespace Nc_Demo_Application.Server.Service [WebGet(UriTemplate = "file/active", BodyStyle = WebMessageBodyStyle.Wrapped, ResponseFormat = WebMessageFormat.Json)] void GetActiveProgramData(out ActiveProgramDataModel programData); + [WebGet(UriTemplate = "file/deactive", BodyStyle = WebMessageBodyStyle.Wrapped, ResponseFormat = WebMessageFormat.Json)] + void RemoveActiveProgram(out ActiveProgramDataModel programData); + [WebGet(UriTemplate = "file/active?filePath={filePath}", BodyStyle = WebMessageBodyStyle.Wrapped, ResponseFormat = WebMessageFormat.Json)] void SetActiveProgramData(string filePath, out ActiveProgramDataModel programData); diff --git a/CMS_CORE_Library/Demo/Nc_Demo.cs b/CMS_CORE_Library/Demo/Nc_Demo.cs index 9aee496..5063202 100644 --- a/CMS_CORE_Library/Demo/Nc_Demo.cs +++ b/CMS_CORE_Library/Demo/Nc_Demo.cs @@ -51,7 +51,11 @@ namespace CMS_CORE.Demo String url = "http://" + Ip + ":" + Port + "/api"; serverAddress = new EndpointAddress(url); - cf = new ChannelFactory(new WebHttpBinding(), serverAddress); + cf = new ChannelFactory(new WebHttpBinding() + { + MaxBufferPoolSize = int.MaxValue, + MaxReceivedMessageSize = int.MaxValue + }, serverAddress); cf.Endpoint.EndpointBehaviors.Add(new WebHttpBehavior()); serverService = cf.CreateChannel(); @@ -1598,7 +1602,7 @@ namespace CMS_CORE.Demo return NO_ERROR; } - public override CmsError FILES_WSetActiveProgram(string filePath, ref ActiveProgramDataModel data) + public override CmsError FILES_WSetActiveProgram(int processId, string filePath, ref ActiveProgramDataModel data) { // Check if the NC Demo is Connected CmsError cmsError = CheckConnection(); @@ -1607,7 +1611,7 @@ namespace CMS_CORE.Demo try { - serverService.SetActiveProgramData(filePath, out ActiveProgramDataModel program); + serverService.SetActiveProgramData(filePath, out data); } catch (Exception ex) { @@ -1617,7 +1621,26 @@ namespace CMS_CORE.Demo return NO_ERROR; } - public override CmsError FILES_RActiveProgramData(ref ActiveProgramDataModel data) + public override CmsError FILES_WDeactivateProgram(int processId) + { + // Check if the NC Demo is Connected + CmsError cmsError = CheckConnection(); + if (cmsError.IsError()) + return cmsError; + + try + { + serverService.RemoveActiveProgram(out ActiveProgramDataModel program); + } + catch (Exception ex) + { + return ManageException(ex); + } + + return NO_ERROR; + } + + public override CmsError FILES_RActiveProgramData(int processId, ref ActiveProgramDataModel data) { // Check if the NC Demo is Connected CmsError cmsError = CheckConnection(); diff --git a/CMS_CORE_Library/Fanuc/Nc_Fanuc.cs b/CMS_CORE_Library/Fanuc/Nc_Fanuc.cs index 2e576c6..4970f3d 100644 --- a/CMS_CORE_Library/Fanuc/Nc_Fanuc.cs +++ b/CMS_CORE_Library/Fanuc/Nc_Fanuc.cs @@ -1562,15 +1562,21 @@ namespace CMS_CORE.Fanuc return NO_ERROR; } - public override CmsError FILES_WSetActiveProgram(string filePath, ref ActiveProgramDataModel data) + public override CmsError FILES_WSetActiveProgram(int processId, string filePath, ref ActiveProgramDataModel data) { return NO_ERROR; } - public override CmsError FILES_RActiveProgramData(ref ActiveProgramDataModel data) + public override CmsError FILES_RActiveProgramData(int processId, ref ActiveProgramDataModel data) { return NO_ERROR; } + + public override CmsError FILES_WDeactivateProgram(int processId) + { + return NO_ERROR; + } + public override CmsError FILES_RProgramToFile(string partProgramPath, FileStream localFile) { string partProgramContent = ""; diff --git a/CMS_CORE_Library/Nc.cs b/CMS_CORE_Library/Nc.cs index d0adf82..4b2f0f7 100644 --- a/CMS_CORE_Library/Nc.cs +++ b/CMS_CORE_Library/Nc.cs @@ -1218,9 +1218,10 @@ namespace CMS_CORE #region File Management (To override) - public abstract CmsError FILES_WSetActiveProgram(string filePath, ref ActiveProgramDataModel data); + public abstract CmsError FILES_WSetActiveProgram(int processId, string filePath, ref ActiveProgramDataModel data); + public abstract CmsError FILES_WDeactivateProgram(int processId); - public abstract CmsError FILES_RActiveProgramData(ref ActiveProgramDataModel data); + public abstract CmsError FILES_RActiveProgramData(int processId, ref ActiveProgramDataModel data); /** * Read a Part Program by path and name diff --git a/CMS_CORE_Library/Osai/Nc_Osai.cs b/CMS_CORE_Library/Osai/Nc_Osai.cs index 0cdded0..0a40d71 100644 --- a/CMS_CORE_Library/Osai/Nc_Osai.cs +++ b/CMS_CORE_Library/Osai/Nc_Osai.cs @@ -1884,12 +1884,17 @@ namespace CMS_CORE.Osai return NO_ERROR; } - public override CmsError FILES_WSetActiveProgram(string filePath, ref ActiveProgramDataModel data) + public override CmsError FILES_WSetActiveProgram(int processId, string filePath, ref ActiveProgramDataModel data) { return NO_ERROR; } - public override CmsError FILES_RActiveProgramData(ref ActiveProgramDataModel data) + public override CmsError FILES_WDeactivateProgram(int processId) + { + return NO_ERROR; + } + + public override CmsError FILES_RActiveProgramData(int processId, ref ActiveProgramDataModel data) { return NO_ERROR; } diff --git a/CMS_CORE_Library/Siemens/Nc_Siemens.cs b/CMS_CORE_Library/Siemens/Nc_Siemens.cs index bafb4be..17e3182 100644 --- a/CMS_CORE_Library/Siemens/Nc_Siemens.cs +++ b/CMS_CORE_Library/Siemens/Nc_Siemens.cs @@ -1773,12 +1773,17 @@ namespace CMS_CORE.Siemens return NO_ERROR; } - public override CmsError FILES_WSetActiveProgram(string filePath, ref ActiveProgramDataModel data) + public override CmsError FILES_WSetActiveProgram(int processId, string filePath, ref ActiveProgramDataModel data) { return NO_ERROR; } - public override CmsError FILES_RActiveProgramData(ref ActiveProgramDataModel data) + public override CmsError FILES_WDeactivateProgram(int processId) + { + return NO_ERROR; + } + + public override CmsError FILES_RActiveProgramData(int processId, ref ActiveProgramDataModel data) { return NO_ERROR; } diff --git a/CMS_CORE_Library/ToolConfigurations.cs b/CMS_CORE_Library/ToolConfigurations.cs index 758c1b3..326415f 100644 --- a/CMS_CORE_Library/ToolConfigurations.cs +++ b/CMS_CORE_Library/ToolConfigurations.cs @@ -205,14 +205,24 @@ namespace CMS_CORE_Library new FieldsConfiguration{ Name = "tcpTable", Type = "int", SelectValues = null, Category = "general", ReadOnly = false, MinValue = 0, MaxValue = byte.MaxValue}, new FieldsConfiguration{ Name = "gamma", Type = "int", SelectValues = null, Category = "general", ReadOnly = false, MinValue = 0, MaxValue = byte.MaxValue}, new FieldsConfiguration{ Name = "rotationType", Type = "int", SelectValues = null, Category = "general", ReadOnly = false, MinValue = 0, MaxValue = byte.MaxValue}, + + new FieldsConfiguration{ Name = "cooling", Type = "bool", SelectValues = null, Category = "cooling", ReadOnly = false, MinValue = 0, MaxValue = int.MaxValue}, + new FieldsConfiguration{ Name = "cooling1", Type = "bool", SelectValues = null, Category = "cooling", ReadOnly = false, MinValue = 0, MaxValue = int.MaxValue}, + new FieldsConfiguration{ Name = "cooling2", Type = "bool", SelectValues = null, Category = "cooling", ReadOnly = false, MinValue = 0, MaxValue = int.MaxValue}, + new FieldsConfiguration{ Name = "cooling3", Type = "bool", SelectValues = null, Category = "cooling", ReadOnly = false, MinValue = 0, MaxValue = int.MaxValue}, + new FieldsConfiguration{ Name = "cooling4", Type = "bool", SelectValues = null, Category = "cooling", ReadOnly = false, MinValue = 0, MaxValue = int.MaxValue}, + new FieldsConfiguration{ Name = "cooling5", Type = "bool", SelectValues = null, Category = "cooling", ReadOnly = false, MinValue = 0, MaxValue = int.MaxValue}, + new FieldsConfiguration{ Name = "cooling6", Type = "bool", SelectValues = null, Category = "cooling", ReadOnly = false, MinValue = 0, MaxValue = int.MaxValue}, + new FieldsConfiguration{ Name = "cooling7", Type = "bool", SelectValues = null, Category = "cooling", ReadOnly = false, MinValue = 0, MaxValue = int.MaxValue}, + new FieldsConfiguration{ Name = "maxSpeed", Type = "int", SelectValues = null, Category = "general", ReadOnly = false, MinValue = 0, MaxValue = ushort.MaxValue}, new FieldsConfiguration{ Name = "maxLoad", Type = "int", SelectValues = null, Category = "general", ReadOnly = false, MinValue = 0, MaxValue = byte.MaxValue}, new FieldsConfiguration{ Name = "minLoadPctAutoload", Type = "int", SelectValues = null, Category = "general", ReadOnly = false, MinValue = 0, MaxValue = byte.MaxValue}, new FieldsConfiguration{ Name = "maxLoadPctAutoload", Type = "int", SelectValues = null, Category = "general", ReadOnly = false, MinValue = 0, MaxValue = byte.MaxValue}, new FieldsConfiguration{ Name = "minLoadDynamicCompensation", Type = "int", SelectValues = null, Category = "general", ReadOnly = false, MinValue = 0, MaxValue = byte.MaxValue}, new FieldsConfiguration{ Name = "maxLoadDynamicCompensation", Type = "int", SelectValues = null, Category = "general", ReadOnly = false, MinValue = 0, MaxValue = byte.MaxValue}, - new FieldsConfiguration{ Name = "lifeType", Type = "int", SelectValues = null, Category = "general", ReadOnly = false, MinValue = 0, MaxValue = byte.MaxValue}, - new FieldsConfiguration{ Name = "nominalLife", Type = "int", SelectValues = null, Category = "general", ReadOnly = false, MinValue = 0, MaxValue = ushort.MaxValue}, + new FieldsConfiguration{ Name = "lifeType", Type = "int", SelectValues = null, Category = "life", ReadOnly = false, MinValue = 0, MaxValue = byte.MaxValue}, + new FieldsConfiguration{ Name = "nominalLife", Type = "int", SelectValues = null, Category = "life", ReadOnly = false, MinValue = 0, MaxValue = ushort.MaxValue}, new FieldsConfiguration{ Name = "reviveDelta", Type = "int", SelectValues = null, Category = "general", ReadOnly = false, MinValue = 0, MaxValue = ushort.MaxValue}, }, ToolsConfiguration = new List() @@ -255,12 +265,12 @@ namespace CMS_CORE_Library { EdgeConfiguration = new List() { - new FieldsConfiguration{Name = "id", Type = "int", SelectValues = null, Category = "general", ReadOnly = true, MinValue = 0, MaxValue = 0 }, - new FieldsConfiguration{Name = "ncOffsetId", Type = "int", SelectValues = null, Category = "general", ReadOnly = false, MinValue = 0, MaxValue = (uint)short.MaxValue }, - new FieldsConfiguration{Name = "lenght", Type = "double", SelectValues = null, Category = "general", ReadOnly = false, MinValue = 0, MaxValue = uint.MaxValue }, - new FieldsConfiguration{Name = "radius", Type = "double", SelectValues = null, Category = "general", ReadOnly = false, MinValue = 0, MaxValue = uint.MaxValue }, - new FieldsConfiguration{Name = "wear_length", Type = "double", SelectValues = null, Category = "general", ReadOnly = false, MinValue = 0, MaxValue = uint.MaxValue }, - new FieldsConfiguration{Name = "wear_radius", Type = "double", SelectValues = null, Category = "general", ReadOnly = false, MinValue = 0, MaxValue = uint.MaxValue } + new FieldsConfiguration{Name = "id", Type = "int", SelectValues = null, Category = "general", ReadOnly = true, MinValue = 0, MaxValue = 0 }, + new FieldsConfiguration{Name = "ncOffsetId", Type = "int", SelectValues = null, Category = "general", ReadOnly = false, MinValue = 0, MaxValue = (uint)short.MaxValue }, + new FieldsConfiguration{Name = "lenght", Type = "double", SelectValues = null, Category = "general", ReadOnly = false, MinValue = 0, MaxValue = uint.MaxValue }, + new FieldsConfiguration{Name = "radius", Type = "double", SelectValues = null, Category = "general", ReadOnly = false, MinValue = 0, MaxValue = uint.MaxValue }, + new FieldsConfiguration{Name = "wear_length", Type = "double", SelectValues = null, Category = "general", ReadOnly = false, MinValue = 0, MaxValue = uint.MaxValue }, + new FieldsConfiguration{Name = "wear_radius", Type = "double", SelectValues = null, Category = "general", ReadOnly = false, MinValue = 0, MaxValue = uint.MaxValue } }, EdgesAdditionalParamsConfiguration = new Dictionary>() // Set value runtime, based on NC vendor }; diff --git a/CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/Server/ServerController.cs b/CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/Server/ServerController.cs index cdaac3e..106986e 100644 --- a/CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/Server/ServerController.cs +++ b/CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/Server/ServerController.cs @@ -12,8 +12,7 @@ namespace Nc_Demo_Application.Server Uri WebUri; WebServiceHost WebHost; WebHttpBinding Binding; - - + // Singleton Method public static ServerController getInstance() { @@ -21,9 +20,7 @@ namespace Nc_Demo_Application.Server Instance = new ServerController(); return Instance; } - - - + // Stop the Server public void Stop() { @@ -34,9 +31,7 @@ namespace Nc_Demo_Application.Server Console.WriteLine("Server closed"); } } - - - + // Start server public void Run() { 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 f403caf..75a19ea 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 @@ -156,6 +156,9 @@ namespace Nc_Demo_Application.Server.Service [WebGet(UriTemplate = "file/active?filePath={filePath}", BodyStyle = WebMessageBodyStyle.Wrapped, ResponseFormat = WebMessageFormat.Json)] void SetActiveProgramData(string filePath, out ActiveProgramDataModel programData); + [WebGet(UriTemplate = "file/deactive", BodyStyle = WebMessageBodyStyle.Wrapped, ResponseFormat = WebMessageFormat.Json)] + void RemoveActiveProgram(out ActiveProgramDataModel programData); + [WebGet(UriTemplate = "file/{fileName}", BodyStyle = WebMessageBodyStyle.Wrapped, ResponseFormat = WebMessageFormat.Json)] void GetFile(string fileName, out string fileContent); 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 f2290b9..8d13c08 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 @@ -422,6 +422,7 @@ namespace Nc_Demo_Application.Server.Service if (!File.Exists(fullPath)) throw new WebFaultException(HttpStatusCode.NotFound); + // System io file info FileInfo f = new FileInfo(fullPath); @@ -432,7 +433,7 @@ namespace Nc_Demo_Application.Server.Service LastModDate = f.LastAccessTime, Content = new List() }; - + // Get image data imagePath = Path.GetFileNameWithoutExtension(fullPath); imageDirectory = Path.GetDirectoryName(fullPath); @@ -445,6 +446,7 @@ namespace Nc_Demo_Application.Server.Service { if (File.Exists(imageDirectory + "/" + imagePath + ext)) { + // Convert image to a base 64 string fileInfo.PreviewBase64 = "data:image/" + ext + ";base64," + Convert.ToBase64String(File.ReadAllBytes(imageDirectory + "/" + imagePath + ext)); break; } @@ -461,10 +463,15 @@ namespace Nc_Demo_Application.Server.Service programData = DatabaseController.GetInstance().ReadActiveProgramData(); string fullPath = FILE_FOLDER + programData.Path; - if (!File.Exists(fullPath)) - throw new WebFaultException(HttpStatusCode.NotFound); - - programData.IsoLines = ReadFileLines(programData.IsoLine, fullPath ); + if (File.Exists(fullPath)) + programData.IsoLines = ReadFileLines(programData.IsoLine, fullPath); + else + programData.IsoLines = new List(); + } + + public void RemoveActiveProgram(out ActiveProgramDataModel programData) + { + programData = DatabaseController.GetInstance().UpdateActiveProgramName(""); } public void SetActiveProgramData(string filePath, out ActiveProgramDataModel programData) @@ -724,6 +731,7 @@ namespace Nc_Demo_Application.Server.Service { positionsData = DatabaseController.GetInstance().GetPositions(); } + public void PutPosition(ref PositionsDataModel position) { DatabaseController.GetInstance().UpdatePosition(position);