org.diirt.datasource.graphene.ExpressionLanguage Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of datasource-graphene Show documentation
Show all versions of datasource-graphene Show documentation
Support for real-time graph rendering with graphene.
/**
* Copyright (C) 2010-14 diirt developers. See COPYRIGHT.TXT
* All rights reserved. Use is subject to license terms. See LICENSE.TXT
*/
package org.diirt.datasource.graphene;
import java.util.Arrays;
import java.util.List;
import org.diirt.datasource.BasicTypeSupport;
import static org.diirt.datasource.ExpressionLanguage.*;
import org.diirt.datasource.NotificationSupport;
import org.diirt.datasource.ReadFunction;
import org.diirt.datasource.TypeSupport;
import org.diirt.datasource.vtype.DataTypeSupport;
import org.diirt.vtype.VNumber;
import org.diirt.vtype.VNumberArray;
import org.diirt.datasource.expression.DesiredRateExpression;
import org.diirt.datasource.expression.DesiredRateExpressionImpl;
import org.diirt.datasource.expression.DesiredRateExpressionList;
import org.diirt.datasource.expression.DesiredRateExpressionListImpl;
import org.diirt.datasource.expression.SourceRateExpression;
import org.diirt.util.array.ListNumbers;
import org.diirt.vtype.VTable;
import org.diirt.vtype.ValueFactory;
/**
*
* @author carcassi
*/
public class ExpressionLanguage {
private ExpressionLanguage() {}
static {
// Add support for Epics types.
DataTypeSupport.install();
// Add support for Basic types
BasicTypeSupport.install();
TypeSupport.addTypeSupport(NotificationSupport.immutableTypeSupport(Graph2DResult.class));
}
public static HistogramGraph2DExpression histogramGraphOf(
DesiredRateExpression> arrayData) {
return new HistogramGraph2DExpression(arrayData);
}
public static IntensityGraph2DExpression intensityGraphOf(
DesiredRateExpression> arrayData) {
return new IntensityGraph2DExpression(arrayData);
}
public static LineGraph2DExpression lineGraphOf(DesiredRateExpression extends VNumberArray> vDoubleArray) {
return lineGraphOf(vDoubleArray, null, null, null);
}
public static LineGraph2DExpression lineGraphOf(final DesiredRateExpression extends VNumberArray> yArray,
final DesiredRateExpression extends VNumber> xInitialOffset,
final DesiredRateExpression extends VNumber> xIncrementSize) {
DesiredRateExpression data = new DesiredRateExpressionImpl<>(createList(yArray, xInitialOffset, xIncrementSize),
new ReadFunction() {
@Override
public VTable readValue() {
VNumberArray values = yArray.getFunction().readValue();
VNumber offset = xInitialOffset.getFunction().readValue();
VNumber increment = xIncrementSize.getFunction().readValue();
if (values == null || offset == null || increment == null) {
return null;
}
return ValueFactory.newVTable(Arrays.>asList(double.class, double.class),
Arrays.asList("X", "Y"),
Arrays.