From b3f3a57fee63775129279d583518817772a84b14 Mon Sep 17 00:00:00 2001
From: Claudio Mandrioli <claudio.mandrioli@control.lth.se>
Date: Wed, 29 Aug 2018 14:14:14 +0200
Subject: [PATCH] updateTurnOff

---
 GPS_pw_modeling.mo              | 122 ++++++++++++++++++++------------
 report/sections/04-Examples.tex |   7 +-
 2 files changed, 83 insertions(+), 46 deletions(-)

diff --git a/GPS_pw_modeling.mo b/GPS_pw_modeling.mo
index 89569b7..26f9c08 100644
--- a/GPS_pw_modeling.mo
+++ b/GPS_pw_modeling.mo
@@ -36,21 +36,21 @@ package GPS_pw_modeling
     //States
     inner Modelica.StateGraph.StateGraphRoot stateGraphRoot annotation(
       Placement(visible = false, transformation(origin = {-90, -90}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
-    Modelica.StateGraph.InitialStep GPS_off(nIn = 2) annotation(
+    Modelica.StateGraph.InitialStep GPS_off(nIn = 4) annotation(
       Placement(visible = true, transformation(origin = {-150, 58}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
-    Modelica.StateGraph.Step warm_start(nOut = 2) annotation(
+    Modelica.StateGraph.Step warm_start(nOut = 3) annotation(
       Placement(visible = true, transformation(origin = {34, -12}, extent = {{10, -10}, {-10, 10}}, rotation = -90)));
-    Modelica.StateGraph.Step hot_start(nOut = 2) annotation(
-      Placement(visible = true, transformation(origin = {72, -12}, extent = {{10, -10}, {-10, 10}}, rotation = -90)));
-    Modelica.StateGraph.Step warm_start_available(nOut = 2) annotation(
-      Placement(visible = true, transformation(origin = {130, -72}, extent = {{-10, -10}, {10, 10}}, rotation = -90)));
-    Modelica.StateGraph.Step hot_start_available(nOut = 3) annotation(
-      Placement(visible = true, transformation(origin = {130, -12}, extent = {{-10, -10}, {10, 10}}, rotation = -90)));
+    Modelica.StateGraph.Step hot_start(nOut = 3) annotation(
+      Placement(visible = true, transformation(origin = {72, -20}, extent = {{10, -10}, {-10, 10}}, rotation = -90)));
+    Modelica.StateGraph.Step warm_start_available(nIn = 2, nOut = 2) annotation(
+      Placement(visible = true, transformation(origin = {80, -90}, extent = {{-10, -10}, {10, 10}}, rotation = 180)));
+    Modelica.StateGraph.Step hot_start_available(nIn = 2, nOut = 3) annotation(
+      Placement(visible = true, transformation(origin = {130, -20}, extent = {{-10, -10}, {10, 10}}, rotation = -90)));
     Modelica.StateGraph.Step position_available(nIn = 4, nOut = 2) annotation(
       Placement(visible = true, transformation(origin = {100, 58}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
-    Modelica.StateGraph.Step freq_and_phase(nIn = 3) annotation(
+    Modelica.StateGraph.Step freq_and_phase(nIn = 3, nOut = 2) annotation(
       Placement(visible = true, transformation(origin = {-4, 58}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
-    Modelica.StateGraph.Step cold_start annotation(
+    Modelica.StateGraph.Step cold_start(nOut = 2)  annotation(
       Placement(visible = true, transformation(origin = {-82, 58}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
     //Transitions
     Modelica.StateGraph.Transition lock_freq_and_phase(enableTimer = true, waitTime = freq_and_phase_acquisition_time) annotation(
@@ -68,30 +68,90 @@ package GPS_pw_modeling
     Modelica.StateGraph.Transition update_ephemeris_data(enableTimer = true, waitTime = time_to_get_ephemeris) annotation(
       Placement(visible = true, transformation(origin = {156, 58}, extent = {{-10, 10}, {10, -10}}, rotation = 0)));
     Modelica.StateGraph.Transition lose_hot_start(enableTimer = true, waitTime = time_lose_hot_start) annotation(
-      Placement(visible = true, transformation(origin = {130, -44}, extent = {{-10, 10}, {10, -10}}, rotation = -90)));
+      Placement(visible = true, transformation(origin = {128, -78}, extent = {{-10, 10}, {10, -10}}, rotation = -90)));
     Modelica.StateGraph.Transition ephemeris_data_expire_1(condition = time > expiration_time) annotation(
-      Placement(visible = true, transformation(origin = {40, -104}, extent = {{10, 10}, {-10, -10}}, rotation = 0)));
+      Placement(visible = true, transformation(origin = {-126, -104}, extent = {{10, 10}, {-10, -10}}, rotation = 0)));
     Modelica.StateGraph.Transition ephemeris_data_expire_2(condition = time > expiration_time) annotation(
-      Placement(visible = true, transformation(origin = {28, -110}, extent = {{10, 10}, {-10, -10}}, rotation = 0)));
+      Placement(visible = true, transformation(origin = {-138, -110}, extent = {{10, 10}, {-10, -10}}, rotation = 0)));
     //turn on transitions
     Modelica.StateGraph.TransitionWithSignal turn_on annotation(
       Placement(visible = true, transformation(origin = {-116, 58}, extent = {{-10, 10}, {10, -10}}, rotation = 0)));
     Modelica.StateGraph.TransitionWithSignal turn_on_hot_start annotation(
-      Placement(visible = true, transformation(origin = {100, -28}, extent = {{10, 10}, {-10, -10}}, rotation = 0)));
+      Placement(visible = true, transformation(origin = {100, -44}, extent = {{10, 10}, {-10, -10}}, rotation = 0)));
     Modelica.StateGraph.TransitionWithSignal turn_on_warm_start annotation(
-      Placement(visible = true, transformation(origin = {74, -60}, extent = {{10, 10}, {-10, -10}}, rotation = 0)));
+      Placement(visible = true, transformation(origin = {32, -60}, extent = {{10, 10}, {-10, -10}}, rotation = -90)));
     //turn off transition
     Modelica.StateGraph.TransitionWithSignal turn_off_antenna annotation(
       Placement(visible = true, transformation(origin = {130, 18}, extent = {{-10, 10}, {10, -10}}, rotation = -90)));
     Modelica.Blocks.MathBoolean.Not not1 annotation(
       Placement(visible = true, transformation(origin = {22, 94}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
+  Modelica.StateGraph.TransitionWithSignal turn_off_antenna2 annotation(
+      Placement(visible = true, transformation(origin = {-126, 14}, extent = {{10, -10}, {-10, 10}}, rotation = 0)));
+  Modelica.StateGraph.TransitionWithSignal turn_off_antenna3 annotation(
+      Placement(visible = true, transformation(origin = {-126, -30}, extent = {{10, -10}, {-10, 10}}, rotation = 0)));
+  Modelica.StateGraph.TransitionWithSignal turn_off_antenna4 annotation(
+      Placement(visible = true, transformation(origin = {104, 2}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
+  Modelica.StateGraph.TransitionWithSignal turn_off_antenna5 annotation(
+      Placement(visible = true, transformation(origin = {66, -60}, extent = {{-10, 10}, {10, -10}}, rotation = -90)));
   equation
+    connect(turn_off_antenna5.condition, not1.y) annotation(
+      Line(points = {{78, -60}, {200, -60}, {200, 98}, {34, 98}, {34, 94}, {34, 94}}, color = {255, 0, 255}));
+    connect(turn_off_antenna5.outPort, warm_start_available.inPort[2]) annotation(
+      Line(points = {{66, -62}, {66, -62}, {66, -70}, {102, -70}, {102, -90}, {92, -90}, {92, -90}}));
+    connect(turn_off_antenna5.inPort, warm_start.outPort[3]) annotation(
+      Line(points = {{66, -56}, {52, -56}, {52, 4}, {34, 4}, {34, -2}, {34, -2}}));
+  connect(turn_on_warm_start.condition, on_signal) annotation(
+      Line(points = {{44, -60}, {50.75, -60}, {50.75, -50}, {-106, -50}, {-106, 93}, {-133, 93}}, color = {255, 0, 255}));
+    connect(not1.y, turn_off_antenna4.condition) annotation(
+      Line(points = {{34, 94}, {200, 94}, {200, -16}, {104, -16}, {104, -10}, {104, -10}}, color = {255, 0, 255}));
+    connect(turn_off_antenna4.outPort, hot_start_available.inPort[2]) annotation(
+      Line(points = {{106, 2}, {130, 2}, {130, -8}, {130, -8}}));
+    connect(turn_off_antenna4.inPort, hot_start.outPort[3]) annotation(
+      Line(points = {{100, 2}, {72, 2}, {72, -10}, {72, -10}}));
+  connect(hot_start_available.outPort[2], ephemeris_data_expire_2.inPort) annotation(
+      Line(points = {{130, -30.5}, {130, -44}, {172, -44}, {172, -110}, {-134, -110}}, thickness = 0.5));
+  connect(turn_on_hot_start.inPort, hot_start_available.outPort[3]) annotation(
+      Line(points = {{104, -44}, {130, -44}, {130, -30.5}}));
+  connect(lose_hot_start.inPort, hot_start_available.outPort[1]) annotation(
+      Line(points = {{128, -74}, {128, -52.25}, {130, -52.25}, {130, -30.5}}));
+  connect(hot_start_available.inPort[1], turn_off_antenna.outPort) annotation(
+      Line(points = {{130, -9}, {130, 18}}, thickness = 0.5));
+    connect(turn_on_hot_start.outPort, hot_start.inPort[1]) annotation(
+      Line(points = {{98.5, -44}, {72, -44}, {72, -31}}));
+    connect(hot_start.outPort[2], lock_freq_and_Phase_4.inPort) annotation(
+      Line(points = {{72, -9.5}, {72, 8}, {-2, 8}, {-2, 14}}, thickness = 0.5));
+    connect(hot_start.outPort[1], lock_freq_and_phase_2.inPort) annotation(
+      Line(points = {{72, -9.5}, {70, -9.5}, {70, 20}}, thickness = 0.5));
+  connect(turn_on_hot_start.condition, on_signal) annotation(
+      Line(points = {{100, -34}, {100, 22}, {-106, 22}, {-106, 93}, {-133, 93}}, color = {255, 0, 255}));
+  connect(warm_start_available.inPort[1], lose_hot_start.outPort) annotation(
+      Line(points = {{91, -90}, {91, -90.125}, {105, -90.125}, {105, -90.25}, {128, -90.25}, {128, -79.5}}, thickness = 0.5));
+  connect(turn_on_warm_start.inPort, warm_start_available.outPort[2]) annotation(
+      Line(points = {{32, -64}, {32, -87.25}, {69.5, -87.25}, {69.5, -90}}));
+  connect(warm_start_available.outPort[1], ephemeris_data_expire_1.inPort) annotation(
+      Line(points = {{69.5, -92}, {4.75, -92}, {4.75, -104}, {-122, -104}}, thickness = 0.5));
+    connect(ephemeris_data_expire_2.outPort, GPS_off.inPort[2]) annotation(
+      Line(points = {{-137.5, -110}, {-172, -110}, {-172, 58}, {-161, 58}}));
+    connect(ephemeris_data_expire_1.outPort, GPS_off.inPort[1]) annotation(
+      Line(points = {{-125.5, -104}, {-172, -104}, {-172, 58}, {-161, 58}}));
+  connect(warm_start.inPort[1], turn_on_warm_start.outPort) annotation(
+      Line(points = {{34, -23}, {34, -40.75}, {30, -40.75}, {30, -58.5}}, thickness = 0.5));
+    connect(turn_off_antenna3.condition, not1.y) annotation(
+      Line(points = {{-126, -42}, {-126, -42}, {-126, -48}, {-190, -48}, {-190, 130}, {56, 130}, {56, 94}, {34, 94}, {34, 94}}, color = {255, 0, 255}));
+    connect(turn_off_antenna3.outPort, GPS_off.inPort[4]) annotation(
+      Line(points = {{-128, -30}, {-172, -30}, {-172, 58}, {-160, 58}, {-160, 58}}));
+    connect(freq_and_phase.outPort[2], turn_off_antenna3.inPort) annotation(
+      Line(points = {{6, 58}, {14, 58}, {14, -30}, {-122, -30}, {-122, -30}}, thickness = 0.5));
+    connect(not1.y, turn_off_antenna2.condition) annotation(
+      Line(points = {{34, 94}, {56, 94}, {56, 130}, {-190, 130}, {-190, -6}, {-126, -6}, {-126, 2}, {-126, 2}}, color = {255, 0, 255}));
+    connect(turn_off_antenna2.inPort, cold_start.outPort[2]) annotation(
+      Line(points = {{-122, 14}, {-60, 14}, {-60, 58}, {-72, 58}, {-72, 58}, {-72, 58}}));
+    connect(turn_off_antenna2.outPort, GPS_off.inPort[3]) annotation(
+      Line(points = {{-128, 14}, {-172, 14}, {-172, 58}, {-160, 58}, {-160, 58}}));
     connect(not1.y, turn_off_antenna.condition) annotation(
       Line(points = {{34, 92}, {190, 92}, {190, 18}, {142, 18}}, color = {255, 0, 255}));
     connect(not1.u, on_signal) annotation(
       Line(points = {{8, 92}, {-66, 92}, {-66, 93}, {-133, 93}}, color = {255, 0, 255}));
-    connect(hot_start.outPort[1], lock_freq_and_phase_2.inPort) annotation(
-      Line(points = {{72, -2}, {70, -2}, {70, 20}, {70, 20}}, thickness = 0.5));
     connect(lock_freq_and_phase_2.outPort, position_available.inPort[3]) annotation(
       Line(points = {{70, 26}, {70, 26}, {70, 58}, {90, 58}, {90, 58}}));
     connect(get_ephemeris_data.outPort, position_available.inPort[1]) annotation(
@@ -112,46 +172,18 @@ package GPS_pw_modeling
       Line(points = {{-2, 20}, {-2, 38}, {-24, 38}, {-24, 58}, {-15, 58}}));
     connect(lock_freq_and_Phase_3.outPort, freq_and_phase.inPort[2]) annotation(
       Line(points = {{-32, 20}, {-32, 38}, {-24, 38}, {-24, 58}, {-15, 58}}));
-    connect(hot_start_available.inPort[1], turn_off_antenna.outPort) annotation(
-      Line(points = {{128, -1}, {128, 8.5}, {130, 8.5}, {130, 18}}, thickness = 0.5));
-    connect(lose_hot_start.inPort, hot_start_available.outPort[1]) annotation(
-      Line(points = {{130, -40}, {130, -31}, {128, -31}, {128, -22.5}}));
-    connect(turn_on_hot_start.inPort, hot_start_available.outPort[3]) annotation(
-      Line(points = {{104, -28}, {128, -28}, {128, -22.5}}));
-    connect(hot_start_available.outPort[2], ephemeris_data_expire_2.inPort) annotation(
-      Line(points = {{128, -22.5}, {128, -34}, {170, -34}, {170, -110}, {32, -110}}, thickness = 0.5));
-    connect(turn_on_warm_start.condition, on_signal) annotation(
-      Line(points = {{74, -48}, {74.75, -48}, {74.75, -44}, {-106, -44}, {-106, 93}, {-133, 93}}, color = {255, 0, 255}));
-    connect(turn_on_hot_start.condition, on_signal) annotation(
-      Line(points = {{100, -16}, {100, 22}, {-106, 22}, {-106, 93}, {-133, 93}}, color = {255, 0, 255}));
     connect(on_signal, turn_on.condition) annotation(
       Line(points = {{-133, 93}, {-116, 93}, {-116, 70}}, color = {255, 0, 255}));
     connect(warm_start.outPort[2], lock_freq_and_Phase_3.inPort) annotation(
       Line(points = {{34, -2}, {34, -2}, {34, 4}, {-32, 4}, {-32, 14}, {-32, 14}}, thickness = 0.5));
-    connect(hot_start.outPort[2], lock_freq_and_Phase_4.inPort) annotation(
-      Line(points = {{72, -2}, {72, -2}, {72, 8}, {-2, 8}, {-2, 14}, {-2, 14}}, thickness = 0.5));
     connect(warm_start.outPort[1], lock_freq_and_phase_1.inPort) annotation(
       Line(points = {{34, -2}, {34, -2}, {34, 20}, {34, 20}}, thickness = 0.5));
-    connect(ephemeris_data_expire_2.outPort, GPS_off.inPort[2]) annotation(
-      Line(points = {{26.5, -110}, {-172, -110}, {-172, 58}, {-161, 58}}));
-    connect(turn_on_warm_start.inPort, warm_start_available.outPort[2]) annotation(
-      Line(points = {{78, -62}, {104, -62}, {104, -92}, {130, -92}, {130, -82}}));
-    connect(warm_start.inPort[1], turn_on_warm_start.outPort) annotation(
-      Line(points = {{34, -23}, {34, -62}, {72.5, -62}}, thickness = 0.5));
-    connect(warm_start_available.outPort[1], ephemeris_data_expire_1.inPort) annotation(
-      Line(points = {{130, -82.5}, {130, -106}, {44, -106}}, thickness = 0.5));
-    connect(ephemeris_data_expire_1.outPort, GPS_off.inPort[1]) annotation(
-      Line(points = {{38.5, -106}, {-172, -106}, {-172, 58}, {-161, 58}}));
     connect(turn_on.inPort, GPS_off.outPort[1]) annotation(
       Line(points = {{-120, 58}, {-137.5, 58}}));
     connect(cold_start.inPort[1], turn_on.outPort) annotation(
       Line(points = {{-93, 58}, {-112.5, 58}}, thickness = 0.5));
     connect(lock_freq_and_phase.inPort, cold_start.outPort[1]) annotation(
       Line(points = {{-44, 58}, {-73.5, 58}}));
-    connect(turn_on_hot_start.outPort, hot_start.inPort[1]) annotation(
-      Line(points = {{98.5, -28}, {72.5, -28}, {72.5, -21}}));
-    connect(warm_start_available.inPort[1], lose_hot_start.outPort) annotation(
-      Line(points = {{130, -63}, {130, -49.5}}, thickness = 0.5));
 //power consumption OUTPUT
     power_consumption = if on_signal then power_consumption_over_time else 0;
   //is position available OUTPUT
diff --git a/report/sections/04-Examples.tex b/report/sections/04-Examples.tex
index 84c031a..095d7cb 100644
--- a/report/sections/04-Examples.tex
+++ b/report/sections/04-Examples.tex
@@ -24,4 +24,9 @@ This event represents the fact that the stored ephemeris data are no more availa
 \subsubsection{lose hot start}
 This event is diffucult to be defined for the same reasons discussed for the event \texttt{fetch frequency and phase} in the case of hot start. For such reason here we only consider a deelay of some milliseconds. When modeling an actual device of the ones available nowadays since the idea of the hot start is not yet available this time should be set to zero.
 
-\subsection{Model execution}
\ No newline at end of file
+\subsection{Model execution}
+
+
+
+
+
-- 
GitLab