Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  1. writing the code for the custom tranformationtransformation.
  2. configuring the custom tranformationtransformation,

How to write a custom transformation?

First step is to write the actual code for the tranformationtransformation. Running and debugging the actual transformation can be done by writing unit tests.

...

Now the code above will explained step by step to understand the details. First note that tranformation transformation implements the interface Calculation.

...

Code Block
package nl.wldelft.fews.openapi.transformationmodule;

import nl.wldelft.util.Initializable;
import nl.wldelft.util.TimeZeroConsumer;

public interface Calculation extends Function {

    /**
     * This method is called by the framework to do the actual calculations.
     * The implementing class should get the input from its InputVariable
     * fields and put the calculation output in its OutputVariable fields.
     * The framework will initialize the InputVariable and OutputVariable
     * fields and set the input values in the InputVariables before calling
     * this method and get the output values out of the OutputVariables
     * afterwards.
     *
     * @throws Exception
     */
    void calculate() throws Exception;
}

The method calculate() will contain the actual code for the transformation. The FEWS Transformation framework will automaticly invoke this method.

...

The fields option1 and option2 however dont have any values assigned! How can they have a value during runtime?
The answer is that the FEWS Transformation framework will inject the values at runtime in these variables. The actual values
are described defined in the configuration of the transformation. In the upcoming section, the configuration will be explained in detail.

...

The major difference between the use of the class Variable and TimeSeriesArray is that Variable is used when the output is only dependend on input values

of at the same timestep. For example when the transformation is calculating the discharge from the stage by using a rating curve than the output is only dependend of

...

In our example the output (just as the input) is defined as a Variable.

Code Block
@Output
Variable output = null;

...

in the input (Note than when the output is defined as a TimeSeriesArray, the input should also be defined as a TimSeriesArrayTimeSeriesArray). The example code we are using, could for example also

be writting with the input and output defined as a TimeSeriesArray.

The example code of such a transformation is given below.

The example code is given below.

...

The main difference between the first and the second example is that in the second example the code needs
to have a for loop to calculate the output value for each time step available in the output time series. In the first
example the FEWS transformation framework takes care of the loop.

How to configure a custom transformation?

...

In this example we showed a custom transformation which uses the example function in the section above.
In the className the name of the implementing class is defined. The binDir section is used to define
the directory which contaings contains the jar(s) with the implementing class and its helper classes.

...