将CHEJIA车架夹具默认扫描方案关联到四站逐层工具Z90度Y退50低位版,保留其他夹具和已冻结任务。 归档已发布的大车架304/308站点调整及长边X余量50毫米维护入口和核对说明。 JDK17编译及6项默认映射检查通过,维护脚本语法和差异检查通过;不包含手持功能运行代码。
40 lines
2.9 KiB
JavaScript
40 lines
2.9 KiB
JavaScript
import fs from 'node:fs'
|
||
import assert from 'node:assert/strict'
|
||
|
||
// Derive only the large-frame draft. Shared planners and other methods stay unchanged.
|
||
const [sourcePath, outputPath] = process.argv.slice(2)
|
||
if (!sourcePath || !outputPath) throw new Error('Usage: node build_large_frame_long_x50.mjs <large-frame-V2-snapshot.json> <flow.json>')
|
||
const source = JSON.parse(fs.readFileSync(sourcePath, 'utf8').replace(/^\uFEFF/, ''))
|
||
assert.equal(source.published.id, '2c8b55ec4fbe10dff0db85c4ff4b4128')
|
||
const original = JSON.parse(source.published.flowData), graph = structuredClone(original)
|
||
const geometryId = 'b5e44f7d775941b3b9e8b993b97eb319'
|
||
const codeOf = g => g.nodes.find(n => n.id === geometryId)?.properties.nodeParams.find(p => p.name === 'code')
|
||
const code = codeOf(graph)
|
||
assert(code && typeof code.input === 'string')
|
||
const before = " var firstX = computed(length / 2 + 100, station + '正端X');\n var lastX = computed(-length / 2 - 100, station + '负端X');"
|
||
const after = " var xMarginMm = station === 'LM404' || station === 'LM408' ? 50 : 100;\n var firstX = computed(length / 2 + xMarginMm, station + '正端X');\n var lastX = computed(-length / 2 - xMarginMm, station + '负端X');"
|
||
assert.equal(code.input.split(before).length, 2, 'Review changed geometry source')
|
||
code.input = code.input.replace(before, after)
|
||
const geometry = g => g.nodes.find(n => n.id === geometryId).properties
|
||
assert(geometry(graph).desc.startsWith('各站X边界±(A/2+100mm),'))
|
||
geometry(graph).desc = geometry(graph).desc.replace('各站X边界±(A/2+100mm),', 'LM304/308的X边界±(A/2+50mm),LM402/406仍为±(A/2+100mm),')
|
||
const inputs = g => g.nodes.find(n => n.type === 'start').properties.inputParams
|
||
for (const key of ['LM404_length_mm', 'LM408_length_mm']) {
|
||
const input = inputs(graph).find(p => p.name === key)
|
||
assert(input?.desc.includes('正端X=A/2+100,负端X=-A/2-100'))
|
||
input.desc = input.desc.replace('正端X=A/2+100,负端X=-A/2-100', '正端X=A/2+50,负端X=-A/2-50')
|
||
}
|
||
const stations = graph.nodes.filter(n => n.properties?.action === 'AGV_MOVE_TO_STATION')
|
||
.map(n => n.properties.nodeParams.find(p => p.name === 'stationId').input)
|
||
assert.deepEqual(stations, ['LM402', 'LM304', 'LM406', 'LM308'])
|
||
const restored = structuredClone(graph)
|
||
codeOf(restored).input = codeOf(original).input
|
||
geometry(restored).desc = geometry(original).desc
|
||
for (const key of ['LM404_length_mm', 'LM408_length_mm'])
|
||
inputs(restored).find(p => p.name === key).desc = inputs(original).find(p => p.name === key).desc
|
||
assert.deepEqual(restored, original, 'Unexpected change outside long-side X margin and descriptions')
|
||
fs.writeFileSync(outputPath, JSON.stringify(graph, null, 2))
|
||
console.log(JSON.stringify({ name: '大车架扫描路径', nodes: graph.nodes.length, stations,
|
||
xMarginMm: { LM402: 100, LM304: 50, LM406: 100, LM308: 50 },
|
||
inputKeysAndValuesUnchanged: true, published: false, deviceCommandsSent: 0 }))
|