#
vincentlu
2025-02-28 c3082458b464b07a571888a94a6070305c9798de
zy-acs-flow/src/map/tool.js
@@ -652,6 +652,56 @@
    }
}
export function createAgvJobPanel(parentContainer, text) {
    const panelScale = 4;
    const panel = new PIXI.Container();
    const sideLen = 50 * panelScale;
    const halfCircle = new PIXI.Graphics();
    halfCircle.beginFill(themeMode === 'light' ? '#333333' : '#eee');
    halfCircle.lineStyle(2 * panelScale, themeMode === 'light' ? '#333333' : '#eee');
    halfCircle.arc(0, 0, sideLen, 0, Math.PI);
    halfCircle.endFill();
    const rectangle = new PIXI.Graphics();
    rectangle.lineStyle(2 * panelScale, themeMode === 'light' ? '#333333' : '#eee', .8);
    rectangle.drawRoundedRect(
        -sideLen / 2,   // 左上角 x
        -sideLen / 2,   // 左上角 y
        sideLen,       // 宽
        sideLen - (20 * panelScale),  // 高 (留一点空间,看起来更像半圆容器)
        16 * panelScale             // 圆角
    );
    rectangle.endFill();
    rectangle.mask = halfCircle;
    panel.addChild(rectangle, halfCircle);
    const msg = new PIXI.Text(text, {
        fill: themeMode === 'light' ? '#2b2b2b' : '#eee',
        fontSize: 12 * panelScale,
        fontFamily: 'MicrosoftYaHei',
        fontWeight: 'bolder',
        align: 'center',
    });
    msg.anchor.set(0.5);
    msg.position.set(0, -10 * panelScale);
    panel.addChild(msg);
    parentContainer.addChild(panel);
    let phase = 0;
    function onTick(delta) {
        phase += delta / 6;  // 旋转速度可调
        phase %= (Math.PI * 2);
        halfCircle.rotation = phase;
    }
    app.ticker.add(onTick);
    panel._onTick = onTick;
    return panel;
}
// dynamic graphic ----------------
@@ -666,13 +716,13 @@
const agvRotationOffset = rotationParseNum(agvRotationOffsetDegrees);
const showAgvSprite = (curZone, agvVo, setCurSprite) => {
    const { agvNo, code, direction, battery, backpack, error } = agvVo;
    const { agvNo, code, direction, battery, jobType, backpack: backpackCount, slots, error } = agvVo;
    if (!code) { return; }
    const codeSprite = querySprite(DEVICE_TYPE.POINT, code);
    if (!codeSprite) { return; }
    const targetRotation = rotationParseNum(direction);
    const backpackCount = backpack?.filter(item => item.loaded === true).length || 0;
    // const backpackCount = backpack?.filter(item => item.loaded === true).length || 0;
    let agvSprite = querySprite(DEVICE_TYPE.AGV, agvNo);
    if (!agvSprite) {
@@ -722,6 +772,25 @@
        animateRotation(agvSprite, targetRotation + agvRotationOffset, agvRotationOffset);
    }
    // job effect
    if (jobType) {
        if (!agvSprite.data.jobEffect) {
            agvSprite.data.jobEffect = createAgvJobPanel(agvSprite, jobType + " (" + backpackCount + "/" + slots + ")");
            agvSprite.data.jobEffect.x = -80;
            agvSprite.data.jobEffect.y = 0;
        }
        if (agvSprite.data.jobEffect) {
            agvSprite.data.jobEffect.rotation = -agvSprite.rotation - rotationParseNum(MAP_DEFAULT_ROTATION);
        }
    } else {
        if (agvSprite.data.jobEffect) {
            app.ticker.remove(agvSprite.data.jobEffect._onTick);
            agvSprite.removeChild(agvSprite.data.jobEffect);
            agvSprite.data.jobEffect.destroy(true);
            agvSprite.data.jobEffect = null;
        }
    }
    if (error) {
        agvSprite.tint = 0xff3f34;
    } else {