Search in sources :

Example 1 with Archive

use of com.cas.circuit.vo.Archive 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);
}
Also used : ElecCompDef(com.cas.circuit.vo.ElecCompDef) Archive(com.cas.circuit.vo.Archive) File(java.io.File) URL(java.net.URL) Test(org.junit.Test)

Example 2 with Archive

use of com.cas.circuit.vo.Archive in project TeachingInSimulation by ScOrPiOzzy.

the class CircuitState method save.

public void save() {
    Archive archive = new Archive();
    // 保存元器件列表
    saveEleccomps(archive);
    // 保存导线
    saveWires(archive);
    SpringUtil.getBean(TypicalCaseAction.class).save(typicalCase, archive);
}
Also used : Archive(com.cas.circuit.vo.Archive) TypicalCaseAction(com.cas.sim.tis.action.TypicalCaseAction)

Example 3 with Archive

use of com.cas.circuit.vo.Archive in project TeachingInSimulation by ScOrPiOzzy.

the class TypicalCaseState method setupCase.

public void setupCase(TypicalCase typicalCase) {
    // 1、清理垃圾
    if (circuitState != null) {
        stateManager.detach(circuitState);
    }
    // 创建新的circuitState
    circuitState = new CircuitState(typicalCase, root);
    stateManager.attach(circuitState);
    // 尝试解析出存档对象
    Archive archive = SpringUtil.getBean(ArchiveAction.class).parse(typicalCase.getArchivePath());
    if (archive == null) {
        // 结束加载界面
        Platform.runLater(() -> SpringUtil.getBean(PageController.class).hideLoading());
        return;
    }
    circuitState.read(archive);
    // 结束加载界面
    Platform.runLater(() -> SpringUtil.getBean(PageController.class).hideLoading());
}
Also used : Archive(com.cas.circuit.vo.Archive) ArchiveAction(com.cas.sim.tis.action.ArchiveAction)

Aggregations

Archive (com.cas.circuit.vo.Archive)3 ElecCompDef (com.cas.circuit.vo.ElecCompDef)1 ArchiveAction (com.cas.sim.tis.action.ArchiveAction)1 TypicalCaseAction (com.cas.sim.tis.action.TypicalCaseAction)1 File (java.io.File)1 URL (java.net.URL)1 Test (org.junit.Test)1