Opc.Ua.Com.Server.ComHdaItemManager.GetAvailableAttributes C# (CSharp) Method

GetAvailableAttributes() private method

Gets the available attributes for an HDA item.
private GetAvailableAttributes ( Session session, NodeId nodeId ) : ReadValueIdCollection
session Opc.Ua.Client.Session The session.
nodeId NodeId The node id.
return ReadValueIdCollection
        private ReadValueIdCollection GetAvailableAttributes(Session session, NodeId nodeId)
        {
            ReadValueIdCollection supportedAttributes = new ReadValueIdCollection();

            // add mandatory HDA attributes.
            supportedAttributes.Add(Construct(nodeId, OpcRcw.Hda.Constants.OPCHDA_ITEMID, Attributes.DisplayName));
            supportedAttributes.Add(Construct(nodeId, OpcRcw.Hda.Constants.OPCHDA_DATA_TYPE, Attributes.DataType));
            supportedAttributes.Add(Construct(nodeId, ComHdaProxy.INTERNAL_ATTRIBUTE_VALUE_RANK, Attributes.ValueRank));
            supportedAttributes.Add(Construct(nodeId, OpcRcw.Hda.Constants.OPCHDA_DESCRIPTION, Attributes.Description));
            supportedAttributes.Add(Construct(nodeId, OpcRcw.Hda.Constants.OPCHDA_ARCHIVING, Attributes.Historizing));

            // check if nodes are defined for all optional HDA attributes.
            BrowsePathCollection pathsToRead = new BrowsePathCollection();

            pathsToRead.Add(Construct(nodeId, ComHdaProxy.INTERNAL_ATTRIBUTE_ANNOTATION, Opc.Ua.BrowseNames.Annotations));
            pathsToRead.Add(Construct(nodeId, OpcRcw.Hda.Constants.OPCHDA_ENG_UNITS, Opc.Ua.BrowseNames.EngineeringUnits)); ;
            pathsToRead.Add(Construct(nodeId, OpcRcw.Hda.Constants.OPCHDA_DERIVE_EQUATION, Opc.Ua.BrowseNames.Definition));
            pathsToRead.Add(Construct(nodeId, OpcRcw.Hda.Constants.OPCHDA_NORMAL_MAXIMUM, Opc.Ua.BrowseNames.EURange));
            pathsToRead.Add(Construct(nodeId, OpcRcw.Hda.Constants.OPCHDA_NORMAL_MINIMUM, Opc.Ua.BrowseNames.EURange));
            pathsToRead.Add(Construct(nodeId, OpcRcw.Hda.Constants.OPCHDA_HIGH_ENTRY_LIMIT, Opc.Ua.BrowseNames.InstrumentRange));
            pathsToRead.Add(Construct(nodeId, OpcRcw.Hda.Constants.OPCHDA_LOW_ENTRY_LIMIT, Opc.Ua.BrowseNames.InstrumentRange));
            pathsToRead.Add(Construct(nodeId, OpcRcw.Hda.Constants.OPCHDA_STEPPED, Opc.Ua.BrowseNames.HAConfiguration, Opc.Ua.BrowseNames.Stepped));
            pathsToRead.Add(Construct(nodeId, OpcRcw.Hda.Constants.OPCHDA_MAX_TIME_INT, Opc.Ua.BrowseNames.HAConfiguration, Opc.Ua.BrowseNames.MaxTimeInterval));
            pathsToRead.Add(Construct(nodeId, OpcRcw.Hda.Constants.OPCHDA_MIN_TIME_INT, Opc.Ua.BrowseNames.HAConfiguration, Opc.Ua.BrowseNames.MinTimeInterval));
            pathsToRead.Add(Construct(nodeId, OpcRcw.Hda.Constants.OPCHDA_EXCEPTION_DEV, Opc.Ua.BrowseNames.HAConfiguration, Opc.Ua.BrowseNames.ExceptionDeviation));
            pathsToRead.Add(Construct(nodeId, OpcRcw.Hda.Constants.OPCHDA_EXCEPTION_DEV_TYPE, Opc.Ua.BrowseNames.HAConfiguration, Opc.Ua.BrowseNames.ExceptionDeviationFormat));

            BrowsePathResultCollection results = null;
            DiagnosticInfoCollection diagnosticInfos = null;

            session.TranslateBrowsePathsToNodeIds(
                null,
                pathsToRead,
                out results,
                out diagnosticInfos);

            Session.ValidateResponse(results, pathsToRead);
            Session.ValidateDiagnosticInfos(diagnosticInfos, pathsToRead);

            for (int ii = 0; ii < pathsToRead.Count; ii++)
            {
                uint attributeId = (uint)pathsToRead[ii].Handle;

                // path does not exist.
                if (StatusCode.IsBad(results[ii].StatusCode))
                {
                    continue;
                }

                // nothing found.
                if (results[ii].Targets.Count == 0)
                {
                    continue;
                }

                // choose the first valid target.
                for (int jj = 0; jj < results[ii].Targets.Count; jj++)
                {
                    BrowsePathTarget target = results[ii].Targets[jj];

                    if (target.RemainingPathIndex == UInt32.MaxValue && !NodeId.IsNull(target.TargetId) && !target.TargetId.IsAbsolute)
                    {
                        supportedAttributes.Add(Construct((NodeId)target.TargetId, attributeId, Attributes.Value));
                        break;
                    }
                }
            }

            return supportedAttributes;
        }