Hi all,
I was wondering if there are any specific requirements for working with Energy Ports in COBIA. More specifically, regarding the type of the connected object. In the case of Material Ports, the Connect() method requires casting to CAPEOPEN_1_2::CapeThermoMaterial, but I couldn't find an equivalent class for Energy.
I'd appreciate any relevant information on the matter, thanks!
Working with Energy Ports
Moderator: jasper
Re: Working with Energy Ports
Energy ports and information ports are discussed in the unit operation specification:
https://www.colan.org/specifications/un ... ification/
In short: both connect to an object that implements ICapeIdenfitication (like all objects) and ICapeCollection, the collection contains parameters.
The PME may use the information that is exposed by the port to aid in populating the collection. Energy and information ports expose also an ICapeCollection. The objects in there are parameter specifications rather than paraemeters. As a stream gets connected on two ends, there is no guarantee to the unit that the energy / information stream is populated according to the unit's needs. So make sure on ICapeUnitPort::Connect.
The only difference that remains between energy and information ports, is that energy ports agree on which information is on the port, and information ports don't. Least common denominator for information ports is support for one single scalar real parameter.
https://www.colan.org/specifications/un ... ification/
In short: both connect to an object that implements ICapeIdenfitication (like all objects) and ICapeCollection, the collection contains parameters.
The PME may use the information that is exposed by the port to aid in populating the collection. Energy and information ports expose also an ICapeCollection. The objects in there are parameter specifications rather than paraemeters. As a stream gets connected on two ends, there is no guarantee to the unit that the energy / information stream is populated according to the unit's needs. So make sure on ICapeUnitPort::Connect.
The only difference that remains between energy and information ports, is that energy ports agree on which information is on the port, and information ports don't. Least common denominator for information ports is support for one single scalar real parameter.
Re: Working with Energy Ports
Hi Jasper,
Thank you for the clarification! My motivation was verifying that a custom implementation of said ICapeCollection was required. Despite it being trivial, I'd rather use a built-in implementation over creating my own where possible, so I wanted to check that this was indeed the way to go.
All the best!
Thank you for the clarification! My motivation was verifying that a custom implementation of said ICapeCollection was required. Despite it being trivial, I'd rather use a built-in implementation over creating my own where possible, so I wanted to check that this was indeed the way to go.
All the best!
Re: Working with Energy Ports
The C++ language binding provides an iterator implementation for the collection wrapper, but it does not provide a default implementation. For small collections, the ItemByName member can be implemented as a naive loop over all items and compare the name (note: case insensitive!). For larger collections you may want to consider an underlying hash table based lookup by name for performance. For collections that change a lot, both table and vector may require custom updating. Hence, the optimal ICapeCollection implementation very much depends on what it is used for. You can of course provide a generic implementation of your own, using template parameters, and use it for information/energy ports, the port collection and the parameter collection.