You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

77 lines
2.2 KiB

/**
* 构建AGV性能数据
* @param rows 行数
* @param cols 列数
*/
export function buildAgvPerformanceData(rows, cols) {
const spacingX = 1.25 // X轴间距
const spacingZ = 1.25 // Y轴间距
// 创建一个二维数组来存储点阵数据
const data = new Map()
for (let row = 0; row < rows; row++) {
for (let col = 0; col < cols; col++) {
// 计算每个点的坐标
const node = createAgvNode(row, col)
node.tf[0][0] = row * spacingX
node.tf[0][2] = col * spacingZ
data.set(node.id, node)
// 与前一个点进行连线
if (row > 0 && col > 0) {
const preXNode = data.get('wp_' + (row - 1) + '_' + (col))
node.dt.center.push(preXNode.id)
preXNode.dt.center.push(node.id)
const preYNode = data.get('wp_' + (row) + '_' + (col - 1))
node.dt.center.push(preYNode.id)
preYNode.dt.center.push(node.id)
} else if (row > 0) {
const preXNode = data.get('wp_' + (row - 1) + '_' + (col))
node.dt.center.push(preXNode.id)
preXNode.dt.center.push(node.id)
} else if (col > 0) {
const preYNode = data.get('wp_' + (row) + '_' + (col - 1))
node.dt.center.push(preYNode.id)
preYNode.dt.center.push(node.id)
}
}
}
data.get('wp_0_0').dt.center.push('wp_0_' + (cols - 1))
data.get('wp_0_' + (cols - 1)).dt.center.push('wp_0_0')
data.get('wp_' + (rows - 1) + '_0').dt.center.push('wp_' + (rows - 1) + '_' + (cols - 1))
data.get('wp_' + (rows - 1) + '_' + (cols - 1)).dt.center.push('wp_' + (rows - 1) + '_0')
data.get('wp_' + (rows - 1) + '_0').dt.center.push('wp_0_0')
data.get('wp_0_0').dt.center.push('wp_' + (rows - 1) + '_0')
data.get('wp_' + (rows - 1) + '_' + (cols - 1)).dt.center.push('wp_0_' + (cols - 1))
data.get('wp_0_' + (cols - 1)).dt.center.push('wp_' + (rows - 1) + '_' + (cols - 1))
return Array.from(data.values())
}
/**
*
* @returns {ItemJson}
*/
export function createAgvNode(x, z) {
return {
id: 'wp_' + x + '_' + z,
t: 'measure',
tf: [
[x, 0.01, z],
[90, 0, 0],
[0.25, 0.25, 0.1]
],
dt: {
in: [],
out: [],
center: []
}
}
}