diff --git a/CMS_CORE_Library/Osai/Nc_Osai.cs b/CMS_CORE_Library/Osai/Nc_Osai.cs index 1b885e0..d0ee3fe 100644 --- a/CMS_CORE_Library/Osai/Nc_Osai.cs +++ b/CMS_CORE_Library/Osai/Nc_Osai.cs @@ -38,6 +38,9 @@ namespace CMS_CORE.Osai // private const string TOOL_MANAGER_DIRECTORY_PATH = @"TEST\\SYS\\STEP\\"; private const string TOOL_MANAGER_DIRECTORY_PATH = @"test\OEM\CMS\SYS\STEP\"; + private const string PROGRAM_DIRECTORY_PATH = @"CAMBIO"; + + private const string TOOL_MANAGER_BACKUP_DIRECTORY_PATH = @"C:\CMS\STEP\TMP\"; private const string FAMILIES_FILE_NAME = @"Families"; @@ -109,6 +112,7 @@ namespace CMS_CORE.Osai Connected = true; else Connected = false; + } catch (Exception ex) { @@ -1926,7 +1930,55 @@ namespace CMS_CORE.Osai public override CmsError FILES_RGetFileList(string path, ref List files) { - return NO_ERROR; + + ushort nReturn; + String temppath; + //Check if the NC is Connected + CmsError cmsError = CheckConnection(); + if (cmsError.IsError()) + return cmsError; + + temppath = path; + if (temppath.StartsWith("\\\\")) + temppath = temppath.Substring(2); + + FILEFINDDATA filesearch = new FILEFINDDATA(); + uint find; + bool found; + Console.WriteLine(PROGRAM_DIRECTORY_PATH + temppath + "\\*"); + nReturn = OpenNC.LogFSFindFirst(PROGRAM_DIRECTORY_PATH + temppath + "\\*", out filesearch, out find, out uint errorClass, out uint errorNum); + + //If there's an error + if (errorClass != 0 || errorNum != 0 || nReturn == 0) + return GetNCError(errorClass, errorNum); + + if(find != 0xFFFFFFFF) + { + do + { + + files.Add(new PreviewFileModel() + { + Name = filesearch.FileName, + AbsolutePath = path + "\\" + filesearch.FileName, + IsDirectory = filesearch.FileAttributes == 16 + }); + + nReturn = OpenNC.LogFSFindNext(find, out filesearch, out found, out errorClass, out errorNum); + //If there's an error + if (errorClass != 0 || errorNum != 0 || nReturn == 0) + return GetNCError(errorClass, errorNum); + + } while (found); + + + nReturn = OpenNC.LogFSFindClose(find, out errorClass, out errorNum); + //If there's an error + if (errorClass != 0 || errorNum != 0 || nReturn == 0) + return GetNCError(errorClass, errorNum); + + } + return NO_ERROR; } public override CmsError FILES_RGetFileInfo(string path, ref InfoFile fileInfo) @@ -1936,7 +1988,34 @@ namespace CMS_CORE.Osai public override CmsError FILES_WSetActiveProgram(int processId, string filePath, ref ActiveProgramDataModel data) { - return NO_ERROR; + String temppath; + //Check if the NC is Connected + CmsError cmsError = CheckConnection(); + if (cmsError.IsError()) + return cmsError; + + temppath = filePath; + if (temppath.StartsWith("\\\\")) + temppath = temppath.Substring(2); + + Console.WriteLine(PROGRAM_DIRECTORY_PATH + temppath); + ushort nReturn; + try + { + // select PP (using empty string) + nReturn = OpenNC.SelectPartProgramFromDrive((ushort)processId, PROGRAM_DIRECTORY_PATH + temppath, out uint errorClass, out uint errorNum); + + //If there's an error launch exception + if (errorClass != 0 || errorNum != 0 || nReturn == 0) + return GetNCError(errorClass, errorNum); + + } + catch (Exception ex) + { + return ManageException(ex); + } + + return NO_ERROR; } public override CmsError FILES_WDeactivateProgram(int processId) @@ -1950,7 +2029,7 @@ namespace CMS_CORE.Osai try { // deselect PP (using empty string) - nReturn = OpenNC.SelectPartProgram((ushort)processId, "", out uint errorClass, out uint errorNum); + nReturn = OpenNC.SelectPartProgramFromDrive((ushort)processId, "", out uint errorClass, out uint errorNum); //If there's an error launch exception if (errorClass != 0 || errorNum != 0 || nReturn == 0)