73 lines
2.5 KiB
Python
73 lines
2.5 KiB
Python
from sqlalchemy import Column, String, Float, Boolean, DateTime, Enum, Text
|
|
from sqlalchemy.sql import func
|
|
from database import Base
|
|
import enum
|
|
|
|
class AidCategory(str, enum.Enum):
|
|
FLOTANTE = "FLOTANTE"
|
|
FIJA = "FIJA"
|
|
|
|
class AidType(str, enum.Enum):
|
|
BOYA_LATERAL = "BOYA_LATERAL"
|
|
BOYA_CARDINAL = "BOYA_CARDINAL"
|
|
BOYA_PELIGRO = "BOYA_PELIGRO"
|
|
BOYA_AGUAS_SEGURAS = "BOYA_AGUAS_SEGURAS"
|
|
BOYA_ESPECIAL = "BOYA_ESPECIAL"
|
|
FARO = "FARO"
|
|
FAROL = "FAROL"
|
|
BALIZA = "BALIZA"
|
|
ENFILACION = "ENFILACION"
|
|
|
|
class AisType(str, enum.Enum):
|
|
ATON_21 = "ATON_21"
|
|
AIS_NORMAL = "AIS_NORMAL"
|
|
SIN_AIS = "SIN_AIS"
|
|
|
|
class Aid(Base):
|
|
__tablename__ = "aids"
|
|
|
|
id = Column(String, primary_key=True)
|
|
nombre = Column(String, nullable=False)
|
|
numero_interno = Column(String)
|
|
categoria = Column(String, nullable=False) # FLOTANTE | FIJA
|
|
tipo = Column(String, nullable=False)
|
|
tipo_ais = Column(String, default="SIN_AIS")
|
|
|
|
# Posición oficial (fuente de verdad)
|
|
lat_nominal = Column(Float, nullable=False)
|
|
lon_nominal = Column(Float, nullable=False)
|
|
fuente_posicion = Column(String, default="MANUAL") # S57 | MANUAL
|
|
|
|
# Solo flotantes
|
|
radio_borneo_m = Column(Float, default=10.0)
|
|
|
|
# Si tiene AIS
|
|
mmsi = Column(String, unique=True, nullable=True)
|
|
|
|
# Posición actual (actualizada por AIS)
|
|
lat_actual = Column(Float, nullable=True)
|
|
lon_actual = Column(Float, nullable=True)
|
|
desplazamiento_m = Column(Float, default=0.0)
|
|
ultima_senal = Column(DateTime, nullable=True)
|
|
|
|
# Estado
|
|
en_posicion = Column(Boolean, default=True)
|
|
en_movimiento = Column(Boolean, default=False)
|
|
activa = Column(Boolean, default=True)
|
|
|
|
# Características luminosas
|
|
caracteristica_luz = Column(String, nullable=True)
|
|
alcance_nm = Column(Float, nullable=True)
|
|
lamp_id = Column(String, nullable=True) # FK → lamps.id (no enforced constraint to allow nullable)
|
|
|
|
# Responsabilidad
|
|
puerto_responsable = Column(String, nullable=True) # ej: "Barranquilla", "Cartagena"
|
|
empresa_responsable = Column(String, nullable=True) # empresa de señalización
|
|
observaciones = Column(Text, nullable=True)
|
|
|
|
# Auditoría
|
|
creado_en = Column(DateTime, server_default=func.now())
|
|
modificado_en = Column(DateTime, onupdate=func.now())
|
|
modificado_por = Column(String, nullable=True)
|
|
motivo_cambio = Column(Text, nullable=True)
|