Search in sources :

Example 6 with ResisRelation

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

the class Encoder method onTargetStop.

public void onTargetStop() {
    // System.out.println("Encoder.onTargetStop()");
    R.SERVICE.execute(() -> {
        // 设置abz与0v接通
        ResisRelation resis = _A.getResisRelationMap().remove(_0v);
        _0v.getResisRelationMap().remove(_A);
        if (resis != null) {
            resis.setActivated(false);
        }
        resis = _B.getResisRelationMap().remove(_0v);
        _0v.getResisRelationMap().remove(_B);
        if (resis != null) {
            resis.setActivated(false);
        }
        Set<String> envs = _0v.getResidualVolt().keySet();
        R r = null;
        for (String env : envs) {
            r = R.getR(env);
            r.getVoltage().putData("PulsePerMillis", null);
            r.getVoltage().putData("PulseDir", null);
            r.shareVoltage();
        }
    });
}
Also used : ResisRelation(com.cas.circuit.vo.ResisRelation) R(com.cas.circuit.util.R)

Example 7 with ResisRelation

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

the class ServoDrive method initialize.

@Override
public void initialize() {
    super.initialize();
    rate = MathUtil.parseFloat(elecComp.getParam("rate"), rate);
    controlVoltEnv = "ServoControlVoltage" + hashCode();
    encoderEnv = "ServoEncoderVoltage" + hashCode();
    _L1C = elecComp.getTerminal("L1C");
    _L2C = elecComp.getTerminal("L2C");
    // 
    _L1 = elecComp.getTerminal("L1");
    _L2 = elecComp.getTerminal("L2");
    _L3 = elecComp.getTerminal("L3");
    // 
    _U = elecComp.getTerminal("U");
    _V = elecComp.getTerminal("V");
    _W = elecComp.getTerminal("W");
    Jack x4 = elecComp.getJackMap().get("X4");
    _OPC1 = x4.getStitch(1);
    _PULS2 = x4.getStitch(2);
    _OPC2 = x4.getStitch(3);
    _SIGN2 = x4.getStitch(4);
    // 
    _POT = x4.getStitch(5);
    _NOT = x4.getStitch(6);
    _SERV_ON = x4.getStitch(10);
    _COM = x4.getStitch(9);
    _ALM = x4.getStitch(7);
    _ALM_ = x4.getStitch(11);
    resis = new ResisRelation(_ALM, _ALM_, 0f, true);
    Jack x6 = elecComp.getJackMap().get("X6");
    _E_24V = x6.getStitch(1);
    _E_0V = x6.getStitch(2);
    _E_A_ = x6.getStitch(3);
    _E_B_ = x6.getStitch(4);
    _E_Z_ = x6.getStitch(5);
}
Also used : ResisRelation(com.cas.circuit.vo.ResisRelation) Jack(com.cas.circuit.vo.Jack)

Example 8 with ResisRelation

use of com.cas.circuit.vo.ResisRelation 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)

Example 9 with ResisRelation

use of com.cas.circuit.vo.ResisRelation 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)

Aggregations

ResisRelation (com.cas.circuit.vo.ResisRelation)9 R (com.cas.circuit.util.R)3 Terminal (com.cas.circuit.vo.Terminal)3 IP (com.cas.circuit.vo.IP)2 Jack (com.cas.circuit.vo.Jack)2 Wire (com.cas.circuit.vo.Wire)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 Entry (java.util.Map.Entry)2 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)2 CR (com.cas.circuit.vo.CR)1