diff --git a/M02_MasterTemplete/DataFlow/M02_DF_Diagram_Parts.ts b/M02_MasterTemplete/DataFlow/M02_DF_Diagram_Parts.ts index c96fe7fe4..cf0616712 100644 --- a/M02_MasterTemplete/DataFlow/M02_DF_Diagram_Parts.ts +++ b/M02_MasterTemplete/DataFlow/M02_DF_Diagram_Parts.ts @@ -322,8 +322,9 @@ export function restParts( for (const b of lg.boxes) { const incoming = lg.links.filter((l) => l.to.box === b.id); const allRest = incoming.length > 0 && incoming.every((l) => links.has(l.id)); - const outs = Object.values(values[b.id] ?? {}); - const hit = rests.some((k) => !k.link && k.box === b.id); + // 내보내는 알약 값만(들어온 값은 빼고) · 쉼이 그 상자에 걸렸나(Eval 쉼 줄은 link 가 늘 있음) + const outs = portsOut(b).map((p) => values[b.id]?.[p.name]); + const hit = rests.some((k) => k.box === b.id); if (allRest || (hit && outs.every(empty))) boxes.add(b.id); } return { links, pills, boxes }; diff --git a/resources/tester/test_m02_df_diagram_parts.py b/resources/tester/test_m02_df_diagram_parts.py index f5842893e..ae8248233 100644 --- a/resources/tester/test_m02_df_diagram_parts.py +++ b/resources/tester/test_m02_df_diagram_parts.py @@ -304,3 +304,103 @@ def test_쉼은_일부면_선과_받는_알약만_모두면_상자도(): assert every["boxes"] == ["f"] # 상자에 걸린 쉼 — 내보내는 값이 있으면 안 흐림 · 모두 빈 값이면 흐림 assert filled["boxes"] == [] and empty["boxes"] == ["m"] + + +def test_지반_토사_쉼_흐림은_브레이커로_깨기_하나(): + def fn(id_, name, ins, out): + return { + "id": id_, + "kind": "function", + "name": name, + "color": "", + "unit": "-", + "x": 0, + "y": 0, + "func": { + "sheet": {}, + "inputs": [{"port": p, "cell": f"B{i + 1}"} for i, p in enumerate(ins)], + "variables": [], + "output": {"cell": "B9", "name": out, "unit": "원"}, + }, + } + + gate = {"kind": "gate", "from": port("ig", "지반"), "op": "=", "value": "암"} + ground = { + "key": None, + "name": "지반", + "resultUnit": "원/㎥", + "userElements": [], + "boxes": [ + { + "id": "ig", + "kind": "input", + "name": "지반 · 굴착량", + "color": "", + "unit": "-", + "x": 0, + "y": 0, + "input": { + "mode": "variable", + "elements": [], + "variables": [ + {"name": "지반", "type": "choice", "unit": "-", "example": "토사"}, + {"name": "굴착량", "type": "number", "unit": "㎥", "example": 1}, + ], + }, + }, + fn("exc", "굴삭기로 파기", ["굴착량", "시간당 경비"], "굴삭기 경비"), + fn("brk", "브레이커로 깨기", ["굴착량", "시간당 경비"], "브레이커 경비"), + fn("sum", "1㎥ 경비", ["굴삭기 경비", "브레이커 경비", "굴착량"], "1㎥ 경비"), + { + "id": "out", + "kind": "output", + "name": "경비", + "color": "", + "unit": "원", + "x": 0, + "y": 0, + "output": {"cost": "경비", "unit": "원"}, + }, + ], + "links": [ + { + "id": "l1", + "from": port("ig", "굴착량"), + "to": port("exc", "굴착량"), + "rule": {**gate, "op": "≠"}, + }, + {"id": "l2", "from": port("ig", "굴착량"), "to": port("brk", "굴착량"), "rule": gate}, + {"id": "l5", "from": port("exc", "굴삭기 경비"), "to": port("sum", "굴삭기 경비")}, + {"id": "l6", "from": port("brk", "브레이커 경비"), "to": port("sum", "브레이커 경비")}, + {"id": "l7", "from": port("ig", "굴착량"), "to": port("sum", "굴착량")}, + {"id": "l8", "from": port("sum", "1㎥ 경비"), "to": port("out", "값")}, + ], + } + # Eval 쉼 줄은 link 가 늘 있음 — 조건 선 l2(받는 상자 브레이커) · 빈 값이 흘러간 l6(받는 상자 1㎥ 경비) + rests = [ + { + "kind": "통과 안 됨", + "level": "쉼", + "box": "brk", + "port": "굴착량", + "link": "l2", + "text": "암이 아님", + }, + { + "kind": "통과 안 됨", + "level": "쉼", + "box": "sum", + "port": "브레이커 경비", + "link": "l6", + "text": "쉼", + }, + ] + values = { + "brk": {"시간당 경비": 80000, "굴착량": None, "브레이커 경비": None}, + "sum": {"굴삭기 경비": 2000, "브레이커 경비": None, "굴착량": 1, "1㎥ 경비": 2000}, + "out": {"값": 2000}, + } + [got] = run([{"op": "restParts", "lg": ground, "rests": rests, "values": values}]) + assert got["boxes"] == ["brk"] + assert got["links"] == ["l2", "l6"] + assert got["pills"] == ["brk|굴착량", "sum|브레이커 경비"]