Capítulos del curso
Formación · Curso 9. Fundamentos de SysML v2 · Capítulo 9.7 de 8
9.7 Restricciones y cálculos 4:26
Escribir restricciones y cálculos, comprobar los valores del sedán con unidades y marcar los valores abiertos.
Muestra Holarch 2.22.
Lo que aprenderá
- Escribir una definición de restricción y una definición de cálculo con parámetros
- Vincular los parámetros de un uso de restricción a valores del modelo
- Ver una restricción cumplirse y fallar en una Vista paramétrica, y comprobar todas las restricciones con Resolver todo
- Marcar los valores abiertos con metadatos TBD y TBR y encontrarlos en el registro TBD/TBR
- Agregar la masa de una parte en Presupuestos y TPM
Escriba restricciones y cálculos de SysML v2 en Holarch, siguiendo el tutorial de SysML v2 Constraints and Calculations en un pequeño proyecto Hybrid Car: una definición de restricción y un cálculo, un uso de restricción vinculado a los valores del sedán, una Vista paramétrica donde la comprobación falla y se cumple, Resolver todo, un caso de análisis, valores TBD y TBR con su registro, y una agregación de masa en Presupuestos. SysML es una marca registrada de Object Management Group, Inc.
Archivos de proyecto
- Proyecto terminado (.holarch.json; Gestionar proyectos → Archivos de proyecto ▾ → Importar proyecto (.json)…)
El vídeo se reproduce desde holarch.app; consulte la Política de privacidad.
Práctica
Hágalo usted mismo en Holarch, en el proyecto de demostración Hybrid Car (SysML v2).
- Abra su proyecto de demostración Hybrid Car (créelo si hace falta: Gestionar proyectos → Archivos de proyecto ▾ → Nuevo proyecto de demostración → Hybrid Car (SysML v2)), abra Modelo → Editor y el paquete
VehicleRequirements. - Después de
constraint def SpeedLimit, añadaconstraint sedanBatteryCheck : MassLimit { in mass = fleet.sedan.powertrain.battery.mass; in limit = 50 [kg]; }. - En la página Diagramas, haga clic en + Nuevo diagrama, elija Vista paramétrica y
VehicleRequirementsen Muestra, y haga clic en Crear. La nueva comprobación se cumple: 48 kg está dentro de 50 kg. - En el paquete
Vehicles, cambie la masa de la batería del sedán a52 [kg]; la vista muestra que la comprobación falla. Pulse ⌘Z / Ctrl+Z y después haga clic en Resolver todo para volver a comprobar todas las restricciones. - En
requirement def <'VR-2'> Acceleration, sustituyaattribute zeroToHundred : TimeValue;porattribute zeroToHundred : TimeValue { @TBD { owner = "Test lead"; rationale = "The test track is not booked yet."; } }. Abra Necesidades y requisitos → TBD/TBR y busque el requisito con su responsable. - Abra Arquitectura → Presupuestos y TPM, haga clic en Seleccionar parte raíz… y elija
sedan. En Magnitud, elija Mass y busque los 48 kg de la batería.
Habrá terminado cuando sedanBatteryCheck muestre Aprobado en la Vista paramétrica y el registro TBD/TBR liste el requisito Acceleration con el responsable Test lead.
Compruebe lo aprendido
- ¿Qué diferencia hay entre una
constraint defy unacalc def? - Una restricción en la Vista paramétrica muestra Requiere datos. ¿Qué falta?
- ¿Por qué marcar un valor abierto con
#TBDo@TBD { … }en lugar de escribir TBD como valor? - ¿Qué aporta un caso de análisis a un cálculo?
Mostrar las respuestas
¿Qué diferencia hay entre una
constraint defy unacalc def?Una definición de restricción expresa una condición sobre sus parámetros que se cumple o no, como
mass <= limit. Una definición de cálculo calcula y devuelve un valor, comoreturn ratio = power / mass;.Una restricción en la Vista paramétrica muestra Requiere datos. ¿Qué falta?
Un parámetro aún no tiene valor. Vincule cada parámetro a un valor, por ejemplo
in mass = fleet.sedan.curbMass;.¿Por qué marcar un valor abierto con
#TBDo@TBD { … }en lugar de escribir TBD como valor?TBDen lugar de un valor no es SysML válido. Los metadatos del paqueteHolarchMetadatade Holarch mantienen el texto válido; TBD y TBR especializan los metadatos estándarStatusInfo, de modo que otras herramientas de SysML v2 los leen como anotaciones de estado.¿Qué aporta un caso de análisis a un cálculo?
Aplica el cálculo a un sujeto, como el sedán, devuelve el resultado y tiene un objetivo cuya restricción require Holarch evalúa como cualquier otra restricción.
Más información
- Tutorial: Constraints and Calculations (tutoriales de SysML v2)
- Docs: Análisis en SysML v2, Comprobar restricciones en una Vista paramétrica
- Docs: Análisis en SysML v2, Resolver valores
- Docs: Requisitos en proyectos SysML v2, Marcar un valor como TBD o TBR
- Docs: Análisis en SysML v2, Agregar un presupuesto
- Ayuda: Presupuestos y TPM en proyectos SysML v2
Transcripción
Mostrar la transcripción (narración y lo que aparece en pantalla)
Introduction
Chapter seven: constraints and calculations. They turn the model's values into checks and results that Holarch evaluates with units.
In this chapter you write a constraint and a calculation, bind a check to the sedan's values, see it fail and pass in a Parametric View, run an analysis case, and mark open values.
Start the tutorial
Start the tutorial Constraints and Calculations from Project Files, Start a Tutorial. Its starter project holds the sedan with its engine and battery values, and two targets: the maximum curb mass and the minimum power to weight.
On screen: Project Files ▾ → Start a Tutorial… → SysML v2: Constraints and Calculations → Start; Model → Editor.
Constraints and calculations
A constraint definition states a condition over its parameters. After the constraints comment, write the mass limit: the mass is at most the limit.
On screen: After // ---- Constraints and calculations ----: constraint def MassLimit.
Below it, a calculation: power to weight divides the power by the mass, and returns the ratio.
On screen: Below it: calc def PowerToWeight.
A constraint usage binds each parameter to a value: here, the sedan's curb mass and the maximum curb mass.
On screen: Below it: constraint sedanMassCheck : MassLimit with bound inputs.
The Parametric View
Open the Diagrams page, click New Diagram, and choose Parametric View. Choose the vehicle analysis package under Shows, and click Create.
On screen: Diagrams → + New Diagram → Parametric View; Shows: VehicleAnalysis; Create.
The check shows its expression, with its parameters bound to the values. Fifteen hundred eighty kilograms is within sixteen hundred fifty, so it passes.
On screen: The mass check: pass.
In the Editor, change the sedan's curb mass to seventeen hundred kilograms. Back in the Parametric View, the mass check now fails.
On screen: Model → Editor: curbMass 1580 → 1700; Diagrams → the Parametric View: fail.
Change it back to fifteen hundred eighty in the Editor. In the view, Solve All checks every constraint again, with units.
On screen: Model → Editor: 1700 → 1580; the view → Solve All → Pass; Close.
An analysis case
An analysis case computes a result for a subject. At the end of the package, add the power to weight analysis, and apply it to the sedan. Its objective requires at least the minimum, and the checker evaluates it like any constraint.
On screen: Model → Editor; after sedanMassCheck: analysis def PowerToWeightAnalysis; analysis sedanPowerToWeight.
TBD and TBR
Values that are still open get a mark. First import Holarch's metadata package after the other imports.
On screen: After the imports: private import HolarchMetadata::*;
Then add a charge time requirement. TBR marks the time limit to be reviewed, and TBD marks the charger power to be determined, with an owner, a due date and a rationale. Both come from Holarch's metadata library and specialize the standard status metadata, so other SysML v2 tools see them as status annotations.
On screen: At the end: requirement def <'VR-5'> ChargeTime with #TBR and @TBD.
Open Needs and Requirements, then TBD/TBR. The charge time is listed with the owner and the due date from its metadata. The register only lists them: to change them, edit the metadata in the Editor.
On screen: Needs & Requirements → TBD/TBR; the ChargeTime row with owner and due date.
Budgets
Last, open Architecture, then Budgets, and select the sedan as the root part. The quantity Mass reads each part's mass attribute with its unit: the battery shows the sedan's own forty eight kilograms.
On screen: Architecture → Budgets & TPMs → Select Root Part… → sedan; the battery 48 kg.
Recap
Every step is ticked off. Click Mark as Done.
On screen: Step panel → Mark as Done.
Let's recap. You wrote a constraint and a calculation, bound a check to the sedan's values, saw it fail and pass in a Parametric View, ran an analysis case, marked open values for the register, and rolled up the mass.
Next, variants and configurations describe a product line.