Skip to content
Snippets Groups Projects
Commit 231c563c authored by Lemmer, Jan's avatar Lemmer, Jan
Browse files

Fix Bug in Centralized Option,

fix realtive Path Issues, fix indexing Issues by using tables
parent 87d9c58a
No related branches found
No related tags found
3 merge requests!13PreRelease_V0.1,!12PreRelease_V0.1,!1Add Link-replacement feature
......@@ -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
File deleted
......@@ -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
function [outputArg1] = example_fcn(inputArg1)
%TEST_2 just a dummy function
outputArg1 = inputArg1;
end
......@@ -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)
......
......@@ -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
......
......@@ -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
No preview for this file type
No preview for this file type
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment