CRCResultCalculator

Functions

CRCResultCalculator

~CRCResultCalculator

bool

initialize

void

getCalculatorParams

bool

setCalculatorParams

void

calculateValue

Detailed Description

class CRCResultCalculator

CRCResultCalculator is the base class for result calculators that can be used in both desktop and cloud products from Ceetron.

A result calculator acts as a result data source for a Ceetron cloud/desktop based host application. It allows for providing result calculations in an unified way. The host application does not need any special handling per result calculator.

Public Functions

inline CRCResultCalculator()
inline virtual ~CRCResultCalculator()
virtual bool initialize(const CRCHostMetaData &hostMetaData, const CRCInitOptions &options, CRCCalculatorMetaData *calculatorMetaData, CRCError *error) = 0

Initializes the result calculator.

You will receive information about the available results in the simulation (in hostMetaData) and an optional initString. If using this information the calculator is able to contribute a result to the model, it should return true. It will then be registered as a result in the host (CEETRON Envision) and called whenever needed.

Note that for e.g. an user defined expresion calculator, you would use the options.initString() to convey the expression from the host, and if this is empty just return false.

If the options.resultIdString() is not empty, you will have to either set this idString as your resultIdString with CRCCalculatorMetaData::setOutputResultIdString() or not set it. Providing a different idString to CRCCalculatorMetaData::setOutputResultIdString() is not allowed.

The options.initString() is also passed unchanged from the user, so it could typically contain both the name of the result, maybe dependencies and the expression. See the ExpressionPlugin example plugin for an example on this.

Return true if this calculator will be able to provide a result given the input (hostMetaData and initString) Return false if this calculator cannot produce a result.

If an error occurred, use the CRCError::setError() method to communicate the error message to the host.

virtual void getCalculatorParams(CRCCalculatorParams *calculatorParams) const = 0

Returns the current value of any parameters used by this calculator.

virtual bool setCalculatorParams(const CRCCalculatorParams &calculatorParams) = 0

Applies the specified parameters to this calculator.

virtual void calculateValue(const crc_double_t *inputArr, crc_size_t inputArraySize, crc_double_t *outputArr, crc_size_t outputArraySize) const = 0

Calculates the new result based on the input values given.

This function is automatically called by the host application whenever it needs a new result value based on the predefined input results.

Parameters
  • inputArr – Contains the requested result values as an array of doubles and in the same order as set when calling addResult on CRCCalculatorMetaData when implementing initialize.

  • inputArraySize – The number of double array elements in inputArr

  • outputArr – Calculated result returned in a preallocated array.

  • outputArraySize – The number of double array elements in outputArr