Search in sources :

Example 1 with LinkerMsg

use of com.cas.circuit.msg.LinkerMsg in project TeachingInSimulation by ScOrPiOzzy.

the class ConnectionHandler method sendDeleteLinkerMsg.

/**
 * 发送删除连线的消息给小组其他成员
 * @param linker 要删除的连线
 * @param type
 * @param wireMark
 */
private void sendDeleteLinkerMsg(ILinker linker, byte type, String wireMark) {
    int key = -1;
    // 如果当前删除线是存档连线则从集合中移除
    if (onlineAndSaves.containsValue(linker)) {
        for (Entry<Integer, ILinker> set : onlineAndSaves.entrySet()) {
            if (linker.equals(set.getValue())) {
                onlineAndSaves.remove(set);
                key = set.getKey();
                break;
            }
        }
    } else {
        key = linker.hashCode();
    }
    // 联机模式下发送删除导线请求信息
    LinkerMsg req = new LinkerMsg();
    req.setKey(key);
    req.setType(type);
    req.setWireMark(wireMark);
    ClientMgr.send(req);
}
Also used : LinkerMsg(com.cas.circuit.msg.LinkerMsg)

Example 2 with LinkerMsg

use of com.cas.circuit.msg.LinkerMsg in project TeachingInSimulation by ScOrPiOzzy.

the class LinkerData method write.

// public byte getStationInCharge() {
// return stationInCharge;
// }
// 
// public void setStationInCharge(byte stationInCharge) {
// this.stationInCharge = stationInCharge;
// }
@Override
public void write(JmeExporter ex) throws IOException {
    OutputCapsule out = ex.getCapsule(this);
    linkerDatas.clear();
    linkerDatas.addAll(linkerMapForSave.values());
    out.writeSavableArrayList(linkerDatas, "LinkerDatas", new ArrayList<LinkerMsg>());
    // out.write(stationInCharge, "StationInCharge", StationConsts.NONE_STATION);
    out.write(userid, "Userid", null);
}
Also used : OutputCapsule(com.jme3.export.OutputCapsule) LinkerMsg(com.cas.circuit.msg.LinkerMsg)

Example 3 with LinkerMsg

use of com.cas.circuit.msg.LinkerMsg 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 4 with LinkerMsg

use of com.cas.circuit.msg.LinkerMsg in project TeachingInSimulation by ScOrPiOzzy.

the class TransducersHandler method showWirePanel.

/**
 * 显示传感器接线面板
 */
public void showWirePanel() {
    // 判断是否可以切换至传感器线缆
    if (!handler.checkChange()) {
        Dispatcher.getIns().getTip().showTip(ITip.ERROR, ConnectionUtil.CONNECTING_CANNOT_CHANGE);
        // state.getMaintenanceUI().showInfo(IAssembleUI.ERROR, UIConsts.CONNECTING_CANNOT_CHANGE);
        return;
    }
    // 如果当前传感器未选中过接线,则初始化传感器线缆
    if (cable == null || cable.getLinkTarget1() == null) {
        cable = this.cableTemplate.clone();
        cable.bind(jack);
        cable.setElecComp(true);
        cable.getModels().put(jack.getModel(), jack);
        handler.setCurrLinker(cable);
        LinkerMsg reqMsg = handler.getLinkerData().addLinker(cable, jack, null);
        if (!handler.isAlone()) {
            // 如果为元器件中线缆,先发绑定元器件的
            reqMsg.setType(LinkerMsg.ADD_LINKER);
            reqMsg.setElecComp(true);
            ClientMgr.send(reqMsg);
        }
    }
    // 取消上一次选中的高亮
    handler.setHighLightLinker(handler.getSelected(), false);
    // 删除上一次的连线
    handler.setLineVisible(false);
    // 如果传感器线缆已经绑定完成,选中传感器即选中线缆
    if (cable.isBothBinded()) {
        handler.selectLinker(cable);
        handler.setCurrSelectedModifiable(modifiable);
        return;
    }
    // 如果线缆为单连接头线缆
    if (cable.isSinglePlug()) {
        // 获得当前等待接线的线缆上导线
        Wire wire = cable.getNowConnectingWire();
        // 如果线缆上导线为空,则为传感器第一次接线,设置当前接线为传感器线缆
        if (wire == null) {
            handler.setCurrLinker(cable);
            handler.initLinkerLine(cable, jack.getModel());
            handler.setLineVisible(true);
        }
        // 根据导线标签名生成初始化线缆上导线面板
        List<Wire> wires = new ArrayList<Wire>(cable.getMark_wire().values());
        handler.getUI().initXianLanPanel(wires, true);
        // 选中面板上导线
        if (wire != null) {
            int index = wires.indexOf(wire);
            handler.getUI().showBorder(index);
        } else {
            cable.setNowConnectingWire(wires.get(0).getPO().getMark());
        }
    } else {
        // 设置当前选中为线缆
        handler.setCurrLinker(cable);
        handler.initLinkerLine(cable, jack.getModel());
        handler.setLineVisible(true);
    }
}
Also used : ArrayList(java.util.ArrayList) Wire(com.cas.circuit.vo.Wire) LinkerMsg(com.cas.circuit.msg.LinkerMsg)

Example 5 with LinkerMsg

use of com.cas.circuit.msg.LinkerMsg in project TeachingInSimulation by ScOrPiOzzy.

the class ConnectionHandler method checkStandard.

public boolean checkStandard(ILinkTarget target, ILinker linker) {
    // List<LinkerMsg> checks = standardData.getLinkerMapForCheck().get(target.getElecCompKey() + target.getTargetKey());
    // if (checks == null || checks.size() == 0) {
    // return false;
    // }
    ILinkTarget anotherTarget = linker.getLinkTarget1();
    if (anotherTarget == null) {
        anotherTarget = linker.getLinkTarget2();
    }
    if (anotherTarget == null) {
        return true;
    }
    List<LinkerMsg> checks = standardData.getLinkerMapForCheck().get(anotherTarget.getElecCompKey() + anotherTarget.getTargetKey());
    if (checks == null) {
        return false;
    }
    for (LinkerMsg check : checks) {
        List<LinkerMsg> checkAnothers = standardData.getLinkerMapForRead().get(check.getKey());
        for (LinkerMsg anothers : checkAnothers) {
            if (anothers.equals(check)) {
                continue;
            }
            if (linker instanceof Cable && ((Cable) linker).isSinglePlug()) {
                Cable cable = (Cable) linker;
                Wire wire = cable.getNowConnectingWire();
                if (anothers.getElecCompKey().equals(target.getElecCompKey()) && anothers.getTargetKey().equals(target.getTargetKey()) && anothers.getWireMark().equals(wire.getPO().getMark())) {
                    return true;
                }
            } else if (anothers.getElecCompKey().equals(target.getElecCompKey()) && anothers.getTargetKey().equals(target.getTargetKey())) {
                return true;
            }
        }
    }
    return false;
}
Also used : Cable(com.cas.circuit.vo.Cable) Wire(com.cas.circuit.vo.Wire) LinkerMsg(com.cas.circuit.msg.LinkerMsg)

Aggregations

LinkerMsg (com.cas.circuit.msg.LinkerMsg)13 Wire (com.cas.circuit.vo.Wire)4 Cable (com.cas.circuit.vo.Cable)3 ArrayList (java.util.ArrayList)3 ConnectionHandler (com.cas.circuit.ConnectionHandler)1 IConnectScreenControl (com.cas.circuit.IConnectScreenControl)1 MultimeterState_MF47 (com.cas.circuit.state.MultimeterState_MF47)1 Jack (com.cas.circuit.vo.Jack)1 Terminal (com.cas.circuit.vo.Terminal)1 Pipe (com.cas.gas.vo.Pipe)1 InputCapsule (com.jme3.export.InputCapsule)1 OutputCapsule (com.jme3.export.OutputCapsule)1 HostedConnection (com.jme3.network.HostedConnection)1 Node (com.jme3.scene.Node)1 Spatial (com.jme3.scene.Spatial)1 AbstractControl (com.jme3.scene.control.AbstractControl)1 Nifty (de.lessvoid.nifty.Nifty)1 ScreenController (de.lessvoid.nifty.screen.ScreenController)1