Search in sources :

Example 11 with Wire

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

the class TransducersHandler method showWirePanel.

/**
 * 显示传感器接线面板
 */
public void showWirePanel() {
    // 判断是否可以切换至传感器线缆
    if (!handler.checkChange()) {
        Dispatcher.getIns().getTip().showTip(ITip.ERROR, ConnectionUtil.CONNECTING_CANNOT_CHANGE);
        // state.getMaintenanceUI().showInfo(IAssembleUI.ERROR, UIConsts.CONNECTING_CANNOT_CHANGE);
        return;
    }
    // 如果当前传感器未选中过接线,则初始化传感器线缆
    if (cable == null || cable.getLinkTarget1() == null) {
        cable = this.cableTemplate.clone();
        cable.bind(jack);
        cable.setElecComp(true);
        cable.getModels().put(jack.getModel(), jack);
        handler.setCurrLinker(cable);
        LinkerMsg reqMsg = handler.getLinkerData().addLinker(cable, jack, null);
        if (!handler.isAlone()) {
            // 如果为元器件中线缆,先发绑定元器件的
            reqMsg.setType(LinkerMsg.ADD_LINKER);
            reqMsg.setElecComp(true);
            ClientMgr.send(reqMsg);
        }
    }
    // 取消上一次选中的高亮
    handler.setHighLightLinker(handler.getSelected(), false);
    // 删除上一次的连线
    handler.setLineVisible(false);
    // 如果传感器线缆已经绑定完成,选中传感器即选中线缆
    if (cable.isBothBinded()) {
        handler.selectLinker(cable);
        handler.setCurrSelectedModifiable(modifiable);
        return;
    }
    // 如果线缆为单连接头线缆
    if (cable.isSinglePlug()) {
        // 获得当前等待接线的线缆上导线
        Wire wire = cable.getNowConnectingWire();
        // 如果线缆上导线为空,则为传感器第一次接线,设置当前接线为传感器线缆
        if (wire == null) {
            handler.setCurrLinker(cable);
            handler.initLinkerLine(cable, jack.getModel());
            handler.setLineVisible(true);
        }
        // 根据导线标签名生成初始化线缆上导线面板
        List<Wire> wires = new ArrayList<Wire>(cable.getMark_wire().values());
        handler.getUI().initXianLanPanel(wires, true);
        // 选中面板上导线
        if (wire != null) {
            int index = wires.indexOf(wire);
            handler.getUI().showBorder(index);
        } else {
            cable.setNowConnectingWire(wires.get(0).getPO().getMark());
        }
    } else {
        // 设置当前选中为线缆
        handler.setCurrLinker(cable);
        handler.initLinkerLine(cable, jack.getModel());
        handler.setLineVisible(true);
    }
}
Also used : ArrayList(java.util.ArrayList) Wire(com.cas.circuit.vo.Wire) LinkerMsg(com.cas.circuit.msg.LinkerMsg)

Example 12 with Wire

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

the class CircuitState method toggleTagName.

private void toggleTagName() {
    for (ElecCompDef elecCompDef : compList) {
        Spatial elecCompMdl = elecCompDef.getSpatial();
        TagNameControl control = elecCompMdl.getControl(TagNameControl.class);
        if (control == null) {
            BitmapText tag = new BitmapText(tagFont);
            tag.setName(elecCompDef.getProxy().getUuid());
            guiNode.attachChild(tag);
            control = new TagNameControl(cam, tag);
            elecCompMdl.addControl(control);
        }
        control.setTagName(elecCompDef.getProxy().getTagName());
        control.setEnabled(tagVisible);
    }
    for (Wire wire : wireList) {
        Spatial wireMdl = wire.getSpatial();
        WireNumberControl control = wireMdl.getControl(WireNumberControl.class);
        if (control == null) {
            BitmapText tag = new BitmapText(tagFont);
            tag.setLocalScale(0.75f);
            tag.setName(String.format("%s-%s", wire.getProxy().getComp1Uuid(), wire.getProxy().getComp2Uuid()));
            control = new WireNumberControl(cam, guiNode, tag, wire.getProxy().getPointList());
            wireMdl.addControl(control);
        }
        control.setNumber(wire.getProxy().getNumber());
        control.setEnabled(tagVisible);
    }
}
Also used : ElecCompDef(com.cas.circuit.vo.ElecCompDef) BitmapText(com.jme3.font.BitmapText) Spatial(com.jme3.scene.Spatial) TagNameControl(com.cas.sim.tis.app.control.TagNameControl) WireNumberControl(com.cas.sim.tis.app.control.WireNumberControl) Wire(com.cas.circuit.vo.Wire)

Example 13 with Wire

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

the class CircuitState method bindWireEvent.

private void bindWireEvent(Geometry wireMdl, final Wire wire) {
    addListener(wireMdl, new MouseEventAdapter() {

        @Override
        public void mouseClicked(MouseEvent e) {
            for (Wire w : wireList) {
                Spatial mdl = w.getSpatial();
                HintControl control = mdl.getControl(HintControl.class);
                boolean enable = w == wire;
                if (control != null) {
                    mdl.removeControl(control);
                } else if (enable) {
                    control = new HintControl();
                    mdl.addControl(control);
                }
            }
            super.mouseClicked(e);
        }

        @Override
        public void mouseRightClicked(MouseEvent e) {
            // 选中显示导线菜单
            IContent content = SpringUtil.getBean(PageController.class).getIContent();
            if (content instanceof TypicalCase3D) {
                Platform.runLater(() -> {
                    ((TypicalCase3D) content).showPopupMenu(wire);
                });
            }
            super.mouseRightClicked(e);
        }
    });
}
Also used : MouseEvent(com.cas.sim.tis.app.event.MouseEvent) Spatial(com.jme3.scene.Spatial) IContent(com.cas.sim.tis.view.control.IContent) MouseEventAdapter(com.cas.sim.tis.app.event.MouseEventAdapter) HintControl(com.cas.sim.tis.app.control.HintControl) Wire(com.cas.circuit.vo.Wire) TypicalCase3D(com.cas.sim.tis.view.control.imp.jme.TypicalCase3D)

Example 14 with Wire

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

the class CircuitState method cleanup.

@Override
public void cleanup() {
    for (ElecCompDef elecCompDef : compList) {
        detachElecComp(elecCompDef);
    }
    compList.clear();
    for (Wire wire : wireList) {
        detachWire(wire);
    }
    wireList.clear();
    combineMap.clear();
    // 除了desktop,其余模型全部清除
    root.detachAllChildren();
    if (desktop != null) {
        root.attachChild(desktop);
    }
    super.cleanup();
}
Also used : ElecCompDef(com.cas.circuit.vo.ElecCompDef) Wire(com.cas.circuit.vo.Wire)

Example 15 with Wire

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

the class R method collectResisIsopotentialTerminal.

/**
 * DING找出从此端子开始联系到的所有端子,包括有电阻的(电压测量法)
 * @param ref
 * @param isopotential
 * @param r
 */
private void collectResisIsopotentialTerminal(Terminal ref, IP isopotential) {
    if (!isopotential.hasTerminal(ref)) {
        isopotential.addTerminal(ref);
    }
    // 遍历所有和ref关联的导线
    List<Terminal> wireAnotherTerms = new ArrayList<Terminal>();
    // List<ILinker> toRemove = new ArrayList<ILinker>();
    for (Wire wire : ref.getWires()) {
        if (!wire.isBothBinded()) {
            // toRemove.add(linker);
            continue;
        }
        if (isopotential.getPassedWires().contains(wire) || wire.isBrokenBreak()) {
            continue;
        }
        isopotential.getPassedWires().add(wire);
        Terminal anotherTerm = wire.getAnother(ref);
        wireAnotherTerms.add(anotherTerm);
        collectResisIsopotentialTerminal(anotherTerm, isopotential);
    }
    // FIXME 删除只接了一个连接头的导线????
    // wires.removeAll(toRemove);
    // 获取线缆中与ref关联的连接头
    Terminal contacted = ref.getContacted();
    if (contacted != null && !isopotential.getPassedContacted().contains(contacted)) {
        isopotential.getPassedContacted().add(contacted);
        collectResisIsopotentialTerminal(contacted, isopotential);
    }
    // 遍历和ref有电阻关系的电阻
    Map<Terminal, ResisRelation> resisRelationMap = ref.getResisRelationMap();
    // System.out.println(str + resisRelationMap);
    Iterator<Entry<Terminal, ResisRelation>> iter = resisRelationMap.entrySet().iterator();
    Terminal key_Terminal = null;
    // ResisRelation resisRelation = null;
    while (iter.hasNext()) {
        Map.Entry<Terminal, ResisRelation> entry = iter.next();
        key_Terminal = entry.getKey();
        if (!isopotential.getPassedResis().contains(key_Terminal)) {
            isopotential.getPassedResis().add(key_Terminal);
            // 阻值为零,则以ref对应的连接头递归处理   或  此电阻被短接了
            collectResisIsopotentialTerminal(key_Terminal, isopotential);
        }
    }
}
Also used : ResisRelation(com.cas.circuit.vo.ResisRelation) Entry(java.util.Map.Entry) ArrayList(java.util.ArrayList) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) Wire(com.cas.circuit.vo.Wire) Terminal(com.cas.circuit.vo.Terminal) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

Wire (com.cas.circuit.vo.Wire)23 Cable (com.cas.circuit.vo.Cable)13 Spatial (com.jme3.scene.Spatial)9 ArrayList (java.util.ArrayList)9 Pipe (com.cas.gas.vo.Pipe)7 Terminal (com.cas.circuit.vo.Terminal)6 Jack (com.cas.circuit.vo.Jack)5 LinkerMsg (com.cas.circuit.msg.LinkerMsg)4 Node (com.jme3.scene.Node)4 ElecCompDef (com.cas.circuit.vo.ElecCompDef)3 GasPort (com.cas.gas.vo.GasPort)3 HashMap (java.util.HashMap)3 Map (java.util.Map)3 ResisRelation (com.cas.circuit.vo.ResisRelation)2 HintControl (com.cas.sim.tis.app.control.HintControl)2 TagNameControl (com.cas.sim.tis.app.control.TagNameControl)2 WireNumberControl (com.cas.sim.tis.app.control.WireNumberControl)2 MouseEvent (com.cas.sim.tis.app.event.MouseEvent)2 MouseEventAdapter (com.cas.sim.tis.app.event.MouseEventAdapter)2 IContent (com.cas.sim.tis.view.control.IContent)2