Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: NAVDATA.cpp
- Revision:
- 5:ae5dfda6b0ab
- Parent:
- 4:400b92fb528c
- Child:
- 6:fc2eb58bac36
diff -r 400b92fb528c -r ae5dfda6b0ab NAVDATA.cpp
--- a/NAVDATA.cpp Tue Apr 04 02:24:45 2017 +0000
+++ b/NAVDATA.cpp Tue Apr 04 06:16:39 2017 +0000
@@ -48,39 +48,43 @@
this->LAST_NAV_DATA[longitude_f]=x;
this->LAST_NAV_DATA[latitude_i]=this->LAST_NAV_DATA[latitude_f];
this->LAST_NAV_DATA[latitude_f]=y;
- this->LAST_NAV_DATA[time_i]=this->LAST_NAV_DATA[time_f] + ZH; // EN HORAS
- this->LAST_NAV_DATA[time_f]=time_NMEA2hours(t); // EN HORAS
+ this->LAST_NAV_DATA[time_i]=this->LAST_NAV_DATA[time_f]; // EN HORAS
+ this->LAST_NAV_DATA[time_f]=time_NMEA2hours(t) + ZH; // EN HORAS
this->LAST_NAV_DATA[distance_p]= sqrt(pow(Klong*(this->LAST_NAV_DATA[longitude_f]-this->LAST_NAV_DATA[longitude_i]),2) + pow(Klat*(this->LAST_NAV_DATA[latitude_f]-this->LAST_NAV_DATA[latitude_i]),2)) ; // Distancia recorrida durante este período.
this->LAST_NAV_DATA[speed_p]=this->LAST_NAV_DATA[distance_p]/(this->LAST_NAV_DATA[time_f]-this->LAST_NAV_DATA[time_i]);
- this->LAST_NAV_DATA[consumption_p]=c; // Consumo en litros del período.
+ this->LAST_NAV_DATA[consumption_i]=this->LAST_NAV_DATA[consumption_f];
+ this->LAST_NAV_DATA[consumption_f]=c/Ksen;
+ this->LAST_NAV_DATA[consumption_p]=this->LAST_NAV_DATA[consumption_f]-this->LAST_NAV_DATA[consumption_i]; // Consumo en litros del período.
- if (this->LAST_NAV_DATA[distance_p] != 0) this->LAST_NAV_DATA[cons_mile_p]=c/this->LAST_NAV_DATA[distance_p]; // Consumo en litros por milla nautica.
- else this->LAST_NAV_DATA[cons_mile_p]= -1; // Variable no mensurable (-1)
+ if (this->LAST_NAV_DATA[distance_p] != 0) this->LAST_NAV_DATA[cons_mile_p]=this->LAST_NAV_DATA[consumption_p]/this->LAST_NAV_DATA[distance_p]; // Consumo en litros por milla nautica.
+ else this->LAST_NAV_DATA[cons_mile_p]= -1; // Variable no mensurable (-1)
- this->LAST_NAV_DATA[cons_hour_p]=c/(this->LAST_NAV_DATA[time_f]-this->LAST_NAV_DATA[time_i]); // Consumo en litros por hora.
+ this->LAST_NAV_DATA[cons_hour_p]=this->LAST_NAV_DATA[consumption_p]/(this->LAST_NAV_DATA[time_f]-this->LAST_NAV_DATA[time_i]); // Consumo en litros por hora.
return 1;
}
else
return 0; // Período no válido. Tiempo <=0!
}
-float NAVDATA::time_NMEA2hours(float timestickNMEA){
+float NAVDATA::time_NMEA2hours(float timetickNMEA){
float seconds, minutes, hours;
- hours= int(timestickNMEA/10000); //Formato NMEA: hhmmss,sss; => int(hh,mmssss)=hh
- seconds= (timestickNMEA/100 - int(timestickNMEA/100))*100; // => (hhmmss,sss/100 - int(hhmmss,sss/100))*100 = ss,sss
- minutes= (int(timestickNMEA/10000 - hours))*100; // => int((hh,mmsssss - hh)*100)= mm
+ hours= int(timetickNMEA/10000); //Formato NMEA: hhmmss,sss; => int(hh,mmssss)=hh
+ seconds= (timetickNMEA/100 - int(timetickNMEA/100))*100; // => (hhmmss,sss/100 - int(hhmmss,sss/100))*100 = ss,sss
+ minutes= int(timetickNMEA/100 - hours*100); // => int((hh,mmsssss - hh)*100)= mm
return (hours + minutes/60 + seconds/3600); // => expresado en horas, formato decimal
}
void NAVDATA::paddata(){
- this->LAST_NAV_DATA[longitude_f]=-58,5797; // Longitud y Latitud iniciales y finales correspondiente a Tigre.
- this->LAST_NAV_DATA[longitude_i]=-58,5797;
- this->LAST_NAV_DATA[latitude_f]=-34,4251;
- this->LAST_NAV_DATA[latitude_i]=-34,4251;
- this->LAST_NAV_DATA[time_f]=0; // El dato (timestamp al final del período en cuestion, en horas) se obtendrá luego proveniente del GPS.
+ this->LAST_NAV_DATA[longitude_f]=-58.5797; // Longitud y Latitud iniciales y finales correspondiente a Tigre.
+ this->LAST_NAV_DATA[longitude_i]=-58.5797;
+ this->LAST_NAV_DATA[latitude_f]=-34.4251;
+ this->LAST_NAV_DATA[latitude_i]=-34.4251;
+ this->LAST_NAV_DATA[time_f]=-1; // El dato (timestamp al final del período en cuestion, en horas) se obtendrá luego proveniente del GPS.
this->LAST_NAV_DATA[time_i]=0; // Timestamp al inicio del período en horas.
this->LAST_NAV_DATA[distance_p]=0; // Distancia recorrida durante este período en millas nauticas.
this->LAST_NAV_DATA[speed_p]=0; // Velocidad media del período en nudos.
+ this->LAST_NAV_DATA[consumption_i]=0; // Consumo en litros al comienzo del período.
+ this->LAST_NAV_DATA[consumption_f]=0; // Consumo en litros al final del período.
this->LAST_NAV_DATA[consumption_p]=0; // Consumo en litros del período.
this->LAST_NAV_DATA[cons_mile_p]=0; // Consumo en litros por milla nautica.
this->LAST_NAV_DATA[cons_hour_p]=0; // Consumo en litros por hora.