Skip to content

Generic client: single sampling scheduler and monitored item fixes - #36

Open
viacheslauK wants to merge 12 commits into
mainfrom
improvements-for-generic-client
Open

Generic client: single sampling scheduler and monitored item fixes#36
viacheslauK wants to merge 12 commits into
mainfrom
improvements-for-generic-client

Conversation

@viacheslauK

@viacheslauK viacheslauK commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Summary

Replaces the reader thread that each OpcUaMonitoredItemFbImpl used to own with one SamplingScheduler per device, and fixes several monitored-item defects found along the way.

Changes

  • SamplingScheduler (new) drives every monitored item of a device from one thread, each item keeping its own deadline.
  • DateTime: added OpcUaDataValue::isDateTime(); DateTime values now build a packet and are read as UA_DateTime instead of readScalar<UA_Int64>, including the UtcTime subtype.
  • Validation: SamplingInterval rejects negative and above-uint32_t values; reads reject a null value, report a failed packet build, and catch std::exception / ... beyond OpcUaException.
  • Tests and docs: new test_sampling_scheduler.cpp; device and monitored-item suites extended; test server publishes .dt and .utc nodes; USAGE.md adds a property reference and walkthrough.

@viacheslauK viacheslauK self-assigned this Aug 28, 2026
@viacheslauK viacheslauK changed the title Improvements for generic client Generic client: single sampling scheduler and monitored item fixes Aug 28, 2026
@viacheslauK
viacheslauK force-pushed the improvements-for-generic-client branch from 8e76917 to c3752de Compare August 28, 2026 19:10
@viacheslauK
viacheslauK marked this pull request as ready for review August 31, 2026 05:56
| `DeviceNodeIDNumeric` | Int | `0` | at connect |
| `DeviceNamespaceIndex` | Int | `0` | at connect |

Everything except `TimestampMode` is read once while the device is being created; changing those

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so everything except TimestampMode can be read only property

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also im not sure that its a great choice to publish user name and password. additionally username and location is existing in "General" property

PropertyObjectPtr config = instance.createDefaultAddDeviceConfig();
PropertyObjectPtr general = config.getPropertyValue("General");
general.setPropertyValue("Username", username);
general.setPropertyValue("Password", password);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and to get local id you can just type device.getLocalId() so the property just duplicates the functionality

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also im not sure that its a great choice to publish user name and password

It is really not a good way but it is not a subject of the PR. Also this will also go away with the introduction of an authentication manager. I would leave Password/Username as is right now.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so everything except TimestampMode can be read only property

All these properties are outside of a device. They are used to create a device but only TimestampMode is displayed as a device property.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and to get local id you can just type device.getLocalId() so the property just duplicates the functionality

LocalId property is used to set a device local Id (before creation)

Comment thread modules/opcua_generic_client_module/USAGE.md Outdated
BEGIN_NAMESPACE_OPENDAQ_OPCUA_GENERIC

class OpcUaMonitoredItemFbImpl final : public FunctionBlock
class OpcUaMonitoredItemFbImpl final : public FunctionBlock, public ISampledItem

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

u can do

class OpcUaMonitoredItemFbImpl final : public FunctionBlockImpl<IFunctionBlock, ISampledItem>
{
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not a real openDAQ interface. And I don't think we should make it that way.

}
}

void SamplingScheduler::loop()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would probably do the simple scheduler where the item set the fn, the scheduler should call, and inside the function should done all checks. if now samples, just return.

and maybe while registering callback get the id of fn (just incremental counter) so than you can remove function. or scheduler which has a queue of tasks, and inside fn you can re register the fn itself

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants