From 87d9c58aa473ad04bd7ebe95ae8590435e3290ad Mon Sep 17 00:00:00 2001 From: Jan Lemmer <jan.lemmer@fst.tu-darmstadt.de> Date: Tue, 3 Aug 2021 09:15:20 +0200 Subject: [PATCH] Centralized is working --- .gitignore | 4 ++++ example.m | 10 +++++++++- fcn_core/Publish.m | 22 ++++++++++++++-------- fcn_help/FileCompare.m | 18 ++++++++++++------ fcn_help/createLinkedHDF5.m | 21 ++++++++++----------- test_data.mat | Bin 1535 -> 1531 bytes testdata_2.h5 | Bin 3064 -> 3064 bytes 7 files changed, 49 insertions(+), 26 deletions(-) diff --git a/.gitignore b/.gitignore index b0afd48..7604078 100644 --- a/.gitignore +++ b/.gitignore @@ -28,5 +28,9 @@ codegen/ test*.m export/* +# files that are crfeated in example.m +testdata_2.h5 +test_data.mat + # Octave session info octave-workspace diff --git a/example.m b/example.m index 45c7e39..e803c2b 100644 --- a/example.m +++ b/example.m @@ -58,5 +58,13 @@ path.script = mfilename('fullpath'); % filename of the m.script path.rdata = {dataset1,dataset2} ; % don't forget the extension -Publish(path, ID, figs, 'Location', 'local','Method','individual','CopyUserFCN',true) +Publish(path, ID, figs, 'Location', 'local','Method','centraliced','CopyUserFCN',true) +% Second Plot to test centralized method + +fig(2) =figure; +plot(x,y,'-k'); +hold on +plot(x1,y1,'-r'); + +Publish(path, ID, figs, 'Location', 'local','Method','centraliced','CopyUserFCN',true) \ No newline at end of file diff --git a/fcn_core/Publish.m b/fcn_core/Publish.m index c970e7d..ebff3ca 100644 --- a/fcn_core/Publish.m +++ b/fcn_core/Publish.m @@ -58,11 +58,14 @@ switch options.Method end % Check if the new plot is based on the original data-set % copy the data(once) - for i=1:numel(DataPaths.rdata) - if fileCompare(DataPaths.rdata{i},{fList.name}) % identical file exists - createLinkedHDF5(DataPaths.rdata{i},storPath,ID) + for i=1:numel(DataPaths.rdata) + % check if identical file exists (status = 1) + [status, id] = fileCompare(DataPaths.rdata{i},fList); + if status + sourcePath = fullfile(fList(id).folder, fList(id).name); + createLinkedHDF5(sourcePath,storPath,ID); else % no identical file exists - createFileCopy(DataPaths.rdata{i},'data',storPath,ID,'data'); + createFileCopy(DataPaths.rdata,'data',storPath,ID,'dataCentral'); end end case 'individual' @@ -93,7 +96,7 @@ function [] = createFileCopy(filePaths,folderName,storPath,ID,type) % folderName is the name of the exporting folder disp(['Start to copy ', type]); - try +% try for i = 1:numel(filePaths) FileNameAndLocation = filePaths{i}; [~,name,ext] = fileparts(filePaths{i}); % get the extension @@ -102,6 +105,9 @@ function [] = createFileCopy(filePaths,folderName,storPath,ID,type) case 'data' sufix = '_data'; newfile = sprintf([ID, sufix, '_' , num2str(i) ,ext]); + case 'dataCentral' + %keep original name + newfile = sprintf([name,ext]); case 'script' sufix = '_script'; newfile = sprintf([ID, sufix ,ext]); @@ -117,9 +123,9 @@ function [] = createFileCopy(filePaths,folderName,storPath,ID,type) copyfile(FileNameAndLocation,RemotePath); end disp([type, ' sucessfully published']); - catch - warning([type,' export was not sucessful']) - end %try +% catch +% warning([type,' export was not sucessful']) +% end %try end function tf = mustBeFigure(h) diff --git a/fcn_help/FileCompare.m b/fcn_help/FileCompare.m index 325cfe5..5a4039d 100644 --- a/fcn_help/FileCompare.m +++ b/fcn_help/FileCompare.m @@ -4,27 +4,33 @@ function [status, id] = fileCompare(filename,fileList) % the functions uses the windows system function fc or the unix function % diff -%% Not working!!! +if isempty(fileList) + % no comparison necessary + status =false; + return +end [~,~,ext1] = fileparts(filename); id = zeros(numel(fileList),1); for i=1:numel(fileList) - [~,~,ext2] = fileparts(fileList{i}); + [~,~,ext2] = fileparts(fileList(i).name); if ~isequal(ext1,ext2) %warning('File extension are not identical'); status = false; - return + continue end + filepath = fullfile(fileList(i).folder,fileList(i).name); if ispc - [status,~] = system(['fc ' filename ' ' fileList{i}]); + [status,~] = system(['fc ' filename ' ' filepath]); % 0 -> identical, 1 -> not identical - id(i) = ~status; % false (not identical), true(identical) + status = ~status; % false (not identical), true(identical) + id(i) = status; elseif isunix %untested! - [status,~] = system(['diff ' filename ' ' fileList{i}]); + [status,~] = system(['diff ' filename ' ' filepath]); id(i) = ~status; % ??? else warning('Platform not supported') diff --git a/fcn_help/createLinkedHDF5.m b/fcn_help/createLinkedHDF5.m index f2d2574..6564a7c 100644 --- a/fcn_help/createLinkedHDF5.m +++ b/fcn_help/createLinkedHDF5.m @@ -1,21 +1,20 @@ function [status] = createLinkedHDF5(SourceFile,TargetPath,ID) -%UNTITLED4 Summary of this function goes here -% Detailed explanation goes here +%createLinkedHDF5 creates a HDF file that references the Sourcefile +% TargetPath is the STorage Location, ID the Foldername +% Status returns true if the function was sucessfull plist_id = 'H5P_DEFAULT'; -% Work in Progress... Problem mit dem Pfad... - -%try - fid = H5F.create(fullfile(TargetPath,[ID,'_data.h5'])); +try + fid = H5F.create(fullfile(TargetPath,ID,[ID,'_data.h5'])); %create External Link to Sourcefile in the Group linkToExternal - H5L.create_external(SourceFile,'/',fid, SourceFile ,plist_id,plist_id); + H5L.create_external(['..\data\',SourceFile],'/',fid, SourceFile ,plist_id,plist_id); H5F.close(fid); status = 1; -% catch -% warning('No linked HDF file was created'); -% status = 0; -% end +catch + warning('No linked HDF file was created'); + status = 0; +end end diff --git a/test_data.mat b/test_data.mat index 773ad46e46d0a3ab0dac6b68c057827c4ecaf9de..1d2004a11e0bf276402abe32cc62b6ed99f7e475 100644 GIT binary patch delta 894 zcmey*{hND&g@|Kmx`KkSf`O%#p^24|v4W9-k>SKZ<%tQb8%s=?>iw7*7%JxIPOSC` zE|)p_{{6lCd#8U|5m3{^>bSN)<JB^^aJBxqoef<Mof=&lD>m@7CnZi>bV8(1Sfpo* zQpXC`-iQya9BjtiJ6;;tNkq0xUBP0?xQxYY(Uj%abMHTSGI{d*pRZ*s4;x7JC9-su zovHs*@#p_MkFMX-TRbOgOg5?aJ$2i^;`Qnq=My`9ODi4~ifvcUvf3=llDEw>+Gib0 z@!D&vkEJmBy;MB9wOd1P-DlmZS=x_g%Q>%hpWb2jeU4JBK>N+b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