Search in sources :

Example 26 with ModelItem

use of org.csstudio.trends.databrowser3.model.ModelItem in project org.csstudio.display.builder by kasemir.

the class EditFormulaDialog method open.

/**
 * Open, i.e. display the dialog.
 *  @return <code>true</code> when the item was updated,
 *          <code>false</code> for 'cancel'
 */
public boolean open() {
    try {
        // Edit
        dialog = new FormulaDialog(shell, formula.getExpression(), determineInputs());
        if (dialog.open() != Window.OK)
            return false;
        // Update model item with new formula from dialog
        final Model model = formula.getModel().get();
        final ArrayList<FormulaInput> new_inputs = new ArrayList<FormulaInput>();
        for (final InputItem input : dialog.getInputs()) {
            final ModelItem item = model.getItem(input.getInputName());
            if (item == null)
                // $NON-NLS-1$
                throw new Exception("Cannot locate formula input " + input.getInputName());
            new_inputs.add(new FormulaInput(item, input.getVariableName()));
        }
        // Update formula via undo-able command
        new ChangeFormulaCommand(shell, operations_manager, formula, dialog.getFormula(), new_inputs.toArray(new FormulaInput[new_inputs.size()]));
    } catch (final Exception ex) {
        ExceptionDetailsErrorDialog.openError(shell, Messages.Error, ex);
        return false;
    }
    return true;
}
Also used : FormulaDialog(org.csstudio.apputil.ui.formula.FormulaDialog) InputItem(org.csstudio.apputil.ui.formula.InputItem) Model(org.csstudio.trends.databrowser3.model.Model) ArrayList(java.util.ArrayList) FormulaInput(org.csstudio.trends.databrowser3.model.FormulaInput) ModelItem(org.csstudio.trends.databrowser3.model.ModelItem)

Example 27 with ModelItem

use of org.csstudio.trends.databrowser3.model.ModelItem in project org.csstudio.display.builder by kasemir.

the class ControllerDemo method createModel.

private void createModel() throws Exception {
    model = new Model();
    model.setMacros(new TestMacros());
    ModelItem item;
    item = new PVItem("$(simu)", 1);
    item.setDisplayName("$(name)");
    item.setAxis(model.addAxis());
    model.addItem(item);
    item = new FormulaItem("math", "sine*0.5+2", new FormulaInput[] { new FormulaInput(item, "sine") });
    item = new PVItem("sim://ramp", 0);
    item.setDisplayName("Ramp (monitored)");
    item.setAxis(model.addAxis());
    model.addItem(item);
    final ArchiveDataSource archive = new ArchiveDataSource("jdbc:oracle:thin:sns_reports/sns@(DESCRIPTION=(ADDRESS_LIST=(LOAD_BALANCE=OFF)(ADDRESS=(PROTOCOL=TCP)(HOST=172.31.75.138)(PORT=1521))(ADDRESS=(PROTOCOL=TCP)(HOST=172.31.75.141)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=ics_prod_lba)))", 1, "rdb");
    item = new PVItem("CCL_LLRF:IOC1:Load", 0);
    ((PVItem) item).addArchiveDataSource(archive);
    item.setDisplayName("CCL 1 CPU Load (monitored)");
    item.setAxis(model.addAxis());
    model.addItem(item);
    item = new PVItem("DTL_LLRF:IOC1:Load", 1.0);
    ((PVItem) item).addArchiveDataSource(archive);
    item.setDisplayName("DTL 1 CPU Load (1 sec)");
    item.setAxis(model.addAxis());
    model.addItem(item);
    item = new FormulaItem("calc", "dtl-10", new FormulaInput[] { new FormulaInput(item, "dtl") });
    item.setDisplayName("Lessened Load");
    item.setAxis(model.getAxis(2));
    model.addItem(item);
}
Also used : FormulaItem(org.csstudio.trends.databrowser3.model.FormulaItem) Model(org.csstudio.trends.databrowser3.model.Model) ModelItem(org.csstudio.trends.databrowser3.model.ModelItem) FormulaInput(org.csstudio.trends.databrowser3.model.FormulaInput) ArchiveDataSource(org.csstudio.trends.databrowser3.model.ArchiveDataSource) PVItem(org.csstudio.trends.databrowser3.model.PVItem)

Aggregations

ModelItem (org.csstudio.trends.databrowser3.model.ModelItem)23 ArrayList (java.util.ArrayList)12 PVItem (org.csstudio.trends.databrowser3.model.PVItem)10 AxisConfig (org.csstudio.trends.databrowser3.model.AxisConfig)7 VType (org.diirt.vtype.VType)6 Instant (java.time.Instant)5 ValueIterator (org.csstudio.archive.reader.ValueIterator)5 Model (org.csstudio.trends.databrowser3.model.Model)4 PlotSample (org.csstudio.trends.databrowser3.model.PlotSample)4 AnnotationInfo (org.csstudio.trends.databrowser3.model.AnnotationInfo)3 ArchiveDataSource (org.csstudio.trends.databrowser3.model.ArchiveDataSource)3 FormulaInput (org.csstudio.trends.databrowser3.model.FormulaInput)3 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)3 SelectionEvent (org.eclipse.swt.events.SelectionEvent)3 PrintWriter (java.io.PrintWriter)2 InputItem (org.csstudio.apputil.ui.formula.InputItem)2 TraceType (org.csstudio.javafx.rtplot.TraceType)2 PlotSamples (org.csstudio.trends.databrowser3.model.PlotSamples)2 RequestType (org.csstudio.trends.databrowser3.model.RequestType)2 XMLPersistence (org.csstudio.trends.databrowser3.persistence.XMLPersistence)2