feat: about half of IEC 80000 quantities support added

This commit is contained in:
Mateusz Pusz
2022-12-27 12:20:23 +01:00
parent 7ee95bcbeb
commit 016984f1b3
7 changed files with 98 additions and 43 deletions

View File

@@ -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
)

View File

@@ -22,7 +22,7 @@
#pragma once
#include <units/prefix.h>
#include <units/unit.h>
namespace units::iec80000 {

View File

@@ -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 <units/dimension.h>
#include <units/isq/base_dimensions.h>
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

View File

@@ -24,7 +24,7 @@
// IWYU pragma: begin_exports
#include <units/iec80000/binary_prefixes.h>
#include <units/iec80000/dimensions.h>
#include <units/iec80000/quantities.h>
#include <units/iec80000/unit_symbols.h>
#include <units/iec80000/units.h>
// IWYU pragma: end_exports

View File

@@ -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 <units/dimension.h>
#include <units/isq/mechanics.h>
#include <units/isq/space_and_time.h>
#include <units/quantity_spec.h>
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

View File

@@ -45,6 +45,25 @@ inline constexpr auto Tibit = tebi<bit>;
inline constexpr auto Pibit = pebi<bit>;
inline constexpr auto Eibit = exbi<bit>;
// octet
inline constexpr auto o = octet;
inline constexpr auto ko = si::kilo<octet>;
inline constexpr auto Mo = si::mega<octet>;
inline constexpr auto Go = si::giga<octet>;
inline constexpr auto To = si::tera<octet>;
inline constexpr auto Po = si::peta<octet>;
inline constexpr auto Eo = si::exa<octet>;
inline constexpr auto Zo = si::zetta<octet>;
inline constexpr auto Yo = si::yotta<octet>;
inline constexpr auto Kio = kibi<octet>;
inline constexpr auto Mio = mebi<octet>;
inline constexpr auto Gio = gibi<octet>;
inline constexpr auto Tio = tebi<octet>;
inline constexpr auto Pio = pebi<octet>;
inline constexpr auto Eio = exbi<octet>;
// byte
inline constexpr auto B = byte;

View File

@@ -22,7 +22,8 @@
#pragma once
#include <units/iec80000/dimensions.h>
#include <units/iec80000/quantities.h>
#include <units/si/units.h>
#include <units/unit.h>
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