From 016984f1b325d18f266fb26afd903965a590d45d Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Tue, 27 Dec 2022 12:20:23 +0100 Subject: [PATCH] feat: about half of IEC 80000 quantities support added --- src/systems/iec80000/CMakeLists.txt | 4 +- .../include/units/iec80000/binary_prefixes.h | 2 +- .../include/units/iec80000/dimensions.h | 38 ---------- .../include/units/iec80000/iec80000.h | 2 +- .../include/units/iec80000/quantities.h | 72 +++++++++++++++++++ .../include/units/iec80000/unit_symbols.h | 19 +++++ .../iec80000/include/units/iec80000/units.h | 4 +- 7 files changed, 98 insertions(+), 43 deletions(-) delete mode 100644 src/systems/iec80000/include/units/iec80000/dimensions.h create mode 100644 src/systems/iec80000/include/units/iec80000/quantities.h diff --git a/src/systems/iec80000/CMakeLists.txt b/src/systems/iec80000/CMakeLists.txt index fd76bda1..592b9030 100644 --- a/src/systems/iec80000/CMakeLists.txt +++ b/src/systems/iec80000/CMakeLists.txt @@ -23,7 +23,7 @@ cmake_minimum_required(VERSION 3.19) add_units_module( - isq-iec80000 DEPENDENCIES mp-units::si - HEADERS include/units/iec80000/binary_prefixes.h include/units/iec80000/dimensions.h + iec80000 DEPENDENCIES mp-units::isq mp-units::si + HEADERS include/units/iec80000/binary_prefixes.h include/units/iec80000/quantities.h include/units/iec80000/iec80000.h include/units/iec80000/unit_symbols.h include/units/iec80000/units.h ) diff --git a/src/systems/iec80000/include/units/iec80000/binary_prefixes.h b/src/systems/iec80000/include/units/iec80000/binary_prefixes.h index 12248554..9e0fd08a 100644 --- a/src/systems/iec80000/include/units/iec80000/binary_prefixes.h +++ b/src/systems/iec80000/include/units/iec80000/binary_prefixes.h @@ -22,7 +22,7 @@ #pragma once -#include +#include namespace units::iec80000 { diff --git a/src/systems/iec80000/include/units/iec80000/dimensions.h b/src/systems/iec80000/include/units/iec80000/dimensions.h deleted file mode 100644 index ed9ca6dc..00000000 --- a/src/systems/iec80000/include/units/iec80000/dimensions.h +++ /dev/null @@ -1,38 +0,0 @@ -// The MIT License (MIT) -// -// Copyright (c) 2018 Mateusz Pusz -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -#pragma once - -#include -#include - -namespace units::iec80000 { - -// clang-format off -inline constexpr struct storage_capacity : base_dimension<"M"> {} storage_capacity; -inline constexpr struct traffic_intensity : base_dimension<"A"> {} traffic_intensity; -// clang-format on - -DERIVED_DIMENSION(transfer_rate, decltype(storage_capacity / si::time)); -DERIVED_DIMENSION(modulation_rate, decltype(1 / si::time)); - -} // namespace units::iec80000 diff --git a/src/systems/iec80000/include/units/iec80000/iec80000.h b/src/systems/iec80000/include/units/iec80000/iec80000.h index fc52bc37..eed775bd 100644 --- a/src/systems/iec80000/include/units/iec80000/iec80000.h +++ b/src/systems/iec80000/include/units/iec80000/iec80000.h @@ -24,7 +24,7 @@ // IWYU pragma: begin_exports #include -#include +#include #include #include // IWYU pragma: end_exports diff --git a/src/systems/iec80000/include/units/iec80000/quantities.h b/src/systems/iec80000/include/units/iec80000/quantities.h new file mode 100644 index 00000000..a06866bc --- /dev/null +++ b/src/systems/iec80000/include/units/iec80000/quantities.h @@ -0,0 +1,72 @@ +// The MIT License (MIT) +// +// Copyright (c) 2018 Mateusz Pusz +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +#pragma once + +#include +#include +#include +#include + +namespace units::iec80000 { + +// clang-format off +inline constexpr struct dim_traffic_intensity : base_dimension<"A"> {} dim_traffic_intensity; +inline constexpr struct dim_storage_capacity : base_dimension<"M"> {} dim_storage_capacity; +// clang-format on + +QUANTITY_SPEC(traffic_intensity, dim_traffic_intensity); +QUANTITY_SPEC(traffic_offered_intensity, traffic_intensity); +QUANTITY_SPEC(traffic_carried_intensity, traffic_intensity); +inline constexpr auto traffic_load = traffic_carried_intensity; +QUANTITY_SPEC(mean_queue_length, dimensionless); +QUANTITY_SPEC(loss_probability, dimensionless); +QUANTITY_SPEC(waiting_probability, dimensionless); +QUANTITY_SPEC(call_intensity, 1 / isq::duration); +inline constexpr auto calling_rate = call_intensity; +QUANTITY_SPEC(completed_call_intensity, call_intensity); +QUANTITY_SPEC(storage_capacity, dim_storage_capacity); +inline constexpr auto storage_size = storage_capacity; +QUANTITY_SPEC(equivalent_binary_storage_capacity, storage_capacity); +QUANTITY_SPEC(transfer_rate, storage_capacity / isq::duration); +QUANTITY_SPEC(period_of_data_elements, 1 / transfer_rate); +QUANTITY_SPEC(binary_digit_rate, transfer_rate); +inline constexpr auto bit_rate = binary_digit_rate; +QUANTITY_SPEC(period_of_binary_digits, 1 / binary_digit_rate); +inline constexpr auto bit_period = period_of_binary_digits; +QUANTITY_SPEC(equivalent_binary_digit_rate, binary_digit_rate); +inline constexpr auto equivalent_bit_rate = bit_rate; +QUANTITY_SPEC(modulation_rate, 1 / isq::duration); +inline constexpr auto line_digit_rate = modulation_rate; +QUANTITY_SPEC(quantizing_distortion_power, isq::power); +QUANTITY_SPEC(carrier_power, isq::power); +QUANTITY_SPEC(signal_energy_per_binary_digit, carrier_power* period_of_binary_digits); +QUANTITY_SPEC(error_probability, dimensionless); +QUANTITY_SPEC(Hamming_distance, dimensionless); +QUANTITY_SPEC(clock_frequency, isq::frequency); +inline constexpr auto clock_rate = clock_frequency; +QUANTITY_SPEC(decision_content, dimensionless); + +// TODO how to model information_content and the following quantities??? +// QUANTITY_SPEC(information_content, ...); + +} // namespace units::iec80000 diff --git a/src/systems/iec80000/include/units/iec80000/unit_symbols.h b/src/systems/iec80000/include/units/iec80000/unit_symbols.h index e16f1693..25d350df 100644 --- a/src/systems/iec80000/include/units/iec80000/unit_symbols.h +++ b/src/systems/iec80000/include/units/iec80000/unit_symbols.h @@ -45,6 +45,25 @@ inline constexpr auto Tibit = tebi; inline constexpr auto Pibit = pebi; inline constexpr auto Eibit = exbi; +// octet +inline constexpr auto o = octet; + +inline constexpr auto ko = si::kilo; +inline constexpr auto Mo = si::mega; +inline constexpr auto Go = si::giga; +inline constexpr auto To = si::tera; +inline constexpr auto Po = si::peta; +inline constexpr auto Eo = si::exa; +inline constexpr auto Zo = si::zetta; +inline constexpr auto Yo = si::yotta; + +inline constexpr auto Kio = kibi; +inline constexpr auto Mio = mebi; +inline constexpr auto Gio = gibi; +inline constexpr auto Tio = tebi; +inline constexpr auto Pio = pebi; +inline constexpr auto Eio = exbi; + // byte inline constexpr auto B = byte; diff --git a/src/systems/iec80000/include/units/iec80000/units.h b/src/systems/iec80000/include/units/iec80000/units.h index daa44350..b078291b 100644 --- a/src/systems/iec80000/include/units/iec80000/units.h +++ b/src/systems/iec80000/include/units/iec80000/units.h @@ -22,7 +22,8 @@ #pragma once -#include +#include +#include #include namespace units::iec80000 { @@ -30,6 +31,7 @@ namespace units::iec80000 { // clang-format off inline constexpr struct erlang : named_unit<"E", traffic_intensity> {} erlang; inline constexpr struct bit : named_unit<"bit", storage_capacity> {} bit; +inline constexpr struct octet : named_unit<"o", mag<8> * bit> {} octet; inline constexpr struct byte : named_unit<"B", mag<8> * bit> {} byte; inline constexpr struct baud : named_unit<"Bd", 1 / si::second> {} baud; // clang-format on