Skip to content
Snippets Groups Projects
Commit 2b7ab764 authored by Pep Martí Saumell's avatar Pep Martí Saumell
Browse files

[memory_mngmnt] Clear methods for navigation ptrs

parent 0c648329
No related branches found
No related tags found
2 merge requests!20new tag,!19new tag
...@@ -30,8 +30,6 @@ class Navigation ...@@ -30,8 +30,6 @@ class Navigation
void clearNavigation(); void clearNavigation();
void freeNavigation();
void setNavigation(nav_t nav); void setNavigation(nav_t nav);
void loadFromRinex(const std::string& rnx_file, gtime_t t_start, gtime_t t_end, double dt = 0.0, const char* opt = ""); void loadFromRinex(const std::string& rnx_file, gtime_t t_start, gtime_t t_end, double dt = 0.0, const char* opt = "");
...@@ -40,11 +38,15 @@ class Navigation ...@@ -40,11 +38,15 @@ class Navigation
/****************** Array memory management ******************/ /****************** Array memory management ******************/
// Ephemeris
bool addEphemeris(const eph_t& eph); bool addEphemeris(const eph_t& eph);
bool addGLONASSEphemeris(const geph_t& geph); bool addGLONASSEphemeris(const geph_t& geph);
bool addSBASEphemeris(const seph_t& seph); bool addSBASEphemeris(const seph_t& seph);
bool addAlmanac(const alm_t& alm); bool addAlmanac(const alm_t& alm);
void clearEphemeris();
void clearGLONASSEphemeris();
void clearSBASEphemeris();
void clearAlmanac();
//void allocateEphemeris(int n_sat = MAXSAT); //void allocateEphemeris(int n_sat = MAXSAT);
//void deleteEphemeris(); //void deleteEphemeris();
......
...@@ -23,9 +23,7 @@ class UBloxRaw ...@@ -23,9 +23,7 @@ class UBloxRaw
Observations obs_; Observations obs_;
Navigation nav_; Navigation nav_;
void updateObservations(); void updateObservations();
void updateNavigation();
}; };
......
...@@ -32,32 +32,12 @@ Navigation::Navigation() ...@@ -32,32 +32,12 @@ Navigation::Navigation()
Navigation::~Navigation() Navigation::~Navigation()
{ {
freeNavigation(); clearNavigation();
}
void Navigation::freeNavigation()
{
freenav(&nav_,255);
} }
void Navigation::clearNavigation() void Navigation::clearNavigation()
{ {
nav_.eph =NULL; freenav(&nav_,255);
nav_.geph=NULL;
nav_.seph=NULL;
nav_.peph=NULL;
nav_.pclk=NULL;
nav_.alm =NULL;
nav_.tec =NULL;
nav_.fcb =NULL;
nav_.n =nav_.nmax =0;
nav_.ng=nav_.ngmax=0;
nav_.ns=nav_.nsmax=0;
nav_.ne=nav_.nemax=0;
nav_.nc=nav_.ncmax=0;
nav_.na=nav_.namax=0;
nav_.nt=nav_.ntmax=0;
nav_.nf=nav_.nfmax=0;
} }
void Navigation::setNavigation(nav_t _nav) void Navigation::setNavigation(nav_t _nav)
...@@ -109,6 +89,7 @@ bool Navigation::addEphemeris(const eph_t& eph) ...@@ -109,6 +89,7 @@ bool Navigation::addEphemeris(const eph_t& eph)
nav_.eph[nav_.n++]=eph; nav_.eph[nav_.n++]=eph;
return true; return true;
} }
bool Navigation::addGLONASSEphemeris(const geph_t& geph) bool Navigation::addGLONASSEphemeris(const geph_t& geph)
{ {
// "inspired" from RTKLIB rinex.c // "inspired" from RTKLIB rinex.c
...@@ -126,6 +107,7 @@ bool Navigation::addGLONASSEphemeris(const geph_t& geph) ...@@ -126,6 +107,7 @@ bool Navigation::addGLONASSEphemeris(const geph_t& geph)
nav_.geph[nav_.ng++]=geph; nav_.geph[nav_.ng++]=geph;
return true; return true;
} }
bool Navigation::addSBASEphemeris(const seph_t& seph) bool Navigation::addSBASEphemeris(const seph_t& seph)
{ {
// "inspired" from RTKLIB rinex.c // "inspired" from RTKLIB rinex.c
...@@ -143,6 +125,7 @@ bool Navigation::addSBASEphemeris(const seph_t& seph) ...@@ -143,6 +125,7 @@ bool Navigation::addSBASEphemeris(const seph_t& seph)
nav_.seph[nav_.ns++]=seph; nav_.seph[nav_.ns++]=seph;
return true; return true;
} }
bool Navigation::addAlmanac(const alm_t& alm) bool Navigation::addAlmanac(const alm_t& alm)
{ {
// "inspired" from RTKLIB rinex.c // "inspired" from RTKLIB rinex.c
...@@ -161,6 +144,26 @@ bool Navigation::addAlmanac(const alm_t& alm) ...@@ -161,6 +144,26 @@ bool Navigation::addAlmanac(const alm_t& alm)
return true; return true;
} }
void Navigation::clearEphemeris()
{
if (nav_.eph != NULL) {free(nav_.eph ); nav_.eph =NULL; nav_.n =nav_.nmax =0;}
}
void Navigation::clearGLONASSEphemeris()
{
if (nav_.geph != NULL) {free(nav_.geph); nav_.geph=NULL; nav_.ng=nav_.ngmax=0;}
}
void Navigation::clearSBASEphemeris()
{
if (nav_.seph != NULL) {free(nav_.seph); nav_.seph=NULL; nav_.ns=nav_.nsmax=0;}
}
void Navigation::clearAlmanac()
{
if (nav_.alm != NULL) {free(nav_.alm ); nav_.alm =NULL; nav_.na=nav_.namax=0;}
}
/****************** Array memory management ******************/ /****************** Array memory management ******************/
//void Navigation::allocateEphemeris(int n_sat) //void Navigation::allocateEphemeris(int n_sat)
//{ //{
......
...@@ -29,15 +29,27 @@ int UBloxRaw::addDataStream(const std::vector<u_int8_t>& data_stream) ...@@ -29,15 +29,27 @@ int UBloxRaw::addDataStream(const std::vector<u_int8_t>& data_stream)
break; break;
case 2: case 2:
// Ephemeris // Ephemeris
updateNavigation(); nav_.clearEphemeris();
nav_.clearGLONASSEphemeris();
nav_.clearSBASEphemeris();
nav_.addEphemeris(*(raw_data_.nav.eph));
nav_.addGLONASSEphemeris(*(raw_data_.nav.geph));
nav_.addSBASEphemeris(*(raw_data_.nav.seph));
break; break;
case 3: case 3:
// SBAS Message (we should update observations, right?) // SBAS
nav_.clearEphemeris();
nav_.clearGLONASSEphemeris();
nav_.clearSBASEphemeris();
nav_.addEphemeris(*(raw_data_.nav.eph));
nav_.addGLONASSEphemeris(*(raw_data_.nav.geph));
nav_.addSBASEphemeris(*(raw_data_.nav.seph));
updateObservations(); updateObservations();
break; break;
case 9: case 9:
// Almanac // Almanac
updateNavigation(); nav_.clearAlmanac();
nav_.addAlmanac(*(raw_data_.nav.alm));
break; break;
} }
...@@ -49,20 +61,15 @@ const Navigation& UBloxRaw::getNavigation() const {return nav_;} ...@@ -49,20 +61,15 @@ const Navigation& UBloxRaw::getNavigation() const {return nav_;}
void UBloxRaw::updateObservations() void UBloxRaw::updateObservations()
{ {
std::cout << "---------------------------JUST BEFORE!-------------------" << std::endl; // std::cout << "---------------------------JUST BEFORE!-------------------" << std::endl;
obs_.print(); // obs_.print();
obs_.clearObservations(); obs_.clearObservations();
for (int ii = 0; ii < raw_data_.obs.n; ++ii) for (int ii = 0; ii < raw_data_.obs.n; ++ii)
{ {
obs_.addObservation(raw_data_.obs.data[ii]); obs_.addObservation(raw_data_.obs.data[ii]);
} }
std::cout << "--------------------------JUST AFTER!---------------------" << std::endl; // std::cout << "--------------------------JUST AFTER!---------------------" << std::endl;
obs_.print(); // obs_.print();
}
void UBloxRaw::updateNavigation()
{
nav_.setNavigation(raw_data_.nav);
} }
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment