use of com.cas.circuit.vo.Terminal in project TeachingInSimulation by ScOrPiOzzy.
the class CircuitState method readWires.
private void readWires(@Nonnull List<WireProxy> wireProxyList) {
Map<String, ElecCompDef> compMap = compList.stream().collect(Collectors.toMap(x -> x.getProxy().getUuid(), x -> x));
wireProxyList.forEach(proxy -> {
ElecCompDef taggedComp1 = compMap.get(proxy.getComp1Uuid());
Terminal term1 = taggedComp1.getTerminal(proxy.getTernimal1Id());
ElecCompDef taggedComp2 = compMap.get(proxy.getComp2Uuid());
Terminal term2 = taggedComp2.getTerminal(proxy.getTernimal2Id());
Wire wire = new Wire();
wire.setProxy(proxy);
wire.bind(term1);
wire.bind(term2);
Future<Geometry> task = app.enqueue((Callable<Geometry>) () -> {
Geometry wireMdl = JmeUtil.createCylinderLine(assetManager, proxy.getPointList(), proxy.getWidth(), proxy.getColor());
return wireMdl;
});
Geometry wireMdl = null;
try {
wireMdl = task.get();
} catch (Exception e) {
LOG.error("无法加载导线模型:{}", e);
throw new RuntimeException(e);
}
attachToCircuit(wireMdl, wire);
});
}
use of com.cas.circuit.vo.Terminal in project TeachingInSimulation by ScOrPiOzzy.
the class CircuitState method attachToBase.
public void attachToBase(Spatial holding, ElecCompDef elecCompDef, ElecCompDef baseDef) {
// FIXME 加入底座指定位置
Node parent = baseDef.getSpatial();
holding.scale(0.04f);
holding.setLocalTranslation(0, 0, 0);
parent.attachChild(holding);
// 2、绑定模型对象
elecCompDef.bindModel((Node) holding);
// 3、添加事件
bindElecCompEvent(elecCompDef);
// 4、连接元器件与底座对应连接头
Map<String, Terminal> bases = baseDef.getTerminalMap();
elecCompDef.getStitchList().forEach(s -> {
Terminal terminal = bases.get(s.getId());
s.setContacted(terminal);
terminal.setContacted(s);
});
// 5、绑定底座对象UUID
String baseUuid = baseDef.getProxy().getUuid();
elecCompDef.getProxy().setBaseUuid(baseUuid);
combineMap.put(baseUuid, elecCompDef.getProxy().getUuid());
// 6、最后将元器件加入列表中
compList.add(elecCompDef);
}
use of com.cas.circuit.vo.Terminal in project TeachingInSimulation by ScOrPiOzzy.
the class BaseElectricCompLogic method initialize.
public void initialize(Node elecCompMdl) {
// XXX for test
// System.out.println("BaseElectricCompLogic.initialize()" + Thread.currentThread().getName());
// log.log(Level.INFO, "加载元器件{0},用时{1}", new Object[] { elecComp.getPO().getTagName(), System.currentTimeMillis() });
this.elecCompMdl = elecCompMdl;
// 读取元器件铭牌信息
readNameplateInfo();
// elecCompMdl = (Node) MdlMapUtil.loadMdlWithAbbr(getElecComp().getDef().getPO().getMdlRef(), app.getAssetManager());
// elecCompMdl = (Node) parentMdl.getChild(getElecComp().getDef().getPO().getMdlRef());
// elecCompMdl = (Node) parentMdl.getChild(getElecComp().getPO().getMdlName());
// elecCompMdl = parentMdl;
// registerEvent();
// elecCompMdl.setLocalTranslation(getElecComp().getLocation());
// elecCompMdl.rotate(getElecComp().getRotation()[0], getElecComp().getRotation()[1], getElecComp().getRotation()[2]);
// elecCompMdl.setUserData(BaseElectricCompLogic.ELECCOMP_STATE, BaseElectricCompLogic.this);
Spatial tempSpatial = null;
// 遍历元气件中所有插座
Collection<Jack> jacks = getElecComp().getDef().getJackMap().values();
for (Jack jack : jacks) {
tempSpatial = getChild(elecCompMdl, jack.getPO().getMdlName(), jack);
jack.setModel(tempSpatial);
}
// 遍历元气件中所有连接头
Collection<Terminal> terminals = getElecComp().getDef().getTerminalMap().values();
for (Terminal terminal : terminals) {
tempSpatial = getChild(elecCompMdl, terminal.getPO().getMdlName(), terminal);
if (tempSpatial == null) {
log.warn(elecComp.getDef().getPO().getName() + "未找到模型名为" + terminal.getPO().getMdlName() + "的端子模型!");
continue;
}
terminal.setModel(tempSpatial);
// FIXME 端子连接数量的标签
String numStr = ((Node) tempSpatial).getChild(0).getUserData("num");
if (Util.isNumeric(numStr)) {
terminal.setNum(Integer.parseInt(numStr));
} else {
terminal.setNum(1);
}
}
// 遍历元器件中所有气口
Collection<GasPort> gasPorts = getElecComp().getDef().getGasPortMap().values();
for (GasPort gasPort : gasPorts) {
tempSpatial = getChild(elecCompMdl, gasPort.getPO().getMdlName(), gasPort);
gasPort.setModel(tempSpatial);
}
// TODO 加入元气件按钮开关...
ElecCompDef compDef = getElecComp().getDef();
List<Magnetism> magnetisms = compDef.getMagnetisms();
for (Magnetism magnetism : magnetisms) {
// 遍历磁环静中所有按钮
for (ControlIO controlIO : magnetism.getControlIOs()) {
tempSpatial = getChild(elecCompMdl, controlIO.getPO().getMdlName(), controlIO);
controlIO.setModel(tempSpatial);
}
// 遍历磁环静中所有指示灯
for (LightIO lightIO : magnetism.getLightIOs()) {
tempSpatial = getChild(elecCompMdl, lightIO.getPO().getMdlName(), lightIO);
lightIO.setModel(tempSpatial);
}
}
// 遍历元气件中所有指示灯
for (LightIO lightIO : compDef.getLightIOs()) {
tempSpatial = getChild(elecCompMdl, lightIO.getPO().getMdlName(), lightIO);
lightIO.setModel(tempSpatial);
}
}
use of com.cas.circuit.vo.Terminal in project TeachingInSimulation by ScOrPiOzzy.
the class ElecCompCPU method sendSignal.
/**
* @param jackNm 信号发生的插孔名称
* @param startIndex 具体的针脚号
* @param endIndex 具体的针脚号
* @param sign 电压对象
*/
public void sendSignal(String jackNm, String startIndex, String endIndex, CommandSignal sign) {
synchronized (this) {
// 判断当前插口是否允许发送指令
Jack jack = getJackMap().get(jackNm);
if (jack.isStopSend()) {
log.warn("无法发送信号!![" + jackNm + "]");
return;
}
Terminal startTerminal = getStitch(jackNm, startIndex);
Terminal endTerminal = getStitch(jackNm, endIndex);
String env = EVN_NAME_PRE + jackNm;
R r = R.getR(env);
if (r == null) {
r = R.createSignal(env, startTerminal, endTerminal, 24);
r.shareVoltage();
}
SignalVolt sv = (SignalVolt) r.getVoltage();
sv.changeCommandSignal(sign);
r.shareVoltage();
}
}
use of com.cas.circuit.vo.Terminal in project TeachingInSimulation by ScOrPiOzzy.
the class ElecCompCPU method getStitch.
/**
* @param jackNm 信号发生的插孔名称
* @param index 具体的针脚号
*/
public Terminal getStitch(String jackName, String index) {
Jack jack = getJackMap().get(jackName);
if (jack == null) {
System.err.println("没有找到名称为: " + jackName + "的插孔");
}
Terminal stitch = jack.getStitch().get(index);
if (stitch == null) {
System.err.println(jackName + "插孔中没有找到第: " + index + "跟针脚");
}
return stitch;
}
Aggregations