Search in sources :

Example 21 with Jack

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

the class R method findElecComp.

private void findElecComp(List<ElecCompDef> elecCompList, List<Terminal> terminals, boolean considerEVN) {
    if (voltage instanceof SignalVolt) {
        return;
    }
    Terminal terminal = null;
    ElecCompDef comp = null;
    ElecCompDef toRemove = null;
    Iterator<Terminal> it = terminals.iterator();
    while (it.hasNext()) {
        terminal = it.next();
        comp = terminal.getElecComp();
        if (!considerEVN || terminal.getResidualVolt().containsKey(voltage.getEnv())) {
            if (comp == null) {
                if (terminal.getParent() != null && terminal.getParent() instanceof Jack) {
                    if (terminal == startTerminal || terminal == endTerminal) {
                        // 针脚的parent是插孔Jack,插孔的parent是ElecCompDef
                        toRemove = (ElecCompDef) terminal.getParent().getParent();
                    }
                }
            }
            if (comp != null && !elecCompList.contains(comp)) {
                elecCompList.add(comp);
            }
        }
    }
    if (toRemove != null) {
        elecCompList.remove(toRemove);
    }
// System.out.println(voltage.getEnv() + "-" +elecCompList);
}
Also used : SignalVolt(com.cas.circuit.SignalVolt) ElecCompDef(com.cas.circuit.vo.ElecCompDef) Jack(com.cas.circuit.vo.Jack) Terminal(com.cas.circuit.vo.Terminal)

Example 22 with Jack

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

the class ConnectionHandler method checkConnect.

/**
 * 验证是否可以接线
 * @param target 端子、气口
 */
public boolean checkConnect(ILinkTarget target) {
    // 获得当前用户选中导线
    if (currLinker == null) {
        Dispatcher.getIns().getTip().showTip(ITip.ERROR, ConnectionUtil.NO_lINKER);
        return false;
    }
    if (target instanceof Jack && !(currLinker instanceof Cable)) {
        Dispatcher.getIns().getTip().showTip(ITip.ERROR, ConnectionUtil.JUST_CABLE);
        return false;
    }
    // 如果当前手中是线缆,但当前接口不符合当前线缆制式
    if ((target instanceof Jack) && (currLinker instanceof Cable)) {
        Jack jack = (Jack) target;
        if (jack.getPlug() != null) {
            Dispatcher.getIns().getTip().showTip(ITip.ERROR, ConnectionUtil.JACK_ALREADY_IN_USED);
            return false;
        }
        Cable cable = (Cable) currLinker;
        // 如果两个连接头都为null,说明用户选择了线缆还没有连接
        if (cable.getPlug1() == null && cable.getPlug2() == null) {
            if (Util.notEmpty(jack.getPO().getBelongElecComp())) {
                return false;
            }
            return true;
        }
        Format format = jack.getFormat();
        Plug plug1 = cable.getPlug1();
        if (plug1 != null) {
            boolean insert = plug1.isInserted();
            if (!insert) {
                return format.equals(plug1.getFormat());
            }
        }
        Plug plug2 = cable.getPlug2();
        if (plug2 != null) {
            boolean insert = plug2.isInserted();
            if (!insert) {
                if (standardData != null && !checkStandard(target, currLinker)) {
                    Dispatcher.getIns().getTip().showTip(ITip.ERROR, "接线不符合标准存档!");
                    return false;
                }
                return format.equals(plug2.getFormat());
            } else {
                return false;
            }
        } else if (cable.isSinglePlug()) {
            return false;
        }
    } else if ((target instanceof Terminal) && (currLinker instanceof Cable)) {
        Cable cable = (Cable) currLinker;
        Wire wire = cable.getNowConnectingWire();
        if (wire == null) {
            Dispatcher.getIns().getTip().showTip(ITip.ERROR, ConnectionUtil.SELECT_ANY_WIRE_IN_CABLE);
            return false;
        }
        if (wire.isBothBinded()) {
            Dispatcher.getIns().getTip().showTip(ITip.ERROR, ConnectionUtil.WIRE_IN_CABLE_LINKED_ALREADY);
            return false;
        }
        Terminal terminal = (Terminal) target;
        if (terminal.getLinkers().size() == terminal.getNum()) {
            Dispatcher.getIns().getTip().showTip(ITip.ERROR, ConnectionUtil.TERMINAL_LIMITED);
            return false;
        }
        if (standardData != null && !checkStandard(target, currLinker)) {
            Dispatcher.getIns().getTip().showTip(ITip.ERROR, "接线不符合标准存档!");
            return false;
        }
        return true;
    }
    if (target instanceof Terminal && !(currLinker instanceof Wire)) {
        Dispatcher.getIns().getTip().showTip(ITip.ERROR, ConnectionUtil.JUST_WIRE);
        return false;
    }
    if (target instanceof Terminal && (currLinker instanceof Wire)) {
        Terminal terminal = (Terminal) target;
        if (terminal.getLinkers().size() == terminal.getNum()) {
            Dispatcher.getIns().getTip().showTip(ITip.ERROR, ConnectionUtil.TERMINAL_LIMITED);
            return false;
        }
        if (terminal.getLinkers().contains(currLinker)) {
            Dispatcher.getIns().getTip().showTip(ITip.ERROR, ConnectionUtil.SAME_LINKER);
            return false;
        }
    }
    if (target instanceof GasPort && !(currLinker instanceof Pipe)) {
        Dispatcher.getIns().getTip().showTip(ITip.ERROR, ConnectionUtil.JUST_PIPE);
        return false;
    }
    if (target instanceof GasPort && target.getLinkers().size() != 0) {
        Dispatcher.getIns().getTip().showTip(ITip.ERROR, ConnectionUtil.GASPORT_LIMITED);
        return false;
    }
    if (standardData != null && !checkStandard(target, currLinker)) {
        Dispatcher.getIns().getTip().showTip(ITip.ERROR, "接线不符合标准存档!");
        return false;
    }
    Dispatcher.getIns().getTip().showTip(ITip.RIGHT, null);
    return true;
}
Also used : Cable(com.cas.circuit.vo.Cable) GasPort(com.cas.gas.vo.GasPort) Format(com.cas.circuit.vo.Format) Pipe(com.cas.gas.vo.Pipe) Jack(com.cas.circuit.vo.Jack) Wire(com.cas.circuit.vo.Wire) Terminal(com.cas.circuit.vo.Terminal)

Example 23 with Jack

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

the class ElecCompCPU method onPulse.

/**
 * @param terminal
 */
public final void onPulse(Terminal terminal) {
    if (terminal.getParent() instanceof Jack) {
        Jack jack = (Jack) terminal.getParent();
        if (CfgConst.BROKEN_STATE_BREAK.equals(jack.getBrokenState())) {
            return;
        }
    }
    TermTeam team = terminal.getTeam();
    team.signIn(terminal);
    if (!team.resetIfReady()) {
        return;
    }
    onPulseLocal(terminal);
}
Also used : Jack(com.cas.circuit.vo.Jack)

Example 24 with Jack

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

the class ElecCompCPU method setElecComp.

/*
	 * (non-Javadoc)
	 * @see com.cas.me.appState.electric.BaseElectricCompState#setElecComp(com.cas.me.data.layout.ElecComp)
	 */
@Override
public void setElecComp(ElecComp elecComp) {
    super.setElecComp(elecComp);
    Map<String, Jack> jackMap = elecComp.getDef().getJackMap();
    for (Jack jack : jackMap.values()) {
        if ("JF".equals(jack.getPO().getFormat())) {
            jf_evn_names.add(EVN_NAME_PRE + jack.getPO().getName());
            jf_jacks.add(jack);
        } else if ("CB".equals(jack.getPO().getFormat())) {
            cb_evn_names.add(EVN_NAME_PRE + jack.getPO().getName());
            cbx_jacks.add(jack);
        } else if ("COP".equals(jack.getPO().getFormat())) {
            cop_evn_names.add(EVN_NAME_PRE + jack.getPO().getName());
            cop_jacks.add(jack);
        } else if (jack.getPO().getFormat().indexOf("JFR") != -1) {
            jfr_evn_names.add(EVN_NAME_PRE + jack.getPO().getName());
            jfr_jacks.add(jack);
        } else {
            log.info(jack.getPO().getFormat() + "这个插孔不能产生信号电,关于'产生信号电'不理解的,可以问振宇");
        }
    }
}
Also used : Jack(com.cas.circuit.vo.Jack)

Example 25 with Jack

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

the class LinkerData method addLinker.

// /**
// * 所负责工作站
// */
// private byte stationInCharge;
public LinkerMsg addLinker(ILinker linker, ILinkTarget target, String wireMark) {
    // 封装LinkerInfo
    LinkerMsg linkInfo = new LinkerMsg();
    if (linker instanceof Wire) {
        linkInfo.setLinkType(LinkerMsg.WIRE);
    } else if (linker instanceof Pipe) {
        linkInfo.setLinkType(LinkerMsg.PIPE);
    } else if (linker instanceof Cable) {
        if (target instanceof Jack) {
            linkInfo.setLinkType(LinkerMsg.CABLE_JACK);
            linkInfo.setElecComp(((Cable) linker).isElecComp());
        } else {
            linkInfo.setLinkType(LinkerMsg.CABLE_TERM);
            // A、B、C
            linkInfo.setWireMark(wireMark);
        }
        linkInfo.setCableKey(((Cable) linker).getPO().getId());
    }
    linkInfo.setKey(linker.hashCode());
    linkInfo.setColor(linker.getColor());
    linkInfo.setElecCompKey(target.getElecCompKey());
    linkInfo.setTargetKey(target.getTargetKey());
    // 线号
    linkInfo.setNumMark(linker.getWireNum());
    linkerMapForSave.put(linker.hashCode() + "_" + target.hashCode(), linkInfo);
    return linkInfo;
}
Also used : Cable(com.cas.circuit.vo.Cable) Pipe(com.cas.gas.vo.Pipe) Wire(com.cas.circuit.vo.Wire) Jack(com.cas.circuit.vo.Jack) LinkerMsg(com.cas.circuit.msg.LinkerMsg)

Aggregations

Jack (com.cas.circuit.vo.Jack)27 Terminal (com.cas.circuit.vo.Terminal)11 GasPort (com.cas.gas.vo.GasPort)5 Cable (com.cas.circuit.vo.Cable)4 Wire (com.cas.circuit.vo.Wire)4 Spatial (com.jme3.scene.Spatial)4 ElecCompDef (com.cas.circuit.vo.ElecCompDef)3 Pipe (com.cas.gas.vo.Pipe)3 ArrayList (java.util.ArrayList)3 MesureResult (com.cas.circuit.util.MesureResult)2 R (com.cas.circuit.util.R)2 ResisRelation (com.cas.circuit.vo.ResisRelation)2 Node (com.jme3.scene.Node)2 SignalVolt (com.cas.circuit.SignalVolt)1 TransducersAdapter (com.cas.circuit.event.TransducersAdapter)1 TransducersHandler (com.cas.circuit.event.TransducersHandler)1 LinkerMsg (com.cas.circuit.msg.LinkerMsg)1 ControlIO (com.cas.circuit.vo.ControlIO)1 ElecComp (com.cas.circuit.vo.ElecComp)1 Format (com.cas.circuit.vo.Format)1