Search in sources :

Example 1 with Model

use of org.csstudio.display.pace.model.Model in project phoebus by ControlSystemStudio.

the class ModelUnitTest method testModel.

/**
 * Check basic model readout:
 *  Correct title, # of columns, instances, cell's PV names?
 */
@Test
public void testModel() throws Exception {
    final Model model = new Model(Model.class.getResourceAsStream("/pace_examples/localtest.pace"));
    assertThat(model.getTitle(), equalTo("Demo"));
    assertThat(model.getColumns().size(), equalTo(3));
    assertThat(model.getColumns().get(0).getName(), equalTo("Setpoint"));
    assertThat(model.getColumns().get(1).getName(), equalTo("Limit"));
    assertThat(model.getInstances().size(), equalTo(5));
    assertThat(model.getInstances().get(0).getName(), equalTo("System 1"));
    assertThat(model.getInstances().get(0).getCell(0).getName(), equalTo("loc://setpoint1(1)"));
    assertThat(model.getInstances().get(4).getName(), equalTo("System 5"));
    assertThat(model.getInstances().get(4).getCell(1).getName(), equalTo("loc://limit5(5)"));
}
Also used : Model(org.csstudio.display.pace.model.Model) Test(org.junit.Test)

Example 2 with Model

use of org.csstudio.display.pace.model.Model in project phoebus by ControlSystemStudio.

the class ModelUnitTest method testModelPVs.

/**
 * Check PV connection.
 */
@Test
public void testModelPVs() throws Exception {
    final Model model = new Model(Model.class.getResourceAsStream("/pace_examples/localtest.pace"));
    model.addListener(listener);
    // Reset counter
    updates.set(0);
    // Should not see changes...
    Thread.sleep(3000);
    assertThat(updates.get(), equalTo(0));
    // Connect PVs, so now we expect to receive the current values
    model.start();
    // Give it some time
    for (int sec = 0; sec < 10; ++sec) {
        if (updates.get() > 20)
            break;
        Thread.sleep(1000);
    }
    model.stop();
    // Even though nobody edited the model...
    assertFalse(model.isEdited());
    // ... should have received a few (initial) updates
    assertTrue(updates.get() > 0);
    // ... should have received a few real values
    assertTrue(values.get() > 0);
}
Also used : Model(org.csstudio.display.pace.model.Model) Test(org.junit.Test)

Example 3 with Model

use of org.csstudio.display.pace.model.Model in project phoebus by ControlSystemStudio.

the class PACEInstance method loadModel.

private void loadModel(final JobMonitor monitor, final URI resource) throws Exception {
    model = new Model(resource.toURL().openStream());
    gui.setModel(model);
    model.start();
    gui.setMessage(null);
    Platform.runLater(() -> tab.setLabel(model.getTitle()));
}
Also used : LogEntryModel(org.phoebus.logbook.ui.write.LogEntryModel) Model(org.csstudio.display.pace.model.Model)

Example 4 with Model

use of org.csstudio.display.pace.model.Model in project phoebus by ControlSystemStudio.

the class GUIDemo method start.

@Override
public void start(final Stage stage) throws Exception {
    final GUI gui = new GUI(dirty -> System.out.println("Table is dirty: " + dirty));
    stage.setScene(new Scene(gui, 800, 600));
    stage.show();
    JobManager.schedule("Load...", monitor -> {
        Thread.sleep(2000);
        final Model model = new Model(Model.class.getResourceAsStream("/pace_examples/localtest.pace"));
        gui.setModel(model);
        model.start();
    });
}
Also used : Model(org.csstudio.display.pace.model.Model) GUI(org.csstudio.display.pace.gui.GUI) Scene(javafx.scene.Scene)

Example 5 with Model

use of org.csstudio.display.pace.model.Model in project phoebus by ControlSystemStudio.

the class ModelUnitTest method testModelEdits.

/**
 * Check editing
 */
@Test
public void testModelEdits() throws Exception {
    // Create model that's not actually listening to PV updates
    final Model model = new Model(Model.class.getResourceAsStream("/pace_examples/localtest.pace"));
    model.addListener(listener);
    // Model has not been edited, find a cell to test changes
    // Reset counter
    updates.set(0);
    // Confirm Model has not been edited
    assertFalse(model.isEdited());
    // Assert that we have a non-readonly cell to test
    final Cell cell = model.getInstances().get(1).getCell(1);
    assertFalse(cell.isReadOnly());
    // Edit the cell
    cell.setUserValue("10");
    // Expect an update, cell and model in "edited" state
    assertThat(updates.get(), equalTo(1));
    assertTrue(cell.isEdited());
    assertTrue(model.isEdited());
    // Cell should reflect the value that we entered via setUserValue
    assertThat(cell.getObservable().getValue(), equalTo("10"));
    assertThat(cell.getUserValue(), equalTo("10"));
    // Revert to original value
    cell.clearUserValue();
    // Should result in another update, since value changes back
    assertThat(updates.get(), equalTo(2));
    // Confirm that the edited values were replaced with the original
    // and is no longer considered edited
    assertFalse(cell.isEdited());
    assertFalse(model.isEdited());
    assertThat(cell.getUserValue(), nullValue());
}
Also used : Model(org.csstudio.display.pace.model.Model) Cell(org.csstudio.display.pace.model.Cell) Test(org.junit.Test)

Aggregations

Model (org.csstudio.display.pace.model.Model)6 Test (org.junit.Test)4 Disposable (io.reactivex.rxjava3.disposables.Disposable)1 Semaphore (java.util.concurrent.Semaphore)1 Scene (javafx.scene.Scene)1 GUI (org.csstudio.display.pace.gui.GUI)1 Cell (org.csstudio.display.pace.model.Cell)1 LogEntryModel (org.phoebus.logbook.ui.write.LogEntryModel)1 PV (org.phoebus.pv.PV)1