Commit 0110ebe0 authored by Claudio Mandrioli's avatar Claudio Mandrioli
Browse files

removed function not used anymore

parent 6e6be874
......@@ -95,7 +95,7 @@ for k=2:N
turn=true;
end
%update sensor state
sensor=gps_randomized_car(t(k),sensor,turn,sv); %remove _randomized for worst case
sensor=gps_randomized_car(t(k),sensor,turn,sv);
%determine if GPS position is available
GPS_position=strcmp(sensor.state,'position_available');
%compute power consumption
......
......@@ -101,7 +101,7 @@ for k=start_sim:start_sim+length_sim
turn=true;
end
%update sensor state
sensor=gps_randomized_cycling(t(k),sensor,turn,sv); %remove _randomized for worst case
sensor=gps_randomized_cycling(t(k),sensor,turn,sv);
%determine if GPS position is available
GPS_position=strcmp(sensor.state,'position_available');
%compute power consumption
......
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% GPS sensor dynamics %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%STATE is a struct (called sensor) with the following fields
% state -[string]the current proceural state: no_info, cold_start, read_ephemeris,
% position_available, warm_start_avaialable, warm_start
% howLong -[double]when the current procedural state has been entered
% ephExp -[double]expiration time of ephemeris data
% fp -[int]number of tracked satelliets
% eph -[int]number of satellites for which ephemeris data are available
%INPUTS
% -time
% -state
% -turn on/off (true=turn_ON, false=turn_OFF)
% -visible satellites
%OUTPUTS
% -state
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function sensor=gps(time,sensor_in,turn,sv)
%% parameters
%define how many satellites you need to track given the accuracy requirements
required_sv= 4;
%define how long ephemeris data last
ephDuration=1800.0;
%define how much time is required to read the ephemeris data
ttge=59.0;
%define how much time is required to fetch the satellites signal
ttfs=0.01;
%% initialize output
sensor = sensor_in;
%% equations
%you cannot track satellites that you dont see
sensor.fp=min(sensor_in.fp,sv);
sensor.eph=min(sensor_in.eph,sv);
%% events
ephemeris_expired=(time>sensor.ephExp)||(sensor.eph<required_sv); %ephemeris data are expired
lost_visibility=(sensor.fp<required_sv);
fetch_fp=(time-sensor_in.howLong)>=ttfs;
get_ephemeris=(time-sensor_in.howLong)>ttge;
%% transitions and updates
%for each of the states handle eventual transitions and updates
%(i)if any transition is fired, always update the time the surrent state was entered
%(ii)other updates depend on the spefic transition that is fired
if strcmp(sensor_in.state,'no_info')
if(turn)
sensor.state='cold_start';
sensor.howLong=time;
end
end
if strcmp(sensor_in.state,'position_available')
if(get_ephemeris)
sensor.state='position_available';
sensor.howLong=time;
sensor.eph=sv;
sensor.ephExp=time+ephDuration;
end
if(~turn)
sensor.state='warm_start_available';
sensor.howLong=time;
sensor.fp=0;
end
if(lost_visibility)
sensor.state='warm_start';
sensor.howLong=time;
%might have to go on to cold_start
if(ephemeris_expired)
sensor.state='cold_start';
sensor.howLong=time;
sensor.eph=0;
end
end
if(ephemeris_expired)
sensor.state='read_ephemeris';
sensor.howLong=time;
sensor.eph=0;
%might have to go on to cold_start
if(lost_visibility)
sensor.state='cold_start';
sensor.howLong=time;
end
end
end
if strcmp(sensor_in.state,'read_ephemeris')
if(get_ephemeris)
sensor.state='position_available';
sensor.howLong=time;
sensor.eph=sv;
sensor.ephExp=time+ephDuration;
end
if(~turn)
sensor.state='no_info';
sensor.howLong=time;
sensor.fp=0;
end
if(lost_visibility)
sensor.state='cold_start';
sensor.howLong=time;
end
end
if strcmp(sensor_in.state,'warm_start')
if(fetch_fp)
sensor.state='position_available';
sensor.howLong=time;
sensor.fp=sv;
end
if(ephemeris_expired)
sensor.state='cold_start';
sensor.howLong=time;
sensor.eph=0;
end
if(~turn)
sensor.state='warm_start_available';
sensor.howLong=time;
sensor.fp=0;
end
end
if strcmp(sensor_in.state,'cold_start')
if(fetch_fp)
sensor.state='read_ephemeris';
sensor.howLong=time;
sensor.fp=sv;
end
if(~turn)
sensor.state='no_info';
sensor.howLong=time;
sensor.fp=0;
end
end
if strcmp(sensor_in.state,'warm_start_available')
if(turn)
sensor.state='warm_start';
sensor.howLong=time;
end
if(ephemeris_expired)
sensor.state='no_info';
sensor.howLong=time;
sensor.eph=0;
end
end
end
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment