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