The Capsis training online
Try to work with the helping elements before looking at the solution…
Helping elements
capsis.extension.dataextractor.DETimeN
, and you have nothing to change in itcapsis.extension
packageDE
is for DataExtractor
: a tool extracting data series from a simulation, on a given step or from the root step to a given stepDETimeN
in your editor and look at the matchWith (Object referent)
method. This method is the extensions default compatibility system in Capsis. It is given a referent object
and returns true if it can work with itDataExtractors.matchWith ()
methods are given an instance of the model class linked to the project of the step they are opened onDETimeN
checks it is a GModel
instance, then it checks something in the MethodProvider
of the model objectWhat is a Capsis MethodProvider ?
All model classes in Capsis (e.g. TraModel extends GModel
) can return an instance (never null) of MethodProvider
(here, TraMethodProvider implements MethodProvider
)
The MethodProvider
of a module is specific to the module and can access every detail in the module data structure (knows TraScene
, TraTree
, etc.).
It contains methods to calculate values, e.g. stand basal area, stand dominant height… for a given GScene
(and optionally for a list of individuals for the individual based models).
These methods are normalized in java interfaces, e.g. GProvider
for getG()
, HDomProvider
for getHDom()
, in the capsis.util.methodprovider
package and can be detected by tools to check the compatibility with a module.
The TraMethodProvider
will be called only for Training
projects and its method will always be passed an instance of TraScene
(and possibly a list of TraTree
instances for the methods accepting a list of individuals)
DETimeN.matchWith ()
checks if the methodProvider is an instance (extends
or implements
) of capsis.util.methodprovider.NProvider
, providing public double getN (GScene stand, Collection trees)
DETimeN
, add this interface (with implements
) and this method to TraMethodProvider
getDg()
to make the same tests at the beginning, copy code to count the trees and manage correctly the possible exceptionsA possible solution