Search in sources :

Example 1 with LightIO

use of com.cas.circuit.vo.LightIO in project TeachingInSimulation by ScOrPiOzzy.

the class BaseElectricCompLogic method initialize.

public void initialize(Node elecCompMdl) {
    // XXX for test
    // System.out.println("BaseElectricCompLogic.initialize()" + Thread.currentThread().getName());
    // log.log(Level.INFO, "加载元器件{0},用时{1}", new Object[] { elecComp.getPO().getTagName(), System.currentTimeMillis() });
    this.elecCompMdl = elecCompMdl;
    // 读取元器件铭牌信息
    readNameplateInfo();
    // elecCompMdl = (Node) MdlMapUtil.loadMdlWithAbbr(getElecComp().getDef().getPO().getMdlRef(), app.getAssetManager());
    // elecCompMdl = (Node) parentMdl.getChild(getElecComp().getDef().getPO().getMdlRef());
    // elecCompMdl = (Node) parentMdl.getChild(getElecComp().getPO().getMdlName());
    // elecCompMdl = parentMdl;
    // registerEvent();
    // elecCompMdl.setLocalTranslation(getElecComp().getLocation());
    // elecCompMdl.rotate(getElecComp().getRotation()[0], getElecComp().getRotation()[1], getElecComp().getRotation()[2]);
    // elecCompMdl.setUserData(BaseElectricCompLogic.ELECCOMP_STATE, BaseElectricCompLogic.this);
    Spatial tempSpatial = null;
    // 遍历元气件中所有插座
    Collection<Jack> jacks = getElecComp().getDef().getJackMap().values();
    for (Jack jack : jacks) {
        tempSpatial = getChild(elecCompMdl, jack.getPO().getMdlName(), jack);
        jack.setModel(tempSpatial);
    }
    // 遍历元气件中所有连接头
    Collection<Terminal> terminals = getElecComp().getDef().getTerminalMap().values();
    for (Terminal terminal : terminals) {
        tempSpatial = getChild(elecCompMdl, terminal.getPO().getMdlName(), terminal);
        if (tempSpatial == null) {
            log.warn(elecComp.getDef().getPO().getName() + "未找到模型名为" + terminal.getPO().getMdlName() + "的端子模型!");
            continue;
        }
        terminal.setModel(tempSpatial);
        // FIXME 端子连接数量的标签
        String numStr = ((Node) tempSpatial).getChild(0).getUserData("num");
        if (Util.isNumeric(numStr)) {
            terminal.setNum(Integer.parseInt(numStr));
        } else {
            terminal.setNum(1);
        }
    }
    // 遍历元器件中所有气口
    Collection<GasPort> gasPorts = getElecComp().getDef().getGasPortMap().values();
    for (GasPort gasPort : gasPorts) {
        tempSpatial = getChild(elecCompMdl, gasPort.getPO().getMdlName(), gasPort);
        gasPort.setModel(tempSpatial);
    }
    // TODO 加入元气件按钮开关...
    ElecCompDef compDef = getElecComp().getDef();
    List<Magnetism> magnetisms = compDef.getMagnetisms();
    for (Magnetism magnetism : magnetisms) {
        // 遍历磁环静中所有按钮
        for (ControlIO controlIO : magnetism.getControlIOs()) {
            tempSpatial = getChild(elecCompMdl, controlIO.getPO().getMdlName(), controlIO);
            controlIO.setModel(tempSpatial);
        }
        // 遍历磁环静中所有指示灯
        for (LightIO lightIO : magnetism.getLightIOs()) {
            tempSpatial = getChild(elecCompMdl, lightIO.getPO().getMdlName(), lightIO);
            lightIO.setModel(tempSpatial);
        }
    }
    // 遍历元气件中所有指示灯
    for (LightIO lightIO : compDef.getLightIOs()) {
        tempSpatial = getChild(elecCompMdl, lightIO.getPO().getMdlName(), lightIO);
        lightIO.setModel(tempSpatial);
    }
}
Also used : GasPort(com.cas.gas.vo.GasPort) ElecCompDef(com.cas.circuit.vo.ElecCompDef) ControlIO(com.cas.circuit.vo.ControlIO) Terminal(com.cas.circuit.vo.Terminal) Spatial(com.jme3.scene.Spatial) Magnetism(com.cas.circuit.vo.Magnetism) Jack(com.cas.circuit.vo.Jack) LightIO(com.cas.circuit.vo.LightIO)

Aggregations

ControlIO (com.cas.circuit.vo.ControlIO)1 ElecCompDef (com.cas.circuit.vo.ElecCompDef)1 Jack (com.cas.circuit.vo.Jack)1 LightIO (com.cas.circuit.vo.LightIO)1 Magnetism (com.cas.circuit.vo.Magnetism)1 Terminal (com.cas.circuit.vo.Terminal)1 GasPort (com.cas.gas.vo.GasPort)1 Spatial (com.jme3.scene.Spatial)1