From 4cac0d226ca86193ef4eff312bb51b43e08d1750 Mon Sep 17 00:00:00 2001 From: Lucio Maranta Date: Wed, 24 Oct 2018 15:46:16 +0000 Subject: [PATCH] Added Fanuc fileList --- CMS_CORE_Application/Form1.cs | 4 +- CMS_CORE_Library/Fanuc/Nc_Fanuc.cs | 78 ++++++++++++++++++++++++++++++ CMS_CORE_Library/Osai/Nc_Osai.cs | 3 +- 3 files changed, 81 insertions(+), 4 deletions(-) diff --git a/CMS_CORE_Application/Form1.cs b/CMS_CORE_Application/Form1.cs index 2067095..a7ef25f 100644 --- a/CMS_CORE_Application/Form1.cs +++ b/CMS_CORE_Application/Form1.cs @@ -139,8 +139,8 @@ namespace CMS_CORE_Application Stopwatch st = new Stopwatch(); sw.Restart(); - ActiveProgramDataModel a = new ActiveProgramDataModel(); - cmsError = N.FILES_RActiveProgramData(1, ref a); + List p = new List(); + cmsError = N.FILES_RGetFileList("", ref p); OffsetModel offset = new OffsetModel(); N.TOOLS_ROffset(1, ref offset); diff --git a/CMS_CORE_Library/Fanuc/Nc_Fanuc.cs b/CMS_CORE_Library/Fanuc/Nc_Fanuc.cs index 0d1f826..2b1ba0d 100644 --- a/CMS_CORE_Library/Fanuc/Nc_Fanuc.cs +++ b/CMS_CORE_Library/Fanuc/Nc_Fanuc.cs @@ -2000,6 +2000,84 @@ namespace CMS_CORE_Library.Fanuc public override CmsError FILES_RGetFileList(string path, ref List files) { + try + { + ODBPDFDRV baseDir = new ODBPDFDRV(); + short nReturn = cnc_rdpdf_drive(nLibHandle[0], baseDir); + + path = "//" + baseDir.drive1 + "/USER/PATH1/"; + + ODBPDFNFIL dataNum = new ODBPDFNFIL(); + nReturn = Focas1.cnc_rdpdf_subdirn(nLibHandle[0], path, dataNum); + if (nReturn != 0) + return GetNcError(nReturn); + + IDBPDFSDIR currDirInput = new IDBPDFSDIR(); + ODBPDFSDIR currDirOutData = new ODBPDFSDIR(); + + short maxDir = 1; + + // Read directories names + if (dataNum.dir_num > 0) + { + // Setup input data + currDirInput.dummy = 0; + currDirInput.path = path; + for(short i = 0; i < dataNum.dir_num; i++) + { + // Update index + currDirInput.req_num = i; + // Read directory data + nReturn = cnc_rdpdf_subdir(nLibHandle[0], ref maxDir, currDirInput, currDirOutData); + if (nReturn != 0) + return GetNcError(nReturn); + + // Add to list read data + files.Add(new PreviewFileModel() + { + AbsolutePath = path + currDirOutData.d_f, + IsDirectory = true, + Name = Path.GetDirectoryName(currDirOutData.d_f), + Path = path + }); + } + } + // Read files names + if(dataNum.file_num > 0) + { + IDBPDFADIR funcInput = new IDBPDFADIR(); + ODBPDFADIR fileData = new ODBPDFADIR(); + + // Setup input data + funcInput.path = path; + funcInput.type = 1; + funcInput.size_kind = 1; + funcInput.dummy = 0; + + for (short i = 0; i < dataNum.file_num; i++) + { + funcInput.req_num = i; // Update file index + // Read file data + nReturn = Focas1.cnc_rdpdf_alldir(nLibHandle[0], ref maxDir, funcInput, fileData); + if (nReturn != 0) + return GetNcError(nReturn); + + // Add to list read data + files.Add(new PreviewFileModel() + { + AbsolutePath = path + fileData.d_f, + IsDirectory = false, + Name = fileData.d_f, + Path = path + }); + } + } + } + catch(Exception ex) + { + + } + return NO_ERROR; } diff --git a/CMS_CORE_Library/Osai/Nc_Osai.cs b/CMS_CORE_Library/Osai/Nc_Osai.cs index a7de54a..b9b8a06 100644 --- a/CMS_CORE_Library/Osai/Nc_Osai.cs +++ b/CMS_CORE_Library/Osai/Nc_Osai.cs @@ -1912,7 +1912,6 @@ namespace CMS_CORE_Library.Osai { ushort nReturn; string temppath; - uint findHandler; bool found; FILEFINDDATA filesearch = new FILEFINDDATA(); @@ -1924,7 +1923,7 @@ namespace CMS_CORE_Library.Osai temppath = path; temppath = temppath.TrimStart('\\'); - nReturn = OpenNC.LogFSFindFirst(NC_PROGRAM_PATH + temppath + "\\*", out filesearch, out findHandler, out uint errorClass, out uint errorNum); + nReturn = OpenNC.LogFSFindFirst(NC_PROGRAM_PATH + temppath + "\\*", out filesearch, out uint findHandler, out uint errorClass, out uint errorNum); //If there's an error if (errorClass != 0 || errorNum != 0 || nReturn == 0)