use of com.cas.circuit.vo.ElecCompDef in project TeachingInSimulation by ScOrPiOzzy.
the class R method shareVoltage.
public void shareVoltage() {
// 记录当前电路中涉及的连接头lastCircuitTerminal
List<Terminal> lastCircuitTerminal = new ArrayList<Terminal>();
for (IP ip : allIsopoList) {
addNonRepeatListAll(lastCircuitTerminal, ip.getTerminals());
// lastCircuitTerminal.addAll(ip.getTerminals());
}
int count = 0;
// 真实的分压操作
while (shareVoltageLocal()) {
count++;
if (count > 10) {
// 防止死循环
System.out.println("死循环啦");
break;
}
}
if (startIP == null || endIP == null) {
return;
}
// 找出分压后当前电路中的连接头thisCircuitTerminal
List<ElecCompDef> elecCompList = new ArrayList<ElecCompDef>();
List<Terminal> thisCircuitTerminal = new ArrayList<Terminal>();
for (IP ip : allIsopoList) {
addNonRepeatListAll(thisCircuitTerminal, ip.getTerminals());
// thisCircuitTerminal.addAll(ip.getTerminals());
// 找出所走到的连接头所属元器件,因为有些元器件如:开关电源,可算是一个电源的,当满足输入电压后,将输出电压
findElecComp(elecCompList, ip.getTerminals(), true);
}
// 过滤出电路没有走到的连接头,这些lastCircuitTerminal连接头即将清除电压
lastCircuitTerminal.removeAll(thisCircuitTerminal);
// 找出要被清理电压的连接头所属的元器件,因为有些元器件如:开关电源,可算是一个电源的将无法输出电压
findElecComp(elecCompList, lastCircuitTerminal, false);
// System.out.println("shareVoltage这些连接头 本次电路中没有走到" + lastCircuitTerminal);
// 即将清除电压
IP ip = null;
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();
}
}
}
use of com.cas.circuit.vo.ElecCompDef in project TeachingInSimulation by ScOrPiOzzy.
the class JaxbTest method testName.
@Test
public void testName() throws Exception {
File file = new File("src/main/resources/config/");
// File[] subFiles = file.listFiles();
// for (int i = 0; i < subFiles.length; i++) {
// File xml = subFiles[i];
// if(xml.getName().endsWith("xml")) {
// ElecCompDef eleccomp = JaxbUtil.converyToJavaBean(new String(Files.readAllBytes(xml.toPath())), ElecCompDef.class);
// System.out.println(JaxbUtil.convertToXml(eleccomp));
// eleccomp.build();
// }
// }
ElecCompDef eleccomp = JaxbUtil.converyToJavaBean(new String(Files.readAllBytes(new File(file, "DZ47-63C16.xml").toPath())), ElecCompDef.class);
System.out.println(JaxbUtil.convertToXml(eleccomp));
// Archive archive = JaxbUtil.converyToJavaBean(new File(file, "Test.xml").toURI().toURL(), Archive.class);
Archive archive = JaxbUtil.converyToJavaBean(new URL("http://192.168.1.123:8082/archives/Test.xml"), Archive.class);
Assert.assertNotNull(archive);
System.out.println(archive);
}
use of com.cas.circuit.vo.ElecCompDef in project TeachingInSimulation by ScOrPiOzzy.
the class FX3UPLCLogic method initialize.
@Override
public void initialize(Node elecCompMdl) {
super.initialize(elecCompMdl);
assist = new FX3UPLCLogicAssist(this);
ElecCompDef elecCompDef = elecComp.getDef();
term_SS = elecCompDef.getTerminal("S/S");
term_24V = elecCompDef.getTerminal("24V");
if (term_24V == null) {
term_24V = elecCompDef.getTerminal("24V_1");
}
if (term_24V == null) {
term_24V = elecCompDef.getTerminal("24V_2");
}
term_0V = elecCompDef.getTerminal("0V");
if (term_0V == null) {
term_0V = elecCompDef.getTerminal("0V_1");
}
if (term_0V == null) {
term_0V = elecCompDef.getTerminal("0V_2");
}
// Jack jack = elecCompDef.getJackMap().get("RS-485");
sda = elecCompDef.getTerminal("SDA");
sdb = elecCompDef.getTerminal("SDB");
rda = elecCompDef.getTerminal("RDA");
rdb = elecCompDef.getTerminal("RDB");
SIGNAL_EVN = "PLC" + hashCode();
// opc中设备名对应的并非工作站,而是针对具体某一个PLC元器件,所以opc相关信息写入
// 1、引用的PLC模型的userdata中,elecCompMdl.getUserdata("device")。注意:并不是elecCompMdl.getChild(0).getUserData("device")。
// 2、在应用PLC元器件配置文件的文本域中,elecComp.getProperty("deivce");
final String deviceName = elecComp.getProperty("device");
if (Util.isEmpty(deviceName)) {
throw new RuntimeException("需要给" + elecComp + "声明opc中的device");
}
this.deviceName = deviceName;
try {
client = new OPCClientImpl(InetAddress.getLocalHost().getHostAddress());
client.setDeviceName(deviceName);
client.addOPCSignalVisitor(this);
} catch (UnknownHostException e) {
log.error(e.getMessage(), e);
}
initialize = true;
}
use of com.cas.circuit.vo.ElecCompDef in project TeachingInSimulation by ScOrPiOzzy.
the class ConnectionHandler method connectByLinkerInfo.
/**
* 联机状态下接线
* @param linkerInfo 接线消息
* @param wireOrPipe
* @param modifiable
*/
private void connectByLinkerInfo(LinkerMsg linkerInfo, ILinker wireOrPipe, boolean modifiable) {
ElecComp elecComp = eleCompMap.get(linkerInfo.getElecCompKey());
if (elecComp == null) {
log.info("未找到指定元器件的定义信息:" + linkerInfo.getElecCompKey());
return;
}
ElecCompDef def = elecComp.getDef();
byte linkType = linkerInfo.getLinkType();
String targetKey = linkerInfo.getTargetKey();
ILinkTarget termOrPort = null;
if (LinkerMsg.WIRE == linkType || LinkerMsg.CABLE_TERM == linkType) {
termOrPort = def.getTerminalMap().get(targetKey);
} else if (LinkerMsg.PIPE == linkType) {
termOrPort = def.getGasPortMap().get(targetKey);
} else if (LinkerMsg.CABLE_JACK == linkType) {
termOrPort = def.getJackMap().get(targetKey);
}
if (wireOrPipe instanceof Cable && termOrPort instanceof Terminal) {
((Cable) wireOrPipe).setNowConnectingWire(linkerInfo.getWireMark());
((Cable) wireOrPipe).getNowConnectingWire().setWireNum(linkerInfo.getNumMark());
}
wireOrPipe.setWireNum(linkerInfo.getNumMark());
Spatial model = connect(wireOrPipe, termOrPort, true);
if (currSaveLinker != null) {
wireOrPipe = currSaveLinker;
}
// 接线头添加鼠标监听事件
addMouseEvent(model, new LinkerEventAdapter(new LinkerEventHandler(wireOrPipe, this, modifiable)));
// 记录准备存档的信息
if (modifiable) {
linkerData.addLinker(wireOrPipe, termOrPort, (String) model.getUserData("WireMark"));
}
}
use of com.cas.circuit.vo.ElecCompDef in project TeachingInSimulation by ScOrPiOzzy.
the class ConnectionHandler method bindSaveTransEvent.
private Cable bindSaveTransEvent(String elecCompKey, Cable cable, boolean modifiable) {
ElecComp elecComp = eleCompMap.get(elecCompKey);
if (elecComp == null) {
System.err.println("找不到elecCompKey : " + elecCompKey);
return null;
// throw new RuntimeException("找不到elecCompKey : " + elecCompKey);
}
ElecCompDef def = elecComp.getDef();
def.buildCompLogic();
Node elecCompMdl = (Node) parent.getChild(elecComp.getPO().getMdlName());
JmeUtil.setSpatialHighLight(elecCompMdl, ColorRGBA.BlackNoAlpha);
// MouseEventState.cleanEvent(elecCompMdl);
elecCompMdl.setUserData("MouseEvent", null);
Jack jack = def.getJackMap().values().iterator().next();
TransducersHandler handler = new TransducersHandler(this, elecComp, jack, modifiable);
cable.bind(jack);
cable.setElecComp(true);
cable.getModels().put(elecCompMdl, jack);
if (modifiable) {
linkerData.addLinker(cable, jack, null);
}
handler.setCable(cable);
addMouseEvent(elecCompMdl, new TransducersAdapter(handler));
return cable;
}
Aggregations