Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Create a dataclass for primitives and generate a file for each primitive #10

Open
chicco785 opened this issue Oct 16, 2024 · 0 comments
Assignees
Labels
feature This issue/PR relates to a feature request.

Comments

@chicco785
Copy link
Member

Is your feature request related to a problem? Please describe the problem.

Primitives are now generated as classes, e.g.:

"""
Generated from the CGMES 3 files via cimgen: https://github.com/sogno-platform/cimgen
"""

from functools import cached_property
from typing import Optional
from pydantic import Field
from pydantic.dataclasses import dataclass
from ..utils.profile import BaseProfile, Profile

from ..utils.base import Base

@dataclass
class Float(Base):
    """
    A floating point number. The range is unspecified and not limited.

    """

    # No attributes defined for this class.


    @cached_property
    def possible_profiles(self)->set[BaseProfile]:
        """
        A resource can be used by multiple profiles. This is the set of profiles
        where this element can be found.
        """
        return { Profile.DL, Profile.DY, Profile.EQ, Profile.EQBD, Profile.OP, Profile.SC, Profile.SSH, Profile.SV,  }

which is no sense, they should be used to annotate cim classes fields and that's all.

Describe the solution you'd like

Float = Primitive(name="Float", type=float, profiles=[Profile.EQBD, Profile.OP, Profile.SSH, Profile.EQ, Profile.DY, Profile.DL, Profile.SV, Profile.SC, ])

...


@dataclass(config=DataclassConfig)
class AnalogLimit(Limit):
    """
    Limit values for Analog measurements.

    value: The value to supervise against.
    LimitSet: The set of limits.
    """

    value : float = Field(default=0.0, in_profiles = [Profile.OP, ], data_type = Float,alias = "value")
    limitSet : AnalogLimitSet = Field(default=None, in_profiles = [Profile.OP, ], alias = "LimitSet")
    
    val_limitSet_wrap = field_validator("limitSet", mode="wrap")(cyclic_references_validator)
    
    @cached_property
    def possible_profiles(self)->set[BaseProfile]:
        """
        A resource can be used by multiple profiles. This is the set of profiles
        where this element can be found.
        """
        return { Profile.OP,  }

Additional context

No response

@chicco785 chicco785 added the feature This issue/PR relates to a feature request. label Oct 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature This issue/PR relates to a feature request.
Projects
None yet
Development

When branches are created from issues, their pull requests are automatically linked.

2 participants