diff --git a/.gitignore b/.gitignore index 7604078ea253ac7ec683c97eab80ef3fe4975906..06d6bb37630051d2de5c5131286c6fdfeb6df232 100644 --- a/.gitignore +++ b/.gitignore @@ -26,11 +26,12 @@ codegen/ # Personal test files test*.m -export/* +test123_data.h5 -# files that are crfeated in example.m +# files that are created in example.m testdata_2.h5 test_data.mat +export/* # Octave session info octave-workspace diff --git a/copiedFile.h5 b/copiedFile.h5 deleted file mode 100644 index 137c2b657dc197e3e12acdc090e5ee5aea52f917..0000000000000000000000000000000000000000 Binary files a/copiedFile.h5 and /dev/null differ diff --git a/example.m b/example.m index e803c2bd5b99d848f8843a1dfa5a2c7e75a4788d..a489c7a00d2bdf82e90f031d0199faf56b854c1b 100644 --- a/example.m +++ b/example.m @@ -44,9 +44,9 @@ set(gca, 'TickDir', 'out', 'YLim', [0,4]); %% Tag the plot [figs, ID] = TagPlot(fig, ProjectID); -%% call dummy function -% a=1; -% a = test_2(a); +%% call a dummy function +a=1; +a = example_fcn(a); %% publishing @@ -54,17 +54,18 @@ set(gca, 'TickDir', 'out', 'YLim', [0,4]); % figure path.script = mfilename('fullpath'); % filename of the m.script -% file name of the data (should be extended to handle arrays) +% file name of the data path.rdata = {dataset1,dataset2} ; % don't forget the extension - -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 +Publish(path, ID, figs, 'Location', 'local','Method','individual') + +%% Second Plot with identical data to test centralized method +% +% fig2 =figure; +% plot(x,y,'-k'); +% hold on +% plot(x1,y1,'-r'); +% +% [fig2, ID] = TagPlot(fig2, ProjectID); +% +% Publish(path, ID, fig2, 'Location', 'local','Method','centraliced') \ No newline at end of file diff --git a/example_fcn.m b/example_fcn.m new file mode 100644 index 0000000000000000000000000000000000000000..418f15ca734ac8423bdda5a6ead2c32af6820e22 --- /dev/null +++ b/example_fcn.m @@ -0,0 +1,6 @@ +function [outputArg1] = example_fcn(inputArg1) +%TEST_2 just a dummy function +outputArg1 = inputArg1; + +end + diff --git a/fcn_core/Publish.m b/fcn_core/Publish.m index ebff3ca809b4a5842a6bf77d2b0749b47f3176ad..9c2fc18e55957f56eda85f32161b115bf063c21b 100644 --- a/fcn_core/Publish.m +++ b/fcn_core/Publish.m @@ -13,7 +13,7 @@ arguments figures (1,:) {mustBeFigure} % Checks if Figures are figures options.Location {mustBeMember(options.Location ,['local','server'])} = 'local' % storage path options.Method {mustBeMember(options.Method ,['individual','centraliced'])} = 'individual' - options.CopyUserFCN (1,1) {mustBeNumericOrLogical} = 'false' % should be true in realease ! + options.CopyUserFCN (1,1) {mustBeNumericOrLogical} = true end switch options.Location @@ -52,17 +52,19 @@ switch options.Method %check if data folder exists if ~isfolder(fullfile(storPath,'data')) mkdir(fullfile(storPath,'data')); - else %list all files - fList = dir(fullfile(storPath,'data', '**\*.*')); %get list of files and folders in any subfolder - fList = fList(~[fList.isdir]); %remove folders from list end + %list all files + fList = dir(fullfile(storPath,'data', '**\*.*')); %get list of files and folders in any subfolder + fList = fList(~[fList.isdir]); %remove folders from list + fList = struct2table(fList); + % Check if the new plot is based on the original data-set % copy the data(once) for i=1:numel(DataPaths.rdata) % check if identical file exists (status = 1) - [status, id] = fileCompare(DataPaths.rdata{i},fList); + [status, idx] = fileCompare(DataPaths.rdata{i},fList); if status - sourcePath = fullfile(fList(id).folder, fList(id).name); + sourcePath = fList.name{idx}; createLinkedHDF5(sourcePath,storPath,ID); else % no identical file exists createFileCopy(DataPaths.rdata,'data',storPath,ID,'dataCentral'); @@ -87,14 +89,14 @@ end %warning('Plot export was not sucessful') %end -disp(['Publishing of ', ID , ' done']); +disp(['publishing of ', ID , ' done']); end %function function [] = createFileCopy(filePaths,folderName,storPath,ID,type) % Creates a copy of the files (can used for multiple paths in a cell array) % folderName is the name of the exporting folder - disp(['Start to copy ', type]); + disp(['start to copy ', type]); % try for i = 1:numel(filePaths) diff --git a/fcn_help/FileCompare.m b/fcn_help/FileCompare.m index 5a4039d83d88b0f28eb394227136cb32a3fcf6c3..29210229e73074a24e5d24f6c910fccfac28c175 100644 --- a/fcn_help/FileCompare.m +++ b/fcn_help/FileCompare.m @@ -7,14 +7,15 @@ function [status, id] = fileCompare(filename,fileList) if isempty(fileList) % no comparison necessary status =false; + id = 0; return end [~,~,ext1] = fileparts(filename); -id = zeros(numel(fileList),1); +id = zeros(height(fileList),1); -for i=1:numel(fileList) - [~,~,ext2] = fileparts(fileList(i).name); +for i=1:height(fileList) + [~,~,ext2] = fileparts(fileList.name(i)); if ~isequal(ext1,ext2) %warning('File extension are not identical'); @@ -22,20 +23,26 @@ for i=1:numel(fileList) continue end - filepath = fullfile(fileList(i).folder,fileList(i).name); + filepath = fullfile(fileList.folder{i},fileList.name{i}); if ispc [status,~] = system(['fc ' filename ' ' filepath]); % 0 -> identical, 1 -> not identical status = ~status; % false (not identical), true(identical) - id(i) = status; - + elseif isunix %untested! [status,~] = system(['diff ' filename ' ' filepath]); - id(i) = ~status; % ??? else warning('Platform not supported') end - + + if status == 1 + id(i) = 1; + else + % Status can also be any other number e.g. 2 + id(i) = 0; + end + + id =logical(id); %bugfix end end diff --git a/fcn_help/createLinkedHDF5.m b/fcn_help/createLinkedHDF5.m index 6564a7cf9d8ea806b9cc4fd4485e420fe14aedff..dd1e7979216b7f2e1aba49e50b6883c7a63f162f 100644 --- a/fcn_help/createLinkedHDF5.m +++ b/fcn_help/createLinkedHDF5.m @@ -5,16 +5,16 @@ function [status] = createLinkedHDF5(SourceFile,TargetPath,ID) plist_id = 'H5P_DEFAULT'; -try +% try fid = H5F.create(fullfile(TargetPath,ID,[ID,'_data.h5'])); %create External Link to Sourcefile in the Group linkToExternal 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 1d2004a11e0bf276402abe32cc62b6ed99f7e475..6f6642858ca39fe4ad4f41979dcdcca3b30b4877 100644 Binary files a/test_data.mat and b/test_data.mat differ diff --git a/testdata_2.h5 b/testdata_2.h5 index 79061fbf1d4dd06ed63a1e4d321d212bdb137e76..8415c693f833bd3db2dc2ca3c7e614efdbc98080 100644 Binary files a/testdata_2.h5 and b/testdata_2.h5 differ