Search in sources :

Example 1 with BaseElectricCompLogic

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();
}
Also used : XmlElementWrapper(javax.xml.bind.annotation.XmlElementWrapper) ElecCompProxy(com.cas.circuit.vo.archive.ElecCompProxy) HashMap(java.util.HashMap) Function(java.util.function.Function) ArrayList(java.util.ArrayList) R(com.cas.circuit.util.R) HashSet(java.util.HashSet) LinkedHashMap(java.util.LinkedHashMap) Node(com.jme3.scene.Node) BaseElectricCompLogic(com.cas.circuit.BaseElectricCompLogic) ElecComp(com.cas.sim.tis.entity.ElecComp) Map(java.util.Map) XmlJavaTypeAdapter(javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter) MesureResult(com.cas.circuit.util.MesureResult) Nonnull(javax.annotation.Nonnull) ElecCompCPU(com.cas.circuit.ElecCompCPU) XmlAccessorType(javax.xml.bind.annotation.XmlAccessorType) XmlAttribute(javax.xml.bind.annotation.XmlAttribute) Unmarshaller(javax.xml.bind.Unmarshaller) ZeroOneBooleanAdapter(com.sun.tools.internal.xjc.runtime.ZeroOneBooleanAdapter) Set(java.util.Set) XmlRootElement(javax.xml.bind.annotation.XmlRootElement) Collectors(java.util.stream.Collectors) XmlAccessType(javax.xml.bind.annotation.XmlAccessType) List(java.util.List) CompLogicAdapter(com.cas.circuit.xml.adapter.CompLogicAdapter) XmlElement(javax.xml.bind.annotation.XmlElement) TermTeam(com.cas.circuit.TermTeam) TermTeam(com.cas.circuit.TermTeam) BaseElectricCompLogic(com.cas.circuit.BaseElectricCompLogic) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

BaseElectricCompLogic (com.cas.circuit.BaseElectricCompLogic)1 ElecCompCPU (com.cas.circuit.ElecCompCPU)1 TermTeam (com.cas.circuit.TermTeam)1 MesureResult (com.cas.circuit.util.MesureResult)1 R (com.cas.circuit.util.R)1 ElecCompProxy (com.cas.circuit.vo.archive.ElecCompProxy)1 CompLogicAdapter (com.cas.circuit.xml.adapter.CompLogicAdapter)1 ElecComp (com.cas.sim.tis.entity.ElecComp)1 Node (com.jme3.scene.Node)1 ZeroOneBooleanAdapter (com.sun.tools.internal.xjc.runtime.ZeroOneBooleanAdapter)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 LinkedHashMap (java.util.LinkedHashMap)1 List (java.util.List)1 Map (java.util.Map)1 Set (java.util.Set)1 Function (java.util.function.Function)1 Collectors (java.util.stream.Collectors)1 Nonnull (javax.annotation.Nonnull)1