Versions Compared

Key

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

...

Make sure the report class is registered. This can be done in the file "\SystemConfigFiles\Moduledescriptors.xml". It is possible that this class is already registered.

Code Block
XML
XML

<moduleDescriptor id="Reports">
	<description>Reports</description>
	<className>nl.wldelft.fews.system.plugin.report.ReportController</className>
</moduleDescriptor>

...

For each report we want FEWS to generate, a separate module instance is created. Each module instance for reporting is saved in the folder "ModuleConfigFiles". In this example we create the file "Create_Report.xml". We start with the next lines:

Code Block
xml
xml

<?xml version="1.0" encoding="UTF-8"?>
<reports version="1.0" xmlns="http://www.wldelft.nl/fews" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.wldelft.nl/fews httphttps://fewsfewsdocs.wldelftdeltares.nl/schemas/version1.0/reports.xsd">
	<declarations>
		<templateDir>$REPORT_TEMPLATE_DIR$</templateDir>
		<reportsRootDir>$REPORT_ROOT_DIR$</reportsRootDir>
		<sendToLocalFileSystem>true</sendToLocalFileSystem>
	</declarations>
	<report>
		<template>template.htm</template>
		<outputFileName>report.html</outputFileName>
	</report>
</reports>

...

The module instance, that creates our simple report, needs to be registered with the other module instances. Therefore the following lines are added to the file "\RegionConfigFile\ModuleInstanceDescriptors.xml":

Code Block
xml
xml

<moduleInstanceDescriptor id="Create_Report">
	<moduleId>Reports</moduleId>
</moduleInstanceDescriptor>

...

For creating the report we will here set up a seperate workflow. Therefore we create a file in the folder "WorkflowFiles", which we call "Report.xml". The file contains the following lines:

Code Block
xml
xml

<?xml version="1.0" encoding="UTF-8"?>
<workflow xmlns="http://www.wldelft.nl/fews" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.wldelft.nl/fews httphttps://fewsfewsdocs.wldelftdeltares.nl/schemas/version1.0/workflow.xsd" version="1.1">
	<!--report-->
	<activity>
		<runIndependent>true</runIndependent>
		<moduleInstanceId>Create_Report</moduleInstanceId>
	</activity>
</workflow>

...

The new workflow in the file "WorkflowFiles\report.xml" needs to be registered in the file "RegionConfigFiles\WorkflowDescriptors.xml":

Code Block
xml
xml

<workflowDescriptor id="report" forecast="false" visible="true" autoApprove="false">
	<description>Creates web reports</description>
</workflowDescriptor>

...

To be able to run the workflow manually, it needs to be registered as a task. Therefore in the file "Taskrundialog.xml" in the folder "DisplayConfigFiles" the following information is added:

Code Block
xml
xml

<simpleTask name="MakeReport" workflowId="report">
	<relativePeriod unit="hour" start="-24" end="0"/>
</simpleTask>

...

In the next code block is a configuration of a simple chart:

Code Block
xml
xml

<chartFormat id="ChartFormat1">
	<includeTime0>true</includeTime0>
	<includeLegend>false</includeLegend>
	<bottomAxis>
		<format>dd/MM HH:mm</format>
		<centerLabelsBetweenTicks>false</centerLabelsBetweenTicks>
	</bottomAxis>
</chartFormat>

<templateDir>$REPORT_TEMPLATE_DIR$</templateDir>
<reportsRootDir>$REPORT_ROOT_DIR$</reportsRootDir>
<sendToLocalFileSystem>true</sendToLocalFileSystem>

...

In the next block of code we connect the chart layout to a time serie.

Code Block
xml
xml

<report>
		<inputVariable variableId="OB_H1" variableType="any">
			<timeSeriesSet>
				<moduleInstanceId>ImportAquaView</moduleInstanceId>
				<valueType>scalar</valueType>
				<parameterId>H.meting</parameterId>
				<locationSetId>OB_H.meting</locationSetId>
				<timeSeriesType>external historical</timeSeriesType>
				<timeStep unit="minute" multiplier="5"/>
				<relativeViewPeriod unit="hour" start="-10" end="10"/>
				<readWriteMode>read only</readWriteMode>
			</timeSeriesSet>
		</inputVariable>
		<chart id="chartMainH" formatId="ChartFormat1" width="600" height="300">
			<leftAxisScaleUnit>0.2</leftAxisScaleUnit>
			<timeSeries>OB_H1</timeSeries>
		</chart>
		<template>template.html</template>
		<outputFileName>chartreport.html</outputFileName>
	</report>

...

The chart will be placed in a HTML file. The HTML file is based on a template file (name and location of the template file was configured in above sections). The template file is a simple HTML file which can be layouted by the user. For the report module to know where to place the chart, a Tag needs to be placed in the HTML file. The TAG for a chart is: $CHART(ID_of_the_chart)$.
An example of an HTML template is given below:

Code Block
HTML
HTML

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
	<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=windows-1252">
	<TITLE>Management Report: System Status Report</TITLE>
	<!--check for right levels up-->
	<link href="css\styles.css" rel="styleSheet" type="text/css">
	<link href="css\tables.css" rel="styleSheet" type="text/css">
</head>
<body>

$CHART(chartMainH)$


</BODY>
</HTML>

...

In the next code block is a configuration of a simple chart:

Code Block
xml
xml

<htmlTableFormat id="SimpleTable" tableStyle="tableStyle1">
			<column>allSeries</column>
			<row>time</row>
			<includeBeforeOrEqualToTimeZeroInChoiceFormat>false</includeBeforeOrEqualToTimeZeroInChoiceFormat>
			<relativeWholePeriod start="-5" end="5" unit="day"/>
			<topLeftText>Datum-Tijd</topLeftText>
			<cellFormat>{0,number,0.00}</cellFormat>
			<topFormat/>
			<leftFormat>{0,date,dd MM yyyy HH mm}</leftFormat>
			<missingValueText>#</missingValueText>
			<nullValueText>-</nullValueText>
		</htmlTableFormat>

...

In the next block of code we connect the chart layout to a time serie.

Code Block
xml
xml

<report>
		<inputVariable variableId="OB_H1" variableType="any">
			<timeSeriesSet>
				<moduleInstanceId>ImportAquaView</moduleInstanceId>
				<valueType>scalar</valueType>
				<parameterId>H.meting</parameterId>
				<locationSetId>OB_H.meting</locationSetId>
				<timeSeriesType>external historical</timeSeriesType>
				<timeStep unit="minute" multiplier="5"/>
				<relativeViewPeriod unit="hour" start="-10" end="10"/>
				<readWriteMode>read only</readWriteMode>
			</timeSeriesSet>
		</inputVariable>
<htmlTable id="test_tabel" formatId="SimpleTable">
			<timeSeries>OB_H1</timeSeries>
		</htmlTable>
		<template>template.html</template>
		<outputFileName>chartreport.html</outputFileName>
	</report>

...