Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Enums, OptStructs and Unions (+ bugfixes) #167

Open
wants to merge 13 commits into
base: master
Choose a base branch
from

Conversation

dirk-zimoch
Copy link
Contributor

@dirk-zimoch dirk-zimoch commented Oct 22, 2024

All the following features have been implemented for both, the UaSdk and the open62541 implementation.
There are no tests for the new features.

Enum

During initialRead, the data type is read from the server. (This mechanism can also be used later to support write-only Nodes where initialRead currently fails.) If it is an enum type, then the string map is stored. mbbi and mbbo records that have no *ST and *VL fields set by the user get updated with this string map during intialRead processing and post a DBE_PROPERTY event to inform CA clients of the change.
String and CHAR array records connected to an enum translate the received Int32 value to the corresponding choice string. Writing to a string output record converts the string to the corresponding Int32 value to be sent to the server. The string is first matched against each enum string and then, if no match was found, the string is converted to an integer and matched against each enum value. If both fails, writing to the record fails with INVALID/WRITE alarm, just as any other out-of-range write attempt.

OptStruct

Records connected to an absent optional element of an OptStruct opcuaItem record are set to INVALID/READ alarm to show that no data is available for this element. Writing to such an absent element creates it and adds it to the optStruct before sending it to the server. There is currently no way to remove an existing optional element via EPICS.

Union

Records connected to not selected choices of a Union opcuaItem record are set to INVALID/READ alarm just like absent OptStruct elements. Writing to either element sets the selected type of the Union to whichever element has been written last and makes the other elements INVALID.
String records connected to a Union NodeId are set to a string consisting of the selected element name, a colon, and the selected choice value converted to a string. Writing a similarly formatted string to a string output record can change the selected choice of the Union if the element name changes. Writing an empty string selects "None" in the Union.
Writing a string fails if it does not start with a valid element name and a colon or when the value part cannot be converted to the type of the selected choice.
String records connected to Unions with Enum elements are not yet supported (due to missing test cases) and will handle the enum as an integer.
The string conversion is mainly meant for easy debugging.

Bugfixes

Some of these have already been part of other pull requests but have not yet been merged.

  • When registering up a monitoredItem fails (because the server returns an error) the record is set to INVALID/READ alarm instead of silently freezing. An error message is printed in this case even if the record is not set to debug mode.
  • Writing arrays of strings fixed.
  • Bug in ConnectionStatus passing fixed in the UaSDK implementation.
  • Attempt to read time stamp from elements with wrong type fixed in the open62541 implementation.
  • Don't follow FLNK when updating elements unless SCAN="I/O Intr". This change has been fixed to work on EPICS 3.15 too. This fixes problems with output records where the user expects the FLNK to be followed after writing to the record but not each time its gets updated from the server.
  • Don't attempt to (re-)process elements at writeComplete if they had not been written to (are not PACT). This fixes the problem that the INVALID/READ alarm of absent optional elements or not selected Union choices was falsely cleared when another element has been written to without changing the value and thus without causing a monitor update.
  • Only convert strings to other types if the full string matches. No longer accept "rubbish" after the convertable initial string part.

Value would appear frozen when installing monitoredItem failed for
example because the server has reached the limit of monitored items
or if an item cannot be monitored because it used invalid filters
like a deadband filter on a string.

show connectionLoss/COMM_ALARM when monitoredItem setup failed

Value would simply appear frozen otherwise.
Needed to revert order of initial read and montior setup so that
errors in monitor setup are not cleared by successful initial read.
When updating records from the driver, disable FLNK unless SCAN="I/O Intr".
Otherwise if the (output) record is a structure element and the FLNK causes
the parent opcuaItem record to process, an inifnite processing loop is created.
Also, the user probably only expects the FLNK to process when actively writing
to the output record, not when updating it from the server.
Commit 56cb080 "fix connection state handling" had a bug:
For UaSDK, the item was not setting the state for is own itemRecord.
outgoingData may still contain old yet unsent data that
needs to be discarded to avoid a memory leak
Read enum type info with strings at connect
Identify enum types during intial read and assign string maps
Update enum strings in mbbi/mbbo records at intial read
Convert enums to and from strings for string records and char waveforms
…tten

If writing to an optstruct or union, processing the records for all elements,
not only the one that has been written to, with a writeComplete callback
would clear errors for non-existing options and not selected choices.
This clears the INVALID alarm for those elements.
This becomes visible only if the value did not change and thus the optsruct
or union did not send back a monitor update.
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.

1 participant