diff --git a/src/core/libs/osnma_msg_receiver.cc b/src/core/libs/osnma_msg_receiver.cc index 1f96afb61..1131ffbc3 100644 --- a/src/core/libs/osnma_msg_receiver.cc +++ b/src/core/libs/osnma_msg_receiver.cc @@ -127,9 +127,11 @@ void osnma_msg_receiver::msg_handler_osnma(const pmt::pmt_t& msg) // compare local time with OSNMA subframe time d_GST_SIS = nma_msg->TOW_sf0 + nma_msg->WN_sf0 * 604800; // TODO - unsure about this operation and of the -24 seconds,... - auto utc = galileo_utc_model.GST_to_UTC_time(d_GST_SIS, static_cast(nma_msg->WN_sf0)); - double_t T_L = 15; // TODO - to define the maximum allowed time difference between local time and OSNMA subframe time - if(abs(d_GST_SIS - d_receiver_time) <= T_L) + // instantiate galileo_utc_model and call init function, then call GST_to_UTC_time + Galileo_Utc_Model::init(nma_msg->utc_data); + double_t utc = Galileo_Utc_Model::GST_to_UTC_time(static_cast(d_GST_SIS), static_cast(nma_msg->WN_sf0)); + double_t T_L = 15.0; // TODO - to define the maximum allowed time difference between local time and OSNMA subframe time + if(abs(utc - d_receiver_time) <= T_L) { process_osnma_message(nma_msg); } diff --git a/src/core/libs/osnma_msg_receiver.h b/src/core/libs/osnma_msg_receiver.h index 27c07ae56..efaadd6a2 100644 --- a/src/core/libs/osnma_msg_receiver.h +++ b/src/core/libs/osnma_msg_receiver.h @@ -72,6 +72,7 @@ private: void read_mack_body(); void process_mack_message(const std::shared_ptr& osnma_msg); +// Galileo_Utc_Model galileo_utc_model; boost::circular_buffer d_old_mack_message; boost::circular_buffer d_old_navdata_buffer; // buffer that holds last 10 received navdata messages std::unique_ptr d_dsm_reader; @@ -91,7 +92,7 @@ private: uint8_t d_Lt_min {}; // minimum equivalent tag length uint32_t d_GST_0 {}; uint32_t d_GST_SIS {}; - std::time_t d_receiver_time {}; + std::time_t d_receiver_time {}; // PVT time computed by the local receiver }; diff --git a/src/core/system_parameters/galileo_utc_model.cc b/src/core/system_parameters/galileo_utc_model.cc index d14aa8c42..74ea2ba43 100644 --- a/src/core/system_parameters/galileo_utc_model.cc +++ b/src/core/system_parameters/galileo_utc_model.cc @@ -17,8 +17,19 @@ #include "galileo_utc_model.h" #include +void Galileo_Utc_Model::init(const Galileo_Utc_Model& data) +{ + A0 = data.A0; + A1 = data.A1; + Delta_tLS = data.Delta_tLS; + Delta_tLSF = data.Delta_tLSF; + DN = data.DN; + tot = data.tot; + WNot = data.WNot; + WN_LSF = data.WN_LSF; -double Galileo_Utc_Model::GST_to_UTC_time(double t_e, int32_t WN) const +} +double Galileo_Utc_Model::GST_to_UTC_time(double t_e, int32_t WN) { double t_Utc; double t_Utc_daytime; @@ -76,4 +87,5 @@ double Galileo_Utc_Model::GST_to_UTC_time(double t_e, int32_t WN) const double Galileo_Utc_Model::UTC_time_to_GST(double t_Utc, int32_t WN) const { // TODO + return 0; } \ No newline at end of file diff --git a/src/core/system_parameters/galileo_utc_model.h b/src/core/system_parameters/galileo_utc_model.h index 6024a41d0..c762c428f 100644 --- a/src/core/system_parameters/galileo_utc_model.h +++ b/src/core/system_parameters/galileo_utc_model.h @@ -41,19 +41,29 @@ public: */ Galileo_Utc_Model() = default; + /** + * @brief Initialize the Galileo_UTC_Model with the provided data. + * + * This function initializes the Galileo_UTC_Model object with the given data. + * + * @param data The Galileo_UTC_Model object containing the data. + */ + static void init(const Galileo_Utc_Model& data); + // double TOW; - double GST_to_UTC_time(double t_e, int32_t WN) const; //!< GST-UTC Conversion Algorithm and Parameters + static double GST_to_UTC_time(double t_e, int32_t WN); //!< GST-UTC Conversion Algorithm and Parameters double UTC_time_to_GST(double t_Utc, int32_t WN) const; + // TODO - make them private? // Word type 6: GST-UTC conversion parameters - double A0{}; - double A1{}; - int32_t Delta_tLS{}; - int32_t tot{}; //!< UTC data reference Time of Week [s] - int32_t WNot{}; //!< UTC data reference Week number [week] - int32_t WN_LSF{}; - int32_t DN{}; - int32_t Delta_tLSF{}; + static double A0; + static double A1; + static int32_t Delta_tLS; + static int32_t tot; //!< UTC data reference Time of Week [s] + static int32_t WNot; //!< UTC data reference Week number [week] + static int32_t WN_LSF; + static int32_t DN; + static int32_t Delta_tLSF; // GPS to Galileo GST conversion parameters double A_0G{};