Search in sources :

Example 16 with Terminal

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

the class LinkTargetHandler method select.

public void select() {
    MultimeterState_MF47 multimeterState = stateManager.getState(MultimeterState_MF47.class);
    if (multimeterState.isEnabled() && target instanceof Terminal) {
        multimeterState.putPenToTerminal((Terminal) target, target.getModel());
        return;
    }
    if (!handler.checkConnect(target)) {
        return;
    }
    LinkerMsg reqMsg = handler.offlineConnect(target);
    // 如果当前为多人联机模式则向服务器发送连线请求
    if (!handler.isAlone()) {
        reqMsg.setType(LinkerMsg.ADD_LINKER);
        ClientMgr.send(reqMsg);
    }
    if (!(target instanceof Terminal)) {
        return;
    }
    // 螺丝拧上拧下
    Node parent = (Node) target.getModel();
    // findCylinder(parent);
    final Spatial luosi = parent.getChild("screw");
    if (luosi == null) {
        throw new RuntimeException("螺丝的模型结构有问题, 没有指出螺杆节点");
    }
    if (luosi.getNumControls() > 0) {
        AbstractControl control = (AbstractControl) luosi.getControl(0);
        control.setEnabled(true);
    }
}
Also used : Spatial(com.jme3.scene.Spatial) MultimeterState_MF47(com.cas.circuit.state.MultimeterState_MF47) Node(com.jme3.scene.Node) AbstractControl(com.jme3.scene.control.AbstractControl) Terminal(com.cas.circuit.vo.Terminal) LinkerMsg(com.cas.circuit.msg.LinkerMsg)

Example 17 with Terminal

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

the class CircuitState method detachFromCircuit.

public boolean detachFromCircuit(ElecCompDef elecCompDef) {
    // 0、判断元器件连接头是否接线
    for (Terminal terminal : elecCompDef.getTerminalList()) {
        if (terminal.getWires().size() > 0) {
            return false;
        }
    }
    for (Jack jack : elecCompDef.getJackList()) {
        if (jack.getCable() != null) {
            return false;
        }
    }
    if (ElecComp.COMBINE_BUTTOM == elecCompDef.getElecComp().getCombine()) {
        if (!StringUtils.isEmpty(combineMap.get(elecCompDef.getProxy().getUuid()))) {
            return false;
        }
    }
    // 1、移除元器件模型
    detachElecComp(elecCompDef);
    // 2、从元器件列表中移除
    compList.remove(elecCompDef);
    return true;
}
Also used : Jack(com.cas.circuit.vo.Jack) Terminal(com.cas.circuit.vo.Terminal)

Example 18 with Terminal

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

the class ElecCompCPU method sendSignal.

/**
 * @param jackNm 信号发生的插孔名称
 * @param startIndex 具体的针脚号
 * @param endIndex 具体的针脚号
 * @param sign 电压对象
 */
public void sendSignal(String jackNm, int startIndex, int endIndex, CommandSignal sign) {
    synchronized (this) {
        // 判断当前插口是否允许发送指令
        Jack jack = getJackMap().get(jackNm);
        if (jack.isStopSend()) {
            LOG.warn("无法发送信号[{}]!!", jackNm);
            return;
        }
        Terminal startTerminal = getStitch(jackNm, startIndex);
        Terminal endTerminal = getStitch(jackNm, endIndex);
        String env = EVN_NAME_PRE + jackNm;
        R r = R.getR(env);
        if (r == null) {
            r = R.createSignal(env, startTerminal, endTerminal, 24);
            r.shareVoltage();
        }
        SignalVolt sv = (SignalVolt) r.getVoltage();
        sv.changeCommandSignal(sign);
        r.shareVoltage();
    }
}
Also used : R(com.cas.circuit.util.R) Jack(com.cas.circuit.vo.Jack) Terminal(com.cas.circuit.vo.Terminal)

Example 19 with Terminal

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

the class ServoDrive method rotateChange.

private void rotateChange() {
    // 让电机停止转动
    List<R> rs = R.get3Phase(controlVoltEnv);
    if (rs != null) {
        for (R r : rs) {
            r.shutPowerDown();
        }
    }
    if (!outputEnable) {
        return;
    }
    // 
    // if (leftLimit || rightLimit || servoOff) {
    // return;
    // }
    rs = R.create3Phase(controlVoltEnv, _U, _V, _W, new Terminal(), 380);
    System.out.println("ServoDrive.rotateChange() cw " + receivedDir);
    R.reversePhase(controlVoltEnv, receivedDir);
    R.set3PhaseFrequency(controlVoltEnv, frequency);
    for (R r : rs) {
        // r.getVoltage().setFrequency(frequency);
        // r.getVoltage().putData("pulseAmount", result.getData("pulseAmount"));
        r.shareVoltage();
    }
}
Also used : R(com.cas.circuit.util.R) Terminal(com.cas.circuit.vo.Terminal)

Example 20 with Terminal

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

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