Skip to content
Snippets Groups Projects
Parameters.py 2.93 KiB
Newer Older
# Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

Lluis Gifre Renom's avatar
Lluis Gifre Renom committed
from typing import List, Optional

class Parameters:
    def __init__(
Lluis Gifre Renom's avatar
Lluis Gifre Renom committed
        self, num_requests : int, request_types : List[str], offered_load : Optional[float] = None,
Lluis Gifre Renom's avatar
Lluis Gifre Renom committed
        inter_arrival_time : Optional[float] = None, holding_time : Optional[float] = None,
Lluis Gifre Renom's avatar
Lluis Gifre Renom committed
        dry_mode : bool = False, record_to_dlt : bool = False, dlt_domain_id : Optional[str] = None
    ) -> None:
Lluis Gifre Renom's avatar
Lluis Gifre Renom committed
        self._num_requests = num_requests
        self._request_types = request_types
        self._offered_load = offered_load
        self._inter_arrival_time = inter_arrival_time
        self._holding_time = holding_time
        self._dry_mode = dry_mode
Lluis Gifre Renom's avatar
Lluis Gifre Renom committed
        self._record_to_dlt = record_to_dlt
        self._dlt_domain_id = dlt_domain_id

        if self._offered_load is None and self._holding_time is not None and self._inter_arrival_time is not None:
            self._offered_load = self._holding_time / self._inter_arrival_time
        elif self._offered_load is not None and self._holding_time is not None and self._inter_arrival_time is None:
            self._inter_arrival_time = self._holding_time / self._offered_load
        elif self._offered_load is not None and self._holding_time is None and self._inter_arrival_time is not None:
            self._holding_time = self._offered_load * self._inter_arrival_time
Lluis Gifre Renom's avatar
Lluis Gifre Renom committed
        else:
            MSG = 'Exactly two of offered_load({:s}), inter_arrival_time({:s}), holding_time({:s}) must be specified.'
            raise Exception(MSG.format(str(self._offered_load), str(self._inter_arrival_time), str(self._holding_time)))

        if self._record_to_dlt and self._dlt_domain_id is None:
            MSG = 'Parameter dlt_domain_id({:s}) must be specified with record_to_dlt({:s}).'
            raise Exception(MSG.format(str(self._dlt_domain_id), str(self._record_to_dlt)))

    @property
Lluis Gifre Renom's avatar
Lluis Gifre Renom committed
    def num_requests(self): return self._num_requests
Lluis Gifre Renom's avatar
Lluis Gifre Renom committed
    @property
Lluis Gifre Renom's avatar
Lluis Gifre Renom committed
    def request_types(self): return self._request_types
Lluis Gifre Renom's avatar
Lluis Gifre Renom committed

    @property
    def offered_load(self): return self._offered_load

    @property
    def inter_arrival_time(self): return self._inter_arrival_time

    @property
    def holding_time(self): return self._holding_time

    @property
    def dry_mode(self): return self._dry_mode
Lluis Gifre Renom's avatar
Lluis Gifre Renom committed

    @property
    def record_to_dlt(self): return self._record_to_dlt

    @property
    def dlt_domain_id(self): return self._dlt_domain_id