feat: 添加绝缘子串长计算与显示
This commit is contained in:
@@ -46,6 +46,8 @@ const props = defineProps<{
|
||||
gcX: number[] // 导、地线水平坐标 [地线, 导线1, ...]
|
||||
hCSag: number // 导线弧垂
|
||||
hGSag: number // 地线弧垂
|
||||
stringCLen: number // 导线串长
|
||||
stringGLen: number // 地线串长
|
||||
groundAngels: number[] // 地面倾角
|
||||
}>()
|
||||
|
||||
@@ -61,13 +63,36 @@ const margin = { top: 40, right: 40, bottom: 60, left: 60 }
|
||||
const plotWidth = canvasWidth - margin.left - margin.right
|
||||
const plotHeight = canvasHeight - margin.top - margin.bottom
|
||||
|
||||
// 计算实际导地线高度(考虑弧垂和串长)
|
||||
const calculateActualHeights = () => {
|
||||
const hArmNums = props.hArm.map(v => Number(v))
|
||||
const hGSagNum = Number(props.hGSag)
|
||||
const hCSagNum = Number(props.hCSag)
|
||||
const stringGLenNum = Number(props.stringGLen)
|
||||
const stringCLenNum = Number(props.stringCLen)
|
||||
|
||||
// 地线实际高度 = 挂点高度 - 地线串长 - 地线弧垂 * 2/3
|
||||
// 导线实际高度 = 挂点高度 - 导线串长 - 导线弧垂 * 2/3
|
||||
return hArmNums.map((h, index) => {
|
||||
if (index === 0) {
|
||||
// 地线
|
||||
return h - stringGLenNum - hGSagNum * 2 / 3
|
||||
} else {
|
||||
// 导线
|
||||
return h - stringCLenNum - hCSagNum * 2 / 3
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 计算坐标范围
|
||||
const calculateRange = () => {
|
||||
// 确保将字符串转换为数字
|
||||
const hArmNums = props.hArm.map(v => Number(v))
|
||||
const gcXNums = props.gcX.map(v => Number(v))
|
||||
const actualHeights = calculateActualHeights()
|
||||
|
||||
const allHeights = [...hArmNums, 0] // 包含地面
|
||||
// 包含挂点高度和实际高度
|
||||
const allHeights = [...hArmNums, ...actualHeights, 0]
|
||||
const allX = [...gcXNums, -gcXNums[0] * 0.5, gcXNums[0] * 1.5] // 扩展水平范围
|
||||
|
||||
const yMin = 0
|
||||
@@ -191,20 +216,37 @@ const draw = () => {
|
||||
const drawWirePoints = (range: ReturnType<typeof calculateRange>) => {
|
||||
if (!ctx) return
|
||||
const c = ctx
|
||||
const actualHeights = calculateActualHeights()
|
||||
|
||||
props.hArm.forEach((height, index) => {
|
||||
// 确保将字符串转换为数字
|
||||
const heightNum = Number(height)
|
||||
const actualHeight = actualHeights[index]
|
||||
const wireX = Number(props.gcX[index]) || 0
|
||||
const isGroundWire = index === 0
|
||||
|
||||
const canvasX = toCanvasX(wireX, range)
|
||||
const canvasY = toCanvasY(heightNum, range)
|
||||
const actualCanvasY = toCanvasY(actualHeight, range)
|
||||
|
||||
// 绘制挂点标记
|
||||
// 绘制从挂点到实际位置的虚线(绝缘子串 + 弧垂)
|
||||
c.strokeStyle = isGroundWire ? '#4CAF50' : '#FF9800'
|
||||
c.lineWidth = 2
|
||||
c.setLineDash([4, 4])
|
||||
c.beginPath()
|
||||
c.moveTo(canvasX, canvasY)
|
||||
c.lineTo(canvasX, actualCanvasY)
|
||||
c.stroke()
|
||||
c.setLineDash([])
|
||||
|
||||
// 绘制挂点标记(方形,表示杆塔挂点)
|
||||
c.fillStyle = '#666'
|
||||
c.fillRect(canvasX - 5, canvasY - 5, 10, 10)
|
||||
|
||||
// 绘制实际导地线位置(圆形)
|
||||
c.fillStyle = isGroundWire ? '#4CAF50' : '#FF9800'
|
||||
c.beginPath()
|
||||
c.arc(canvasX, canvasY, 8, 0, Math.PI * 2)
|
||||
c.arc(canvasX, actualCanvasY, 8, 0, Math.PI * 2)
|
||||
c.fill()
|
||||
|
||||
// 标注信息
|
||||
@@ -213,10 +255,10 @@ const drawWirePoints = (range: ReturnType<typeof calculateRange>) => {
|
||||
c.textAlign = 'left'
|
||||
|
||||
const labelX = canvasX + 12
|
||||
const labelY = canvasY - 8
|
||||
const labelY = actualCanvasY - 8
|
||||
|
||||
const wireName = isGroundWire ? '地线' : `导线${index}`
|
||||
const heightLabel = `H=${heightNum}m`
|
||||
const heightLabel = `H=${actualHeight.toFixed(1)}m`
|
||||
const xLabel = `X=${wireX}m`
|
||||
|
||||
c.fillText(wireName, labelX, labelY)
|
||||
@@ -265,7 +307,7 @@ const drawGround = (range: ReturnType<typeof calculateRange>) => {
|
||||
|
||||
// 监听参数变化
|
||||
watch(
|
||||
() => [props.hArm, props.gcX, props.hCSag, props.hGSag, props.groundAngels],
|
||||
() => [props.hArm, props.gcX, props.hCSag, props.hGSag, props.stringCLen, props.stringGLen, props.groundAngels],
|
||||
() => {
|
||||
draw()
|
||||
},
|
||||
|
||||
@@ -210,6 +210,8 @@
|
||||
:gc-x="params.parameter.gc_x"
|
||||
:h-c-sag="params.parameter.h_c_sag"
|
||||
:h-g-sag="params.parameter.h_g_sag"
|
||||
:string-c-len="params.parameter.string_c_len"
|
||||
:string-g-len="params.parameter.string_g_len"
|
||||
:ground-angels="params.parameter.ground_angels"
|
||||
/>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user