Search in sources :

Example 16 with ElecCompDef

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

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

the class R method shutPowerDown.

public void shutPowerDown() {
    List<ElecCompDef> elecCompList = new ArrayList<ElecCompDef>();
    for (IP ip : allIsopoList) {
        findElecComp(elecCompList, ip.getTerminals(), true);
        ip.clearVolt();
    }
    cleanProperty();
    for (ElecCompDef elecCompDef : elecCompList) {
        if (elecCompDef != null) {
            elecCompDef.doMagnetism();
        }
    }
    if ("Tmp_REMOVE".equals(voltage.getEnv())) {
        return;
    }
    R removed = cache.remove(voltage.getEnv());
    boolean result = this == removed;
    if (result) {
        Logger.getLogger(R.class.getCanonicalName()).info("移除电源" + voltage.getEnv() + "剩余电源" + String.valueOf(cache.size()) + ":" + cache.values().toString());
    }
}
Also used : ElecCompDef(com.cas.circuit.vo.ElecCompDef) CR(com.cas.circuit.vo.CR) IP(com.cas.circuit.vo.IP) ArrayList(java.util.ArrayList) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList)

Example 18 with ElecCompDef

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

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

the class MMT_4QLogic method initialize.

@Override
public void initialize(Node elecCompMdl) {
    super.initialize(elecCompMdl);
    ElecCompDef def = elecComp.getDef();
    dcin1 = def.getTerminal("DCIN+");
    dcin2 = def.getTerminal("DCIN-");
    en = def.getTerminal("EN");
    com1 = def.getTerminal("COM1");
    dir = def.getTerminal("DIR");
    com2 = def.getTerminal("COM2");
    out1 = def.getTerminal("OUT+");
    out2 = def.getTerminal("OUT-");
}
Also used : ElecCompDef(com.cas.circuit.vo.ElecCompDef)

Aggregations

ElecCompDef (com.cas.circuit.vo.ElecCompDef)19 Terminal (com.cas.circuit.vo.Terminal)7 Spatial (com.jme3.scene.Spatial)6 Jack (com.cas.circuit.vo.Jack)5 ElecCompAction (com.cas.sim.tis.action.ElecCompAction)5 URL (java.net.URL)5 ArrayList (java.util.ArrayList)5 Wire (com.cas.circuit.vo.Wire)4 Archive (com.cas.circuit.vo.Archive)3 ControlIO (com.cas.circuit.vo.ControlIO)3 TagNameControl (com.cas.sim.tis.app.control.TagNameControl)3 WireNumberControl (com.cas.sim.tis.app.control.WireNumberControl)3 MouseEvent (com.cas.sim.tis.app.event.MouseEvent)3 MouseEventAdapter (com.cas.sim.tis.app.event.MouseEventAdapter)3 ElecComp (com.cas.sim.tis.entity.ElecComp)3 ModelKey (com.jme3.asset.ModelKey)3 BitmapText (com.jme3.font.BitmapText)3 Node (com.jme3.scene.Node)3 CfgConst (com.cas.circuit.CfgConst)2 CR (com.cas.circuit.vo.CR)2