use of com.cas.gas.vo.BlockRelation in project TeachingInSimulation by ScOrPiOzzy.
the class ValveLogic method changeBlockState.
private void changeBlockState(String oldId, String newId) {
BlockState oldBlock = def.getBlockStatesMap().get(oldId);
if (oldBlock != null) {
List<BaseVO<?>> oldBlockList = oldBlock.getChildren();
for (BaseVO<?> baseVO : oldBlockList) {
if (baseVO instanceof BlockRelation) {
BlockRelation relation = (BlockRelation) baseVO;
def.blockRelationRemoved(relation);
G.g().refreshGasPressure();
}
}
}
BlockState newBlock = def.getBlockStatesMap().get(newId);
if (newBlock != null) {
List<BaseVO<?>> newBlockList = newBlock.getChildren();
for (BaseVO<?> baseVO : newBlockList) {
if (baseVO instanceof BlockRelation) {
BlockRelation relation = (BlockRelation) baseVO;
def.blockRelationAdded(relation);
G.g().refreshGasPressure();
}
}
}
}
use of com.cas.gas.vo.BlockRelation in project TeachingInSimulation by ScOrPiOzzy.
the class ValveLogicEx method changeBlockState.
private void changeBlockState(String oldId, String newId) {
BlockState oldBlock = def.getBlockStatesMap().get(oldId);
if (oldBlock != null) {
List<BaseVO<?>> oldBlockList = oldBlock.getChildren();
for (BaseVO<?> baseVO : oldBlockList) {
if (baseVO instanceof BlockRelation) {
BlockRelation relation = (BlockRelation) baseVO;
def.blockRelationRemoved(relation);
G.g().refreshGasPressure();
}
}
}
BlockState newBlock = def.getBlockStatesMap().get(newId);
if (newBlock != null) {
List<BaseVO<?>> newBlockList = newBlock.getChildren();
for (BaseVO<?> baseVO : newBlockList) {
if (baseVO instanceof BlockRelation) {
BlockRelation relation = (BlockRelation) baseVO;
def.blockRelationAdded(relation);
G.g().refreshGasPressure();
}
}
}
}
use of com.cas.gas.vo.BlockRelation in project TeachingInSimulation by ScOrPiOzzy.
the class ElecCompDef method onAllChildAdded.
@Override
protected void onAllChildAdded() {
super.onAllChildAdded();
// 搜集所有的连接头和针脚
// 搜集连接头
termAndStich.putAll(terminalMap);
// 搜集所有的针脚
Map<String, Terminal> stitchMap = null;
Iterator<Entry<String, Terminal>> it = null;
Entry<String, Terminal> entry = null;
for (BaseVO<?> baseVO : children) {
if (baseVO instanceof Jack) {
stitchMap = ((Jack) baseVO).getStitch();
it = stitchMap.entrySet().iterator();
while (it.hasNext()) {
entry = it.next();
termAndStich.put(entry.getValue().getLocalKey(), entry.getValue());
}
}
}
for (Magnetism mag : magnetisms) {
for (VoltageIO voltIO : mag.getVoltageIOs()) {
Terminal term1 = getTerminal(voltIO.getPO().getTerm1Id());
Terminal term2 = getTerminal(voltIO.getPO().getTerm2Id());
if (term1 == null) {
throw new NullPointerException(po.getName() + "里的" + voltIO.getPO().getTerm1Id() + "端子没找到");
} else {
term1.getVoltIOs().add(voltIO);
voltIO.setTerm1(term1);
}
if (term2 == null) {
throw new NullPointerException(po.getName() + "里的" + voltIO.getPO().getTerm2Id() + "端子没找到");
} else {
term2.getVoltIOs().add(voltIO);
voltIO.setTerm2(term2);
}
}
}
for (ResisState resisState : resisStates) {
for (BaseVO<?> baseVO : resisState.getChildren()) {
ResisRelation resis = (ResisRelation) baseVO;
resis.setTerm1(getTerminal(resis.getPO().getTerm1Id()));
resis.setTerm2(getTerminal(resis.getPO().getTerm2Id()));
if (resisState.isDef()) {
resisRelationAdded(resis);
}
}
}
//
Map<String, List<Terminal>> teamTerminalMap = new LinkedHashMap<String, List<Terminal>>();
String teamName = null;
for (Terminal terminal : termAndStich.values()) {
teamName = terminal.getPO().getTeam();
if (Util.notEmpty(teamName)) {
if (!teamTerminalMap.containsKey(teamName)) {
teamTerminalMap.put(teamName, new ArrayList<Terminal>());
}
teamTerminalMap.get(teamName).add(terminal);
}
}
for (Entry<String, List<Terminal>> entry2 : teamTerminalMap.entrySet()) {
new TermTeam(teamName, entry2.getValue());
}
for (BlockState blockState : blockStates) {
for (BaseVO<?> baseVO : blockState.getChildren()) {
BlockRelation block = (BlockRelation) baseVO;
block.setPort1(getGasPort(block.getPO().getPortId1()));
block.setPort2(getGasPort(block.getPO().getPortId2()));
if (blockState.isDef()) {
blockRelationAdded(block);
}
}
}
}
Aggregations