use of com.cas.sim.tis.entity.ElecComp in project TeachingInSimulation by ScOrPiOzzy.
the class CircuitState method readEleccomps.
private void readEleccomps(@Nonnull List<ElecCompProxy> compProxyList) {
ElecCompAction action = SpringUtil.getBean(ElecCompAction.class);
// 一、开始加载元器件
compProxyList.forEach(proxyComp -> {
// 1、根据元器件型号(model字段),查找数据库中的元器件实体对象
ElecComp elecComp = action.findElecCompById(proxyComp.getId());
if (elecComp == null) {
LOG.warn("没有找到ID号为{}的元器件", proxyComp.getId());
}
// 2、加载模型,同时设置好坐标与旋转
Future<Node> task = app.enqueue((Callable<Node>) () -> {
Node node = (Node) loadAsset(new ModelKey(elecComp.getMdlPath()));
// 设置transform信息:location、rotation
node.setLocalTranslation(proxyComp.getLocation());
node.setLocalRotation(proxyComp.getRotation());
node.scale(25);
return node;
});
Node compMdl = null;
try {
compMdl = task.get();
} catch (Exception e) {
LOG.error("无法加载元器件模型{}:{}", elecComp.getMdlPath(), e);
throw new RuntimeException(e);
}
// 3、初始化元器件逻辑对象
URL cfgUrl = SpringUtil.getBean(HTTPUtils.class).getUrl(elecComp.getCfgPath());
ElecCompDef def = JaxbUtil.converyToJavaBean(cfgUrl, ElecCompDef.class);
def.setProxy(proxyComp);
def.setElecComp(elecComp);
if (ElecComp.COMBINE_TOP == elecComp.getCombine()) {
// 获得底座,底座的排序一定在元器件之前
Map<String, ElecCompDef> compMap = compList.stream().collect(Collectors.toMap(x -> x.getProxy().getUuid(), x -> x));
ElecCompDef baseDef = compMap.get(proxyComp.getBaseUuid());
attachToBase(compMdl, def, baseDef);
} else {
// 加入电路板中
attachToCircuit(compMdl, def);
}
});
}
use of com.cas.sim.tis.entity.ElecComp in project TeachingInSimulation by ScOrPiOzzy.
the class PreparationDetail method openCognition.
private void openCognition(Integer id) {
ElecComp comp = SpringUtil.getBean(ElecCompAction.class).findElecCompById(id);
PageController controller = SpringUtil.getBean(PageController.class);
Recongnize3D content = new Recongnize3D();
controller.loadContent(content, PageLevel.Level2);
controller.showLoading();
controller.setEndHideLoading((v) -> {
content.setElecComp(comp);
});
}
use of com.cas.sim.tis.entity.ElecComp in project TeachingInSimulation by ScOrPiOzzy.
the class CircuitTest method testParseCfg.
@Test
public void testParseCfg() throws Exception {
ElecCompService service = (ElecCompService) elecCompServiceFactory.getObject();
// ID:10\11
// ElecComp elecComp = service.findById(10);
ElecComp elecComp = service.findBy("model", "CJX2-12");
String cfgPath = util.getFullPath(elecComp.getCfgPath());
URL url = new URL(cfgPath);
ElecCompDef elecCompDef = JaxbUtil.converyToJavaBean(url, ElecCompDef.class);
System.out.println(elecCompDef);
System.out.println(JaxbUtil.convertToXml(elecCompDef));
}
use of com.cas.sim.tis.entity.ElecComp in project TeachingInSimulation by ScOrPiOzzy.
the class ElecCompServiceImpl method findElecCompGroupByType.
@Override
public Map<Integer, List<ElecComp>> findElecCompGroupByType() {
ElecCompMapper dao = (ElecCompMapper) mapper;
List<ElecComp> all = dao.selectAll();
if (all == null) {
return new HashMap<>();
}
return all.stream().collect(Collectors.groupingBy(ElecComp::getType));
}
use of com.cas.sim.tis.entity.ElecComp in project TeachingInSimulation by ScOrPiOzzy.
the class ElecCompServiceImpl method findElecCompByModel.
@Override
public ElecComp findElecCompByModel(String model) {
ElecCompMapper dao = (ElecCompMapper) mapper;
Condition condition = new Condition(ElecComp.class);
Criteria criteria = condition.createCriteria();
criteria.andEqualTo("model", model);
List<ElecComp> compList = dao.selectByCondition(condition);
if (compList.size() == 0) {
return null;
} else if (compList.size() > 1) {
throw new TooManyResultsException();
}
return compList.get(0);
}
Aggregations