Scripting#
Classes for Rhai scripting integration and criteria verification.
Script Engine#
- class ScriptEngine#
Rhai script execution engine.
- run_script_file(path, context)#
Run a Rhai script from file.
- Parameters:
path (str) – Path to .rhai script file
context (CriteriaContext) – Data context for the script
- Returns:
Verification result
- Return type:
- Raises:
ValueError – If script execution fails
- run_script(script, context)#
Run a Rhai script from string.
- Parameters:
script (str) – Rhai script content
context (CriteriaContext) – Data context for the script
- Returns:
Verification result
- Return type:
Criteria Context#
- class CriteriaContext#
Context for Rhai scripts, wrapping stability results.
- static from_result(result, vessel_name, loading_condition)#
Create a context from a CompleteStabilityResult.
- Parameters:
result (CompleteStabilityResult) – The stability calculation result
vessel_name (str) – Name of the vessel
loading_condition (str) – Description of loading condition
- Return type:
- set_param(key, value)#
Set a parameter accessible to the script.
- get_first_flooding_angle()#
Get the first angle where downflooding occurs.
- Returns:
Angle in degrees or None
- Return type:
Optional[float]
- find_equilibrium_angle(heeling_arm)#
Find the first stable equilibrium angle (where GZ = heeling_arm).
Criteria Result#
- class CriteriaResult#
Result of a criteria verification script.
- criteria: list[CriterionResult]#
List of individual criterion results.