24 lines
1.0 KiB
Python
24 lines
1.0 KiB
Python
from sqlalchemy import Column, String, Float, Integer, Text, DateTime
|
|
from sqlalchemy.sql import func
|
|
from database import Base
|
|
|
|
|
|
class Lamp(Base):
|
|
"""Marine navigation lamp catalog. Aids reference a Lamp by id; the
|
|
battery warning/alarm thresholds for each Aid are computed from the
|
|
lamp's voltage_min / voltage_max:
|
|
warn = voltage_min + (voltage_max - voltage_min) * 0.20
|
|
alarm = voltage_min + (voltage_max - voltage_min) * 0.10
|
|
"""
|
|
__tablename__ = "lamps"
|
|
|
|
id = Column(String, primary_key=True)
|
|
manufacturer = Column(String, nullable=False)
|
|
model = Column(String, nullable=False)
|
|
lamp_count = Column(Integer, default=1)
|
|
voltage_min = Column(Float, nullable=False) # discharged threshold (V)
|
|
voltage_max = Column(Float, nullable=False) # fully-charged nominal (V)
|
|
notes = Column(Text, nullable=True)
|
|
creado_en = Column(DateTime, server_default=func.now())
|
|
modificado_en = Column(DateTime, onupdate=func.now())
|