UserComponentA.cpp
#include "UserComponentA.h" #include "UserNodeA.h" using namespace UserDefinedStructureLib; /*! \class UserComponentA \inmodule UserDefinedStructureLib \section1 Usage Add documentation for UserComponentA here. */ /*! \internal \brief Component constructor. The first function to be called. Can be used to initialize member variables, etc. */ UserComponentA::UserComponentA() { } /*! \internal \brief Component destructor. The last function to be called. Typically used to clean up when stopping, like freeing allocated memory, etc. */ UserComponentA::~UserComponentA() { for (auto node: m_userNodesA) delete node; } /*! \internal \brief Creates the component instance and other related CDP objects. Called after constructor Note, that this function is normally filled automatically by the code generator. */ void UserComponentA::Create(const char* fullName) { CDPComponent::Create(fullName); } /*! \internal \brief Creates a model instance for this class and fills model data. Registers messages, states and state transitions. Note, that this function is normally filled automatically by the code generator. */ void UserComponentA::CreateModel() { CDPComponent::CreateModel(); RegisterStateProcess("Null", (CDPCOMPONENT_STATEPROCESS)&UserComponentA::ProcessNull, "Initial Null state"); } /*! \internal \brief Configures the component by reading the configuration. Called after Create()/CreateModel(). Note, that this function is normally filled automatically by the code generator. */ void UserComponentA::Configure(const char* componentXML) { CDPComponent::Configure(componentXML); } bool UserComponentA::HandleXMLElement(XMLElementEx *pEx) { const XMLString& currentElement = pEx->GetName(); if (currentElement == "UserNodeA") { m_userNodesA.push_back(new UserNodeA(pEx, this)); return true; // done with handling the structure } return CDPComponent::HandleXMLElement(pEx); } void UserComponentA::FillNodeChildren(CDP::StudioAPI::NodeStream &serializer) const { serializer.StdContainerStreamer(m_userNodesA); CDPComponent::FillNodeChildren(serializer); } /*! \brief Component Null state processing function Write your component's processing code here. When the component is simple, all the processing code may reside here. This function gets called periodically. The period is changed by setting the "fs" (frequency) Property when you use the component in a project. Functions called ProcessSTATENAME(), like ProcessNull(), are state processing functions and are only called when components are in given state. The default component state is "Null". Note, that state processing functions are not allowed to block (i.e. read files, sleep, communicate with network in blocking mode etc.) For blocking code use the 'Threaded Component Model' wizard instead. Please consult CDP Studio "Code Mode Manual" for more information and examples. */ void UserComponentA::ProcessNull() { /* Write your code here */ }
Get started with CDP Studio today
Let us help you take your great ideas and turn them into the products your customer will love.