Search in sources :

Example 11 with LinkerMsg

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

the class LinkerData method modifyWireNum.

public List<LinkerMsg> modifyWireNum(ILinker linker, String wireNum) {
    int hashCode = linker.hashCode();
    // 因为连线时的判断所以此处线缆必然是特殊线缆
    if (linker instanceof Cable) {
        Cable cable = (Cable) linker;
        List<Wire> bindWires = cable.getBindWires();
        // 最近Bind的导线
        linker = bindWires.get(bindWires.size() - 1);
    }
    List<LinkerMsg> msgs = new ArrayList<LinkerMsg>();
    ILinkTarget target1 = linker.getLinkTarget1();
    modifyTargetWireNum(msgs, hashCode, target1, wireNum);
    ILinkTarget target2 = linker.getLinkTarget2();
    modifyTargetWireNum(msgs, hashCode, target2, wireNum);
    return msgs;
}
Also used : Cable(com.cas.circuit.vo.Cable) ArrayList(java.util.ArrayList) Wire(com.cas.circuit.vo.Wire) LinkerMsg(com.cas.circuit.msg.LinkerMsg)

Example 12 with LinkerMsg

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

the class LinkMsgHandler method execute.

@Override
public void execute(HostedConnection source, Message m) {
    LinkerMsg reqMsg = (LinkerMsg) m;
    String myLeader = source.getAttribute(GROUP_LEADER_ID);
    if (Util.isEmpty(myLeader)) {
        throw new RuntimeException("在线连线状态下参数:GROUP_LEADER_ID不可能为空!");
    }
    String userid = source.getAttribute(PERSONAL_ID);
    Collection<HostedConnection> conns = source.getServer().getConnections();
    String leaderid = null;
    String loginid = null;
    for (HostedConnection conn : conns) {
        leaderid = conn.getAttribute(GROUP_LEADER_ID);
        loginid = conn.getAttribute(PERSONAL_ID);
        if (!myLeader.equals(leaderid) || userid.equals(loginid)) {
            continue;
        }
        LinkerMsg respMsg = reqMsg;
        conn.send(respMsg);
    }
}
Also used : HostedConnection(com.jme3.network.HostedConnection) LinkerMsg(com.cas.circuit.msg.LinkerMsg)

Example 13 with LinkerMsg

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

the class LinkMsgHandler method execute.

@Override
public void execute(Client client, Message m) {
    LinkerMsg respMsg = (LinkerMsg) m;
    Nifty nifty = Dispatcher.getIns().getNifty();
    ScreenController screenCtrl = nifty.getCurrentScreen().getScreenController();
    if (screenCtrl instanceof IConnectScreenControl) {
        ConnectionHandler handler = ((IConnectScreenControl) screenCtrl).getConnectionHandler();
        byte type = respMsg.getType();
        if (LinkerMsg.ADD_LINKER == type) {
            handler.connectByOnlineMsg(respMsg);
        } else if (LinkerMsg.DELETE_LINKER == type || LinkerMsg.DELETE_SINGLE_TARGET == type) {
            handler.onlineDeleteLinker(respMsg, type);
        } else if (LinkerMsg.MARK_LINKER == type) {
            handler.onlineMark(respMsg);
        }
    }
}
Also used : ConnectionHandler(com.cas.circuit.ConnectionHandler) Nifty(de.lessvoid.nifty.Nifty) IConnectScreenControl(com.cas.circuit.IConnectScreenControl) ScreenController(de.lessvoid.nifty.screen.ScreenController) 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