Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vcpkg update glaze 1.9.6 and mp-units 2.1.0 #343

Merged
merged 4 commits into from
Dec 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/compile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
uses: lukka/run-vcpkg@v11
with:
vcpkgDirectory: '/opt/vcpkg'
vcpkgGitCommitId: 'c8696863d371ab7f46e213d8f5ca923c4aef2a00'
vcpkgGitCommitId: '50bffcc62d7f6571eb32bc1a0b1807e77af1166c'
vcpkgJsonGlob: 'vcpkg.json'

- name: Run CMake consuming CMakePreset.json and vcpkg.json by mean of vcpkg.
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
uses: lukka/run-vcpkg@v11
with:
vcpkgDirectory: '/opt/vcpkg'
vcpkgGitCommitId: 'c8696863d371ab7f46e213d8f5ca923c4aef2a00'
vcpkgGitCommitId: '50bffcc62d7f6571eb32bc1a0b1807e77af1166c'
vcpkgJsonGlob: 'vcpkg.json'

- name: Build
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ubuntu-packaging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
uses: lukka/run-vcpkg@v11
with:
vcpkgDirectory: '/opt/vcpkg'
vcpkgGitCommitId: 'c8696863d371ab7f46e213d8f5ca923c4aef2a00'
vcpkgGitCommitId: '50bffcc62d7f6571eb32bc1a0b1807e77af1166c'
vcpkgJsonGlob: 'vcpkg.json'

- name: Run CMake consuming CMakePreset.json and vcpkg.json by mean of vcpkg.
Expand Down
2 changes: 1 addition & 1 deletion exes/ethercat/inc/public/tfc/ec/devices/base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class base {

template <mp_units_quantity_setting_c setting_t>
auto sdo_write(setting_t&& in) const {
return base::sdo_write(in.index, in.value.numerical_value_);
return base::sdo_write(in.index, in.value.numerical_value_ref_in(decltype(in.value)::unit));
}

protected:
Expand Down
3 changes: 2 additions & 1 deletion exes/ethercat/inc/public/tfc/ec/devices/eilersen/4x60a.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,8 @@ PRAGMA_CLANG_WARNING_POP
return std::unexpected{ ipc::details::mass_error_e::not_calibrated };
}
auto normalized_calibration_signal{ calibration_signal - *zero };
result = ((calculated_signal * calibration_mass.numerical_value_) / normalized_calibration_signal) *
result = ((calculated_signal * calibration_mass.numerical_value_ref_in(mass_t::unit)) /
normalized_calibration_signal) *
mass_t::reference;
// at this point we have result with full resolution
if (auto resolution{ group_1_cal.get_resolution() }) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ constexpr auto percentage_to_deci_freq(mp_units::quantity<mp_units::percent, dou
if (mp_units::abs(percentage) < 1 * mp_units::percent) {
return { .value = 0 * dHz, .reverse = false };
}
bool reverse = percentage.numerical_value_ <= -1;
bool const reverse{ percentage <= -1 * mp_units::percent };
mp_units::Quantity auto mapped{ ec::util::map(mp_units::abs(percentage), (1.0 * mp_units::percent),
(100.0 * mp_units::percent), min_freq.value, max_freq.value) };
return { .value = mapped, .reverse = reverse };
Expand Down
2 changes: 1 addition & 1 deletion libs/dbus_util/inc/public/tfc/dbus/sdbusplus_meta.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ template <mp_units::Quantity quantity_t>
struct append_single<quantity_t> {
static void op(auto* interface, auto* sd_bus_msg, mp_units::Quantity auto&& item) {
using value_t = typename quantity_t::rep;
append_single<value_t>::op(interface, sd_bus_msg, item.numerical_value_);
append_single<value_t>::op(interface, sd_bus_msg, item.numerical_value_ref_in(quantity_t::unit));
}
};

Expand Down
10 changes: 6 additions & 4 deletions libs/motor/tests/positioner_test.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#include <mp-units/format.h>
#include <boost/ut.hpp>

#include <tfc/ipc/details/dbus_client_iface_mock.hpp>
#include <tfc/motors/positioner.hpp>
#include <tfc/progbase.hpp>
Expand Down Expand Up @@ -216,25 +218,25 @@ int main(int argc, char** argv) {
signal_b.send(true);
io_context.run_for(milliseconds(5));

expect(positioner.position() == 1 * mm) << positioner.position().numerical_value_;
expect(positioner.position() == 1 * mm) << fmt::format("{}", positioner.position());
expect(callback_counter == 1);

signal_a.send(true);
io_context.run_for(milliseconds(5));

expect(positioner.position() == 2 * mm) << positioner.position().numerical_value_;
expect(positioner.position() == 2 * mm) << fmt::format("{}", positioner.position());
expect(callback_counter == 2);

signal_b.send(false);
io_context.run_for(milliseconds(5));

expect(positioner.position() == 3 * mm) << positioner.position().numerical_value_;
expect(positioner.position() == 3 * mm) << fmt::format("{}", positioner.position());
expect(callback_counter == 3);

signal_a.send(false);
io_context.run_for(milliseconds(5));

expect(positioner.position() == 4 * mm) << positioner.position().numerical_value_;
expect(positioner.position() == 4 * mm) << fmt::format("{}", positioner.position());
expect(callback_counter == 3);
};

Expand Down
32 changes: 4 additions & 28 deletions libs/stx/inc/public/tfc/utils/units_glaze_meta.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,35 +24,14 @@ struct glz::meta<mp_units::ratio> {
static constexpr auto name{ "units::ratio" };
};

template <typename CharT, mp_units::Unit U, mp_units::unit_symbol_formatting fmt>
struct const_unit_symbol {
static consteval auto unit_symbol_len() -> std::size_t { return unit_symbol(U{}, fmt).size(); }
static constexpr auto impl() noexcept {
std::array<CharT, unit_symbol_len() + 1> buffer{};
auto foo = unit_symbol(U{}, fmt);
std::ranges::copy(std::begin(foo), std::end(foo), std::begin(buffer));
return buffer;
}
// Give the joined string static storage
static constexpr auto arr = impl();
// View as a std::string_view
static constexpr std::basic_string_view<CharT> value{ arr.data(), arr.size() - 1 };
};

template <typename CharT = char, mp_units::Unit U, mp_units::unit_symbol_formatting fmt = mp_units::unit_symbol_formatting{}>
[[nodiscard]] constexpr std::basic_string_view<CharT> unit_symbol_view(U) {
return const_unit_symbol<CharT, U, fmt>::value;
}

template <mp_units::Reference auto ref_t, typename rep_t>
struct glz::meta<mp_units::quantity<ref_t, rep_t>> {
using type = mp_units::quantity<ref_t, rep_t>;
static constexpr std::string_view unit{
unit_symbol_view<char, decltype(ref_t), mp_units::unit_symbol_formatting{ .encoding = mp_units::text_encoding::ascii }>(
ref_t)
mp_units::unit_symbol<mp_units::unit_symbol_formatting{ .encoding = mp_units::text_encoding::ascii }>(ref_t)
};
static constexpr auto dimension{ tfc::unit::dimension_name<ref_t>() };
static auto constexpr value{ [](auto&& self) -> auto& { return self.numerical_value_; } };
static auto constexpr value{ [](auto&& self) -> auto& { return self.numerical_value_ref_in(type::unit); } };
static std::string_view constexpr prefix{ "units::quantity<" };
static std::string_view constexpr postfix{ ">" };
static std::string_view constexpr separator{ "," };
Expand All @@ -69,13 +48,10 @@ struct to_json_schema;
template <mp_units::Reference auto ref_t, typename rep_t>
struct to_json_schema<mp_units::quantity<ref_t, rep_t>> {
static constexpr std::string_view unit_ascii{
unit_symbol_view<char, decltype(ref_t), mp_units::unit_symbol_formatting{ .encoding = mp_units::text_encoding::ascii }>(
ref_t)
mp_units::unit_symbol<mp_units::unit_symbol_formatting{ .encoding = mp_units::text_encoding::ascii }>(ref_t)
};
static constexpr std::string_view unit_unicode{
unit_symbol_view<char,
decltype(ref_t),
mp_units::unit_symbol_formatting{ .encoding = mp_units::text_encoding::unicode }>(ref_t)
mp_units::unit_symbol<mp_units::unit_symbol_formatting{ .encoding = mp_units::text_encoding::unicode }>(ref_t)
};
static constexpr mp_units::ratio ratio{ mp_units::as_ratio(ref_t) };
static constexpr auto dimension{ tfc::unit::dimension_name<ref_t>() };
Expand Down
2 changes: 1 addition & 1 deletion vcpkg-configuration.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"default-registry": {
"kind": "git",
"repository": "https://github.com/microsoft/vcpkg",
"baseline": "c8696863d371ab7f46e213d8f5ca923c4aef2a00"
"baseline": "50bffcc62d7f6571eb32bc1a0b1807e77af1166c"
},
"registries": [
{
Expand Down
Loading