use of com.cas.circuit.vo.Jack in project TeachingInSimulation by ScOrPiOzzy.
the class R method findElecComp.
private void findElecComp(List<ElecCompDef> elecCompList, List<Terminal> terminals, boolean considerEVN) {
if (voltage instanceof SignalVolt) {
return;
}
Terminal terminal = null;
ElecCompDef comp = null;
ElecCompDef toRemove = null;
Iterator<Terminal> it = terminals.iterator();
while (it.hasNext()) {
terminal = it.next();
comp = terminal.getElecComp();
if (!considerEVN || terminal.getResidualVolt().containsKey(voltage.getEnv())) {
if (comp == null) {
if (terminal.getParent() != null && terminal.getParent() instanceof Jack) {
if (terminal == startTerminal || terminal == endTerminal) {
// 针脚的parent是插孔Jack,插孔的parent是ElecCompDef
toRemove = (ElecCompDef) terminal.getParent().getParent();
}
}
}
if (comp != null && !elecCompList.contains(comp)) {
elecCompList.add(comp);
}
}
}
if (toRemove != null) {
elecCompList.remove(toRemove);
}
// System.out.println(voltage.getEnv() + "-" +elecCompList);
}
use of com.cas.circuit.vo.Jack in project TeachingInSimulation by ScOrPiOzzy.
the class ConnectionHandler method checkConnect.
/**
* 验证是否可以接线
* @param target 端子、气口
*/
public boolean checkConnect(ILinkTarget target) {
// 获得当前用户选中导线
if (currLinker == null) {
Dispatcher.getIns().getTip().showTip(ITip.ERROR, ConnectionUtil.NO_lINKER);
return false;
}
if (target instanceof Jack && !(currLinker instanceof Cable)) {
Dispatcher.getIns().getTip().showTip(ITip.ERROR, ConnectionUtil.JUST_CABLE);
return false;
}
// 如果当前手中是线缆,但当前接口不符合当前线缆制式
if ((target instanceof Jack) && (currLinker instanceof Cable)) {
Jack jack = (Jack) target;
if (jack.getPlug() != null) {
Dispatcher.getIns().getTip().showTip(ITip.ERROR, ConnectionUtil.JACK_ALREADY_IN_USED);
return false;
}
Cable cable = (Cable) currLinker;
// 如果两个连接头都为null,说明用户选择了线缆还没有连接
if (cable.getPlug1() == null && cable.getPlug2() == null) {
if (Util.notEmpty(jack.getPO().getBelongElecComp())) {
return false;
}
return true;
}
Format format = jack.getFormat();
Plug plug1 = cable.getPlug1();
if (plug1 != null) {
boolean insert = plug1.isInserted();
if (!insert) {
return format.equals(plug1.getFormat());
}
}
Plug plug2 = cable.getPlug2();
if (plug2 != null) {
boolean insert = plug2.isInserted();
if (!insert) {
if (standardData != null && !checkStandard(target, currLinker)) {
Dispatcher.getIns().getTip().showTip(ITip.ERROR, "接线不符合标准存档!");
return false;
}
return format.equals(plug2.getFormat());
} else {
return false;
}
} else if (cable.isSinglePlug()) {
return false;
}
} else if ((target instanceof Terminal) && (currLinker instanceof Cable)) {
Cable cable = (Cable) currLinker;
Wire wire = cable.getNowConnectingWire();
if (wire == null) {
Dispatcher.getIns().getTip().showTip(ITip.ERROR, ConnectionUtil.SELECT_ANY_WIRE_IN_CABLE);
return false;
}
if (wire.isBothBinded()) {
Dispatcher.getIns().getTip().showTip(ITip.ERROR, ConnectionUtil.WIRE_IN_CABLE_LINKED_ALREADY);
return false;
}
Terminal terminal = (Terminal) target;
if (terminal.getLinkers().size() == terminal.getNum()) {
Dispatcher.getIns().getTip().showTip(ITip.ERROR, ConnectionUtil.TERMINAL_LIMITED);
return false;
}
if (standardData != null && !checkStandard(target, currLinker)) {
Dispatcher.getIns().getTip().showTip(ITip.ERROR, "接线不符合标准存档!");
return false;
}
return true;
}
if (target instanceof Terminal && !(currLinker instanceof Wire)) {
Dispatcher.getIns().getTip().showTip(ITip.ERROR, ConnectionUtil.JUST_WIRE);
return false;
}
if (target instanceof Terminal && (currLinker instanceof Wire)) {
Terminal terminal = (Terminal) target;
if (terminal.getLinkers().size() == terminal.getNum()) {
Dispatcher.getIns().getTip().showTip(ITip.ERROR, ConnectionUtil.TERMINAL_LIMITED);
return false;
}
if (terminal.getLinkers().contains(currLinker)) {
Dispatcher.getIns().getTip().showTip(ITip.ERROR, ConnectionUtil.SAME_LINKER);
return false;
}
}
if (target instanceof GasPort && !(currLinker instanceof Pipe)) {
Dispatcher.getIns().getTip().showTip(ITip.ERROR, ConnectionUtil.JUST_PIPE);
return false;
}
if (target instanceof GasPort && target.getLinkers().size() != 0) {
Dispatcher.getIns().getTip().showTip(ITip.ERROR, ConnectionUtil.GASPORT_LIMITED);
return false;
}
if (standardData != null && !checkStandard(target, currLinker)) {
Dispatcher.getIns().getTip().showTip(ITip.ERROR, "接线不符合标准存档!");
return false;
}
Dispatcher.getIns().getTip().showTip(ITip.RIGHT, null);
return true;
}
use of com.cas.circuit.vo.Jack in project TeachingInSimulation by ScOrPiOzzy.
the class ElecCompCPU method onPulse.
/**
* @param terminal
*/
public final void onPulse(Terminal terminal) {
if (terminal.getParent() instanceof Jack) {
Jack jack = (Jack) terminal.getParent();
if (CfgConst.BROKEN_STATE_BREAK.equals(jack.getBrokenState())) {
return;
}
}
TermTeam team = terminal.getTeam();
team.signIn(terminal);
if (!team.resetIfReady()) {
return;
}
onPulseLocal(terminal);
}
use of com.cas.circuit.vo.Jack in project TeachingInSimulation by ScOrPiOzzy.
the class ElecCompCPU method setElecComp.
/*
* (non-Javadoc)
* @see com.cas.me.appState.electric.BaseElectricCompState#setElecComp(com.cas.me.data.layout.ElecComp)
*/
@Override
public void setElecComp(ElecComp elecComp) {
super.setElecComp(elecComp);
Map<String, Jack> jackMap = elecComp.getDef().getJackMap();
for (Jack jack : jackMap.values()) {
if ("JF".equals(jack.getPO().getFormat())) {
jf_evn_names.add(EVN_NAME_PRE + jack.getPO().getName());
jf_jacks.add(jack);
} else if ("CB".equals(jack.getPO().getFormat())) {
cb_evn_names.add(EVN_NAME_PRE + jack.getPO().getName());
cbx_jacks.add(jack);
} else if ("COP".equals(jack.getPO().getFormat())) {
cop_evn_names.add(EVN_NAME_PRE + jack.getPO().getName());
cop_jacks.add(jack);
} else if (jack.getPO().getFormat().indexOf("JFR") != -1) {
jfr_evn_names.add(EVN_NAME_PRE + jack.getPO().getName());
jfr_jacks.add(jack);
} else {
log.info(jack.getPO().getFormat() + "这个插孔不能产生信号电,关于'产生信号电'不理解的,可以问振宇");
}
}
}
use of com.cas.circuit.vo.Jack in project TeachingInSimulation by ScOrPiOzzy.
the class LinkerData method addLinker.
// /**
// * 所负责工作站
// */
// private byte stationInCharge;
public LinkerMsg addLinker(ILinker linker, ILinkTarget target, String wireMark) {
// 封装LinkerInfo
LinkerMsg linkInfo = new LinkerMsg();
if (linker instanceof Wire) {
linkInfo.setLinkType(LinkerMsg.WIRE);
} else if (linker instanceof Pipe) {
linkInfo.setLinkType(LinkerMsg.PIPE);
} else if (linker instanceof Cable) {
if (target instanceof Jack) {
linkInfo.setLinkType(LinkerMsg.CABLE_JACK);
linkInfo.setElecComp(((Cable) linker).isElecComp());
} else {
linkInfo.setLinkType(LinkerMsg.CABLE_TERM);
// A、B、C
linkInfo.setWireMark(wireMark);
}
linkInfo.setCableKey(((Cable) linker).getPO().getId());
}
linkInfo.setKey(linker.hashCode());
linkInfo.setColor(linker.getColor());
linkInfo.setElecCompKey(target.getElecCompKey());
linkInfo.setTargetKey(target.getTargetKey());
// 线号
linkInfo.setNumMark(linker.getWireNum());
linkerMapForSave.put(linker.hashCode() + "_" + target.hashCode(), linkInfo);
return linkInfo;
}
Aggregations