COM CAPE-OPEN Wizard GetOverallPropery()
Posted: 14 July 2015, 15:27
Hello again,
I used the COM CAPE-OPEN Wizard 2.0 to generate a unit operation framework.
Classes for parameters, ports, material etc. are therefore automatically generated.
1. There is a typo in the "material" classes:
It reads "Propery" instead of "Property", e.g. "GetOverallPropery()". This is sometimes confusing when not using autocompletion all the time
2. I'm still failing to get properties out of the material object. Here some code of my calculate() function, where I want to get the pressure of an inlet:
In this code value.GetCount() always returns 0 and the program stops. I debug mode I get errors like 'try to avoid this, this is expensive' when I assign the return value of "GetOverallPropery()" to the variable "value".
The "default" wizard implementation is used:
When I try to "convince" the variable "value" to be an array with size 1 representing a single double to obtain the pressure, I get something like minus infinity and not the actual value that should be 100000 [Pa] (the pressure is defined in the inlet stream in the flowsheet).
What do I have to do here, what is wrong with my approach?
I used the COM CAPE-OPEN Wizard 2.0 to generate a unit operation framework.
Classes for parameters, ports, material etc. are therefore automatically generated.
1. There is a typo in the "material" classes:
It reads "Propery" instead of "Property", e.g. "GetOverallPropery()". This is sometimes confusing when not using autocompletion all the time

2. I'm still failing to get properties out of the material object. Here some code of my calculate() function, where I want to get the pressure of an inlet:
Code: Select all
COMSmartPtr<MaterialPort> aPort = (MaterialPort*)(Port*)portCollection.items[0];
Material material = aPort->GetMaterial();
CVariant value = material->GetOverallPropery(L"pressure", NULL, false);
//check count
if (value.GetCount() != 1){
SetError(L"Invalid value for pressure from material object: scalar expected", L"ICapeUnit", L"Calculate");
return ECapeUnknownHR;
}
The "default" wizard implementation is used:
Code: Select all
CVariant GetOverallPropery(BSTR name,BSTR basis,bool isSpecialProp) override {
CVariant res;
HRESULT hr=mat->GetOverallProp(name,basis,res.OutputArgument());
if (FAILED(hr)) throw COException(CO_Error(mat,hr));
return res;
}
What do I have to do here, what is wrong with my approach?