sprint-0: fundaciones VMS-Sailor
Sprint 0 completo del producto VMS-Sailor (Vessel Management System integrado para buques 30-40m). Brief de referencia en VMS_Sailor_v2_Parte_*.md (intacto). Core (vmssailor.core, 95.17% coverage, 99 tests verde): - ShipCoord: sistema naval x_pp/y_cl/z_bl frozen - Vessel, Deck, Bulkhead - Equipment, EquipmentModel, Sensor, EquipmentSpec - Tag, AlarmConfig, TagBinding, Scaling - CardInstance, Bus, Topology con validacion 21 puntos I/O AR-NMEA-IO-v1.0 - Alarm, PermissiveRule, Condition - Project agregado raiz con validacion cross-entity - Persistencia portable .vmsproj (SQLite) con roundtrip verificable Biblioteca curada seed (vmssailor.library): - systems_catalog.json completo (catalogo maestro Parte 1 sec 7) - 2 vessels: Sunseeker 76, Ferretti 850 - 2 motores: MTU 12V 2000 M96, Volvo D13-900 - 1 genset: Northern Lights M65C13 - yacht_motor_planeo.yaml (reglas heuristicas) - TODO marcado data_source=seed_estimate - requiere validacion datasheets Tools: - vms-validate-library: CLI valida biblioteca completa - vms-generate-test-project: CLI demo + verificacion roundtrip persistencia Design System + 8 mockups HTML estaticos: - docs/design_system.md (paleta Deep Ocean, gradientes, typography, motion) - docs/brand/ (logo + variantes SVG) - docs/mockups/splash, studio_main, runtime_overview, runtime_mimic_fuel (P&ID animado), runtime_alarms, runtime_trim (panel estrella con horizonte artificial), mobile_overview, mobile_trim - docs/mockups/index.html (galeria) Firmware (Sprint 12+ implementacion): - firmware/ar_nmea_io_v1/src/config/pinout.h con macros GPIO Decisiones autonomas documentadas en docs/decisions_sprint0.md. Stack: Python 3.11 + uv + Pydantic v2 + SQLite stdlib + hatchling + pytest 9 + ruff + mypy. Sin PySide6, FastAPI, Flutter ni firmware funcional (entran en sprints siguientes). Criterio de aceptacion Sprint 0: cumplido. - uv sync: OK - pytest: 99/99 verde - cov vmssailor.core: 95.17% (objetivo >=80%) - ruff: clean - vms-validate-library: OK - vms-generate-test-project: INTEGRIDAD OK Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,145 @@
|
||||
"""Fixtures comunes para los tests de vmssailor.core."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
from vmssailor.core import (
|
||||
AlarmConfig,
|
||||
AlarmPriority,
|
||||
Bus,
|
||||
BusRole,
|
||||
CardInstance,
|
||||
ChannelType,
|
||||
Equipment,
|
||||
Project,
|
||||
Protocol,
|
||||
Scaling,
|
||||
ShipCoord,
|
||||
SignalType,
|
||||
SystemId,
|
||||
Tag,
|
||||
TagBinding,
|
||||
Topology,
|
||||
UnitSI,
|
||||
Vessel,
|
||||
VesselSubtype,
|
||||
VesselType,
|
||||
)
|
||||
from vmssailor.core.vessel import Deck
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
def repo_root() -> Path:
|
||||
return Path(__file__).resolve().parents[1]
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
def sample_ship_coord() -> ShipCoord:
|
||||
return ShipCoord(x_pp=10.0, y_cl=-1.5, z_bl=2.0)
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
def minimal_vessel() -> Vessel:
|
||||
return Vessel(
|
||||
id="test_vessel",
|
||||
name="Test Vessel",
|
||||
type=VesselType.YACHT_MOTOR,
|
||||
subtype=VesselSubtype.PLANING,
|
||||
length_overall_m=24.0,
|
||||
beam_max_m=5.5,
|
||||
draft_m=1.8,
|
||||
decks=[
|
||||
Deck(id="main", name="Main", z_bl_bottom=2.0, z_bl_top=4.5),
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
def sample_card() -> CardInstance:
|
||||
return CardInstance(
|
||||
id="card_001",
|
||||
slot_number=1,
|
||||
bus_id="bus_main",
|
||||
bus_role=BusRole.MODBUS_SLAVE,
|
||||
modbus_address=1,
|
||||
physical_location="SM panel A",
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
def sample_bus() -> Bus:
|
||||
return Bus(
|
||||
id="bus_main",
|
||||
name="Bus principal",
|
||||
protocol=Protocol.MODBUS_RTU,
|
||||
physical_port="COM3",
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
def sample_topology(sample_bus: Bus, sample_card: CardInstance) -> Topology:
|
||||
return Topology(buses=[sample_bus], cards=[sample_card])
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
def sample_equipment() -> Equipment:
|
||||
return Equipment(
|
||||
id="eq_me_port",
|
||||
model_ref="mtu_12v_2000_m96",
|
||||
tag_prefix="ME_PORT",
|
||||
display_name="Motor babor",
|
||||
location=ShipCoord(x_pp=6.0, y_cl=-0.9, z_bl=1.2),
|
||||
deck_id="main",
|
||||
system_id=SystemId.MAIN_ENGINE,
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
def sample_tag(sample_equipment: Equipment) -> Tag:
|
||||
return Tag(
|
||||
id=f"{sample_equipment.tag_prefix}.OIL_PRESS",
|
||||
equipment_id=sample_equipment.id,
|
||||
description="Presión aceite",
|
||||
unit_si=UnitSI.BAR,
|
||||
range_normal_min=3.5,
|
||||
range_normal_max=6.5,
|
||||
alarms=[
|
||||
AlarmConfig(
|
||||
id=f"{sample_equipment.tag_prefix}.OIL_PRESS.LOW",
|
||||
threshold=1.5,
|
||||
operator="<",
|
||||
priority=AlarmPriority.EMERGENCY,
|
||||
hysteresis=0.2,
|
||||
)
|
||||
],
|
||||
protocol=Protocol.MODBUS_RTU,
|
||||
physical_binding=TagBinding(
|
||||
card_id="card_001",
|
||||
channel_type=ChannelType.AI,
|
||||
channel_number=1,
|
||||
signal_type=SignalType.SIG_4_20_MA,
|
||||
scaling=Scaling(raw_min=4.0, raw_max=20.0, eng_min=0.0, eng_max=10.0),
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
def sample_project(
|
||||
minimal_vessel: Vessel,
|
||||
sample_equipment: Equipment,
|
||||
sample_tag: Tag,
|
||||
sample_topology: Topology,
|
||||
) -> Project:
|
||||
return Project(
|
||||
id="test_project",
|
||||
name="Test project",
|
||||
customer="Pytest",
|
||||
vessel=minimal_vessel,
|
||||
systems_enabled=[SystemId.MAIN_ENGINE],
|
||||
equipment=[sample_equipment],
|
||||
tags=[sample_tag],
|
||||
topology=sample_topology,
|
||||
)
|
||||
Reference in New Issue
Block a user