# 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 ControlFormingOutputIntfor 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.keyword_base import KeywordBase
from ansys.dyna.core.lib.keyword_base import LinkType
from ansys.dyna.core.keywords.keyword_classes.auto.define.define_curve import DefineCurve

_CONTROLFORMINGOUTPUTINTFOR_CARD0 = (
    FieldSchema("cid", int, 0, 10, None),
    FieldSchema("nout", int, 10, 10, None),
    FieldSchema("tbeg", float, 20, 10, None),
    FieldSchema("tend", float, 30, 10, None),
    FieldSchema("y1_lcid", float, 40, 10, None, "y1/lcid"),
    FieldSchema("y2_lcid", float, 50, 10, None, "y2/lcid"),
    FieldSchema("y3", float, 60, 10, None),
    FieldSchema("y4", float, 70, 10, None),
)

class ControlFormingOutputIntfor(KeywordBase):
    """DYNA CONTROL_FORMING_OUTPUT_INTFOR keyword"""

    keyword = "CONTROL"
    subkeyword = "FORMING_OUTPUT_INTFOR"
    _link_fields = {
        "cid": LinkType.DEFINE_CURVE,
    }

    def __init__(self, **kwargs):
        """Initialize the ControlFormingOutputIntfor class."""
        super().__init__(**kwargs)
        self._cards = [
            Card.from_field_schemas_with_defaults(
                _CONTROLFORMINGOUTPUTINTFOR_CARD0,
                **kwargs,
            ),        ]
    @property
    def cid(self) -> typing.Optional[int]:
        """Get or set the ID of a tooling kinematics curve, as defined by *DEFINE_CURVE and used by *BOUNDARY_PRESCRIBED_MOTION_RIGID.
        """ # nopep8
        return self._cards[0].get_value("cid")

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

    @property
    def nout(self) -> typing.Optional[int]:
        """Get or set the Total number of D3PLOT outputs for the tooling kinematics curve, excluding the beginning and final time, see figures below.
        """ # nopep8
        return self._cards[0].get_value("nout")

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

    @property
    def tbeg(self) -> typing.Optional[float]:
        """Get or set the Start time of the curve.
        """ # nopep8
        return self._cards[0].get_value("tbeg")

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

    @property
    def tend(self) -> typing.Optional[float]:
        """Get or set the End time of the curve.
        """ # nopep8
        return self._cards[0].get_value("tend")

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

    @property
    def y1_lcid(self) -> typing.Optional[float]:
        """Get or set the GT.0:	All four variables (Y1, Y2, Y3, Y4) are taken to be the distances from the punch home, where d3plot files will be output
        LT.0:	The absolute value of Y1/LCID (must be an integer) is taken as a load curve ID (see *DEFINE_CURVE).
        Only the abscissas in the load curve, which are the distances to punch home, are used.
        These distances specify the states that are written to the d3plot files.  Ordinates of the curve are ignored.
        This case accommodates more states than is possible with the four variables Y1, Y2, Y3, Y4.  Furthermore, when Y1/LCID < 0, Y2, Y3, and Y4 are ignored.
        Available starting from Dev Revision 112604, the output will be skipped for any negative abscissa in the load curve.
        Note a curve with only negative abscissas is not allowed..
        """ # nopep8
        return self._cards[0].get_value("y1_lcid")

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

    @property
    def y2_lcid(self) -> typing.Optional[float]:
        """Get or set the GT.0:	The input is taken as the distance from the punch home, where a d3plot file will be output
        LT.0:	The absolute value of Y2/CIDT (must be an integer) is taken as a load curve ID (see *DEFINE_CURVE).
        Only the abscissas in the load curve, which are the simulation times, are used.
        These times specify the states that are written to the d3plot files.  Ordinates of the curve are ignored.
        Note this time-dependent load curve will output additional d3plot files on top of the d3plot files already written in case Y1/LCID < 0 (if specified).
        Furthermore, when Y2/CIDT < 0, Y3 and Y4 are ignored.  See the example Using CIDT below.
        """ # nopep8
        return self._cards[0].get_value("y2_lcid")

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

    @property
    def y3(self) -> typing.Optional[float]:
        """Get or set the Distances to tooling home, where D3PLOT files will be output.
        """ # nopep8
        return self._cards[0].get_value("y3")

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

    @property
    def y4(self) -> typing.Optional[float]:
        """Get or set the Distances to tooling home, where D3PLOT files will be output.
        """ # nopep8
        return self._cards[0].get_value("y4")

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

    @property
    def cid_link(self) -> typing.Optional[DefineCurve]:
        """Get the DefineCurve object for cid."""
        if self.deck is None:
            return None
        for kwd in self.deck.get_kwds_by_full_type("DEFINE", "CURVE"):
            if kwd.lcid == self.cid:
                return kwd
        return None

    @cid_link.setter
    def cid_link(self, value: DefineCurve) -> None:
        """Set the DefineCurve object for cid."""
        self.cid = value.lcid

