Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
  • How to add a custom transformation to my FEWS system?

Adding a custom transformation involves several steps which will be explained in detail in the upcoming section:

...

Code Block
<?xml version="1.0" encoding="UTF-8"?>
<transformationModule xmlns="http://www.wldelft.nl/fews" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.wldelft.nl/fews http://fews.wldelft.nl/schemas/version1.0/transformationModule.xsd" version="1.0">
	<variable>
		<variableId>input1</variableId>
	<timeSeriesSet>
        <moduleInstanceId>POFlathead_MergeMAP_UpdateStates</moduleInstanceId>
        <valueType>scalar</valueType>
        <parameterId>MAP</parameterId>
        <locationId>WGCM8U</locationId>
        <timeSeriesType>simulated historical</timeSeriesType>
        <timeStep unit="hour" multiplier="6"/>
        <relativeViewPeriod unit="week" start="-520" end="0"/>
        <readWriteMode>add originals</readWriteMode>
    </timeSeriesSet>
	</variable>
	<variable>
		<variableId>input2</variableId>
		<timeSeriesSet>
        <moduleInstanceId>POFlathead_MergeMAP_UpdateStates</moduleInstanceId>
        <valueType>scalar</valueType>
        <parameterId>MAP</parameterId>
        <locationId>WGCM8L</locationId>
        <timeSeriesType>simulated historical</timeSeriesType>
        <timeStep unit="hour" multiplier="6"/>
           <relativeViewPeriod unit="week" start="-520" end="0"/>
        <readWriteMode>add originals</readWriteMode>
    </timeSeriesSet>
	</variable>
	<variable>
		<variableId>output</variableId>
		<timeSeriesSet>
			<moduleInstanceId>example1</moduleInstanceId>
			<valueType>scalar</valueType>
			<parameterId>MAP</parameterId>
			<locationId>WGCM8</locationId>
			<timeSeriesType>simulated forecasting</timeSeriesType>
			<timeStep unit="hour" multiplier="6"/>
			    <relativeViewPeriod unit="week" start="-520" end="0"/>
			<readWriteMode>add originals</readWriteMode>
		</timeSeriesSet>
	</variable>
	<transformation id="Example1">
<custom>
	<userDefined>
		<input>
			<fieldName>input1</fieldName>
			<inputVariable>
				<variableId>input1</variableId>
			</inputVariable>
		</input>
		<input>
			<fieldName>input2</fieldName>
			<inputVariable>
				<variableId>input2</variableId>
			</inputVariable>
		</input>
		<options>
			<float value="0.3" key="option1"></float>
			<float value="0.7" key="option2"></float>
		</options>
		<output>
			<fieldName>output</fieldName>
			<outputVariable>
				<variableId>output</variableId>
			</outputVariable>
		</output>
		<binDir>example</binDir>
		<className>example.Example1</className>
	</userDefined>
</custom>
	</transformation>
</transformationModule>

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 the jar(s) with the implementing class and its helper classes.

The section options is used to define optional fields.

Optional fields can be of type:

  • String,
  • int,
  • float,
  • boolean.

The optional fields have a name. By using the name defined in the xml-config a field with the same name is looked up in the java-class.

Secondly a check is done to verify that the type defined int the xml-config is the same as the type defined in the java class. If the check

succeeds the value is injected into the field.

The output section defined the output time series. A output variable (identified by @Output) is searched for in the java class which has the same

name as the name identified in the tag fieldName. If such a variable is found it is linked to the time series configured in the xml file.

The input section defines the input time series. The same logic as is used for the output time series is used here for the input time series.