FORUM CTRLX AUTOMATION
ctrlX World Partner Apps for ctrlX AUTOMATION
Dear Community User! We are updating our platform to a new
system.
Read more: Important
information on the platform change.
08-01-2023 09:11 PM - edited 08-01-2023 09:16 PM
Objective: To read the parameters from the drives and publish them near real time into the data layer further to be consumed by REST/OPC UA clients
Overall, my code tries to read parameter from the drive connected to ctrlX core. It overwrite/update the data nodes created in data layer by deregistering and registering nodes with new data inside an infinite while loop.
Sample from my code:
float count = 0.5f;
tmp_count.setValue(count);
std::cout << "INFO Register node 'ocx/HMI/tmp_count' " << std::endl;
result = provider->registerNode("ocx/HMI/tmp_count", new MyProviderNode(tmp_count));
std::cout << "INFO Running endless loop - end with Ctrl+C" << std::endl;
while (endProcess == false)
{
if (provider->isConnected() == false)
{
std::cout << "ERROR Datalayer connection broken!" << std::endl;
break;
}
count += 0.1;
std::cout << "Setting value of tmp_count" << count << std::endl;
comm::datalayer::DlResult res;
res = tmp_count.setValue(count);
std::cout << "Result after SetValue " << res.toString() << std::endl;
res = provider->registerNode("ocx/HMI/tmp_count", new MyProviderNode(tmp_count));
std::cout << "Result after Registering node " << res.toString() << std::endl;
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
provider->unregisterNode("ocx/HMI/tmp_count");
}
Is it the correct way to overwrite the nodes ? Do we need a constantly running while loop to update nodes?Is there any better way to achieve this?
Solved! Go to Solution.
08-02-2023 07:41 AM
Hi Dave
some hints regarding your questions:
Best regards,
Nick