1"""A probe clipped to a line reads the line.
3pid-designer clips an RTD, a TC or a load cell to a tank, a valve *or a line*
4(its ``attach.ts``): on a line ``attachedTo`` is the line's id and
5``attachedAt`` the fraction of its drawn length from the source end. The twin
6resolved a clip only against symbols, so a probe on a line read nothing and was
7reported "not clipped to anything" -- and with the cart cut (``ignore_gse``)
8it was dropped from the vehicle without a word.
11from __future__
import annotations
15from pathlib
import Path
24DRAWING = Path(__file__).resolve().parent /
"fixtures" /
"le4_rocket_and_gse.json"
25LINE =
"node_38-node_36"
30 payload = copy.deepcopy(json.loads(DRAWING.read_text()))
31 for node
in payload[
"nodes"]:
32 if node[
"id"] == PROBE:
33 node[
"data"][
"attachedTo"] = LINE
34 node[
"data"].pop(
"attachedAt",
None)
36 node[
"data"][
"attachedAt"] = at
41 return next((i.node
for i
in built.instruments
if i.id == PROBE),
None)
44@pytest.mark.parametrize(("at", "end"), [(0.2,
"upstream"), (0.8,
"downstream")])
48 built = build_network(read_diagram(
_on_the_line(at), name=
"LE4"))
49 line = built.network.branches[LINE]
50 assert _reads(built) == getattr(line, end)
51 assert not [w
for w
in built.warnings
if "OX-RTD-1" in w], built.warnings
55 """Saved before ``attachedAt`` existed: drawn at the line's middle."""
56 built = build_network(read_diagram(
_on_the_line(
None), name=
"LE4"))
58 built.network.branches[LINE].upstream,
59 built.network.branches[LINE].downstream,
65 vehicle = vehicle_ids(diagram)
66 assert vehicle
is not None and PROBE
in vehicle
67 model = assemble_model(diagram, diagram_id=
"le4", vehicle_only=
True)
68 assert any(n.id == PROBE
for n
in model.diagram.nodes)
69 assert _reads(model.built)
is not None
70 assert not [w
for w
in model.report.warnings
if "OX-RTD-1" in w]
74 built = build_network(read_diagram(json.loads(DRAWING.read_text()), name=
"LE4"))
75 tank = built.tanks[
"node_22"]
76 assert _reads(built)
in {tank.ullage, tank.outlet}
None test_a_probe_on_a_vehicle_line_stays_with_the_vehicle()
None test_a_probe_on_a_line_with_no_position_reads_it()
str|None _reads(Any built)
None test_a_probe_on_a_line_reads_the_end_it_is_clipped_nearer(float at, str end)
Any _on_the_line(float|None at)
None test_a_probe_on_a_symbol_reads_as_before()