Added activate program & deactivate

& Minor fixes
This commit is contained in:
Lucio Maranta
2018-07-31 15:46:09 +00:00
parent d806f9d88c
commit 296e8d5b30
10 changed files with 92 additions and 33 deletions
+3
View File
@@ -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);
+27 -4
View File
@@ -51,7 +51,11 @@ namespace CMS_CORE.Demo
String url = "http://" + Ip + ":" + Port + "/api";
serverAddress = new EndpointAddress(url);
cf = new ChannelFactory<ILibraryService>(new WebHttpBinding(), serverAddress);
cf = new ChannelFactory<ILibraryService>(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();
+8 -2
View File
@@ -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 = "";
+3 -2
View File
@@ -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);
/**
* <summary>Read a Part Program by path and name
+7 -2
View File
@@ -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;
}
+7 -2
View File
@@ -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;
}
+18 -8
View File
@@ -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<FieldsConfiguration>()
@@ -255,12 +265,12 @@ namespace CMS_CORE_Library
{
EdgeConfiguration = new List<FieldsConfiguration>()
{
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<int, List<string>>() // Set value runtime, based on NC vendor
};
@@ -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()
{
@@ -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);
@@ -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<string>()
};
// 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<string>();
}
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);