Skip to content
Snippets Groups Projects
Commit c9c4657b authored by Joan Vallvé Navarro's avatar Joan Vallvé Navarro
Browse files

navigation copying elements working!

parent a3294f76
No related branches found
No related tags found
2 merge requests!20new tag,!19new tag
...@@ -69,8 +69,6 @@ class Navigation ...@@ -69,8 +69,6 @@ class Navigation
//////////////////////////////// nav UTILS ////////////////////////////////////// //////////////////////////////// nav UTILS //////////////////////////////////////
template <typename T> template <typename T>
static void copyArrayElement(const T &new_element, T& element_spot);
template <typename T>
static bool addToArray(const T &new_element, T *&array, int &n, int &nmax); static bool addToArray(const T &new_element, T *&array, int &n, int &nmax);
template <typename T> template <typename T>
static bool copyArray(const T *array_in, const int &n_in, T *&array_out, int &n_out, int &nmax_out); static bool copyArray(const T *array_in, const int &n_in, T *&array_out, int &n_out, int &nmax_out);
...@@ -252,115 +250,15 @@ inline void Navigation::freeAlmanac() ...@@ -252,115 +250,15 @@ inline void Navigation::freeAlmanac()
} }
//////////////////////////////// nav UTILS ////////////////////////////////////// //////////////////////////////// nav UTILS //////////////////////////////////////
template <typename T>
inline void Navigation::copyArrayElement(const T &new_element, T& element_spot)
{
element_spot = new_element;
}
//template <>
//inline void Navigation::copyArrayElement<eph_t>(const eph_t& new_element, eph_t& element_spot)
//{
// element_spot = new_element;
// std::cout << "tgd new element " << new_element.tgd << std::endl;
// std::cout << "before tgd element_spot " << element_spot.tgd << std::endl;
// double tgd[4];
// element_spot.tgd = tgd;
// std::cout << "tgd element_spot " << element_spot.tgd << std::endl;
//}
//template <>
//inline void Navigation::copyArrayElement<geph_t>(const geph_t& new_element, geph_t& element_spot)
//{
// element_spot = new_element;
// std::cout << "pos new element " << new_element.pos << std::endl;
// std::cout << "before pos element_spot " << element_spot.pos << std::endl;
// double pos[3];
// element_spot.pos = pos;
// std::cout << "pos element_spot " << element_spot.pos << std::endl;
//}
//template <>
//inline void Navigation::copyArrayElement<seph_t>(const seph_t& new_element, seph_t& element_spot)
//{
// element_spot = new_element;
// std::cout << "pos new element " << new_element.pos << std::endl;
// std::cout << "before pos element_spot " << element_spot.pos << std::endl;
// double pos[3];
// element_spot.pos = pos;
// std::cout << "pos element_spot " << element_spot.pos << std::endl;
//}
//template <>
//inline void Navigation::copyArrayElement<peph_t>(const peph_t& new_element, peph_t& element_spot)
//{
// element_spot = new_element;
// std::cout << "pos new element " << new_element.pos << std::endl;
// std::cout << "before pos element_spot " << element_spot.pos << std::endl;
// double pos[MAXSAT][4];
// element_spot.pos = pos;
// std::cout << "pos element_spot " << element_spot.pos << std::endl;
//}
//template <>
//inline void Navigation::copyArrayElement<pclk_t>(const pclk_t& new_element, pclk_t& element_spot)
//{
// element_spot = new_element;
// std::cout << "clk new element " << new_element.clk << std::endl;
// std::cout << "before clk element_spot " << element_spot.clk << std::endl;
// double clk[MAXSAT][1];
// element_spot.clk = clk;
// std::cout << "clk element_spot " << element_spot.clk << std::endl;
//}
template <>
inline void Navigation::copyArrayElement<alm_t>(const alm_t& new_element, alm_t& element_spot)
{
std::cout << "copyArrayElement<alm_t>\n";
std::cout << "new element: ";
std::cout << new_element.sat << std::endl; /* satellite number */
std::cout << new_element.svh << std::endl; /* sv health (0:ok) */
std::cout << new_element.svconf << std::endl; /* as and sv config */
std::cout << new_element.week << std::endl; /* GPS/QZS: gps week, GAL: galileo week */
//toa; /* Toa */
std::cout << new_element.A << std::endl;
std::cout << new_element.e << std::endl;
std::cout << new_element.i0 << std::endl;
std::cout << new_element.OMG0 << std::endl;
std::cout << new_element.omg << std::endl;
std::cout << new_element.M0 << std::endl;
std::cout << new_element.OMGd << std::endl;
std::cout << new_element.toas << std::endl; /* Toa (s) in week */
std::cout << new_element.f0 << std::endl;
std::cout << new_element.f1 << std::endl;
std::cout << "element_spot: " << std::endl;
std::cout << element_spot.sat << std::endl; /* satellite number */
std::cout << element_spot.svh << std::endl; /* sv health (0:ok) */
std::cout << element_spot.svconf << std::endl; /* as and sv config */
std::cout << element_spot.week << std::endl; /* GPS/QZS: gps week, GAL: galileo week */
//toa; /* Toa */
std::cout << element_spot.A << std::endl;
std::cout << element_spot.e << std::endl;
std::cout << element_spot.i0 << std::endl;
std::cout << element_spot.OMG0 << std::endl;
std::cout << element_spot.omg << std::endl;
std::cout << element_spot.M0 << std::endl;
std::cout << element_spot.OMGd << std::endl;
std::cout << element_spot.toas << std::endl; /* Toa (s) in week */
std::cout << element_spot.f0 << std::endl;
std::cout << element_spot.f1 << std::endl;
std::cout << "copying..";
element_spot = new_element;
}
template <typename T> template <typename T>
inline bool Navigation::addToArray(const T &new_element, T *&array, int &n, int &nmax) inline bool Navigation::addToArray(const T &new_element, T *&array, int &n, int &nmax)
{ {
std::cout << "addToArray: n = " << n << " nmax = " << nmax << "\n"; //std::cout << "addToArray: n = " << n << " nmax = " << nmax << "\n";
// "inspired" from RTKLIB rinex.c // "inspired" from RTKLIB rinex.c
T *array_ref; T *array_ref;
if (nmax <= n) if (nmax <= n)
{ {
std::cout << "addToArray: nmax <= n\n"; //std::cout << "addToArray: nmax <= n\n";
nmax += 1024; nmax += 1024;
if (!(array_ref = (T*)realloc(array, sizeof(T) * nmax))) if (!(array_ref = (T*)realloc(array, sizeof(T) * nmax)))
{ {
...@@ -370,36 +268,36 @@ inline bool Navigation::addToArray(const T &new_element, T *&array, int &n, int ...@@ -370,36 +268,36 @@ inline bool Navigation::addToArray(const T &new_element, T *&array, int &n, int
n = nmax = 0; n = nmax = 0;
return false; return false;
} }
std::cout << "addToArray: assigning reallocated array\n"; //std::cout << "addToArray: assigning reallocated array\n";
array = array_ref; array = array_ref;
} }
std::cout << "addToArray: adding element " << n << "\n"; //std::cout << "addToArray: adding element " << n << "\n";
copyArrayElement<T>(new_element, array[n++]); array[n++] = new_element;
std::cout << "addToArray: added!\n"; //std::cout << "addToArray: added!\n";
return true; return true;
} }
template<typename T> template<typename T>
inline bool Navigation::copyArray(const T *array_in, const int &n_in, T *&array_out, int &n_out, int &nmax_out) inline bool Navigation::copyArray(const T *array_in, const int &n_in, T *&array_out, int &n_out, int &nmax_out)
{ {
std::cout << "copyArray: " << n_in << " elements\n"; //std::cout << "copyArray: " << n_in << " elements\n";
if (array_in == NULL) if (array_in == NULL)
return false; return false;
std::cout << "copyArray: array in not null\n"; //std::cout << "copyArray: array in not null\n";
for (int i = 0; i<n_in; i++) for (int i = 0; i<n_in; i++)
{ {
std::cout << "copyArray: adding element " << i << "\n"; //std::cout << "copyArray: adding element " << i << "\n";
if (!addToArray<T>(array_in[i], array_out, n_out, nmax_out)) if (!addToArray<T>(array_in[i], array_out, n_out, nmax_out))
{ {
std::cout << "copyArray: failed to add..\n"; //std::cout << "copyArray: failed to add..\n";
return false; return false;
} }
std::cout << "copyArray: n_out = " << n_out << " nmax_out = " << nmax_out << "\n"; //std::cout << "copyArray: n_out = " << n_out << " nmax_out = " << nmax_out << "\n";
} }
std::cout << "copyArray: all copied\n"; //std::cout << "copyArray: all copied\n";
return true; return true;
} }
......
...@@ -79,9 +79,6 @@ RawDataType UBloxRaw::addDataStream(const std::vector<u_int8_t>& data_stream) ...@@ -79,9 +79,6 @@ RawDataType UBloxRaw::addDataStream(const std::vector<u_int8_t>& data_stream)
} }
} }
std::cout << "ALL BYTES DECODED!\n\n";
return raw_data_type_; return raw_data_type_;
} }
......
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