use of com.cas.circuit.BaseElectricCompLogic in project TeachingInSimulation by ScOrPiOzzy.
the class ElecCompDef method afterUnmarshal.
public void afterUnmarshal(Unmarshaller u, Object parent) {
jackMap = jackList.stream().collect(Collectors.toMap(Jack::getId, data -> data));
terminalMap = terminalList.stream().collect(Collectors.toMap(Terminal::getId, data -> data));
stitchMap = stitchList.stream().collect(Collectors.toMap(Stitch::getId, data -> data));
resisStatesMap = resisStateList.stream().collect(Collectors.toMap(ResisState::getId, data -> data));
//
termAndStich.putAll(terminalMap);
termAndStich.putAll(stitchMap);
jackList.stream().forEach(jack -> termAndStich.putAll(jack.getStitchList().stream().collect(Collectors.toMap(Terminal::getId, Function.identity(), (key1, key2) -> key2, HashMap::new))));
magnetismList.stream().forEach(mag -> {
mag.getVoltageIOList().forEach(io -> {
Terminal term1 = getTerminal(io.getTerm1Id());
Terminal term2 = getTerminal(io.getTerm2Id());
if (term1 == null) {
throw new NullPointerException(name + "里的" + io.getTerm1Id() + "端子没找到");
} else {
term1.getVoltIOs().add(io);
io.setTerm1(term1);
}
if (term2 == null) {
throw new NullPointerException(name + "里的" + io.getTerm2Id() + "端子没找到");
} else {
term2.getVoltIOs().add(io);
io.setTerm2(term2);
}
});
});
resisStateList.stream().forEach(state -> {
state.getResisRelationList().forEach(resis -> {
resis.setTerm1(getTerminal(resis.getTerm1Id()));
resis.setTerm2(getTerminal(resis.getTerm2Id()));
if (state.getIsDef() == null) {
System.out.println("ElecCompDef.build()");
}
if (state.getIsDef()) {
resisRelationAdded(resis);
}
});
});
terminalList.forEach(t -> t.setElecComp(this));
// 将所有连接头进行分类
// Key:分类的名称, List<Terminal>一组的连接头
Map<String, List<Terminal>> groupTerminals = termAndStich.values().stream().filter(t -> t.getTeam() != null).collect(Collectors.groupingBy(Terminal::getTeam));
groupTerminals.entrySet().forEach(e -> new TermTeam(e.getKey(), e.getValue()));
paramMap = params.stream().collect(Collectors.toMap(Param::getKey, Param::getValue));
// ------------------
if (logic == null) {
logic = new BaseElectricCompLogic();
}
logic.setElecComp(this);
logic.initialize();
}
Aggregations