- 박스암거 명세(design_structure_box) — 본체 규격 2.0×2.0 · 3.0×3.0 · 사용자 입력(가로 × 세로 숫자 칸) · 유입 · 유출 구조 없음 · 날개벽 · 흙막이 · 컨테이너마다 구조물 조합 잇기(gboxbody · gboxin · gboxout) - 저장 키 = 옛 키 그대로(body_width_m · body_height_m · wing_in · wing_out) · 규격 칸은 저장 안 함(폭 · 높이로 되찾음) · 옛 「있음」 = 날개벽 · 옛 날개벽 치수는 화면에서 빼고 지난 정의 값 - 명세 등록(STRUCTURE_SPECS) · 배관 시험 헬퍼가 같은 폴더 명세를 옮겨 읽음 - B06 날개벽 설치 판정 한 곳(wingInstalled) — 흙막이 = 날개벽 안 세움 · 저장 글을 있음/없음으로 안 덮음 · 날개벽 조정 행은 명세 유입 · 유출 칸으로 - 정의 판 7 — box_culvert 이름 표 · 그룹 셋 · wing_in/out 선택지 · 판 6 이력 보관 - 시험 test_52_structure_spec_box · 레지스트리 · 새 구조물 기본값 기대값 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01W4uKaV4ZBhsJN4GHG7yRj4
90 lines
3.7 KiB
JavaScript
90 lines
3.7 KiB
JavaScript
/* 구조물 명세 공용 틀 · 배관 명세 단위검증 헬퍼(PLAN 52-1) — `design_structure_spec.ts` ·
|
|
* `design_structure_pipe.ts` 를 그 자리에서 트랜스파일해 Node 로 돌림(꼴만 import). 결과 = JSON 한 벌.
|
|
* 인자 `names` 면 배관 이름 표(정의 `종류.pipe.이름`)만 냄.
|
|
*/
|
|
const fs = require("fs");
|
|
const path = require("path");
|
|
const ts = require(path.join(__dirname, "..", "..", "config", "node_modules", "typescript"));
|
|
|
|
const ROOT = path.join(__dirname, "..", "..");
|
|
const load = (file, deps = {}) => {
|
|
const src = fs.readFileSync(path.join(ROOT, "A00_Common", "design", file), "utf8");
|
|
const js = ts.transpileModule(src, {
|
|
compilerOptions: { module: ts.ModuleKind.CommonJS, target: ts.ScriptTarget.ES2020 },
|
|
}).outputText;
|
|
const box = { exports: {} };
|
|
// 같은 폴더 명세(./design_structure_*)는 같은 식으로 옮겨 읽음
|
|
const need = (m) => deps[m] ?? (m.startsWith("./") ? load(`${m.slice(2)}.ts`) : require(m));
|
|
new Function("exports", "module", "require", js)(box.exports, box, need);
|
|
return box.exports;
|
|
};
|
|
const s = load("design_structure_spec.ts");
|
|
const { PIPE_SPEC } = load("design_structure_pipe.ts");
|
|
|
|
if (process.argv[2] === "names") {
|
|
process.stdout.write(JSON.stringify(s.nameTable(PIPE_SPEC)));
|
|
process.exit(0);
|
|
}
|
|
|
|
const old = {
|
|
pipe_kind: "흄관",
|
|
wing_wall_type: "A-TYPE",
|
|
pipe_diameter_mm: 1000,
|
|
inlet_type: "집수정",
|
|
inlet_structure: "L",
|
|
inlet_basin_length_m: 2,
|
|
inlet_basin_before_m: 1,
|
|
inlet_basin_after_m: 1,
|
|
outlet_type: "기슭막이",
|
|
outlet_revet_form: "돌쌓기(메)",
|
|
outlet_revet_length_m: 10,
|
|
outlet_revet_height_m: 2.5,
|
|
soil_add_2_structure: "기슭막이",
|
|
soil_add_2_form: "바자",
|
|
soil_add_5_length_m: 4,
|
|
chute_add_1_structure: "도수로",
|
|
};
|
|
const state = s.readState(PIPE_SPEC, old);
|
|
const back = s.writeOptions(PIPE_SPEC, state);
|
|
// 흙막이로 바꿈 → 갈래 키가 기슭막이 쪽 · also(inlet_structure revet)
|
|
const soil = JSON.parse(JSON.stringify(state));
|
|
soil.inlet[0].structure = "기슭막이";
|
|
soil.inlet[0].form = "콘크리트";
|
|
soil.inlet[0].length = "6";
|
|
const soilOut = s.writeOptions(PIPE_SPEC, soil);
|
|
const inlet = PIPE_SPEC.containers.find((c) => c.id === "inlet");
|
|
const form = inlet.items.find((i) => i.id === "form");
|
|
const keys = s.specKeys(PIPE_SPEC);
|
|
|
|
const out = {
|
|
containers: PIPE_SPEC.containers.map((c) => [c.id, c.title, c.required]),
|
|
state,
|
|
back,
|
|
soilOut,
|
|
formBasin: s.choicesOf(form, { structure: "집수정" }).map((c) => c.label),
|
|
formSoil: s.choicesOf(form, { structure: "기슭막이" }).map((c) => c.label),
|
|
formNone: s.branchOf(form, {}),
|
|
outletForms: s
|
|
.choicesOf(
|
|
PIPE_SPEC.containers.find((c) => c.id === "outlet").items.find((i) => i.id === "form"),
|
|
{ structure: "기슭막이" },
|
|
)
|
|
.map((c) => c.label),
|
|
keys,
|
|
links: PIPE_SPEC.containers.map((c) => s.linkOf(c, 2)),
|
|
split: {
|
|
lengthFromSides: s.solveSplit({ length: "10", before: "3", after: "4" }, ["after", "before"]),
|
|
beforeFromLength: s.solveSplit({ length: "10", before: "3", after: "4" }, ["after", "length"]),
|
|
defaultKeepsLength: s.solveSplit({ length: "10", before: "3", after: "" }, ["before"]),
|
|
blankKept: s.solveSplit({ length: "", before: "3", after: "4" }, ["before", "length"]),
|
|
clamp: s.solveSplit({ length: "2", before: "", after: "5" }, ["after", "length"]),
|
|
},
|
|
names: {
|
|
renamed: s.itemLabel(inlet, form, { "inlet.form": "모양" }),
|
|
title: s.containerTitle(inlet, {}, "그룹 이름"),
|
|
titleOwn: s.containerTitle(inlet, { inlet: "유입 보호" }, "그룹 이름"),
|
|
choice: s.choiceLabel(inlet, form, { value: "U", label: "ㄷ형" }, {}),
|
|
},
|
|
};
|
|
process.stdout.write(JSON.stringify(out));
|