From 92f7e7efb865ca317798ccd00ec6b17badfadff1 Mon Sep 17 00:00:00 2001
From: Marco Marchesi <marco4.marchesi@mail.polimi.it>
Date: Fri, 29 Sep 2023 15:49:20 +0200
Subject: [PATCH]  added recursive submodule automation

---
 RoccarasoFlight/postprocessing/GNC/mainPP.m   |  2 ++
 .../postprocessing/GNC/postProcess.m          | 15 ++++++-----
 .../miscellaneous/checkSubmodules.m           | 25 +++++++++++++++++++
 3 files changed, 34 insertions(+), 8 deletions(-)
 create mode 100644 RoccarasoFlight/postprocessing/commonFunctions/miscellaneous/checkSubmodules.m

diff --git a/RoccarasoFlight/postprocessing/GNC/mainPP.m b/RoccarasoFlight/postprocessing/GNC/mainPP.m
index 757ce1c..0045d05 100644
--- a/RoccarasoFlight/postprocessing/GNC/mainPP.m
+++ b/RoccarasoFlight/postprocessing/GNC/mainPP.m
@@ -2,7 +2,9 @@ clear; close all; clc;
 
 addpath(genpath('../commonFunctions/'))
 addpath('../RCS/Functions&Files/')
+checkSubmodules;
 addpath('../../../general-utilities/')
+
 %% import data from logs
 
 % import and parse data
diff --git a/RoccarasoFlight/postprocessing/GNC/postProcess.m b/RoccarasoFlight/postprocessing/GNC/postProcess.m
index 888d7b3..7efc753 100644
--- a/RoccarasoFlight/postprocessing/GNC/postProcess.m
+++ b/RoccarasoFlight/postprocessing/GNC/postProcess.m
@@ -99,15 +99,14 @@ exportStandardizedFigure(gcf, 'Expulsion zoom',textDim, 'addMarkers',false,'chan
 yyaxis right
 plot(RIG.TARSData(:,1),RIG.TARSData(:,4),'DisplayName','TARS Mass','Color','#D3212D')
 xline(RIG.EVENTData(findEventIndex(RIG.EVENTData,2,'MOTOR_START_TARS',main.EVENTNames),1),'k--',"START TARS",'HandleVisibility','off')
-xline(RIG.EVENTData(findEventIndex(RIG.EVENTData,2,'TARS_PRESSURE_STABILIZED',main.EVENTNames),1),'--',"PRESSURE STABILIZED",'HandleVisibility','off','Color','#00A86B')
+% xline(RIG.EVENTData(findEventIndex(RIG.EVENTData,2,'TARS_PRESSURE_STABILIZED',main.EVENTNames),1),'--',"PRESSURE STABILIZED",'HandleVisibility','off','Color','#00A86B')
 title('Pressure and Mass measures')
 xlabel('Time [s]')
 ylabel('Mass [kg]')
 set(gca,"YColor",'#D3212D')
-xlim([-1180,-900])
+xlim([-1160,-1000])
 legend
-exportStandardizedFigure(gcf, 'TARS pressure mass',textDim, 'addMarkers',false,'changeColors',false)
-
+exportStandardizedFigure(gcf, 'TARS pressure mass',textDim, 'addMarkers',false,'changeColors',false,'overwriteFigure',true)
 
 figure
 yyaxis left
@@ -120,14 +119,14 @@ exportStandardizedFigure(gcf, 'Expulsion zoom',textDim, 'addMarkers',false,'chan
 yyaxis right
 stairs(RIG.ventValve(:,1),RIG.ventValve(:,2)*100,'DisplayName','Venting Valve Position','Color','#D3212D')
 xline(RIG.EVENTData(findEventIndex(RIG.EVENTData,2,'MOTOR_START_TARS',main.EVENTNames),1),'k--',"START TARS",'HandleVisibility','off')
-xline(RIG.EVENTData(findEventIndex(RIG.EVENTData,2,'TARS_PRESSURE_STABILIZED',main.EVENTNames),1),'--',"PRESSURE STABILIZED",'HandleVisibility','off','Color','#00A86B')
-ylabel('Valve Position [%]')
+% xline(RIG.EVENTData(findEventIndex(RIG.EVENTData,2,'TARS_PRESSURE_STABILIZED',main.EVENTNames),1),'--',"PRESSURE STABILIZED",'HandleVisibility','off','Color','#00A86B')
+ylabel('Valve Position [\%]')
 xlabel('Time [s]')
 legend
 set(gca,"YColor",'#D3212D')
-xlim([-1180,-900])
+xlim([-1160,-1000])
 title('Mass finite difference vs venting valve')
-exportStandardizedFigure(gcf, 'TARS mass offset',textDim, 'addMarkers',false,'changeColors',false)
+exportStandardizedFigure(gcf, 'TARS mass offset',textDim, 'addMarkers',false,'changeColors',false,'overwriteFigure',true)
 
 % % % commento: non abbiamo lasciato che TARS finisse, ma abbiamo stoppato
 % % %           noi perché abbiamo visto fase liquida. Probabilmente si
diff --git a/RoccarasoFlight/postprocessing/commonFunctions/miscellaneous/checkSubmodules.m b/RoccarasoFlight/postprocessing/commonFunctions/miscellaneous/checkSubmodules.m
new file mode 100644
index 0000000..f49d239
--- /dev/null
+++ b/RoccarasoFlight/postprocessing/commonFunctions/miscellaneous/checkSubmodules.m
@@ -0,0 +1,25 @@
+currentPath = pwd;
+localRepoPath_generalUtilities = '../../../general-utilities/';
+if ~exist([localRepoPath_generalUtilities,'exportStandardizedFigure'],'file')
+    % clone repo
+    answer = input('WARNING! You don''have the exportStandardizedFigure installed. Do you want to install it? (recommended) (y/n)','s');
+    if answer == "y" || answer == "yes"
+        
+        cloneType = input('Which type of clone do you want to use? (SSH/HTTP) ','s');
+        if cloneType =="SSH" || cloneType == "ssh"
+            mkdir(localRepoPath_generalUtilities)    
+            system(['git submodule add "git@git.skywarder.eu:skyward/general-utilities.git" ',localRepoPath_generalUtilities])
+        elseif cloneType == "HTTP" || cloneType == "http"
+            mkdir(localRepoPath_generalUtilities)
+            system(['git submodule add "https://git.skywarder.eu/skyward/general-utilities.git" ',localRepoPath_generalUtilities])
+        else
+            fprintf('\n WARNING! Input not valid: aborting')
+        return
+        end
+    end
+else 
+    answer_pull = input('Do you want to update the graphics submodule? (y/n)','s');
+    if answer_pull == "yes" || answer_pull == "y"
+        system('git submodule update --recursive')
+    end
+end
-- 
GitLab