#include <CarbonValueCalculator.h>
Public Member Functions | |
clCarbonValueCalculator (clSimManager *p_oSimManager) | |
Constructor. | |
~clCarbonValueCalculator () | |
Destructor. | |
void | Action () |
Makes value calculations. | |
void | GetData (xercesc::DOMDocument *p_oDoc) |
Does setup for this behavior. | |
void | RegisterTreeDataMembers () |
Registers the "Carbon" tree float data member. | |
Protected Member Functions | |
void | GetBiomassCodes (clTreePopulation *p_oPop) |
Retrieves the "Biomass" float data member. | |
void | GetParameterFileData (xercesc::DOMDocument *p_oDoc, clTreePopulation *p_oPop) |
Reads values from the parameter file. | |
void | FormatQueryString (clTreePopulation *p_oPop) |
Formats the string in m_cQuery. | |
void | SetupGrid () |
Sets up the "Carbon Value" grid. | |
Protected Attributes | |
clGridBase * | mp_oValueGrid |
Grid holding total values for each species. | |
float * | mp_fCPercentBiomass |
Percent of biomass that is carbon. | |
char * | m_cQuery |
String to pass to clTreePopulation::Find() in order to get the trees for which to calculate volume. | |
short int ** | mp_iBiomassCodes |
Holds data member codes for "Biomass" float data member (registered by the clDimensionAnalysis class). | |
short int ** | mp_iTreeCarbonCodes |
Holds data member codes for "Carbon" float data member. | |
short int * | mp_iValueCodes |
Holds data member codes for the "value_x" float data members of the "Carbon Value" grid. | |
short int * | mp_iCarbonCodes |
Holds data member codes for the "carbon_x" float data members of the "Carbon Value" grid. | |
float | m_fPricePerTonCarbon |
Price per metric ton of carbon - currency unimportant. | |
short int | m_iNumTotalSpecies |
Total number of species. |
This behavior calculates carbon value per species. The amount of carbon is given by the user as a percent of biomass for each species. This behavior expects the Dimension Analysis behavior (clDimensionAnalysis) to calculate tree biomass.
The user also supplies a price per metric ton of carbon. This is multipled by the amount of carbon and added up into a total value of carbon per species. The species carbon totals and carbon value totals are stored in a grid called "Carbon Value".
Each tree gets a data member called "Carbon". This contains the tree's own carbon value.
This class's namestring and parameter call string are both "Carbon Value Calculator".
This behavior may not be applied to seedlings.
Edit history:
-----------------
March 14, 2006 - Created (LEM)
April 25, 2006 - Added a value tree data member to each tree (LEM)
clCarbonValueCalculator::clCarbonValueCalculator | ( | clSimManager * | p_oSimManager | ) |
clCarbonValueCalculator::~clCarbonValueCalculator | ( | ) |
Destructor.
Deletes arrays.
void clCarbonValueCalculator::Action | ( | ) | [virtual] |
Makes value calculations.
First, the values in the "Carbon Value" grid are cleared. Then a query is sent to the tree population to get all trees to which this behavior is applied. For each, the amount of biomass (in metric tons) is retrieved, and the carbon amount and value calculated. Then the species values are totaled and placed in the "Carbon Value" grid.
Reimplemented from clBehaviorBase.
void clCarbonValueCalculator::GetData | ( | xercesc::DOMDocument * | p_oDoc | ) | [virtual] |
Does setup for this behavior.
Calls:
p_oDoc | DOM tree of parsed input file. |
Implements clWorkerBase.
void clCarbonValueCalculator::RegisterTreeDataMembers | ( | ) | [virtual] |
Registers the "Carbon" tree float data member.
The return codes are captured in the mp_iTreeCarbonCodes array.
modelErr | if this behavior is being applied to any tree type except saplings, adults, and snags. |
Reimplemented from clBehaviorBase.
void clCarbonValueCalculator::GetBiomassCodes | ( | clTreePopulation * | p_oPop | ) | [protected] |
Retrieves the "Biomass" float data member.
The return codes are captured in the mp_iBiomassCodes array.
modelErr | if any code comes back -1 for a tree to which this behavior is applied. |
void clCarbonValueCalculator::GetParameterFileData | ( | xercesc::DOMDocument * | p_oDoc, | |
clTreePopulation * | p_oPop | |||
) | [protected] |
Reads values from the parameter file.
p_oDoc | DOM tree of parsed input file. | |
p_oPop | Tree population object. |
modelErr | if the percentage of biomass that is carbon is less than 0 or greater than 100. |
void clCarbonValueCalculator::FormatQueryString | ( | clTreePopulation * | p_oPop | ) | [protected] |
Formats the string in m_cQuery.
This value will be used in Action() to pass to clTreePopulation::Find() in order to get the trees to act on.
p_oPop | Tree population object. |
void clCarbonValueCalculator::SetupGrid | ( | ) | [protected] |
Sets up the "Carbon Value" grid.
This ignores any maps.
clGridBase* clCarbonValueCalculator::mp_oValueGrid [protected] |
Grid holding total values for each species.
The grid name is "Carbon Value". The grid contains only 1 grid cell. It has 2 times X float data members, where X = the total number of species. The data member names are "carbon_x" (where "x" is the species number) for amount of carbon, and "value_x" for value of carbon.
float* clCarbonValueCalculator::mp_fCPercentBiomass [protected] |
Percent of biomass that is carbon.
In the parameter file, this is as a percentage between 0 and 100. We convert this upon reading to a proportion between 0 and 1. Array size is # total species.
char* clCarbonValueCalculator::m_cQuery [protected] |
String to pass to clTreePopulation::Find() in order to get the trees for which to calculate volume.
This will instigate a species/type search for all the species and types to which this behavior applies.
short int** clCarbonValueCalculator::mp_iBiomassCodes [protected] |
Holds data member codes for "Biomass" float data member (registered by the clDimensionAnalysis class).
First array index is total # species, second is number types (3 - sapling, adult, snag)
short int** clCarbonValueCalculator::mp_iTreeCarbonCodes [protected] |
Holds data member codes for "Carbon" float data member.
First array index is total # species, second is number types (3 - sapling, adult, snag)
short int* clCarbonValueCalculator::mp_iValueCodes [protected] |
Holds data member codes for the "value_x" float data members of the "Carbon Value" grid.
Array size is total # species.
short int* clCarbonValueCalculator::mp_iCarbonCodes [protected] |
Holds data member codes for the "carbon_x" float data members of the "Carbon Value" grid.
Array size is total # species.
float clCarbonValueCalculator::m_fPricePerTonCarbon [protected] |
Price per metric ton of carbon - currency unimportant.
short int clCarbonValueCalculator::m_iNumTotalSpecies [protected] |
Total number of species.
For the destructor.