from __future__ import annotations
from typing import List, Optional, Union, Any
from enum import Enum
from pydantic import Field
from ..base import CIMBase, CIMModelRegistry
from rdflib import URIRef

CIM = URIRef('http://iec.ch/TC57/2013/CIM-schema-cim16#')

from .DiagramLayout import IdentifiedObject
from .Dynamics import ConductingEquipment, PowerSystemResource

class EquipmentBoundaryVersion(CIMBase):
    __cim_class__ = URIRef('http://entsoe.eu/CIM/SchemaExtension/3/1#EquipmentBoundaryVersion')
    baseUML: Optional[str] = Field(default=None, alias='http://entsoe.eu/CIM/SchemaExtension/3/1#EquipmentBoundaryVersion.baseUML')
    baseURI: Optional[str] = Field(default=None, alias='http://entsoe.eu/CIM/SchemaExtension/3/1#EquipmentBoundaryVersion.baseURI')
    date: Optional[str] = Field(default=None, alias='http://entsoe.eu/CIM/SchemaExtension/3/1#EquipmentBoundaryVersion.date')
    differenceModelURI: Optional[str] = Field(default=None, alias='http://entsoe.eu/CIM/SchemaExtension/3/1#EquipmentBoundaryVersion.differenceModelURI')
    entsoeUML: Optional[str] = Field(default=None, alias='http://entsoe.eu/CIM/SchemaExtension/3/1#EquipmentBoundaryVersion.entsoeUML')
    entsoeURIcore: Optional[str] = Field(default=None, alias='http://entsoe.eu/CIM/SchemaExtension/3/1#EquipmentBoundaryVersion.entsoeURIcore')
    entsoeURIoperation: Optional[str] = Field(default=None, alias='http://entsoe.eu/CIM/SchemaExtension/3/1#EquipmentBoundaryVersion.entsoeURIoperation')
    modelDescriptionURI: Optional[str] = Field(default=None, alias='http://entsoe.eu/CIM/SchemaExtension/3/1#EquipmentBoundaryVersion.modelDescriptionURI')
    namespaceRDF: Optional[str] = Field(default=None, alias='http://entsoe.eu/CIM/SchemaExtension/3/1#EquipmentBoundaryVersion.namespaceRDF')
    namespaceUML: Optional[str] = Field(default=None, alias='http://entsoe.eu/CIM/SchemaExtension/3/1#EquipmentBoundaryVersion.namespaceUML')
    shortName: Optional[str] = Field(default=None, alias='http://entsoe.eu/CIM/SchemaExtension/3/1#EquipmentBoundaryVersion.shortName')

CIMModelRegistry.register(URIRef('http://entsoe.eu/CIM/SchemaExtension/3/1#EquipmentBoundaryVersion'), EquipmentBoundaryVersion)

class ConnectivityNode(IdentifiedObject):
    __cim_class__ = URIRef('http://iec.ch/TC57/2013/CIM-schema-cim16#ConnectivityNode')
    ConnectivityNodeContainer: Optional['ConnectivityNodeContainer'] = Field(default=None, alias='http://iec.ch/TC57/2013/CIM-schema-cim16#ConnectivityNode.ConnectivityNodeContainer')
    Terminals: List['Terminal'] = Field(default_factory=list, alias='http://iec.ch/TC57/2013/CIM-schema-cim16#ConnectivityNode.Terminals')
    TopologicalNode: Optional['TopologicalNode'] = Field(default=None, alias='http://iec.ch/TC57/2013/CIM-schema-cim16#ConnectivityNode.TopologicalNode')
    boundaryPoint: Optional[bool] = Field(default=None, alias='http://entsoe.eu/CIM/SchemaExtension/3/1#ConnectivityNode.boundaryPoint')
    fromEndIsoCode: Optional[str] = Field(default=None, alias='http://entsoe.eu/CIM/SchemaExtension/3/1#ConnectivityNode.fromEndIsoCode')
    fromEndName: Optional[str] = Field(default=None, alias='http://entsoe.eu/CIM/SchemaExtension/3/1#ConnectivityNode.fromEndName')
    fromEndNameTso: Optional[str] = Field(default=None, alias='http://entsoe.eu/CIM/SchemaExtension/3/1#ConnectivityNode.fromEndNameTso')
    toEndIsoCode: Optional[str] = Field(default=None, alias='http://entsoe.eu/CIM/SchemaExtension/3/1#ConnectivityNode.toEndIsoCode')
    toEndName: Optional[str] = Field(default=None, alias='http://entsoe.eu/CIM/SchemaExtension/3/1#ConnectivityNode.toEndName')
    toEndNameTso: Optional[str] = Field(default=None, alias='http://entsoe.eu/CIM/SchemaExtension/3/1#ConnectivityNode.toEndNameTso')

CIMModelRegistry.register(URIRef('http://iec.ch/TC57/2013/CIM-schema-cim16#ConnectivityNode'), ConnectivityNode)

class ConnectivityNodeContainer(PowerSystemResource):
    __cim_class__ = URIRef('http://iec.ch/TC57/2013/CIM-schema-cim16#ConnectivityNodeContainer')
    ConnectivityNodes: List['ConnectivityNode'] = Field(default_factory=list, alias='http://iec.ch/TC57/2013/CIM-schema-cim16#ConnectivityNodeContainer.ConnectivityNodes')
    TopologicalNode: List['TopologicalNode'] = Field(default_factory=list, alias='http://iec.ch/TC57/2013/CIM-schema-cim16#ConnectivityNodeContainer.TopologicalNode')

CIMModelRegistry.register(URIRef('http://iec.ch/TC57/2013/CIM-schema-cim16#ConnectivityNodeContainer'), ConnectivityNodeContainer)

class EquipmentContainer(ConnectivityNodeContainer):
    __cim_class__ = URIRef('http://iec.ch/TC57/2013/CIM-schema-cim16#EquipmentContainer')
    Equipments: List['Equipment'] = Field(default_factory=list, alias='http://iec.ch/TC57/2013/CIM-schema-cim16#EquipmentContainer.Equipments')

CIMModelRegistry.register(URIRef('http://iec.ch/TC57/2013/CIM-schema-cim16#EquipmentContainer'), EquipmentContainer)

class BaseVoltage(IdentifiedObject):
    __cim_class__ = URIRef('http://iec.ch/TC57/2013/CIM-schema-cim16#BaseVoltage')
    ConductingEquipment: List['ConductingEquipment'] = Field(default_factory=list, alias='http://iec.ch/TC57/2013/CIM-schema-cim16#BaseVoltage.ConductingEquipment')
    TopologicalNode: List['TopologicalNode'] = Field(default_factory=list, alias='http://iec.ch/TC57/2013/CIM-schema-cim16#BaseVoltage.TopologicalNode')
    TransformerEnds: List['TransformerEnd'] = Field(default_factory=list, alias='http://iec.ch/TC57/2013/CIM-schema-cim16#BaseVoltage.TransformerEnds')
    VoltageLevel: List['VoltageLevel'] = Field(default_factory=list, alias='http://iec.ch/TC57/2013/CIM-schema-cim16#BaseVoltage.VoltageLevel')
    nominalVoltage: Optional[float] = Field(default=None, alias='http://iec.ch/TC57/2013/CIM-schema-cim16#BaseVoltage.nominalVoltage')

CIMModelRegistry.register(URIRef('http://iec.ch/TC57/2013/CIM-schema-cim16#BaseVoltage'), BaseVoltage)

class Voltage(CIMBase):
    __cim_class__ = URIRef('http://iec.ch/TC57/2013/CIM-schema-cim16#Voltage')
    multiplier: Optional['UnitMultiplier'] = Field(default=None, alias='http://iec.ch/TC57/2013/CIM-schema-cim16#Voltage.multiplier')
    unit: Optional['UnitSymbol'] = Field(default=None, alias='http://iec.ch/TC57/2013/CIM-schema-cim16#Voltage.unit')
    value: Optional[float] = Field(default=None, alias='http://iec.ch/TC57/2013/CIM-schema-cim16#Voltage.value')

CIMModelRegistry.register(URIRef('http://iec.ch/TC57/2013/CIM-schema-cim16#Voltage'), Voltage)

class GeographicalRegion(IdentifiedObject):
    __cim_class__ = URIRef('http://iec.ch/TC57/2013/CIM-schema-cim16#GeographicalRegion')
    Regions: List['SubGeographicalRegion'] = Field(default_factory=list, alias='http://iec.ch/TC57/2013/CIM-schema-cim16#GeographicalRegion.Regions')

CIMModelRegistry.register(URIRef('http://iec.ch/TC57/2013/CIM-schema-cim16#GeographicalRegion'), GeographicalRegion)

class SubGeographicalRegion(IdentifiedObject):
    __cim_class__ = URIRef('http://iec.ch/TC57/2013/CIM-schema-cim16#SubGeographicalRegion')
    DCLines: List['DCLine'] = Field(default_factory=list, alias='http://iec.ch/TC57/2013/CIM-schema-cim16#SubGeographicalRegion.DCLines')
    Lines: List['Line'] = Field(default_factory=list, alias='http://iec.ch/TC57/2013/CIM-schema-cim16#SubGeographicalRegion.Lines')
    Region: Optional['GeographicalRegion'] = Field(default=None, alias='http://iec.ch/TC57/2013/CIM-schema-cim16#SubGeographicalRegion.Region')
    Substations: List['Substation'] = Field(default_factory=list, alias='http://iec.ch/TC57/2013/CIM-schema-cim16#SubGeographicalRegion.Substations')

CIMModelRegistry.register(URIRef('http://iec.ch/TC57/2013/CIM-schema-cim16#SubGeographicalRegion'), SubGeographicalRegion)

class EnergySchedulingType(IdentifiedObject):
    __cim_class__ = URIRef('http://entsoe.eu/CIM/SchemaExtension/3/1#EnergySchedulingType')
    EnergySource: List['EnergySource'] = Field(default_factory=list, alias='http://entsoe.eu/CIM/SchemaExtension/3/1#EnergySchedulingType.EnergySource')
    EnergySource_EnergySchedulingType_EnergySource: List['EnergySource'] = Field(default_factory=list, alias='http://iec.ch/TC57/2013/CIM-schema-cim16#EnergySchedulingType.EnergySource')

CIMModelRegistry.register(URIRef('http://entsoe.eu/CIM/SchemaExtension/3/1#EnergySchedulingType'), EnergySchedulingType)

class Line(EquipmentContainer):
    __cim_class__ = URIRef('http://iec.ch/TC57/2013/CIM-schema-cim16#Line')
    Region: Optional['SubGeographicalRegion'] = Field(default=None, alias='http://iec.ch/TC57/2013/CIM-schema-cim16#Line.Region')

CIMModelRegistry.register(URIRef('http://iec.ch/TC57/2013/CIM-schema-cim16#Line'), Line)

class Connector(ConductingEquipment):
    __cim_class__ = URIRef('http://iec.ch/TC57/2013/CIM-schema-cim16#Connector')
    pass

CIMModelRegistry.register(URIRef('http://iec.ch/TC57/2013/CIM-schema-cim16#Connector'), Connector)

class Junction(Connector):
    __cim_class__ = URIRef('http://iec.ch/TC57/2013/CIM-schema-cim16#Junction')
    pass

CIMModelRegistry.register(URIRef('http://iec.ch/TC57/2013/CIM-schema-cim16#Junction'), Junction)

__all__ = [
    'EquipmentBoundaryVersion',
    'ConnectivityNode',
    'ConnectivityNodeContainer',
    'EquipmentContainer',
    'BaseVoltage',
    'Voltage',
    'GeographicalRegion',
    'SubGeographicalRegion',
    'EnergySchedulingType',
    'Line',
    'Connector',
    'Junction',
]
