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;
}
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);
}
}
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);
}
}
}
Aggregations