ScalingOperator Class
(Automation::ScalingOperator)A ScalingOperator scales input value to output value using interpolation between scaling points. This allows CDP Components to work with known/engineering values (and not values tied to a particular hardware) and helps to decouple the system. More...
Header: | #include <ScalingOperator.h> |
Inherits: | CDPOperator<T> |
Public Functions
ScalingOperator(const CDPPropertyBase &in) | |
virtual | ~ScalingOperator() |
Reimplemented Public Functions
virtual void | Configure(XMLPrimitive *pScalingOperatorXML) override |
virtual void | Create(const char *shortName, CDPBaseObject *pParent) override |
virtual void | Destroy() override |
virtual void | FillNodeChildren(CDP::StudioAPI::NodeStream &stream) const |
virtual unsigned int | Process() override |
- 18 public functions inherited from CDPOperator
- 17 public functions inherited from CDPOperatorBase
- 46 public functions inherited from CDPBaseObject
- 26 public functions inherited from CDP::StudioAPI::CDPNode
- 22 public functions inherited from CDP::StudioAPI::ICDPNode
Reimplemented Protected Functions
virtual bool | AddChild(const std::string &name, const std::string &typeName, const std::string &configuration) override |
virtual bool | RemoveChild(const std::string &name) override |
- 1 protected function inherited from CDP::StudioAPI::CDPNode
Additional Inherited Members
- 1 public variable inherited from CDPOperatorBase
- 1 static public member inherited from CDPBaseObject
- 1 protected function inherited from CDP::StudioAPI::CDPNode
- 8 protected variables inherited from CDPOperator
- 5 protected variables inherited from CDPOperatorBase
- 11 protected variables inherited from CDPBaseObject
Detailed Description
A ScalingOperator scales input value to output value using interpolation between scaling points. This allows CDP Components to work with known/engineering values (and not values tied to a particular hardware) and helps to decouple the system.
Internally, the scaling points are sorted by InValue, lowest first. Whenever a scaling point is updated, the scaling points are re-sorted and the slopes between them are recalculated. It is possible to have as many scaling points as memory allows.
Properties
Property Name | Description |
---|---|
Interpolation | Interpolation method to use. |
Inverse | When set to true, then ScalingPoint InValues and OutValues would be treated in inverse. Useful to set after copy-pasting existing ScalingOperator configuration with need to make the copy to scale in reverse compared to the original. |
Available Interpolation Methods
Interpolation method | Minimum number of ScalingPoints needed | Description |
---|---|---|
Linear | 2 | Linear interpolation (default method) |
Makima | 4 | Modified Akima interpolation. This method interpolates between ScalingPoints via cubic Hermite polynomials whose slopes are chosen by a modification of a geometric construction proposed by Hiroshi Akima. The modification was proposed by Cosmin Ionita. |
PCHIP | 4 | Piecewise Cubic Hermite Interpolating Polynomial. This method interpolates between ScalingPoints via cubic Hermite polynomials whose slopes are chosen so that the resulting interpolant is monotonic. Proposed by Fritsch and Carlson. |
BaryRatio3 | 4 | Barycentric Rational interpolation with approximation order = 3. This is a high-accuracy interpolation method proposed by Floater and Hormann. This method generates very stable interpolation, unless some ScalingPoints are very close to eachother, and some ScalingPoints are very far. |
BaryRatio5 | 6 | Barycentric Rational interpolation with approximation order = 5. This is a high-accuracy interpolation method proposed by Floater and Hormann. This method generates very stable interpolation, unless some ScalingPoints are very close to eachother, and some ScalingPoints are very far. |
Extrapolation
When input value is out of the range of configured ScalingPoints output value is calculated as follows:
Interpolation method | How out-of-range input value is scaled |
---|---|
Linear, BaryRatio3 and BaryRatio5 | Output value is calulated using extrapolation (estimate) based on the nearest ScalingPoints. |
Makima, PCHIP | Value corresponding to the nearest ScalingPoint is outputted. No extrapolation is done. |
Note: Having fewer scalingpoints than required by the interpolation method will cause the operator to just bypass all values (no scaling).
Note: As the ScalingOperator uses CPU computing power to do complex scalings, keep ScalingPoint number low and interpolation method on Linear if your system CPU power is very limited.
Example
To eliminate the deadband area of a valve output signal, the following scaling points could be set up:
Input Value (CDP side) | Output Value (Valve side) | Description |
---|---|---|
-1 | -32768 | Maximum value 'when opening to the left' |
-0.00001 | -1040 | The value -0.00001 causes a slight flow. (The valve does not give flow between values -1030 and 1100) |
0 | 0 | We don't want flow when signal is 0 |
0.00001 | 1100 | The value 0.00001 causes a slight flow. (The valve does not give flow between values -1030 and 1100) |
1 | 32767 | Maximum value 'when opening to the right' |
Different Interpolation Methods Example
Below is an example plot of the outputs of ScalingOperators with different interpolation methods with following ScalingPoints, assuming that constantly increasing ramp signal from -1 to 1 is in their input:
Input Value | Output Value |
---|---|
-1 | -200 |
-0.85 | -100 |
-0.15 | -10 |
0 | 0 |
0.15 | 10 |
0.85 | 100 |
1 | 200 |
See also ScalingPoint.
Member Function Documentation
ScalingOperator::ScalingOperator(const CDPPropertyBase &in)
Constructs a ScalingOperator with input in.
[virtual]
ScalingOperator::~ScalingOperator()
Destructs the ScalingOperator
[override virtual protected]
bool ScalingOperator::AddChild(const std::string &name, const std::string &typeName, const std::string &configuration)
[override virtual]
void ScalingOperator::Configure(XMLPrimitive *pScalingOperatorXML)
Reimplemented from CDPBaseObject::Configure().
[override virtual]
void ScalingOperator::Create(const char *shortName, CDPBaseObject *pParent)
Reimplemented from CDPBaseObject::Create().
[override virtual]
void ScalingOperator::Destroy()
[virtual]
void ScalingOperator::FillNodeChildren(CDP::StudioAPI::NodeStream &stream) const
Reimplemented from CDPNode::FillNodeChildren().
[override virtual]
unsigned int ScalingOperator::Process()
Reimplemented from CDPOperatorBase::Process().
Returns STATUS_OK.
[override virtual protected]
bool ScalingOperator::RemoveChild(const std::string &name)
Get started with CDP Studio today
Let us help you take your great ideas and turn them into the products your customer will love.