Search in sources :

Example 1 with SimpleConfig

use of io.engineblock.util.SimpleConfig in project engineblock by engineblock.

the class CoreServices method getInputDispenser.

// public static <A extends Activity> Optional<IntPredicateDispenser> getResultFilterDispenser(A activity) {
// Optional<IntPredicateDispenser> intPredicateDispenser = new SimpleConfig(activity, "resultfilter")
// .getString("type")
// .flatMap(ExperimentalResultFilterType.FINDER::get)
// .map(rft -> rft.getFilterDispenser(activity));
// return intPredicateDispenser;
// }
// 
public static <A extends Activity> InputDispenser getInputDispenser(A activity) {
    String inputTypeName = new SimpleConfig(activity, "input").getString("type").orElse("targetrate");
    InputType inputType = InputType.FINDER.getOrThrow(inputTypeName);
    InputDispenser dispenser = inputType.getInputDispenser(activity);
    Optional<Predicate<ResultReadable>> inputFilterDispenser = getInputFilter(activity);
    if (inputFilterDispenser.isPresent()) {
        dispenser = new FilteringInputDispenser(dispenser, inputFilterDispenser.get());
    }
    return dispenser;
}
Also used : SimpleConfig(io.engineblock.util.SimpleConfig) InputType(io.engineblock.activityapi.input.InputType) InputDispenser(io.engineblock.activityapi.input.InputDispenser) Predicate(java.util.function.Predicate)

Example 2 with SimpleConfig

use of io.engineblock.util.SimpleConfig in project engineblock by engineblock.

the class CoreInputDispenser method createInput.

private synchronized Input createInput(long slot) {
    SimpleConfig conf = new SimpleConfig(activity, "input");
    String inputType = conf.getString("type").orElse("targetrate");
    InputType inputTypeImpl = InputType.FINDER.getOrThrow(inputType);
    InputDispenser inputDispenser = inputTypeImpl.getInputDispenser(activity);
    if (inputDispenser instanceof ActivitiesAware) {
        ((ActivitiesAware) inputDispenser).setActivitiesMap(activities);
    }
    Input input = inputDispenser.getInput(slot);
    return input;
}
Also used : SimpleConfig(io.engineblock.util.SimpleConfig) Input(io.engineblock.activityapi.input.Input) InputType(io.engineblock.activityapi.input.InputType) InputDispenser(io.engineblock.activityapi.input.InputDispenser) ActivitiesAware(io.engineblock.activityapi.core.ActivitiesAware)

Example 3 with SimpleConfig

use of io.engineblock.util.SimpleConfig in project engineblock by engineblock.

the class CoreServices method getOutputDispenser.

public static <A extends Activity> Optional<OutputDispenser> getOutputDispenser(A activity) {
    OutputDispenser outputDispenser = new SimpleConfig(activity, "output").getString("type").flatMap(OutputType.FINDER::get).map(mt -> mt.getOutputDispenser(activity)).orElse(null);
    if (outputDispenser == null) {
        return Optional.empty();
    }
    Optional<Predicate<ResultReadable>> outputFilterDispenser = getOutputFilter(activity);
    if (outputFilterDispenser.isPresent()) {
        outputDispenser = new FilteringOutputDispenser(outputDispenser, outputFilterDispenser.get());
    }
    return Optional.ofNullable(outputDispenser);
}
Also used : SimpleConfig(io.engineblock.util.SimpleConfig) InputType(io.engineblock.activityapi.input.InputType) Activity(io.engineblock.activityapi.core.Activity) ResultValueFilterType(io.engineblock.activityapi.cyclelog.filters.ResultValueFilterType) OutputType(io.engineblock.activityapi.output.OutputType) Predicate(java.util.function.Predicate) OutputDispenser(io.engineblock.activityapi.output.OutputDispenser) SimpleConfig(io.engineblock.util.SimpleConfig) Optional(java.util.Optional) ResultReadable(io.engineblock.activityapi.cyclelog.buffers.results.ResultReadable) ResultFilterDispenser(io.engineblock.activityapi.cyclelog.filters.ResultFilterDispenser) InputDispenser(io.engineblock.activityapi.input.InputDispenser) OutputDispenser(io.engineblock.activityapi.output.OutputDispenser) Predicate(java.util.function.Predicate)

Aggregations

InputDispenser (io.engineblock.activityapi.input.InputDispenser)3 InputType (io.engineblock.activityapi.input.InputType)3 SimpleConfig (io.engineblock.util.SimpleConfig)3 Predicate (java.util.function.Predicate)2 ActivitiesAware (io.engineblock.activityapi.core.ActivitiesAware)1 Activity (io.engineblock.activityapi.core.Activity)1 ResultReadable (io.engineblock.activityapi.cyclelog.buffers.results.ResultReadable)1 ResultFilterDispenser (io.engineblock.activityapi.cyclelog.filters.ResultFilterDispenser)1 ResultValueFilterType (io.engineblock.activityapi.cyclelog.filters.ResultValueFilterType)1 Input (io.engineblock.activityapi.input.Input)1 OutputDispenser (io.engineblock.activityapi.output.OutputDispenser)1 OutputType (io.engineblock.activityapi.output.OutputType)1 Optional (java.util.Optional)1