Working with Energy Ports

Discusses CAPE-OPEN specific middleware and corresponding development kit

Moderator: jasper

Post Reply
User avatar
desyk
Posts: 13
Joined: 12 March 2025, 09:43
Location: U.K. / Greece

Working with Energy Ports

Post by desyk »

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!
User avatar
jasper
Posts: 1152
Joined: 24 October 2012, 15:33
Location: Spain
Contact:

Re: Working with Energy Ports

Post by jasper »

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.
User avatar
desyk
Posts: 13
Joined: 12 March 2025, 09:43
Location: U.K. / Greece

Re: Working with Energy Ports

Post by desyk »

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!
User avatar
jasper
Posts: 1152
Joined: 24 October 2012, 15:33
Location: Spain
Contact:

Re: Working with Energy Ports

Post by jasper »

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.
Post Reply

Return to “CAPE-OPEN Binary Interop Architecture”