Commit b910413f authored by Claudio Mandrioli's avatar Claudio Mandrioli
Browse files

removed report for fbc4cs course

parent 87cb8252
This diff is collapsed.
pdflatex main.tex
bibtex main
pdflatex main.tex
pdflatex main.tex
rm main.aux main.bbl main.blg main.log
%libro con tutto sulla tecnologia gps
title={Understanding GPS: Principles and Applications},
author={Kaplan, E.D.},
series={Artech House telecommunications library},
publisher={Artech House}
%lavoro di microsoft in cui discutono la possibilità di usare i dati precedenti di fase e frequenza per velocizzzare il fetching
author = {Ramos, Heitor S. and Zhang, Tao and Liu, Jie and Priyantha, Nissanka B. and Kansal, Aman},
title = {LEAP: A Low Energy Assisted GPS for Trajectory-based Services},
booktitle = {Proceedings of the 13th International Conference on Ubiquitous Computing},
series = {UbiComp '11},
year = {2011},
isbn = {978-1-4503-0630-0},
location = {Beijing, China},
pages = {335--344},
numpages = {10},
url = {},
doi = {10.1145/2030112.2030158},
acmid = {2030158},
publisher = {ACM},
address = {New York, NY, USA},
keywords = {gps, low energy, mobile location},
%studio di fattibilità del downsampling per ricostruire la traiettoria
author={Xiaohan Li and Fengpeng Yuan and J. Lindqvist},
booktitle={2016 13th IEEE Annual Consumer Communications Networking Conference (CCNC)},
title={Feasibility of software-based duty cycling of GPS for trajectory-based services},
keywords={Global Positioning System;smart phones;software based duty cycling;trajectory based services;smartphone apps;route accuracy;map matching;path construction algorithm;smartphone GPS receiver;Global Positioning System;Roads;Databases;Energy consumption;Conferences;Google;Image color analysis},
%design principles per applicazioni smartphone
author = {Zhuang, Zhenyun and Kim, Kyu-Han and Singh, Jatinder Pal},
title = {Improving Energy Efficiency of Location Sensing on Smartphones},
booktitle = {Proceedings of the 8th International Conference on Mobile Systems, Applications, and Services},
series = {MobiSys '10},
year = {2010},
isbn = {978-1-60558-985-5},
location = {San Francisco, California, USA},
pages = {315--330},
numpages = {16},
url = {},
doi = {10.1145/1814433.1814464},
acmid = {1814464},
publisher = {ACM},
address = {New York, NY, USA},
keywords = {energy efficiency, location sensing, location-based applications, smartphone},
%energy accuracy trade off
author = {Lin, Kaisen and Kansal, Aman and Lymberopoulos, Dimitrios and Zhao, Feng},
title = {Energy-accuracy Trade-off for Continuous Mobile Device Location},
booktitle = {Proceedings of the 8th International Conference on Mobile Systems, Applications, and Services},
series = {MobiSys '10},
year = {2010},
isbn = {978-1-60558-985-5},
location = {San Francisco, California, USA},
pages = {285--298},
numpages = {14},
url = {},
doi = {10.1145/1814433.1814462},
acmid = {1814462},
publisher = {ACM},
address = {New York, NY, USA},
keywords = {GPS energy, continuous location, location-based applications},
author = {Thiagarajan, Arvind and Ravindranath, Lenin and LaCurts, Katrina and Madden, Samuel and Balakrishnan, Hari and Toledo, Sivan and Eriksson, Jakob},
title = {VTrack: Accurate, Energy-aware Road Traffic Delay Estimation Using Mobile Phones},
booktitle = {Proceedings of the 7th ACM Conference on Embedded Networked Sensor Systems},
series = {SenSys '09},
year = {2009},
isbn = {978-1-60558-519-2},
location = {Berkeley, California},
pages = {85--98},
numpages = {14},
url = {},
doi = {10.1145/1644038.1644048},
acmid = {1644048},
publisher = {ACM},
address = {New York, NY, USA},
keywords = {GPS, car, congestion, energy, localization, location, mobile, phone, sensor, traffic, transportation},
%data driven modeling of power consumption
author = {Kj{\ae}rgaard, Mikkel Baun and Langdal, Jakob and Godsk, Torben and Toftkj{\ae}r, Thomas},
title = {EnTracked: Energy-efficient Robust Position Tracking for Mobile Devices},
booktitle = {Proceedings of the 7th International Conference on Mobile Systems, Applications, and Services},
series = {MobiSys '09},
year = {2009},
isbn = {978-1-60558-566-6},
location = {Krak\&\#243;w, Poland},
pages = {221--234},
numpages = {14},
url = {},
doi = {10.1145/1555816.1555839},
acmid = {1555839},
publisher = {ACM},
address = {New York, NY, USA},
keywords = {energy-efficient, gps, positioning, tracking},
author = {Wang, Yi and Lin, Jialiu and Annavaram, Murali and Jacobson, Quinn A. and Hong, Jason and Krishnamachari, Bhaskar and Sadeh, Norman},
title = {A Framework of Energy Efficient Mobile Sensing for Automatic User State Recognition},
booktitle = {Proceedings of the 7th International Conference on Mobile Systems, Applications, and Services},
series = {MobiSys '09},
year = {2009},
isbn = {978-1-60558-566-6},
location = {Krak\&\#243;w, Poland},
pages = {179--192},
numpages = {14},
url = {},
doi = {10.1145/1555816.1555835},
acmid = {1555835},
publisher = {ACM},
address = {New York, NY, USA},
keywords = {eemss, energy efficiency, human state recognition, mobile sensing},
author="Thompson, Chris
and White, Jules
and Dougherty, Brian
and Schmidt, Douglas C.",
editor="Lee, Sunggu
and Narasimhan, Priya",
title="Optimizing Mobile Application Performance with Model--Driven Engineering",
booktitle="Software Technologies for Embedded and Ubiquitous Systems",
publisher="Springer Berlin Heidelberg",
address="Berlin, Heidelberg",
abstract="Future embedded and ubiquitous computing systems will operate continuously on mobile devices, such as smartphones, with limited processing capabilities, memory, and power. A critical aspect of developing future applications for mobile devices will be ensuring that the application provides sufficient performance while maximizing battery life. Determining how a software architecture will affect power consumption is hard because the impact of software design on power consumption is not well understood. Typically, the power consumption of a mobile software architecture can only be determined after the architecture is implemented, which is late in the development cycle when design changes are costly.",
author = {C. Yin and W. Qiang and M. Chang and A. Terzis},
title = {Ultra-low power time synchronization using passive radio receivers},
booktitle = {Information Processing in Sensor Networks (IPSN), 2011 10th International Conference on},
address = {???},
pages = {235--245},
% keep equation labels to normal size when the eq. is small or so (redefine amsmath macro)
% TiKz stuff
\tikzstyle{block} = [draw, rectangle, minimum height=2.5em, minimum width=2.8em]
\tikzstyle{sum} = [draw, circle, node distance=0]
\tikzstyle{input} = [coordinate]
\tikzstyle{output} = [coordinate]
\title{Dynamical modeling of power consumpion in GPS sensors}
\IEEEauthorblockN{Claudio Mandrioli}
\IEEEauthorblockA{Feedback control in computing systems - phd course, november 2017}
~This is a stub paper on the ``GPS'' subject as discussed in the last lecture of the PhD course in Lund, November 2017. Your task is to carry out the activities sketched out in the introduction, applying the notions and methods treated in the course wherever applicable, and to document your work by turning this stub into a 6--8 pages paper (indicative length). Needless to say, the title is just a placeholder, and you can change everything---including the introduction, that is a stub as well. For any question, just drop me a line.
\vspace{5mm}\textit{Keywords---} GPS, cyber-physical systems, energy consumption.
\section{How GPS works}
\section{Implementation and examples}
\section{Related Work}
\section{Conclusions and Possible Extensions}
Nowadays, virtually any mobile devices is equipped with a GPS receiver, that provides both a position measurement and a time reference, which may be crucial for the correct operation of several applications~\cite{bib:YinEtAl-2011a}. Both the position and the time provided by GPS can be very accurate, but come at the cost of a potentially significant energy consumption. As a result, trading position and time accuracy versus battery charge duration in an effective, predictable and possibly well configurable manner, is an enabler for improving many modern applications---sport related ones are an example, but for sure not the only one.
To address the problem just sketched, a cyber-physical attitude is inevitable, as is a correct determination of the required model complexity and detail. In fact, modern devices offer various other sensors for time and position, like an internal clock, the network itself, wifi beacons, accelerometers and so on. Each of these sources of information is subjected to its own physics, and for an effective use of the available resources -- including, and with special emphasis, the battery -- needs coordinating by software.
\caption{The ``cameras'' whiteboard.
Based on the considerations above, and in accordance with the discussion summarised by the whiteboard shown in Figure~\ref{fig:whiteboard-gps}, this work is devoted to exploring (some of) the so opened possibilities, verifying the statements made, and the possible consequent design of controllers when required, with the help of conveniently devised dynamic simulation models. A few possible subjects to address are listed below.
The first -- and very intuitive -- idea is to exploit event-based acquisition of GPS information instead of activating the receiver on a time-triggered, periodic basis. This can be done, as a first possibility, by using movement information taken e.g. from the accelerometer to detect that the position has changed enough for a new GPS measurement.
A more advanced idea is to generalise the concept above in such a way to define a ``quality'' of the position measurement, for example resorting to sensor fusion techniques, so as to refine the triggering mechanism.
As for \emph{time} measurements, they could be used along any of the available synchronisation scheme. This however comes to superimpose two event generation mechanism -- one for space, one for time -- that should as a consequence be somehow coordinated; for example, one could slightly defer a position-triggered GPS measurement if a synchronisation-triggered one is known to be coming shortly. More in general, one could think of not just fusing (or coordinating) the sensor measurements, but to directly define a ``joint space-time quality'' of the information possessed by the device under control. As can be seen, a lot of possible management schemes can be thought of, and evaluating their performance necessarily calls for simulation models to reliably compute the necessary quality indicators in the presence of conveniently characterised sets of external conditions and \emph{stimuli}.
The required simulation models will be written in Modelica, so as to take profit of the underlying object-oriented and multi-physics paradigm, with particular reference to the possibility of mixing equation-based non-causal models and algorithmic, prescriptive ones.
% \item localization through trilateration
% \item how distance is measured
% \item in what consists a gps receiver
All reported in this section (unless stated differently) is referenced by the book~\cite{bib:gps-book}.
The Global Positioning System (GPS) is the only positioning system that provides an absolute measure and is available worldwide. This is achieved using a constellation of space vehicles (SV) whose position is known with an high grade of accuracy and that is designed in such a way that at least five of them are visible at any time in every point over the world.
Any device able to listen to the signals broadcasted by the satellites can retrieve (i) their position and (ii) its distance from those: performing specific computations over this information it will be able to locate itself. We call such device a \textbf{GPS receiver}. The cited computation is called \emph{trilateration}, and it theoretically requires to listen to at least three satellites at the same time since the spatial coordinates to be determied are three.
From a technological perspective the measure of the distance from the satellites is based on a time difference, and it assumes that the time reference is the same for the SV and the receiver. Since this is apparently not true for devices that do not contain atomic clocks -- i.e. most of the commonly used GPS receivers -- another constraint must be introduced. This is done in order to be able to treat also the receiver time offset as an unknown variable. For this reason at least four satellites must be visible to be able to position the receiver. In case the receiver can listen to more than four satellites those can also be used to improve accuracy.
It shall be underlined moreover that the receiver only needs to listen to the SVs and it doesn't need to send any message.
\subsection{GPS signal modulation and multiplexing}
The GPS signal sent by the satellites is modulated using the Binary Phase Shift Key (BPSK) technique that includes the bit information in a $180^0$ phase shift of the carrier wave. This means that the carrier is transmitted ``as is'' or in counter-phase according to whether a 0 or 1 is being transmitted, an example is shown in figure~\ref{fig:bpsk}.
\caption{Representation of how BFSK works.
The signals from the different satellites are multiplexed on the same carrier frequency using Code Division Multiple Access (CDMA), more precisely Direct Sequence Spread Spectrum (DSSS) technique is used. In this methodology the data (in our case the ephemeris and almanac data) are trasmitted overlapped with another signal at much higher simbol rate. The data are therefore considered a \emph{baseband} signal while the latter is referred to as a \emph{spreading} waveform, meaning that the former can be considered at almost zero frequency with respect to the other signals (the carrier and the spreading sequence). The spreading sequence is a periodic signal and is completely known by the receivers, it is the ``key'' that the receivers will use for distinguishing the signals from the different sources. In the GPS system sequences of PseudoRandom Noise called \emph{golden codes} are used as spreading signals: those deterministic codes have the property of looking like white noises (so to have null correlation with themself) and are not correlated with each other. As we will see in section~\ref{sec:receiverSegment} both those properties are crucial for the GPS system to actually work.
The GPS signal sent by each satellite has therefore three components: the carrier, the localization data and the PRN sequence, a grsficsl example of this is shown in figure~\ref{fig:dsss}. The signal is broadcast in parallel on different band frequencies L1 (1575.42 MHz) and L2 (1227.60 MHz).
\caption{GPS signal composition and modulation.
\subsection{Positioning the satellites}
The position of the SVs can be retrieved from a set of parameters that describe their orbit around the earth. Since the orbits are not fixed in time due to trajectory corrections, collision avoidance or other uncertainties and disturbances, such parameters need to be continuously updated. To make those parameters always available the satellites broadcast them toward the earth surface.
Two kind of data are broadcast and can be used for SV positioning: \emph{almanac data} or \emph{ephemeris data}. The former are a subset of the latter (7 parameters out of 15) and are valid for several months while the latter are valid for 30 minutes after they are broadcast. Being apparently less precise the achivable precision with only the almanac data is around one order of magnitude less when used for positioning. The difference in time validity allows on the other side that satellites are able to share such information betwen each other and therefore each of them transmits the almanac data for every satellite. The ephemeris data of each satellite are instead transmitted only by the SV itself. In practice almanac data are mainly used by the receiving devices to know which SVs will be visible at a certain point in time and speed up the tracking phase, the ephemeris data are instead the ones actually used for the positioning.
The ephemeris data are fully repeated every 30 seconds by each SV. They are exact at the beginning of each of those half-minute cycles and are considered to be valid for 30 minutes. With those the receiver is able to achieve a precision of the order of meters in the positioning.
Since there are stations around the world that listen at the satellites and make the ephemeris data available in the internet devices that are also connected to the internet, instead of listening to the satellites can retrieve the ephemeris data from the web. This avoids the bottleneck of the GPS transmission channel which has a capacity of 50bit/s and is at the basis of the 30 seconds that are necessary for retrieving them. Such intenet-connected implementation of the GPS positioning system is called \textbf{Assisted-GPS}.
\subsection{Measuring the distance from the satellites}
The distance between the receiving device and the satellites is determined measuring the time it takes for the microwave signal generated by the satellite to reach the receiver. Since both the SVs and the receivers know exactly the PRN code this can be done measuring the phase shift (i.e. the delay) with which such signal is received by the device. The sender and the receiver generate the same signal with the same time reference: assumming that the clocks of the receiver and of the SV are synchronized the phase delay of the signal received by the GPS device will be equivalent to the distance divided by the speed of light. This way the receiver only needs to measure how much it has to delay the PRN code (generating the so-called \emph{replica code}) in order to measure the distance from the SV, a graphical representaiton of this is shown in figure~\ref{fig:phase_delay}. As a consequence the bit rate of the PRN code defines the maximum resolution achivable with this technology.
Since the atomic clocks of the different satellites are deisgned to be extremely stable and precise they can be considered synchronized (they are also corrected on a regulard basis), this way the only one extra variable as to be introduced to compensate for the non-synchronization is the receiver's clock.
\caption{How the phase delay is measured from the time-shift of the replica code generated by the receiver.
\subsection{How the receiver works}
A GPS receiver listens to the satellite signals through an antenna. The device must then decode the signal to identify the visible satellites, locate them and retrieve the distance from those. Since the satellites and the receivers are moving with respect to each other there will also be a distortion in the signal frequencies due to the doppler effect. This implies that for decoding the GPS signal for a given satellite the receiver must perform a two-dimensional search: in frequency and phase. The device will generate the replica code and distorce it in both frequency and phase shift it until it correlates with the GPS signal received from the antenna. This is why the correlation properties of the golden codes are so critical. First since they look like white-noises they will not correlate to themselfes unless they have the same phase shift. Second they do not correlate with each other avoiding the risk of not distinguishing the signal from different satellites.
Once frequency and phase are tracked two information are directly accessible: the ranging data and the speed of the receiver. The ranging data are computed from the phase as described in section~\ref{measuring_distance} from the phase shift. The speed instead can be computed from the relative speed measured with the doppler frequency and the satellite speed that is known from the ephemeris data.
It must be recalled that also the location data are sent by the satellite and those, according to whether a 0 or 1 is being trasmitted, can turn the PRN code into its complement (in the sense of logical negation) or leave it as it is. Depending on whether the replica code or its complement correlates with the signal itself the receiver is able to tell if a 0 or 1 is being transmitted. This exploits the fact that the location data are transmitted at much lower frequency (a baseband signal) with respect the spreading waveform and therefore don't interfere.
\subsection{The receiver technologies}
Until some years ago due to performance limitations of processors the processing of the GPS signal was performed with embedded circuits, hence not programmable: a GPS receiver was just a set of circuits that would listen to the satellites and provide the position as output. Nowadays it is possible to digitalize the GPS signal (after downconverting it to lower frequencies) and decode it with programs written in high level languages, allowing for more degrees of freedom when implementing a GPS receiver. This technology is called software-based GPS receiver, as opposed to the previous hardware-based ones. According to this the components of a software-based GPS receiver are: the antenna, a down-converter\footnote{The down converter lowers the frequency spectrum of the signal making it managable by the A/D converter.}, an A/D converter and a sufficiently performing processor programmable in high-level language.
%\subsection{Other aspects taken into account in GPS devices}
%\textcolor{red}{NOT SURE IF TO INCLUDE THIS}
%Other aspects of signal trasmission are taken into account when designing GPS devices in order to actually achieve such a precise positioning: main classes are interferences with other signals, the multipath phenomenon and the ionospheric scintillation. However those aspects do not influence the dynamics of the position acquisition since they are built on top or aside on the described positioning methodology and do not significantly \textcolor{red}{?} affect its behavior (at least from a power consumption perspesctive).
% \item what it means to model this kind of system: we want to model the ´´dynamics of information'' not of some physical phenomena
% \item use-case
% \item what do we want to capture (no almanac data but they could be considered for longer time-horizon applications): when and for how long we need to turn on the antenna (about almanac data: Since almanac data play a marginal role in the GPS system, both because their acquisition is much more time consuming (around 12 minutes) and marginally contribute to the performance of the positioning system they will not be taken into account in the rest of this work.)
% \item how do we capture it
% \item model presentation
% \item model limits and possible ways to overcome them (mention the second modeling approach that captures the channels paralleism)
Given how the GPS receiver works it is now possible to model how the GPS sensor affects energy consumpion in order to provide the position (and speed) information. As stated in the introducion a cyber-phisical approach is necessary since on one side is present the phisical consumption of energy while on the other there is the availability of the position information which belongs to the cyber domain.
The following sections discuss the choices for the inputs and outputs for the model. Afterward the modeling of the dynamics inbetwen the two is described.
\subsection{Input definition}
The sensor interacts with the user (in both the cases that it is a human or an application running on the same device) receiving ON/OFF control signals. This signal must therefore be considered when modeling a GPS sensor.
Once turned on the sensor listens to the signals broadcasted by the different satellites. If we neglect distinguishing the different satellites this can be captured by an integer representing the number of visible satellites.
%Another modeling approach could be to capture instead whether each of the satellites is visible or not.
Modeling indepentendtly the different satellites would increase the complexity of the model but provide quite marginal improvement in the descriptive power. This because the dynamics with which the device listens to the different SVs are strongly synchronized. Whenever the sensor is fetching the frequency, phase or ephemeris data it can do it in parallel for all of the visible satellites. Not distinguishing between the different satellites doesn't allow to simulate precisely how long it will take to get this information since the dynamics of fetching of each of the satellite's signal cannot be captured. On the other side this can be replaced with rigorous worst-case analysis or probabilistic modeling with bounded errors with respect to a precise model. Also the loss of connection with the different satellites, which is apparently not synchronized, cannot be represented becxause of not distinguishing the different satellites. Since the interest here is modelling the behavior of the overall device, it is sufficient to detect when not enough satellites are tracked and it can be neglected which of the satellites is actually tracked.
%\textcolor{red}{AN EXAMPLE OF THIS SHOULD BE MADE AFTER THE MODEL IS PRESENTED: the problem arises when the same satellte disappears and come back fast enough that the device should still have ephemeris data available. Another case is when a extra satellite is seen but not tracked, if after that another satellite is no more visible then the ephemeris data are of the previous satellite but this is not recognized by the model since the number of visible satellites is the same as before.}
All of this is apparently arguable and it should be re-considered for the specific use case.
The inputs choice for the model here presented is therefore: (i) the control signal that turns ON and OFF the antenna and (ii) the number of visible satellites\footnote{Modeling the tracking of each of the satellites individually would instead require including whether each of the satellites is visible or not and also the time reference for the broadcast of the ephemeris data for each of the satellites.}.
\subsection{Output definition}
What we want to capture with this model are the position availability and the power consumption, here we discuss and define them individually.
\subsubsection{Modeling the position availability and accuracy}
As stated before what we want to capture are the availability of the position information and the power consumption. It would be very useful to have a model of the accuracy of the positioning as well, but this is a very complex problem and is strongly related to the specific use cases. Accuracy of positioning depends on the number of visible satellites, their positioning in the sky and the quality of signal transmission. Both modeling those phenomena and defining rigorously they can affect the accuracy is not straight forward. For instance having two satellites that are very close to each other might not make much difference from having only one of those, or capturing how the clouds (or other structures around the device) might deteriorate the satellite signal is apparently very complex. Those considerations make defining a general model with still a managable complexity rarely (if not ever) feasible.
If we neglect the quality of the signals received and how the satellites are distributed in the visible sky we can define the accuracy requirements as a minimum number of satellites to be used for positioning --- which as stated in section~\ref{sec:how_it_works} cannot be less than 4. The output can then be defined as a boolean that is true when enough satellites are tracked and therefore the position is available or false otherwise. This is apparently incomplete but valid in general cases with good sky visibility and not degenerate distributions of the SVs (which is avoided in most cases by the constellation design)\footnote{If this approach is shown to be insufficient further extensions of this model could be investigated: for instance distinguishing the different satellites could allow for probabilistic modeling of the quality of the signal --- still leaving the problem of modeling how does this affect the quality of positioning though.}.
\subsubsection{Modeling the power consumption}
A GPS device consumes power in two ways: (i) powering the antenna, (ii) performing the computation for the positioning. Experiments~\cite{bib:microsoft-leap} show that the overall power consumption of a GPS sensor is mainly related to the powering of the antenna. The GPS signal sent by the SV is infact not very strong and good amplification of it must be performed. The power consumption related to the computations can therefore with respect to the antenna be neglected.
The antenna doesn't present any relevant dynamics~\cite{bib:microsoft-leap} and consumes a constant amount of power when it is turned on. According to this the power consumption of the GPS sensor can be modeled as a prescribed constant value when the antenna is turned on or a null value when the antenna is off\footnote{Some power brusts are actually present at the start and stop of the sensor, those are not relevant with respect the overall consumption and can be neglected in a high-level analysis.}.
\subsection{Modeling the Information Dynamics}
% per il paper riscrivi definendo gli stati rilevanti (parti da quali informazioni sono necessarie --, acceso/spento, p&f tracciati e dati epfemeri -- e poi scarta le combinazioni non sensate) e poi le transizioni, sii piu' sistematico
It is now defined when the sensor is consuming power, when it is not and how much it consumes. Now, for what concerns the \emph{cyber} domain we want to describe when the position is available in relation to the defined inputs.
To locate the receiver two information for each satellite are required: (i) the position of the visible satellites and (ii) the ranging data. Those are respectively encoded in the ephemeris data and the phase shift of the signal of each satellite. Since to decode the signal and read the ephemeris data the device must have fetched the phase and frequency shift the retrieval of the two is connected. This means for example that the ephemeris data cannot be read without having first fetched frequency and phase.
The phase and frequency are lost as soon as the antenna is turned off or a satellite is no more visible: in those cases the device has to perform a new search when the antenna is turned on again or when the satellite is visible again respectively. In~\cite{bib:microsoft-leap} an algorithm that exploits previous knowledge of frequency and phase shift for improving the speed of fetching the signal has been proposed: this can be done under the assumption that the device has not moved too far away and relative speed has not changed too much from last positioning\footnote{In the discussed work the authors have only simulated what could be the improvement in performance using this method, so there has not been real testing of it.}.
The ephemeris data are characterized by a well defined expiration time, 30 minutes after being collected they won't be accurate enough to allow correct positioning and new data must be collected.
When ephemeris data are not available -- for instance at the start up -- and the device must fetch the signal and wait to read them the procedure is called \textbf{cold start}. When instead Ephemeris data are available and the device must only fetch the signal in order to get the ranging data it is called \textbf{warm start}. Here, by analogy, we introduce the notation of \textbf{hot start}, to define when the innformation about previous ranging and frequency are exploited for improving the speed of signal fetching.
The relation betwen those procedures can be described as a discrete system with states representing what the system is doing and which information are available and transitions representing either when those information are acquired by the device or when they lose (or have lost) validity, plus of course the input events of turning on and off the antenna.
%\textcolor{red}{consider putting those in tables with descriptions}
The cited transitions are:
\item turn ON,
\item turn OFF,
\item fetch frequency and phase,
\item fetch frequency and phase quick (in case of hot start),
\item get ephemeris data,
\item ephemeris data expired,
\item lose visibility,
\item lose hot start.
All the transitions are defined with respect the minimum number of required satellites. This means for example that \emph{lose visibility} will be triggered when the signal is not tracked for the prescribed minimum number of satellites, and not in general when one of the satellites is no more visible.
The states instead are:
\item No Info,
\item Cold Start,
\item Read Ephemeris,
\item Position Available,
\item Hot Start,
\item Hot Start Available,
\item Warm Start,
\item Warm Start Available.
The model includes also two integers: \texttt{sv\_tracked\_freq\_phase} and \texttt{sv\_tracked\_ephemeris}. The former describes the number of satellites for which frequency and phase are known and the latter the number of satellites for which ephemeris data are available. The number of tracked satellites (both for frequency and phase and for the ephemeris data) is set equal to the number of visible satellites respectively when the transitions \emph{fetch frequency and phase (quick)} and \emph{get ephemeris data} are executed.
Both those numbers must be bounded by the number of visible sateliltes. While this is apparently always true for the state variable \texttt{sv\_tracked\_freq\_phase}, it is not for \texttt{sv\_tracked\_ephemeris}. A satellite might in fact not be visible for some minutes and the ephemeris data are still valid after the connection interruption. This limit cannot be overcome without distinguishing the different satellites, which, as stated previously, would increase the complexity of the model with marginal improvement in the descriptive power. Those bounds are expressed with the equations:
sv\_tracked\_ephemeris = \\
min\{sv\_tracked\_ephemeris, visible\_satellites\}
sv\_tracked\_freq\_phase = \\
min\{sv\_tracked\_freq\_phase, visible\_satellites\}
Along with the ephemeris data comes the necessity of representing the expiration time of those: we introduce therefore another state variable called \texttt{expiration\_time}. Since the acquisition is performed in parallel for all the satellites the expiration time will be the same for all the satellites currently tracked and it is updated (i.e. increased by 30 minutes) when the transition \emph{get ephemeris} is executed.
% (sv\_tracked\_ephemeris < required\_satellites) \\
% \lor \\
% (expiration\_time < time) .
%A possible representation of the states and the transitions are connected is given in figure~\ref{fig:cyberDynamics}.
%\footnote{In this representation it is assumed that after a \texttt{turn\_ON} signal no \texttt{turn\_OFF} signal will be received before the system is able to provide the position. This looks like a non desirable situation. The model could still easily be extended to include this case defining the following transitions (all triggered by the event \texttt{turn\_OFF}):
% \item from Cold Start to No Info,
% \item from Read Ephemeris to No Info,
% \item from Hot Start to Hot Start Available,
% \item from Warm Start to Hot Start Available.
p_off/.style = {circle, draw=black, inner sep=3mm},
p_on/.style = {circle, draw=black, fill=black!40!green, inner sep=3mm},
arr/.style = {->, densely dashed, black!60},
>=triangle 60,
\node[thick] (ni) at ( 0, 0) [p_off, label={No Info}] {1};
\node[thick] (cs) at ( 4, 0) [p_on, label={Cold Start}] {2};
\node[thick] (re) at ( 8, 0) [p_on, label={Read Ephemeris}] {3};
\node[thick] (pa) at (12, 0) [p_on, label={Position Available}] {4};
\node[thick] (hs) at (11, -4) [p_on, label={Hot Start}] {5};
\node[thick] (hsa) at (11, -8) [p_off, label={Hot Start Available}] {6};
\node[thick] (ws) at ( 5, -4) [p_on, label={Warm Start}] {7};
\node[thick] (wsa) at ( 5, -8) [p_off, label={Warm Start Available}] {8};
\node[thick] (zero) at (-1.5, 1) [circle, draw=black!60, fill=black!60, inner sep=0.75mm] {};
% arrows from beginning node
\draw [arr, bend right] (zero) to (ni);
% arrows from 1
\draw [arr] (ni) to node [above] {turn ON} (cs);
% arrows from 2
\draw [arr] (cs) to node [above] {fetch freq and phase} (re);
\draw [arr, in=60, out=120] (cs) to node [above] {turn OFF} (ni);
\draw [arr, in=200, out=260] (cs) edge[loop] node [xshift=-10mm] {lose visibility} (cs);
% arrows from 3
\draw [arr] (re) to node [above] {get ephemeris} (pa);
\draw [arr, in=60, out=120] (re) to node [above] {turn OFF} (ni);
\draw [arr, in=60, out=120] (re) to node [left] {lose visibility} (cs);
% arrows from 4 - position available
\draw [arr, in=60, out=120] (pa) to node [above]
{ephemeris data expired} (re);
\draw [arr, in=0, out=-45] (pa) to node
[right, at start, yshift=-5mm, xshift=4mm] {turn OFF} (hsa);
\draw [arr] (pa) edge[loop right] node {get ephemeris data} (pa);
\draw [arr, in=90, out=-90] (pa) to node [right, at start, yshift=-7mm, xshift=-19mm] {lose visibility} (hs);
% arrows from 5 - hot start
\draw [arr, in=-75, out=45] (hs) to node [right, align=left, yshift=-0mm, xshift=-0mm] {fetch freq and phase quick} (pa);
\draw [arr, in=-45, out=135] (hs) to node [right, near end, yshift=0mm, xshift=0mm] {fetch freq and phase quick} (cs);
\draw [arr, in=135, out=225] (hs) to node [right, near start] {turn OFF} (hsa);
\draw [arr] (hs) to node [below] {lose visibility} (ws);
% arrows from 6 - hot start available
\draw [arr] (hsa) to node [below] {lose hot start} (wsa);
\draw [arr, in=-45, out=45] (hsa) to node [right, near end] {turn ON} (hs);
\draw [arr, in=-75, out=165] (hsa) to node [left, xshift=-3mm,
align=center] {ephemeris data\\expired} (ni);
% arrows from 7 - warm start
\draw [arr, in=225, out=45] (ws) to node [right, align=left, at start,
xshift=5mm, yshift=2mm] {fetch freq and phase} (pa);
\draw [arr, in=285, out=110] (ws) to node [left, near start, align=right] {ephemeris data expired} (cs);
\draw [arr, in=135, out=225] (ws) to node [right, near start] {turn OFF} (wsa);
\draw [arr, in=200, out=160] (ws) edge[loop left] node [xshift=0mm] {lose visibility} (ws);
% arrows from 8 - warm start available
\draw [arr, in=-45, out=45] (wsa) to node [right, near end] {turn ON} (ws);
\draw [arr, in=-90, out=180] (wsa) to node [left, xshift=-2mm,
align=center, near start] {ephemeris data\\expired} (ni);
\caption{State machine representing the \emph{cyber} dynamics.
The way the states and the transitions are connected is shown in figure~\ref{fig:cyberDynamics}. This state machine models how the signal acquisition and the ephemeris data acquisition are related to each other and how they can happen in different sequences. For instance we can see that at the first start up only a cold start is available and therefore the sensor is forced first to fetch the signal and then to read the ephemeris data before actually providing the position. i.e. path 1-2-3-4. Instead after the first position fix the system is able to go back in the state \emph{Position Available} without aquiring again the position data of the satellites. This is represented by path 6-5-4 in case of hot start and 8-7-4 for the warm start.
When ephemeris data stop being available (condition \emph{ephemeris data expired}) the sensor can behave in two ways according to whether the antenna is turned on or off. If it is off then the sensor doesn't have either of the required information for positioning itself any more and therefore it goes back to the state \emph{No Info}, transitions 6-1 and 8-1. If instead the antenna is turned on and frequency and phase are fetched the sensor will just go back from state \emph{Position Available} (in the described scenario in fact both the information are available and therefore also the positioning) to the state in which it is reading the ephemeris data, \emph{Read Ephemeris} with the transition 4-3.
%Different consideration must be done if the antenna is on but has not yet fetched the signal, this is the case in states 5 and 7. In fact in those states moving directly to state 2 would overestimate the time required for fetching the signal since the search for frequency and phase shift would be ``reset'', and instead moving to state 3 would underestimate it skipping directly to the moment when the devivce is able to read the ephemeris data. Therefore what is defined in the model is that the sensor remains in state 5 and 7 until it has fetched the signal and then move to state 4 or 3 depending on whether ephemeris data are respectively available or not.
%\textcolor{red}{fai venire fuori che conoscenza otteniamo dal modello (puo' venire dagli esempi)}
%transition definition in the implementation
%couple of examples of ways you could use this model
%\textcolor{red}{fai vedere come strategie del controllo possono sfruttare le dinamiche descritte dal modello}
In this section is discussed an object-oriented implementation of the described model with the modeling language Modelica\footnote{}.
\subsection{Transition definition}
What is now to be discussed is how to define the firing of the different transitions defined in the model.
\subsubsection{turn ON/OFF}
Those transitions as defined in section~\ref{sec:input-def} are the controlled inputs of the defined system. Since apparently to have coherency the two must be one the negation of the other they can be defined as a boolean being \emph{true} whe the input is turn ON and \emph{false} when the input is turn OFF. This signal can also be used for defining the output power consumption, since it is equivalent to distinguishing the states in which the antenna is on and off.
\subsubsection{fetch frequency and phase}
This transition represents when the devices matches the phase shift and frequency distortion of the signal. This procedure takes some time after the antenna has been turned on, usually of the order of milliseconds~\cite{bib:gps-book} from 1mS to 10mS depending on signal strength.
\subsubsection{get ephemeris data}