Search in sources :

Example 1 with GetSampleOutputV1

use of com.seeq.model.GetSampleOutputV1 in project com.inova8.intelligentgraph by peterjohnlawrence.

the class SEEQSource method getSignal.

/**
 * Gets the signal.
 *
 * @param signal the signal
 * @param customQueryOptions the custom query options
 * @return the signal
 * @throws HandledException the handled exception
 */
public Object getSignal(String signal, CustomQueryOptions customQueryOptions) throws HandledException {
    String start = getStart(customQueryOptions);
    String end = getEnd(customQueryOptions);
    String aggregate = getAggregate(customQueryOptions);
    String formula;
    switch(aggregate) {
        case INSTANT:
            GetSampleOutputV1 signalValue = signalsApi.getSample(signal, end, null, null, null);
            return signalValue.getSample().getValue();
        case AVERAGE:
            formula = "$tx01.average(capsule ('" + start + "','" + end + "')) ";
            return executeFunction(signal, formula);
        case MAXIMUM:
            formula = "$tx01.maxValue(capsule ('" + start + "','" + end + "')) ";
            return executeFunction(signal, formula);
        case MINIMUM:
            formula = "$tx01.minValue(capsule ('" + start + "','" + end + "')) ";
            return executeFunction(signal, formula);
        case TOTALIZED:
            formula = "$tx01.totalized(capsule ('" + start + "','" + end + "')) ";
            return executeFunction(signal, formula);
        default:
            logger.error("SEEQ Invalid aggregate: {}", aggregate);
            throw new HandledException(INVALIDAGGREGATE_EXCEPTION, aggregate);
    }
// return (olgap.Value) null;
}
Also used : HandledException(com.inova8.intelligentgraph.exceptions.HandledException) GetSampleOutputV1(com.seeq.model.GetSampleOutputV1)

Aggregations

HandledException (com.inova8.intelligentgraph.exceptions.HandledException)1 GetSampleOutputV1 (com.seeq.model.GetSampleOutputV1)1