### C++ Data Transformation Component Service Function Source: https://github.com/redhawksdr/core-framework/blob/develop-2.2/docs/shared-address/component-examples.md Demonstrates the core logic of a data transformation component's service function. It handles input stream retrieval, output stream management (creation and retrieval), data block reading, end-of-stream conditions, SRI changes, parameter updates, and data processing using a templated function. The example utilizes the BulkIO stream API for data transfer. ```cpp int FmDemod_i::serviceFunction() { // InFloatPort::getCurrentStream() returns the first input stream that has data available to be read, // blocking if none are currently ready. bulkio::InFloatStream input = dataFloat_in->getCurrentStream(); if (!input) { // No streams are available (typically due to a stop). return NOOP; } // If an output stream has already been created, OutFloatPort::getStream() finds it by streamID. bulkio::OutFloatStream output = dataFloat_out->getStream(input.s treamID()); if (!output) { // Otherwise, create a new stream. output = dataFloat_out->createStream(input.streamID()); // configureStream() is a user-defined method to apply any transformations from the input SRI to the // output SRI configureStream(output, input.sri()); } // Blocking read from the input stream. The default behavior returns exactly one packet worth of data, // but a sample count and consume length (for overlap) can be provided as well. bulkio::FloatDataBlock block = input.read(); if (!block) { // There are two reasons why InFloatStream::read() might return a "null" block: if (input.eos()) { // 1. End-of-stream; close the output stream. LOG_DEBUG(FmDemod_i, "Stream " << input.streamID() << " got an EOS"); output.close(); return NORMAL; } else { // 2. The component was stopped. return NOOP; } } // Handle an input queue flush. Depending on your algorithm, this may require resetting state, etc. if (block.inputQueueFlushed()) { LOG_WARN(FmDemod_i, "Input queue flushed"); } // Handle SRI changes. The configureStream() method is also used on output stream creation; the SRI change flag // is not set for a new stream. // Optionally, FloatDataBlock::sriChangeFlags() returns a set of bit flags to check which parts of the SRI changed, // if only certain fields are relevant. if (block.sriChanged()) { LOG_INFO(FmDemod_i, "SRI changed"); configureStream(output, block.sri()); } // Update any internal variables or properties. This a user-defined method, and the behavior is up to the // implementer. In this case, the algorithm depends on the sample rate of the input SRI. updateParameters(block.sri()); // Run the algorithm here (FM demodulation, in this case), taking into account whether the input is complex or // real. In this example, the output is always real regardless of the input, but this can differ on a per-component // basis. The actual work is done in a private templatized member function, doFmDemod(). redhawk::buffer buffer; if (block.complex()) { buffer = doFmDemod(block.cxbuffer()); } else { buffer = doFmDemod(block.buffer()); } // Write the processed data to the output stream. After calling OutFloatStream::write(), the buffer is now shared // with an unknown number of consumers. No more modifications should be made. // Regarding the BULKIO::PrecisionUTCTime, a block can contain multiple timestamps, if you explicitly request // a read size; here, we are just taking the data in the block sizes it comes in, so we can just use the starting // timestamp for the entire block. Algorithms that affect the time basis should compute a new block time. output.write(buffer, block.getStartTime()); return NORMAL; } ``` -------------------------------- ### Install JacORB Source: https://github.com/redhawksdr/core-framework/blob/develop-2.2/docs/jacorb/using-jacorb.md Installs JacORB by extracting its archive and linking necessary JAR files into the REDHAWK library directory. ```sh cd /usr/share/java unzip /tmp/jacorb-3.9.zip ``` ```sh ln -s /usr/share/java/jacorb-3.9/lib/jacorb-*.jar $OSSIEHOME/lib/ ln -s /usr/share/java/jacorb-3.9/lib/slf4j-*.jar $OSSIEHOME/lib/ ``` -------------------------------- ### C++ FM Demodulation Algorithm Source: https://github.com/redhawksdr/core-framework/blob/develop-2.2/docs/shared-address/component-examples.md An example of using functional programming in C++ for FM demodulation. This templated method allows for both real and complex input types by utilizing a stateful functor for processing. ```cpp template redhawk::shared_buffer FmDemod_i::doFmDemod(const redhawk::shared_buffer& input) { redhawk::buffer output(input.size()); dsp::process(input.begin(), input.end(), output.begin(), demod); return output; } ``` -------------------------------- ### Log4j Configuration Source: https://github.com/redhawksdr/core-framework/blob/develop-2.2/bulkioInterfaces/libsrc/testing/tests/java/log4j_config.txt Configures the root logger to WARN level and directs output to the console with a simple message and newline pattern. This setup is fundamental for observing framework logs during operation. ```properties log4j.rootLogger=WARN,stdout log4j.appender.stdout=org.apache.log4j.ConsoleAppender log4j.appender.stdout.layout=org.apache.log4j.PatternLayout log4j.appender.stdout.layout.ConversionPattern=%m%n ``` -------------------------------- ### Log4j Configuration Source: https://github.com/redhawksdr/core-framework/blob/develop-2.2/frontendInterfaces/libsrc/testing/tests/java/log4j_config.txt Configures the root logger to WARN level and directs output to the console with a simple message and newline pattern. This setup is fundamental for observing framework logs during operation. ```properties log4j.rootLogger=WARN,stdout log4j.appender.stdout=org.apache.log4j.ConsoleAppender log4j.appender.stdout.layout=org.apache.log4j.PatternLayout log4j.appender.stdout.layout.ConversionPattern=%m%n ``` -------------------------------- ### Control CPU-Based Policy CPUs per Pool Source: https://github.com/redhawksdr/core-framework/blob/develop-2.2/docs/shared-memory/tuning.md Adjusts the ratio of CPUs to pools in the CPU-based heap policy. This example assigns 4 CPUs to each pool, creating fewer pools and potentially grouping allocations by CPU affinity. ```sh export RH_SHMALLOC_CPUS_PER_POOL=4 ``` -------------------------------- ### C++ Generative Component Service Function Source: https://github.com/redhawksdr/core-framework/blob/develop-2.2/docs/shared-address/component-examples.md Example C++ code for the `serviceFunction` of a generative component in Redhawk. This function handles updating parameters, managing output streams, and writing generated waveform data. ```cpp int Waveform_i::serviceFunction() { // Update any internal variables or properties. This a user-defined method, and the behavior is up to the // implementer. In this case, the waveform parameters could be copied from properties to shadow variables // while holding the properties lock (propertySetAccess). updateParameters(); // For this example, the output stream is a member variable on the Waveform_i class. If it's not already // created, do it here. Another option would be to create it inthe constructor() method. if (!_outputStream) { _outputStream = dataFloat_out->createStream(_streamID); _sriChanged = true; } // If the SRI needs to be updated, based on the properties (or some other reason), one option is to set an // internal flag; another possibility might be to update the SRI in updateParameters()--if the stream is only // used from within serviceFunction(), there are no threading concerns. // configureStream() is a user-defined method to apply any changes to the output stream SRI. if (_sriChanged) { configureStream(_outputStream); } // Create a buffer of the desired size. The redhawk::buffer class is the mutable version, and it gracefullly // "degrades" to the immutable redhawk::shared_buffer class. redhawk::buffer data(1024); // The implementation of the generator function is left as an exercise to the reader. doWaveform(data.begin(), data.end()); // This example keeps a running BULKIO::PrecisionUTCTime for the first sample of each block. There are overloaded // arithmetic operators to make it easier to modify. _currentTimestamp += _outputStream.xdelta() * data.size(); // After calling OutFloatStream::write(), the buffer is now shared with an unknown number of consumers. No more // modifications should be made. _outputStream.write(data, _currentTimestamp); return NORMAL; } ``` -------------------------------- ### Example Shared Memory Metrics Report Source: https://github.com/redhawksdr/core-framework/blob/develop-2.2/docs/shared-memory/metrics.md Displays a typical output of shared memory metrics collected by a REDHAWK process upon exit. This report includes details on file operations, heap usage, pool allocations, and superblock activity, identified by the process ID. ```text SHM metrics (24003): Executable: /var/redhawk/sdr/dom/components/rh/SigGen/cpp/SigGen Files created: 1 Files opened: 0 Files closed: 0 Files total bytes: 2101248 Heaps created: 1 Pools created: 8 Pools used: 1 Pool allocations hot: 8090 Pool allocations cold: 1 Pool allocations failed: 0 Superblocks created: 1 Superblocks mapped: 0 Superblocks reused: 0 Superblocks unmapped: 0 Heap clients created: 0 Heap clients destroyed: 0 Blocks created: 8091 Blocks attached: 0 Blocks released: 8091 Blocks destroyed: 695 ``` -------------------------------- ### Custom Output Manager Get Negotiation Properties Source: https://github.com/redhawksdr/core-framework/blob/develop-2.2/docs/custom-transport/add_transport.md Implements the `getNegotiationProperties` method for `CustomOutputManager`. It retrieves properties from the associated `CustomOutputTransport` and returns them, ensuring the transport object is valid. ```cpp redhawk::PropertyMap CustomOutputManager::getNegotiationProperties(redhawk::UsesTransport* transport) { CustomOutputTransport* _transport = dynamic_cast(transport); if (!_transport) { throw redhawk::FatalTransportError("Invalid transport object provided."); } redhawk::PropertyMap properties; properties = _transport->getNegotiationProperties(); return properties; } ``` -------------------------------- ### Set Minimum Superblock Size Source: https://github.com/redhawksdr/core-framework/blob/develop-2.2/docs/shared-memory/tuning.md Configures the minimum size for superblocks, which are contiguous regions of shared memory dedicated to pools. The default is 2MB, and the value is rounded to the nearest page size. ```sh export RH_SHMALLOC_SUPERBLOCK_SIZE= ``` -------------------------------- ### Testing Custom Ports with Python Source: https://github.com/redhawksdr/core-framework/blob/develop-2.2/docs/custom-transport/add_transport.md Demonstrates the process of launching, connecting, and disconnecting components using the `ossie.utils.sb` module in Python. It also shows how to inspect the connection status and transport information. ```python from ossie.utils import sb src=sb.launch('transport_out') snk=sb.launch('transport_in') src.connect(snk) src.ports[0]._get_connectionStatus() src.disconnect(snk) ``` -------------------------------- ### Testing Component Connection and Disconnection Source: https://github.com/redhawksdr/core-framework/blob/develop-2.2/docs/custom-transport/add_transport.md Demonstrates launching, connecting, and disconnecting REDHAWK components using the `ossie.utils.sb` module in Python. It shows how to verify connection status and the output during these operations. ```python from ossie.utils import sb src=sb.launch('transport_out', shared=False) snk=sb.launch('transport_in') src.connect(snk) print(src.ports[0]._get_connectionStatus()) src.disconnect(snk) ``` -------------------------------- ### Replacing BulkIO Port with Custom Port (C++) Source: https://github.com/redhawksdr/core-framework/blob/develop-2.2/docs/custom-transport/add_transport.md Illustrates the change in class instantiation within `transport_out_base.cpp`, replacing the default `bulkio::OutFloatPort` with the custom `CustomOutPort`. ```cpp dataFloat_out = new CustomOutPort("dataFloat_out"); ``` -------------------------------- ### Create and Use Writeable Buffer Source: https://github.com/redhawksdr/core-framework/blob/develop-2.2/docs/shared-address/shared-address-components-howto.md Demonstrates how to create a writeable buffer of floats, populate it with data, and write it to an output stream. The buffer is shared with local connections and transferred remotely. Once shared, the buffer should not be modified. ```C++ redhawk::buffer buffer(1024); for (size_t ii = 0; ii < buffer.size(); ++ii) { buffer[ii] = (float) ii; } stream.write(buffer, bulkio::time::utils::now()); ``` -------------------------------- ### Creating and Applying a Custom Transport Source: https://github.com/redhawksdr/core-framework/blob/develop-2.2/docs/custom-transport/add_transport.md Demonstrates how to create a new transport and apply it to links between REDHAWK components running in different processes. This is crucial for scenarios where data exchange needs to bypass built-in BulkIO mechanisms, such as communication between software on a GPP and firmware on an FPGA. ```python fromredhawk.transport.transport_factoryimportTransportFactory fromredhawk.transport.transport_managerimportTransportManager fromredhawk.transport.transportimportTransport # Assume CustomTransport, CustomTransportFactory, CustomTransportManager are defined elsewhere # Global transport factory custom_transport_factory = CustomTransportFactory() # In the output component (uses side) classOutputComponent: def__init__(self): self.dataFloat_out = None # Assume this is a BulkIO output port self.transport_manager = None defconnect_output_port(self,output_port): self.dataFloat_out = output_port self.transport_manager = TransportManager(custom_transport_factory) # Register the custom transport with priority 0 self.transport_manager.registerTransport("custom", 0) defestablish_connection(self,target_input_port): # Create a connection using the custom transport connection=self.transport_manager.connect(self.dataFloat_out, target_input_port, "custom") # Exchange properties (example) negotiation_properties={"custom_property": "value"} self.dataFloat_out.setNegotiationResult(connection, negotiation_properties) # In the input component (provides side) classInputComponent: def__init__(self): self.dataFloat_in = None # Assume this is a BulkIO input port self.transport_manager = None defregister_input_port(self,input_port): self.dataFloat_in = input_port self.transport_manager = TransportManager(custom_transport_factory) # Register the custom transport with priority 0 self.transport_manager.registerTransport("custom", 0) defcreate_input_transport(self,connection,properties): # Create the custom transport instance custom_transport=self.transport_manager.createTransport(connection, "custom", properties) # Get negotiation properties to send back response_properties=custom_transport.getNegotiationProperties() returncustom_transport, response_properties # Example Usage: # output_comp=OutputComponent() # input_comp=InputComponent() # ... initialize ports and connect them ... # output_comp.establish_connection(input_comp.dataFloat_in) ``` -------------------------------- ### Read and Process Shared Buffer from Input Stream Source: https://github.com/redhawksdr/core-framework/blob/develop-2.2/docs/shared-address/shared-address-components-howto.md Shows how to read data from a BulkIO input stream, access the internal shared buffer (either scalar or complex), and perform operations like calculating the sum of elements. The input buffer can be passed to an output stream, adhering to sharing rules. ```C++ bulkio::InFloatStream stream = dataFloat_in->getCurrentStream(); if (!stream) { return NOOP; } bulkio::FloatDataBlock block = stream.read(); if (!block) { return NOOP; } if (block.complex()) { redhawk::shared_buffer > buffer = block.cxbuffer(); std::complex sum = std::accumulate(buffer.begin(), buffer.end(), std::complex(0.0, 0.0)); } else { redhawk::shared_buffer buffer = block.buffer(); float sum = std::accumulate(buffer.begin(), buffer.end(), 0.0); } return NORMAL; ``` -------------------------------- ### Slicing Buffer Data Source: https://github.com/redhawksdr/core-framework/blob/develop-2.2/docs/shared-address/shared-address-components-howto.md Shows how to create a new buffer that represents a subset of an existing buffer's data without copying. The `slice` method returns a view into the original memory, sharing the underlying data. ```cpp // NB: The arguments are the start and end indices. redhawk::shared_buffer part = buffer.slice(8, 24); // part.size() == 16 ``` -------------------------------- ### Set Allocator Policy to CPU-Based Source: https://github.com/redhawksdr/core-framework/blob/develop-2.2/docs/shared-memory/tuning.md Configures the REDHAWK shared memory allocator to use the CPU-based policy for memory allocation. This policy assigns pools to CPUs, potentially reducing contention on multi-core systems. ```sh export RH_SHMALLOC_POLICY=cpu ``` -------------------------------- ### Control Thread-Based Policy Pools Source: https://github.com/redhawksdr/core-framework/blob/develop-2.2/docs/shared-memory/tuning.md Sets the total number of pools for the thread-based heap policy. Using fewer pools can reduce total shared memory usage by increasing the likelihood of threads sharing pools. Setting to 1 is optimal for single-threaded legacy components. ```sh export RH_SHMALLOC_THREAD_NUM_POOLS=1 ``` -------------------------------- ### Wrapping Externally Acquired Memory Source: https://github.com/redhawksdr/core-framework/blob/develop-2.2/docs/shared-address/shared-address-components-howto.md Demonstrates how to wrap existing memory pointers into `redhawk::shared_buffer` or `redhawk::buffer`. The `shared_buffer` takes ownership of the memory and manages its deallocation when the last reference is released. ```cpp float* data = new float[1024]; redhawk::shared_buffer buffer(data, 1024); ``` -------------------------------- ### C++ Component Factory Function Source: https://github.com/redhawksdr/core-framework/blob/develop-2.2/docs/shared-address/component-model.md The component code provides a factory function, `make_component()`, that implements creation of an instance of the specific component. This is a subset of what `main()` used to do. ```cpp /* * The component code provides a factory function, `make_component()`, that implements creation of an instance of the specific component. */ // Example signature (actual implementation may vary): // ComponentImpl* make_component(int argc, char* argv[]); ``` -------------------------------- ### Custom Output Transport Class Declaration Source: https://github.com/redhawksdr/core-framework/blob/develop-2.2/docs/custom-transport/add_transport.md Declares the `CustomOutputTransport` class, inheriting from `bulkio::OutputTransport`. It includes constructors, a destructor, `transportType`, `transportInfo`, `_pushSRI`, `_pushPacket`, `disconnect`, and `getNegotiationProperties` methods, along with private members for connection ID and properties. ```cpp // class implementing the custom output transport class CustomOutputTransport : public bulkio::OutputTransport { public: CustomOutputTransport(bulkio::OutPort* parent, BULKIO::dataFloat_ptr port, const std::string& connectionId, const redhawk::PropertyMap &props ) : bulkio::OutputTransport(parent, port) { _connectionId = connectionId; _inProps = props; }; virtual ~CustomOutputTransport() { RH_NL_INFO("custom.transport", "CustomOutputTransport::~CustomOutputTransport" ); }; std::string transportType() const { return "custom"; }; virtual CF::Properties transportInfo() const { redhawk::PropertyMap props; props["transport_side_information"] = "outbound"; props["another_number"] = static_cast(100); return props; }; void _pushSRI(const BULKIO::StreamSRI& sri) {}; void _pushPacket(const BufferType& data, const BULKIO::PrecisionUTCTime& T, bool EOS, const std::string& streamID) {}; void disconnect() { RH_NL_INFO("custom.transport", "CustomOutputTransport::disconnect" ); // perform disconnection }; redhawk::PropertyMap getNegotiationProperties(); protected: std::string _connectionId; redhawk::PropertyMap _inProps; }; ``` -------------------------------- ### Custom Output Manager Class Declaration Source: https://github.com/redhawksdr/core-framework/blob/develop-2.2/docs/custom-transport/add_transport.md Declares the `CustomOutputManager` class, inheriting from `bulkio::OutputManager`. This class is responsible for creating output transport layers for negotiable ports. ```cpp // manager class that creates output transport layer for a negotiable port class CustomOutputManager : public bulkio::OutputManager { public: ``` -------------------------------- ### Custom Input Manager Class Declaration Source: https://github.com/redhawksdr/core-framework/blob/develop-2.2/docs/custom-transport/add_transport.md Declares the `CustomInputManager` class, inheriting from `bulkio::InputManager`. It includes constructors, a destructor, `createInputTransport`, `transportType`, and `getNegotiationProperties` methods for managing custom input transports. ```cpp // manager class that creates input transport layer for a negotiable port class CustomInputManager : public bulkio::InputManager { public: CustomInputManager(bulkio::InPort* port) : bulkio::InputManager(port) { }; virtual ~CustomInputManager() { }; CustomInputTransport* createInputTransport(const std::string& transportId, const redhawk::PropertyMap& properties) { RH_NL_INFO("custom.transport", "CustomInputManager::createInputTransport" ); for ( redhawk::PropertyMap::const_iterator it = properties.begin(); it != properties.end(); it++) { RH_NL_INFO("custom.transport", "CustomInputManager, key (from uses): "<id ); } return new CustomInputTransport(this->_port, transportId, properties); }; std::string transportType(){ return "custom"; }; redhawk::PropertyMap getNegotiationProperties(redhawk::ProvidesTransport* providesTransport); }; ``` -------------------------------- ### Traditional C++ Component Main Function Source: https://github.com/redhawksdr/core-framework/blob/develop-2.2/docs/shared-address/component-model.md Historically in REDHAWK, a C++ component is an executable which contains both the component-specific implementation class and a small `main()` driver that creates and executes the component. Most of the actual work of `main()` is done inside of the core libraries, in the `Resource_impl::start_component()` function. ```cpp /* * Historically in REDHAWK, a C++ component is an executable which contains both the component-specific implementation class (e.g., "TuneFilterDecimate_i") and a small `main()` driver that creates and executes the component. */ // Example main function structure: // int main(int argc, char* argv[]) { // // ... component setup ... // Resource_impl::start_component(); // // ... component execution ... // return 0; // } ``` -------------------------------- ### Custom Output Manager Create Output Transport Source: https://github.com/redhawksdr/core-framework/blob/develop-2.2/docs/custom-transport/add_transport.md Implements the `createOutputTransport` method for `CustomOutputManager`. This method constructs and returns a new `CustomOutputTransport` instance, passing necessary parameters. ```cpp CustomOutputTransport* CustomOutputManager::createOutputTransport(PtrType object, const std::string& connectionId, const redhawk::PropertyMap& inputTransportProps) { return new CustomOutputTransport(this->_port, object, connectionId, inputTransportProps ); } ``` -------------------------------- ### Custom Input Transport Negotiation Properties Source: https://github.com/redhawksdr/core-framework/blob/develop-2.2/docs/custom-transport/add_transport.md Implements the `getNegotiationProperties` method for `CustomInputTransport`. This method returns a `redhawk::PropertyMap` containing details for data requests, including size, address, port, and protocol. ```cpp redhawk::PropertyMap CustomInputTransport::getNegotiationProperties() { RH_NL_INFO("custom.transport", "CustomInputTransport::getNegotiationProperties"); redhawk::PropertyMap props; props["data::requestSize"] = static_cast(1000); props["data::address"] = "0.0.0.0"; props["data::port"] = static_cast(0); props["data::protocol"] = "udp"; return props; } ``` -------------------------------- ### Subclassing BulkIO Port to Change Local Transport Source: https://github.com/redhawksdr/core-framework/blob/develop-2.2/docs/custom-transport/add_transport.md Illustrates how to subclass a REDHAWK BulkIO port to override its default local transport behavior. This allows for the integration of custom transport mechanisms for inter-component communication within the same process, leveraging shared address space. ```c++ #include< விழ/ விழ.h> #include< விழ/ விழ_properties.h> #include< விழ/ விழ_transport.h> #include< விழ/ விழ_transport_factory.h> #include< விழ/ விழ_transport_manager.h> // Assume CustomLocalTransport, CustomLocalTransportFactory, CustomLocalTransportManager are defined elsewhere // Custom BulkIO Port classMyCustomPort:public விழ::BulkIOFloatPort { public: MyCustomPort(conststd::string&name, விழ::ComponentImpl*comp): விழ::BulkIOFloatPort(name, comp){} voidconnect( விழ:: விழ_connection_idconnection, விழ:: விழ_properties_tproperties)override{ // Get the transport manager associated with this port விழ::TransportManager*tm=this->getTransportManager(); // Create a custom local transport instance விழ::Transport*custom_transport=tm->createTransport(connection, "custom_local", properties); // Set the created transport for this connection this->setTransport(connection, custom_transport); // Perform any custom initialization or property exchange விழ:: விழ_properties_tresponse_properties; custom_transport->getNegotiationProperties(response_properties); this->setNegotiationResult(connection, response_properties); } }; // In the component implementation: // MyCustomPort*my_output_port=newMyCustomPort("dataFloat_out",this); // this->addComponentOutput(my_output_port); // ... // Register the custom local transport factory globally or per component // விழ::TransportFactory::Instance().registerTransportFactory("custom_local", newCustomLocalTransportFactory()); ``` -------------------------------- ### Custom Input Transport Class Declaration Source: https://github.com/redhawksdr/core-framework/blob/develop-2.2/docs/custom-transport/add_transport.md Declares the `CustomInputTransport` class, inheriting from `bulkio::InputTransport`. It includes constructors, a destructor, `transportType`, `getNegotiationProperties`, `startTransport`, `stopTransport` methods, and protected/private members for managing transport statistics and properties. ```cpp #include #include #include #include // class implementing the custom input transport class CustomInputTransport : public bulkio::InputTransport { public: CustomInputTransport(bulkio::InPort* port, const std::string& transportId, const redhawk::PropertyMap &usesTransportProps ) : bulkio::InputTransport(port, transportId) { // save off source end point description _usesTransportProps = usesTransportProps; }; virtual ~CustomInputTransport() { RH_NL_INFO("custom.transport", "CustomInputTransport::~CustomInputTransport" ); } std::string transportType() const { return "custom"; }; redhawk::PropertyMap getNegotiationProperties(); /** Control interface used by port when a connectPort occurs to start the transport after the negotiation has completed. */ void startTransport() { RH_NL_INFO("custom.transport", "CustomInputTransport::startTransport"); }; /** Control interface used by port when a disconnectPort occurs to stop the transport. */ void stopTransport() { RH_NL_INFO("custom.transport", "CustomInputTransport::stopTransport"); }; protected: // provides transport layer statistics to port redhawk::PropertyMap _getExtendedStatistics() { return redhawk::PropertyMap(); } private: redhawk::PropertyMap _usesTransportProps; }; ``` -------------------------------- ### Custom Output Transport Negotiation Properties Source: https://github.com/redhawksdr/core-framework/blob/develop-2.2/docs/custom-transport/add_transport.md Implements the `getNegotiationProperties` method for `CustomOutputTransport`. This method returns a `redhawk::PropertyMap` indicating the data protocol used by the output transport. ```cpp redhawk::PropertyMap CustomOutputTransport::getNegotiationProperties() { RH_NL_INFO("custom.transport", "CustomOutputTransport::getNegotiationProperties"); redhawk::PropertyMap props; props["data_protocol"] = "hello"; return props; } ``` -------------------------------- ### Custom Output Manager Set Negotiation Result Source: https://github.com/redhawksdr/core-framework/blob/develop-2.2/docs/custom-transport/add_transport.md Implements the `setNegotiationResult` method for `CustomOutputManager`. This method logs information about the negotiation properties received from the provider transport. ```cpp void CustomOutputManager::setNegotiationResult(redhawk::UsesTransport* transport, const redhawk::PropertyMap& properties) { if (!transport) { throw redhawk::FatalTransportError("Invalid transport object provided."); } RH_NL_INFO("custom.transport", "CustomOutputManager::setNegotiationResult"); for ( redhawk::PropertyMap::const_iterator it = properties.begin(); it != properties.end(); it++) { RH_NL_INFO("custom.transport", "CustomOutputManager, key (from provides): "<id ); } } ``` -------------------------------- ### Custom Transport Factory Input Manager Creation Source: https://github.com/redhawksdr/core-framework/blob/develop-2.2/docs/custom-transport/add_transport.md Implements the `createInputManager` method in `CustomTransportFactory`. This method is responsible for creating and returning a new instance of `CustomInputManager`. ```cpp CustomInputManager* CustomTransportFactory::createInputManager(bulkio::InPort* port) { return new CustomInputManager(port); } ``` -------------------------------- ### Custom Transport Factory Output Manager Creation Source: https://github.com/redhawksdr/core-framework/blob/develop-2.2/docs/custom-transport/add_transport.md Implements the `createOutputManager` method in `CustomTransportFactory`. This method is responsible for creating and returning a new instance of `CustomOutputManager`. ```cpp CustomOutputManager* CustomTransportFactory::createOutputManager(OutPortType* port) { return new CustomOutputManager(port); }; ``` -------------------------------- ### Using `redhawk::buffer` for Shared Memory Source: https://github.com/redhawksdr/core-framework/blob/develop-2.2/docs/shared-memory/shared-memory-ipc.md The `redhawk::buffer` template class automatically acquires memory from a process-shared heap. This enables shared memory-aware connections to transfer data buffers between processes efficiently by only passing metadata. ```cpp redhawk::buffer myBuffer; // myBuffer now uses a process-shared heap for optimal IPC. ``` -------------------------------- ### Custom Transport Classes and Factory Source: https://github.com/redhawksdr/core-framework/blob/develop-2.2/docs/custom-transport/add_transport.md Defines the `CustomOutputManager`, `CustomInputManager`, and `CustomTransportFactory` classes. These classes are responsible for managing input and output ports, negotiating transport properties, and creating transport instances for a custom data transport mechanism. ```cpp // CustomOutputManager class definition class CustomOutputManager : public bulkio::OutputManager { public: CustomOutputManager(bulkio::OutPort* port) : bulkio::OutputManager(port) {}; virtual ~CustomOutputManager() {}; std::string transportType() { return "custom"; } virtual CF::Properties transportProperties(); virtual CustomOutputTransport* createOutputTransport(PtrType object, const std::string& connectionId, const redhawk::PropertyMap& properties); virtual redhawk::PropertyMap getNegotiationProperties(redhawk::UsesTransport* transport); virtual void setNegotiationResult(redhawk::UsesTransport* transport, const redhawk::PropertyMap& properties); }; // factory class that registers input/ouptut managers with a negotiation port class CustomTransportFactory : public bulkio::BulkioTransportFactory { public: std::string transportType() { return "custom"; }; int defaultPriority() { return 0; }; virtual ~CustomTransportFactory() {}; CustomOutputManager* createOutputManager(OutPortType* port); CustomInputManager* createInputManager(InPortType* port); }; ``` -------------------------------- ### Custom Input Manager Negotiation Properties Source: https://github.com/redhawksdr/core-framework/blob/develop-2.2/docs/custom-transport/add_transport.md Implements the `getNegotiationProperties` method for `CustomInputManager`. It retrieves negotiation properties from the provided `CustomInputTransport` and returns them, ensuring the transport instance is valid. ```cpp redhawk::PropertyMap CustomInputManager::getNegotiationProperties(redhawk::ProvidesTransport* providesTransport) { CustomInputTransport* _transport = dynamic_cast(providesTransport); if (!_transport) { throw redhawk::FatalTransportError("Invalid provides transport instance"); } // return data end point connection information redhawk::PropertyMap properties; properties = _transport->getNegotiationProperties(); return properties; } ``` -------------------------------- ### Custom Outgoing Port for Shared Address Space Source: https://github.com/redhawksdr/core-framework/blob/develop-2.2/docs/custom-transport/add_transport.md Provides the C++ code for a custom outgoing port (`CustomOutPort`) that inherits from `bulkio::OutFloatPort`. This custom port redefines the `_createLocalTransport` method to disable the local transport when endpoints are in the same process space. ```cpp class CustomOutPort : public bulkio::OutFloatPort { public: virtual ~CustomOutPort() {}; CustomOutPort(std::string port_name) : bulkio::OutFloatPort(port_name) {}; virtual redhawk::UsesTransport* _createLocalTransport(PortBase* port, CORBA::Object_ptr object, const std::string& connectionId); }; ``` -------------------------------- ### Log4j Root Logger Configuration Source: https://github.com/redhawksdr/core-framework/blob/develop-2.2/burstioInterfaces/testing/tests/java/log4j_config.txt Configures the root logger for Log4j to set the logging level to INFO and direct output to the console (stdout). This is a standard Log4j configuration. ```properties log4j.rootLogger=INFO,stdout log4j.appender.stdout=org.apache.log4j.ConsoleAppender log4j.appender.stdout.layout=org.apache.log4j.PatternLayout log4j.appender.stdout.layout.ConversionPattern=%m%n ``` -------------------------------- ### Set Permissions for orb.properties Source: https://github.com/redhawksdr/core-framework/blob/develop-2.2/docs/jacorb/using-jacorb.md Ensures that all users have read permissions for the `orb.properties` file. ```sh chmod a+r $JAVA_HOME/jre/lib/orb.properties ``` -------------------------------- ### Configure JacORB Properties Source: https://github.com/redhawksdr/core-framework/blob/develop-2.2/docs/jacorb/using-jacorb.md Copies a template JacORB properties file to the REDHAWK configuration directory and adjusts logging verbosity. ```sh mkdir -p $OSSIEHOME/etc/ cp /usr/share/java/jacorb-3.9/etc/jacorb_properties.template $OSSIEHOME/etc/jacorb.properties ``` -------------------------------- ### Redhawk Custom Transport Registration Source: https://github.com/redhawksdr/core-framework/blob/develop-2.2/docs/custom-transport/add_transport.md Registers the `CustomTransportFactory` with the Redhawk transport registry. This allows the custom transport to be discovered and utilized by the framework. ```cpp static int initializeModule() { static CustomTransportFactory factory; redhawk::TransportRegistry::RegisterTransport(&factory); return 0; } static int initialized = initializeModule(); ``` -------------------------------- ### Custom Deleter for Memory Management Source: https://github.com/redhawksdr/core-framework/blob/develop-2.2/docs/shared-address/shared-address-components-howto.md Illustrates how to provide a custom deleter function or callable object to `redhawk::shared_buffer` for managing memory allocated with non-standard methods like `malloc`. This allows for flexible memory deallocation strategies. ```cpp float* data = (float*) malloc(sizeof(float) * 1024)); redhawk::shared_buffer buffer(data, 1024, &std::free); ``` -------------------------------- ### Custom Output Manager Transport Properties Source: https://github.com/redhawksdr/core-framework/blob/develop-2.2/docs/custom-transport/add_transport.md Implements the `transportProperties` method for `CustomOutputManager`. This method is intended to return transport-specific properties, currently returning an empty map. ```cpp CF::Properties CustomOutputManager::transportProperties() { RH_NL_INFO("custom.transport", "CustomOutputManager::transportProperties"); redhawk::PropertyMap props; return props; } ``` -------------------------------- ### Custom Output Port Implementation (C++) Source: https://github.com/redhawksdr/core-framework/blob/develop-2.2/docs/custom-transport/add_transport.md Defines a custom output port by overriding the `_createLocalTransport` method to disable the local transport and force negotiation. This is a C++ code snippet. ```cpp redhawk::UsesTransport* CustomOutPort::_createLocalTransport(PortBase* port, CORBA::Object_ptr object, const std::string& connectionId) { // disable the local transport and force a negotiation return 0; } ``` -------------------------------- ### Configure Java ORB Properties Source: https://github.com/redhawksdr/core-framework/blob/develop-2.2/docs/jacorb/using-jacorb.md Sets the default CORBA ORB implementation to JacORB by creating and configuring the `orb.properties` file. ```properties org.omg.CORBA.ORBClass=org.jacorb.orb.ORB org.omg.CORBA.ORBSingletonClass=org.jacorb.orb.ORBSingleton jacorb.config.dir=/usr/local/redhawk/core/etc ```