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)"));
}
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);
}
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()));
}
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();
});
}
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());
}
Aggregations