From ab53c088599901a7e74d99f87c35728a3c758587 Mon Sep 17 00:00:00 2001
From: Jan Lemmer <jan.lemmer@fst.tu-darmstadt.de>
Date: Tue, 16 Nov 2021 15:32:55 +0100
Subject: [PATCH] Add initialisation implements #77

---
 +PlotID/@config/config.m |  2 +-
 +PlotID/@config/wizard.m |  2 +-
 Initialisation.m         | 29 ++++++++++++++++
 PlotID_Demo.m            | 74 ----------------------------------------
 4 files changed, 31 insertions(+), 76 deletions(-)
 create mode 100644 Initialisation.m
 delete mode 100644 PlotID_Demo.m

diff --git a/+PlotID/@config/config.m b/+PlotID/@config/config.m
index 73409aa..e3a5ed4 100644
--- a/+PlotID/@config/config.m
+++ b/+PlotID/@config/config.m
@@ -43,7 +43,7 @@ classdef config < handle
             %   TODo;
             fid = fopen(fullfile(path,obj.configFileName),'w');
             txt = jsonencode(obj.configData,'PrettyPrint',true);
-            %fprintf does not write paths correcctly !!!
+            %fprintf does not write paths correctly !!!
             fwrite(fid,txt);
             fclose(fid);
         end
diff --git a/+PlotID/@config/wizard.m b/+PlotID/@config/wizard.m
index 1b274f4..de66181 100644
--- a/+PlotID/@config/wizard.m
+++ b/+PlotID/@config/wizard.m
@@ -10,7 +10,7 @@ switch mode
 
         msg = ['Do you want to add a remote path?' newline,...
             'Otherwise your files will be stored locally.' newline,...
-            '>ou can add this later by rerunning the initilisation.'];
+            'You can add this later by rerunning the initilisation.'];
         disp(msg);                
         m = input('Do you want add a remothe path, Y/N [Y]:','s');
 
diff --git a/Initialisation.m b/Initialisation.m
new file mode 100644
index 0000000..97835f3
--- /dev/null
+++ b/Initialisation.m
@@ -0,0 +1,29 @@
+%% This is the PlotID Initialisation file
+% Please run this script before using PlotID
+
+%% Step 1: Add plotID location to you MATLAB path
+% This is necessary to use PlotID in your personal MATLAB Scripts
+addpath(pwd);
+savepath;
+
+%% Section 2 Config File
+% To make things easy, you should use the config file. The following wizard
+% will help you create one:
+writeConfig = true;
+
+% Ask User if current config should be overwritten
+if isfile('config.json')
+    m = input('Do you want to overwrite the current config file, Y/N [Y]:','s');
+    writeConfig = ismember(m,{'Y','y'});
+end    
+
+if writeConfig
+   config = PlotID.config.wizard('initilise');
+   fid = fopen('config.json','w');
+   txt = jsonencode(config,'PrettyPrint',true);
+   fwrite(fid,txt);
+   fclose(fid);
+end
+
+%%
+disp('Initialisition done.')
diff --git a/PlotID_Demo.m b/PlotID_Demo.m
deleted file mode 100644
index 766ad17..0000000
--- a/PlotID_Demo.m
+++ /dev/null
@@ -1,74 +0,0 @@
-%% Example Script
-% This Script is meant to demonstrate the capabilities of the PlotID tool.
-
-%% Clear Environment
-clear; clc; close all;
-addpath('CI_files'); % Test scripts
-try
-    delete testdata2.h5;
-end
-
-%% Set ProjectID
-% ProjectID can also be set in the config file 
-% Leave empty for using the ID from the config file
-ProjectID = 'FST01';
-
-%% Data
-% Creating Random Data to use as data-file
-x = linspace(0,7);
-y = rand(1,100)+2;
-dataset1 = 'test_data.mat';
-% use absolute paths for good practise
-dataset1 = fullfile(pwd, dataset1);
-save(dataset1,'x','y');
-
-% some data as .h5
-x1 = linspace(0,2*pi);
-y1 = sin(x1)+.5*sin(2*x1)+2;
-
-% define file path & name
-
-fpath = fullfile(pwd,"./testdata2.h5");
-dataset2 = fullfile(pwd,'testdata2.h5');
-
-% create hdf5 file and dataset > write data to hdf5 file / dataset
-h5create(fpath, "/x1", size(x1), "Datatype", class(x1))
-h5create(fpath, "/y1", size(y1), "Datatype", class(y1))
-h5write(fpath, "/x1", x1)
-h5write(fpath, "/y1", y1)
-
-%% Plotting
-% This is still part of a normal script to produce plots.
-% Make sure to save each figure in a variable to pass to PlotID-functions.
-fig(1) = figure;
-set(gcf,'Units','centimeters','PaperUnits','centimeters','PaperSize',[9 7],...
-'Position',[5 5 9 7]);
-plot(x,y,'Color',0.5*[1 1 1]);
-box off; hold on;
-plot(x1,y1,'-k');
-set(gca, 'TickDir', 'out', 'YLim', [0,4],'YTick',[0:1:4],'XLim',[0,6]);
-%fstplt.setfiguresize('1/2ppt16:9');
-%fstplt.pimpplot;
-
-%% Example 1: single plot based on two data-sets
-
-%% Tag the plot
-% PlotID Implementation starts here.
-% TagPlot adds a visible ID to the figure(s) and to the figures property
-% 'Tag'
-[fig, ID] = PlotID.TagPlot(fig, 'ProjectID', ProjectID);
-
-%% Publishing
-% Second part of plotID 
-% The functions needs the file location, the location of the data and the
-% figure and can take several options.
-path.script = mfilename('fullpath'); % filename of the m.script
-% file names of the datasets
-path.rdata =  {dataset1,dataset2} ; % don't forget the extension
-
-PlotID.Publish(path, ID, fig(1), 'Location', 'local' ,'Method','individual')
-
-
-
-%% End 
-
-- 
GitLab