# 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 DefineBeamSolidCoupling 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

_DEFINEBEAMSOLIDCOUPLING_CARD0 = (
    FieldSchema("lstrid", int, 0, 10, None),
    FieldSchema("msolidm", int, 10, 10, None),
    FieldSchema("lstrtype", int, 20, 10, 0),
    FieldSchema("soltype", int, 30, 10, 0),
    FieldSchema("form", int, 40, 10, 0),
    FieldSchema("psf", float, 50, 10, 1.0),
)

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

class DefineBeamSolidCoupling(KeywordBase):
    """DYNA DEFINE_BEAM_SOLID_COUPLING keyword"""

    keyword = "DEFINE"
    subkeyword = "BEAM_SOLID_COUPLING"
    option_specs = [
        OptionSpec("TITLE", -1, 1),
    ]

    def __init__(self, **kwargs):
        """Initialize the DefineBeamSolidCoupling class."""
        super().__init__(**kwargs)
        kwargs["parent"] = self
        self._cards = [
            Card.from_field_schemas_with_defaults(
                _DEFINEBEAMSOLIDCOUPLING_CARD0,
                **kwargs,
            ),            OptionCardSet(
                option_spec = DefineBeamSolidCoupling.option_specs[0],
                cards = [
                    Card.from_field_schemas_with_defaults(
                        _DEFINEBEAMSOLIDCOUPLING_OPTION0_CARD0,
                        **kwargs,
                    ),
                ],
                **kwargs
            ),
        ]
    @property
    def lstrid(self) -> typing.Optional[int]:
        """Get or set the Part set ID or part ID of the Lagrangian structure.  LSTRTYPE below indicates the ID type specified by LSTRTYPE.
        """ # nopep8
        return self._cards[0].get_value("lstrid")

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

    @property
    def msolidm(self) -> typing.Optional[int]:
        """Get or set the Part set ID or part ID of the solid block.  SOLTYPE below indicates the ID type specified by SOLTYPE.
        """ # nopep8
        return self._cards[0].get_value("msolidm")

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

    @property
    def lstrtype(self) -> int:
        """Get or set the Type of Lagrangian structures set:
        EQ.0:	Part set
        EQ.1:	Part
        """ # nopep8
        return self._cards[0].get_value("lstrtype")

    @lstrtype.setter
    def lstrtype(self, value: int) -> None:
        """Set the lstrtype property."""
        if value not in [0, 1, None]:
            raise Exception("""lstrtype must be `None` or one of {0,1}.""")
        self._cards[0].set_value("lstrtype", value)

    @property
    def soltype(self) -> int:
        """Get or set the Type of solid set:
        EQ.0:	Part set
        EQ.1:	Part
        """ # nopep8
        return self._cards[0].get_value("soltype")

    @soltype.setter
    def soltype(self, value: int) -> None:
        """Set the soltype property."""
        if value not in [0, 1, None]:
            raise Exception("""soltype must be `None` or one of {0,1}.""")
        self._cards[0].set_value("soltype", value)

    @property
    def form(self) -> int:
        """Get or set the Coupling type
        EQ.0: Constrained acceleration and velocity
        EQ.1: Penalty tied in all directions
        """ # nopep8
        return self._cards[0].get_value("form")

    @form.setter
    def form(self, value: int) -> None:
        """Set the form property."""
        if value not in [0, 1, None]:
            raise Exception("""form must be `None` or one of {0,1}.""")
        self._cards[0].set_value("form", value)

    @property
    def psf(self) -> float:
        """Get or set the Scale factor for penalty stiffness
        """ # nopep8
        return self._cards[0].get_value("psf")

    @psf.setter
    def psf(self, value: float) -> None:
        """Set the psf property."""
        self._cards[0].set_value("psf", 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")

