use of com.cas.circuit.vo.ElecCompDef in project TeachingInSimulation by ScOrPiOzzy.
the class R method shareVoltageLocal.
/**
* 电源调用,
* @return
*/
protected boolean shareVoltageLocal() {
// 找出上一次电路中参与的连接头
List<Terminal> lastCircuitTerminal = new ArrayList<Terminal>();
for (IP ip : allIsopoList) {
addNonRepeatListAll(lastCircuitTerminal, ip.getTerminals());
// lastCircuitTerminal.addAll(ip.getTerminals());
}
// 计算电路电阻
CR cr = mesure();
if (startIP == null || endIP == null) {
Logger.getLogger(this.getClass().getCanonicalName()).warn("startIP == null || endIP == null");
return true;
}
if (cr.getValue() == CR.MIN_RESIS_VALUE) {
startTerminal.getElecComp().powerShorted(startTerminal, endTerminal);
return false;
}
cr.getIsopo2().setVoltageValue(0);
cr.getIsopo1().setVoltageValue(voltage.getValue());
// 根据电阻分压
cr.shareVoltage();
if (startIP == null || endIP == null) {
// System.out.println("电压已经清除了");
return false;
}
// 记录所走到元器件
List<ElecCompDef> elecCompList = new ArrayList<ElecCompDef>();
// 找出本次电路中参与的连接头
List<Terminal> thisCircuitTerminal = new ArrayList<Terminal>();
for (IP ip : allIsopoList) {
// thisCircuitTerminal.addAll(ip.getTerminals());
addNonRepeatListAll(thisCircuitTerminal, ip.getTerminals());
findElecComp(elecCompList, ip.getTerminals(), true);
}
// 剩余的连接头表示是此次电路中没有涉及的,需要清理连接头上的电压
lastCircuitTerminal.removeAll(thisCircuitTerminal);
// elecCompSet.clear();
IP ip = null;
// FIXME false
findElecComp(elecCompList, lastCircuitTerminal, false);
for (Terminal terminal : lastCircuitTerminal) {
if (!startIP.hasTerminal(terminal) && !endIP.hasTerminal(terminal)) {
ip = terminal.getIsopotential(voltage.getEnv());
if (ip != null) {
ip.detory();
}
terminal.removeVolt(voltage.getEnv());
}
}
for (ElecCompDef elecCompDef : elecCompList) {
if (elecCompDef != null) {
elecCompDef.doMagnetism();
}
}
return lastCircuitTerminal.size() != 0;
}
use of com.cas.circuit.vo.ElecCompDef in project TeachingInSimulation by ScOrPiOzzy.
the class R method shutPowerDown.
public void shutPowerDown() {
List<ElecCompDef> elecCompList = new ArrayList<ElecCompDef>();
for (IP ip : allIsopoList) {
findElecComp(elecCompList, ip.getTerminals(), true);
ip.clearVolt();
}
cleanProperty();
for (ElecCompDef elecCompDef : elecCompList) {
if (elecCompDef != null) {
elecCompDef.doMagnetism();
}
}
if ("Tmp_REMOVE".equals(voltage.getEnv())) {
return;
}
R removed = cache.remove(voltage.getEnv());
boolean result = this == removed;
if (result) {
Logger.getLogger(R.class.getCanonicalName()).info("移除电源" + voltage.getEnv() + "剩余电源" + String.valueOf(cache.size()) + ":" + cache.values().toString());
}
}
use of com.cas.circuit.vo.ElecCompDef 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.ElecCompDef in project TeachingInSimulation by ScOrPiOzzy.
the class MMT_4QLogic method initialize.
@Override
public void initialize(Node elecCompMdl) {
super.initialize(elecCompMdl);
ElecCompDef def = elecComp.getDef();
dcin1 = def.getTerminal("DCIN+");
dcin2 = def.getTerminal("DCIN-");
en = def.getTerminal("EN");
com1 = def.getTerminal("COM1");
dir = def.getTerminal("DIR");
com2 = def.getTerminal("COM2");
out1 = def.getTerminal("OUT+");
out2 = def.getTerminal("OUT-");
}
Aggregations