# Copyright (C) 2021 - 2024 ANSYS, Inc. and/or its affiliates.
# SPDX-License-Identifier: MIT
#
#
# 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.

"""Module providing the MatS07 class."""
import typing
from ansys.dyna.core.lib.card import Card, Field, Flag
from ansys.dyna.core.lib.field_schema import FieldSchema
from ansys.dyna.core.lib.option_card import OptionCardSet, OptionSpec
from ansys.dyna.core.lib.keyword_base import KeywordBase

_MATS07_CARD0 = (
    FieldSchema("mid", int, 0, 10, None),
    FieldSchema("k0", float, 10, 10, None),
    FieldSchema("ki", float, 20, 10, None),
    FieldSchema("beta", float, 30, 10, None),
    FieldSchema("tc", float, 40, 10, None),
    FieldSchema("fc", float, 50, 10, None),
    FieldSchema("copt", float, 60, 10, None),
)

_MATS07_OPTION0_CARD0 = (
    FieldSchema("title", str, 0, 80, None),
)

class MatS07(KeywordBase):
    """DYNA MAT_S07 keyword"""

    keyword = "MAT"
    subkeyword = "S07"
    option_specs = [
        OptionSpec("TITLE", -1, 1),
    ]

    def __init__(self, **kwargs):
        """Initialize the MatS07 class."""
        super().__init__(**kwargs)
        kwargs["parent"] = self
        self._cards = [
            Card.from_field_schemas_with_defaults(
                _MATS07_CARD0,
                **kwargs,
            ),            OptionCardSet(
                option_spec = MatS07.option_specs[0],
                cards = [
                    Card.from_field_schemas_with_defaults(
                        _MATS07_OPTION0_CARD0,
                        **kwargs,
                    ),
                ],
                **kwargs
            ),
        ]
    @property
    def mid(self) -> typing.Optional[int]:
        """Get or set the Material identification. A unique number has to be used.
        """ # nopep8
        return self._cards[0].get_value("mid")

    @mid.setter
    def mid(self, value: int) -> None:
        """Set the mid property."""
        self._cards[0].set_value("mid", value)

    @property
    def k0(self) -> typing.Optional[float]:
        """Get or set the K0, short time stiffness.
        """ # nopep8
        return self._cards[0].get_value("k0")

    @k0.setter
    def k0(self, value: float) -> None:
        """Set the k0 property."""
        self._cards[0].set_value("k0", value)

    @property
    def ki(self) -> typing.Optional[float]:
        """Get or set the K-infinity, long time stiffness.
        """ # nopep8
        return self._cards[0].get_value("ki")

    @ki.setter
    def ki(self, value: float) -> None:
        """Set the ki property."""
        self._cards[0].set_value("ki", value)

    @property
    def beta(self) -> typing.Optional[float]:
        """Get or set the Decay parameter.
        """ # nopep8
        return self._cards[0].get_value("beta")

    @beta.setter
    def beta(self, value: float) -> None:
        """Set the beta property."""
        self._cards[0].set_value("beta", value)

    @property
    def tc(self) -> typing.Optional[float]:
        """Get or set the Cut off time. After this time a constant force/moment is transmitted.
        """ # nopep8
        return self._cards[0].get_value("tc")

    @tc.setter
    def tc(self, value: float) -> None:
        """Set the tc property."""
        self._cards[0].set_value("tc", value)

    @property
    def fc(self) -> typing.Optional[float]:
        """Get or set the Force/moment after cutoff time
        """ # nopep8
        return self._cards[0].get_value("fc")

    @fc.setter
    def fc(self, value: float) -> None:
        """Set the fc property."""
        self._cards[0].set_value("fc", value)

    @property
    def copt(self) -> typing.Optional[float]:
        """Get or set the Time implementation option:
        EQ.0.0: incremental time change (default),
        NE.0: continuous time change.
        """ # nopep8
        return self._cards[0].get_value("copt")

    @copt.setter
    def copt(self, value: float) -> None:
        """Set the copt property."""
        self._cards[0].set_value("copt", value)

    @property
    def title(self) -> typing.Optional[str]:
        """Get or set the Additional title line
        """ # nopep8
        return self._cards[1].cards[0].get_value("title")

    @title.setter
    def title(self, value: str) -> None:
        """Set the title property."""
        self._cards[1].cards[0].set_value("title", value)

        if value:
            self.activate_option("TITLE")

