Search in sources :

Example 21 with Terminal

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

the class R method shareVoltageLocal.

/**
 * 电源调用,
 * @return
 */
protected boolean shareVoltageLocal() {
    // 找出上一次电路中参与的连接头
    List<Terminal> lastCircuitTerminal = new ArrayList<Terminal>();
    for (IP ip : allIsopoList) {
        addNonRepeatListAll(lastCircuitTerminal, ip.getTerminals());
    // lastCircuitTerminal.addAll(ip.getTerminals());
    }
    // 计算电路电阻
    CR cr = mesure();
    if (startIP == null || endIP == null) {
        Logger.getLogger(this.getClass().getCanonicalName()).warn("startIP == null || endIP == null");
        return true;
    }
    if (cr.getValue() == CR.MIN_RESIS_VALUE) {
        startTerminal.getElecComp().powerShorted(startTerminal, endTerminal);
        return false;
    }
    cr.getIsopo2().setVoltageValue(0);
    cr.getIsopo1().setVoltageValue(voltage.getValue());
    // 根据电阻分压
    cr.shareVoltage();
    if (startIP == null || endIP == null) {
        // System.out.println("电压已经清除了");
        return false;
    }
    // 记录所走到元器件
    List<ElecCompDef> elecCompList = new ArrayList<ElecCompDef>();
    // 找出本次电路中参与的连接头
    List<Terminal> thisCircuitTerminal = new ArrayList<Terminal>();
    for (IP ip : allIsopoList) {
        // thisCircuitTerminal.addAll(ip.getTerminals());
        addNonRepeatListAll(thisCircuitTerminal, ip.getTerminals());
        findElecComp(elecCompList, ip.getTerminals(), true);
    }
    // 剩余的连接头表示是此次电路中没有涉及的,需要清理连接头上的电压
    lastCircuitTerminal.removeAll(thisCircuitTerminal);
    // elecCompSet.clear();
    IP ip = null;
    // FIXME false
    findElecComp(elecCompList, lastCircuitTerminal, false);
    for (Terminal terminal : lastCircuitTerminal) {
        if (!startIP.hasTerminal(terminal) && !endIP.hasTerminal(terminal)) {
            ip = terminal.getIsopotential(voltage.getEnv());
            if (ip != null) {
                ip.detory();
            }
            terminal.removeVolt(voltage.getEnv());
        }
    }
    for (ElecCompDef elecCompDef : elecCompList) {
        if (elecCompDef != null) {
            elecCompDef.doMagnetism();
        }
    }
    return lastCircuitTerminal.size() != 0;
}
Also used : ElecCompDef(com.cas.circuit.vo.ElecCompDef) IP(com.cas.circuit.vo.IP) ArrayList(java.util.ArrayList) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) Terminal(com.cas.circuit.vo.Terminal) CR(com.cas.circuit.vo.CR)

Example 22 with Terminal

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

the class FX3UPLCLogicAssist method dealWithYSignal.

private void dealWithYSignal(String singalAddress, Variant value, Map<String, String> data) {
    // Y信号:当某Y信号点有信号时将该端子与对应的COM端子导通
    // System.out.println("PLCLogic.update()");
    // 获取信号所对应的连接头id
    String signal = singalAddress.substring(singalAddress.lastIndexOf('.') + 1);
    String termId = Signal.untiFormatSignal(signal);
    int index = Integer.parseInt(termId.substring(1));
    // 找到信号所对应的COM端连接头ID
    int a = index / 10;
    int b = index % 10 >= 4 ? 1 : 0;
    // int group = 2 * a + b;		// COM0 开始
    // COM1 开始
    int group = 2 * a + b + 1;
    if (group > 5) {
        // FX3u-48M, 20 - 27 都与COM5连接
        group = 5;
    }
    // System.out.println("Y" + index + " group=" + group);
    Terminal term = logic.getElecComp().getDef().getTerminal(termId);
    Terminal docom = logic.getElecComp().getDef().getTerminal("COM" + group);
    if (term == null) {
        throw new RuntimeException("信号:" + singalAddress + "所对应的连接头" + termId + "没有找到");
    }
    if (docom == null) {
        throw new RuntimeException("连接头:" + termId + "所对应的COM" + group + "端没有找到");
    }
    ResisRelation resis = resisRelations.get(term);
    if (resis == null) {
        resisRelations.put(term, resis = new ResisRelation(term, docom, 0f, true));
    }
    if (value.getBoolean()) {
        // 没有信号
        term.getResisRelationMap().put(docom, resis);
        docom.getResisRelationMap().put(term, resis);
        resis.setActivated(true);
    } else {
        // 有信号
        term.getResisRelationMap().remove(docom);
        docom.getResisRelationMap().remove(term);
        resis.setActivated(false);
    }
    Set<String> envs = docom.getResidualVolt().keySet();
    R r = null;
    for (String env : envs) {
        r = R.getR(env);
        r.getVoltage().setData(data);
        r.shareVoltage();
    }
}
Also used : ResisRelation(com.cas.circuit.vo.ResisRelation) R(com.cas.circuit.util.R) Terminal(com.cas.circuit.vo.Terminal)

Example 23 with Terminal

use of com.cas.circuit.vo.Terminal 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 24 with Terminal

use of com.cas.circuit.vo.Terminal 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 25 with Terminal

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

the class FR_D720SInverter method onReceivedLocal.

@Override
protected void onReceivedLocal(Terminal terminal) {
    super.onReceivedLocal(terminal);
    if (_l == terminal || _n == terminal) {
        // 分别测量uvw三者之间的电压情况
        MesureResult result = R.matchRequiredVolt(Voltage.IS_AC, _l, _n, 220, 10);
        // 判断三者之间是否存在电势差
        boolean tmp = Util.notEmpty(result);
        List<R> controlVoltPower = R.get3Phase(controlVoltEnv);
        if (tmp && !workable) {
            workable = true;
            if (controlVoltPower == null) {
                controlVoltPower = R.create3Phase(controlVoltEnv, _u, _v, _w, new Terminal(), 380);
            }
            R.set3PhaseFrequency(controlVoltEnv, 50);
            R.reversePhase(controlVoltEnv, dir != Dir.CW);
            for (R r : controlVoltPower) {
                r.shareVoltage();
            }
        } else if (!tmp && workable) {
            if (controlVoltPower != null) {
                for (R r : controlVoltPower) {
                    r.shutPowerDown();
                }
            }
            workable = false;
        }
    } else if (_rda == terminal || _rdb == terminal) {
        // 处理PLC侧发来的数据
        MesureResult result = R.matchRequiredVolt(Voltage.IS_DC, _rda, _rdb, 5, 1);
        if (result != null) {
            Map<String, String> data = R.getR(result.getEvn()).getVoltage().getData();
            assist.decode(data);
        }
        if (voltNeedChange) {
        }
    } else {
    }
}
Also used : MesureResult(com.cas.circuit.util.MesureResult) R(com.cas.circuit.util.R) Terminal(com.cas.circuit.vo.Terminal) Map(java.util.Map)

Aggregations

Terminal (com.cas.circuit.vo.Terminal)25 Jack (com.cas.circuit.vo.Jack)12 ArrayList (java.util.ArrayList)8 R (com.cas.circuit.util.R)7 Spatial (com.jme3.scene.Spatial)7 ElecCompDef (com.cas.circuit.vo.ElecCompDef)6 Wire (com.cas.circuit.vo.Wire)6 GasPort (com.cas.gas.vo.GasPort)5 Cable (com.cas.circuit.vo.Cable)4 Node (com.jme3.scene.Node)4 Map (java.util.Map)4 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)4 ResisRelation (com.cas.circuit.vo.ResisRelation)3 HashMap (java.util.HashMap)3 MesureResult (com.cas.circuit.util.MesureResult)2 CR (com.cas.circuit.vo.CR)2 ControlIO (com.cas.circuit.vo.ControlIO)2 IP (com.cas.circuit.vo.IP)2 Pipe (com.cas.gas.vo.Pipe)2 ColorRGBA (com.jme3.math.ColorRGBA)2