Skip to content
Snippets Groups Projects
Commit 2d1a5c16 authored by Jupp Tscheak's avatar Jupp Tscheak
Browse files

Reintroduced type "Time" that should be used in the API to specify durations or time points.


Type "Time" is now an alias to "units::time::millisecond_t". The conversion functions as provided by "time_utils.h" are still present and revised accordingly."

Signed-off-by: default avatarJupp Tscheak <jupp.tscheak@daimler.com>
parent 242c3639
No related branches found
No related tags found
1 merge request!11Replaced the types of all physical quantities related members/arguments with SI unit types as provided by the Units library.
......@@ -15,15 +15,15 @@
#ifndef MANTLEAPI_COMMON_SIMULATION_TIME_H
#define MANTLEAPI_COMMON_SIMULATION_TIME_H
#include <units.h>
#include <MantleAPI/Common/time_utils.h>
namespace mantle_api
{
struct SimulationTime
{
units::time::second_t current_sim_time{0};
units::time::second_t last_delta_time{0};
Time current_sim_time{0};
Time last_delta_time{0};
};
} // namespace mantle_api
......
......@@ -17,6 +17,7 @@
#define MANTLEAPI_COMMON_SPLINE_H
#include <MantleAPI/Common/floating_point_helper.h>
#include <MantleAPI/Common/time_utils.h>
#include <MantleAPI/Common/vector.h>
#include <units.h>
......@@ -36,8 +37,8 @@ struct SplineSegment
struct SplineSection
{
units::time::second_t start_time{0};
units::time::second_t end_time{0};
Time start_time{0};
Time end_time{0};
/// @brief Represents the polynomial.
///
/// The array stores in format \f$[a_3, a_2, a_1, a_0]\f$ for a polynomial in form
......
/*******************************************************************************
* Copyright (c) 2021, Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*******************************************************************************/
//-----------------------------------------------------------------------------
/** @file time_utils.h */
//-----------------------------------------------------------------------------
#ifndef MANTLEAPI_COMMON_TIME_UTILS_H
#define MANTLEAPI_COMMON_TIME_UTILS_H
#include <units.h>
namespace mantle_api
{
using Time = units::time::millisecond_t;
/// @brief Converts input in [s] to @ref Time.
/// @tparam T Input type, eg. `double`.
/// @param duration Input value
/// @return Duration representing the given input in units of @ref Time.
template <typename T>
inline Time SecondsToTime(T duration)
{
return units::convert<units::time::seconds, units::time::milliseconds>(duration);
}
/// @brief Converts input @ref Time to [s].
/// @param time Time
/// @return Duration in seconds representing the passed in @ref Time.
inline double TimeToSeconds(const Time& time)
{
return units::time::second_t{time}.value();
}
} // namespace mantle_api
#endif // MANTLEAPI_COMMON_TIME_UTILS_H
......@@ -15,7 +15,7 @@
#ifndef MANTLEAPI_ENVIRONMENTALCONDITIONS_DATETIME_H
#define MANTLEAPI_ENVIRONMENTALCONDITIONS_DATETIME_H
#include <units.h>
#include <MantleAPI/Common/time_utils.h>
namespace mantle_api
{
......@@ -23,7 +23,7 @@ namespace mantle_api
// TODO: Delete this struct and use Time directly in Get/SetDateTime once the move to the MantleAPI is complete
struct [[deprecated]] DateTime
{
units::time::second_t date_time{0};
Time date_time{0};
};
} // namespace mantle_api
......
......@@ -15,7 +15,7 @@
#ifndef MANTLEAPI_EXECUTION_SCENARIOINFO_H
#define MANTLEAPI_EXECUTION_SCENARIOINFO_H
#include <units.h>
#include <MantleAPI/Common/time_utils.h>
#include <map>
#include <string>
......@@ -25,7 +25,7 @@ namespace mantle_api
struct ScenarioInfo
{
units::time::second_t scenario_timeout_duration;
Time scenario_timeout_duration;
std::string description;
std::map<std::string, std::string> additional_information;
};
......
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