示例#1
0
        /// <summary>
        /// Creates a deep copy of the value.
        /// </summary>
        /// <remarks>
        /// Creates a deep copy of the value.
        /// </remarks>
        /// <param name="value">The text to create an instance from</param>
        /// <exception cref="ArgumentNullException">Thrown when the value is null</exception>
        public LocalizedText(LocalizedText value)
        {
            if (value == null) throw new ArgumentNullException("value");

            Locale = value.Locale;
            Text = value.Text;
        }
示例#2
0
        /// <summary>
        /// Initializes the object with the unitName and namespaceUri.
        /// </summary>
        public EUInformation(string shortName, string longName, string namespaceUri)
        {
            Initialize();

            m_displayName  = new LocalizedText(shortName);
            m_description  = new LocalizedText(longName);
            m_namespaceUri = namespaceUri;
        }
 /// <summary>
 /// Constructs a object by specifying each property.
 /// </summary>
 public ServiceResult(
     StatusCode    code,
     string        symbolicId,
     string        namespaceUri,
     LocalizedText localizedText,
     string        additionalInfo)
 :
     this(code, symbolicId, namespaceUri, localizedText, additionalInfo, (ServiceResult)null)
 {
 }
 /// <summary>
 /// Initializes the instance with the default values.
 /// </summary>
 protected override void Initialize(ISystemContext context)
 {
     SuperTypeId = Opc.Ua.NodeId.Create(Opc.Ua.ObjectTypes.BaseObjectType, Opc.Ua.Namespaces.OpcUa, context.NamespaceUris);
     NodeId = Opc.Ua.NodeId.Create(Opc.Ua.ObjectTypes.BaseObjectType, Opc.Ua.Namespaces.OpcUa, context.NamespaceUris);
     BrowseName = Opc.Ua.QualifiedName.Create(Opc.Ua.BrowseNames.BaseObjectType, Opc.Ua.Namespaces.OpcUa, context.NamespaceUris);
     DisplayName = new LocalizedText(Opc.Ua.BrowseNames.BaseObjectType, String.Empty, Opc.Ua.BrowseNames.BaseObjectType);
     Description = null;
     WriteMask = AttributeWriteMask.None;
     UserWriteMask = AttributeWriteMask.None;
     IsAbstract = false;
 }
 /// <summary>
 /// Constructs a object by specifying each property.
 /// </summary>
 public ServiceResult(
     StatusCode    code,
     string        symbolicId,
     string        namespaceUri,
     LocalizedText localizedText,
     string        additionalInfo,
     ServiceResult innerResult)
 {
     StatusCode     = code;
     SymbolicId     = symbolicId;
     NamespaceUri   = namespaceUri;
     LocalizedText  = localizedText;
     AdditionalInfo = additionalInfo;
     InnerResult    = innerResult;
 }
        /// <summary>
        /// Called when one or more sub-states change state.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="displayName">The display name for the effective state.</param>
        /// <param name="transitionTime">The transition time.</param>
        public virtual void SetEffectiveSubState(ISystemContext context, LocalizedText displayName, DateTime transitionTime)
        {
            if (this.EnabledState.EffectiveDisplayName != null)
            {
                this.EnabledState.EffectiveDisplayName.Value = displayName;
            }

            if (this.EnabledState.EffectiveTransitionTime != null)
            {
                if (transitionTime != DateTime.MinValue)
                {
                    this.EnabledState.EffectiveTransitionTime.Value = transitionTime;
                }
                else
                {
                    this.EnabledState.EffectiveTransitionTime.Value = DateTime.UtcNow;
                }
            }
        }
        /// <summary>
        /// Initializes a new event.
        /// </summary>
        /// <param name="context">The current system context.</param>
        /// <param name="source">The source of the event.</param>
        /// <param name="severity">The severity for the event.</param>
        /// <param name="message">The default message.</param>
        public virtual void Initialize(
            ISystemContext context, 
            NodeState source, 
            EventSeverity severity,
            LocalizedText message)
        {
            m_eventId = new PropertyState<byte[]>(this);
            m_eventId.Value = Guid.NewGuid().ToByteArray();

            m_eventType = new PropertyState<NodeId>(this);
            m_eventType.Value = GetDefaultTypeDefinitionId(context.NamespaceUris);

            TypeDefinitionId = m_eventType.Value;

            if (source != null)
            {
                if (!NodeId.IsNull(source.NodeId))
                {
                    m_sourceNode = new PropertyState<NodeId>(this);
                    m_sourceNode.Value = source.NodeId;
                }

                if (!QualifiedName.IsNull(source.BrowseName))
                {
                    m_sourceName = new PropertyState<string>(this);
                    m_sourceName.Value = source.BrowseName.Name;
                }
            }

            m_time = new PropertyState<DateTime>(this);
            m_time.Value = DateTime.UtcNow;

            m_receiveTime = new PropertyState<DateTime>(this);
            m_receiveTime.Value = DateTime.UtcNow;

            m_severity = new PropertyState<ushort>(this);
            m_severity.Value = (ushort)severity;

            m_message = new PropertyState<LocalizedText>(this);
            m_message.Value = message;
        }
        /// <summary>
        /// Initializes a new event.
        /// </summary>
        /// <param name="context">The current system context.</param>
        /// <param name="source">The source of the event.</param>
        /// <param name="severity">The severity for the event.</param>
        /// <param name="message">The default message.</param>
        /// <param name="status">Whether the operation that caused the event succeeded.</param>
        /// <param name="actionTimestamp">When the operation started.</param>
        public virtual void Initialize(
            ISystemContext context, 
            NodeState source, 
            EventSeverity severity,
            LocalizedText message,
            bool status,
            DateTime actionTimestamp)
        {
            base.Initialize(context, source, severity, message);

            m_status = new PropertyState<bool>(this);
            m_status.Value = status;

            if (actionTimestamp != DateTime.MinValue)
            {
                m_actionTimeStamp = new PropertyState<DateTime>(this);
                m_actionTimeStamp.Value = actionTimestamp;
            }

            if (context.NamespaceUris != null)
            {
                m_serverId = new PropertyState<string>(this);
                m_serverId.Value = context.NamespaceUris.GetString(1);
            }

            if (context.AuditEntryId != null)
            {
                m_clientAuditEntryId = new PropertyState<string>(this);
                m_clientAuditEntryId.Value = context.AuditEntryId;
            }

            if (context.UserIdentity != null)
            {
                m_clientUserId = new PropertyState<string>(this);
                m_clientUserId.Value = context.UserIdentity.DisplayName;
            }
        }
示例#9
0
        private ServiceResult OnUserArrayValue2(
            ISystemContext context,
            MethodState method,
            NodeId objectId,
            DateTime[] dateTimeIn,
            Uuid[] guidIn,
            byte[][] byteStringIn,
            XmlElement[] xmlElementIn,
            NodeId[] nodeIdIn,
            ExpandedNodeId[] expandedNodeIdIn,
            QualifiedName[] qualifiedNameIn,
            LocalizedText[] localizedTextIn,
            StatusCode[] statusCodeIn,
            Variant[] variantIn,
            ref DateTime[] dateTimeOut,
            ref Uuid[] guidOut,
            ref byte[][] byteStringOut,
            ref XmlElement[] xmlElementOut,
            ref NodeId[] nodeIdOut,
            ref ExpandedNodeId[] expandedNodeIdOut,
            ref QualifiedName[] qualifiedNameOut,
            ref LocalizedText[] localizedTextOut,
            ref StatusCode[] statusCodeOut,
            ref Variant[] variantOut)
        {
            dateTimeOut = dateTimeIn;
            guidOut = guidIn;
            byteStringOut = byteStringIn;
            xmlElementOut = xmlElementIn;
            nodeIdOut = nodeIdIn;
            expandedNodeIdOut = expandedNodeIdIn;
            qualifiedNameOut = qualifiedNameIn;
            localizedTextOut = localizedTextIn;
            statusCodeOut = statusCodeIn;
            variantOut = variantIn;

            return ServiceResult.Good;
        }
示例#10
0
        private ServiceResult OnUserScalarValue2(
            ISystemContext context,
            MethodState method,
            NodeId objectId,
            DateTime dateTimeIn,
            Uuid guidIn,
            byte[] byteStringIn,
            XmlElement xmlElementIn,
            NodeId nodeIdIn,
            ExpandedNodeId expandedNodeIdIn,
            QualifiedName qualifiedNameIn,
            LocalizedText localizedTextIn,
            StatusCode statusCodeIn,
            object variantIn,
            ref DateTime dateTimeOut,
            ref Uuid guidOut,
            ref byte[] byteStringOut,
            ref XmlElement xmlElementOut,
            ref NodeId nodeIdOut,
            ref ExpandedNodeId expandedNodeIdOut,
            ref QualifiedName qualifiedNameOut,
            ref LocalizedText localizedTextOut,
            ref StatusCode statusCodeOut,
            ref object variantOut)
        {
            dateTimeOut = dateTimeIn;
            guidOut = guidIn;
            byteStringOut = byteStringIn;
            xmlElementOut = xmlElementIn;
            nodeIdOut = nodeIdIn;
            expandedNodeIdOut = expandedNodeIdIn;
            qualifiedNameOut = qualifiedNameIn;
            localizedTextOut = localizedTextIn;
            statusCodeOut = statusCodeIn;
            variantOut = variantIn;

            return ServiceResult.Good;
        }
示例#11
0
        /// <summary>
        /// Parses an XML element and returns the value contained in it.
        /// </summary>
        private object ToObject(XmlElement element)
        {
            switch (element.Name)
            {
            case "Byte":
            {
                return(XmlConvert.ToByte(element.InnerText));
            }

            case "SByte":
            {
                return(XmlConvert.ToSByte(element.InnerText));
            }

            case "Int16":
            {
                return(XmlConvert.ToInt16(element.InnerText));
            }

            case "UInt16":
            {
                return(XmlConvert.ToUInt16(element.InnerText));
            }

            case "Int32":
            {
                return(XmlConvert.ToInt32(element.InnerText));
            }

            case "UInt32":
            {
                return(XmlConvert.ToUInt32(element.InnerText));
            }

            case "Int64":
            {
                return(XmlConvert.ToInt64(element.InnerText));
            }

            case "UInt64":
            {
                return(XmlConvert.ToUInt64(element.InnerText));
            }

            case "Single":
            {
                return(XmlConvert.ToSingle(element.InnerText));
            }

            case "Double":
            {
                return(XmlConvert.ToDouble(element.InnerText));
            }

            case "String":
            {
                return(element.InnerText);
            }

            case "DateTime":
            {
                return(XmlConvert.ToDateTime(element.InnerText, XmlDateTimeSerializationMode.Utc));
            }

            case "NodeId":
            {
                XmlNode child = element.FirstChild;

                string id = null;

                if (GetValue(element, ref child, "Identifier", out id))
                {
                    return(new NodeId(id));
                }

                break;
            }

            case "ExpandedNodeId":
            {
                XmlNode child = element.FirstChild;

                string id = null;

                if (GetValue(element, ref child, "Identifier", out id))
                {
                    return(new NodeId(id));
                }

                break;
            }

            case "QualifiedName":
            {
                QualifiedName value = new QualifiedName();

                XmlNode child = element.FirstChild;

                string namespaceIndex = null;

                if (GetValue(element, ref child, "NamespaceIndex", out namespaceIndex))
                {
                    value.NamespaceIndex = XmlConvert.ToUInt16(namespaceIndex);
                }

                string name = null;

                if (GetValue(element, ref child, "Name", out name))
                {
                    value.Name = name;
                }

                return(value);
            }

            case "LocalizedText":
            {
                LocalizedText value = new LocalizedText();

                XmlNode child = element.FirstChild;

                string locale = null;

                if (GetValue(element, ref child, "Locale", out locale))
                {
                    value.Locale = locale;
                }

                string text = null;

                if (GetValue(element, ref child, "Text", out text))
                {
                    value.Text = text;
                }

                return(value);
            }

            case "StatusCode":
            {
                StatusCode value = new StatusCode();

                XmlNode child = element.FirstChild;

                string code = null;

                if (GetValue(element, ref child, "Code", out code))
                {
                    value.Code = XmlConvert.ToUInt32(code);;
                }

                return(value);
            }

            case "ExtensionObject":
            {
                ExtensionObject value = new ExtensionObject();

                XmlNode child = element.FirstChild;

                string typeId = null;

                if (GetValue(element, ref child, "TypeId", out typeId))
                {
                    value.TypeId = new ExpandedNodeId(typeId);
                }

                for (XmlNode node = child; node != null; node = node.NextSibling)
                {
                    XmlElement element2 = child as XmlElement;

                    if (element2 != null)
                    {
                        if (element2.Name == "Body")
                        {
                            ExtensionObjectBody body = new ExtensionObjectBody();
                            body.Nodes = new XmlNode[] { GetFirstElement(element2) };
                            value.Body = body;
                        }

                        break;
                    }
                }

                return(value);
            }
            }

            return(null);
        }
 /// <summary>
 /// Constructs a object by specifying each property.
 /// </summary>
 public ServiceResult(
     StatusCode    code,
     string        symbolicId,
     string        namespaceUri,
     LocalizedText localizedText)
 :
     this(code, symbolicId, namespaceUri, localizedText, (string)null, (ServiceResult)null)
 {
 }
        /// <summary>
        /// Called when the Confirm method is called.
        /// </summary>
        /// <param name="context">The system context.</param>
        /// <param name="method">The method being called.</param>
        /// <param name="objectId">The id of the object.</param>
        /// <param name="eventId">The identifier for the event which is the target for the comment.</param>
        /// <param name="comment">The comment.</param>
        /// <returns>Any error.</returns>
        protected virtual ServiceResult OnConfirmCalled(
            ISystemContext context,
            MethodState method,
            NodeId objectId,
            byte[] eventId,
            LocalizedText comment)
        {
            ServiceResult error = ProcessBeforeConfirm(context, eventId, comment);

            if (ServiceResult.IsGood(error))
            {
                AcknowledgeableConditionState branch = GetAcknowledgeableBranch(eventId);

                if (branch != null)
                {
                    branch.OnConfirmCalled(context, method, objectId, eventId, comment);
                    RemoveBranchEvent(eventId);
                }
                else
                {
                    SetConfirmedState(context, true);
                }

                // If this is a branch, the comment goes to both the branch and the original event
                if (CanSetComment(comment))
                {
                    SetComment(context, comment, GetCurrentUserId(context));
                }

                UpdateRetainState();
            }

            if (EventsMonitored())
            {
                // report a state change event.
                if (ServiceResult.IsGood(error))
                {
                    ReportStateChange(context, false);
                }

                // raise the audit event.
                AuditConditionConfirmEventState e = new AuditConditionConfirmEventState(null);

                TranslationInfo info = new TranslationInfo(
                    "AuditConditionConfirm",
                    "en-US",
                    "The Confirm method was called.");

                e.Initialize(
                    context,
                    this,
                    EventSeverity.Low,
                    new LocalizedText(info),
                    ServiceResult.IsGood(error),
                    DateTime.UtcNow);

                e.SetChildValue(context, BrowseNames.SourceNode, NodeId, false);
                e.SetChildValue(context, BrowseNames.SourceName, "Method/Confirm", false);

                e.SetChildValue(context, BrowseNames.MethodId, method.NodeId, false);
                e.SetChildValue(context, BrowseNames.InputArguments, new object[] { eventId, comment }, false);

                e.SetChildValue(context, BrowseNames.ConditionEventId, eventId, false);
                e.SetChildValue(context, BrowseNames.Comment, comment, false);

                ReportEvent(context, e);
            }

            return(error);
        }
        /// <summary>
        /// Adds a set of nodes to the table.
        /// </summary>
        /// <param name="nodeSet">The node set.</param>
        /// <param name="externalReferences">The external references.</param>
        /// <returns></returns>
        public List <Node> Import(NodeSet nodeSet, IDictionary <NodeId, IList <IReference> > externalReferences)
        {
            List <Node> importedNodes = new List <Node>();

            if (nodeSet == null)
            {
                return(importedNodes);
            }

            // add the nodes.
            foreach (Node nodeToImport in nodeSet.Nodes)
            {
                // ignore empty nodes.
                if (nodeToImport == null || NodeId.IsNull(nodeToImport.NodeId))
                {
                    continue;
                }

                Node node = nodeSet.Copy(nodeToImport, m_namespaceUris, m_serverUris);

                // assign a browse name.
                if (QualifiedName.IsNull(node.BrowseName))
                {
                    node.BrowseName = new QualifiedName(node.NodeId.ToString(), 1);
                }

                // assign a display name.
                if (LocalizedText.IsNullOrEmpty(node.DisplayName))
                {
                    node.DisplayName = new LocalizedText(node.BrowseName.Name);
                }

                // index references (the node ids in the references were translated by the Copy() call above).
                foreach (ReferenceNode reference in node.References)
                {
                    // ignore invalid references.
                    if (NodeId.IsNull(reference.ReferenceTypeId) || NodeId.IsNull(reference.TargetId))
                    {
                        continue;
                    }

                    // ignore missing targets.
                    ExpandedNodeId targetId = reference.TargetId;

                    if (NodeId.IsNull(targetId))
                    {
                        continue;
                    }

                    // index reference.
                    node.ReferenceTable.Add(reference.ReferenceTypeId, reference.IsInverse, targetId);

                    // see if a remote node needs to be created.
                    if (targetId.ServerIndex != 0)
                    {
                        RemoteNode remoteNode = Find(targetId) as RemoteNode;

                        if (remoteNode == null)
                        {
                            remoteNode = new RemoteNode(this, targetId);
                            InternalAdd(remoteNode);
                        }

                        remoteNode.AddRef();
                    }
                }

                // clear imported references.
                node.References.Clear();

                // add the node.
                InternalAdd(node);
                importedNodes.Add(node);
            }

            // import the nodes.
            foreach (Node node in importedNodes)
            {
                // ignore invalid nodes.
                if (node == null || NodeId.IsNull(node.NodeId))
                {
                    continue;
                }

                // add reverse references.
                foreach (IReference reference in node.ReferenceTable)
                {
                    Node targetNode = Find(reference.TargetId) as Node;

                    if (targetNode == null)
                    {
                        if (reference.TargetId.ServerIndex != 0)
                        {
                            continue;
                        }

                        // return the reverse reference to a node outside the table.
                        if (externalReferences != null)
                        {
                            NodeId targetId = ExpandedNodeId.ToNodeId(reference.TargetId, m_namespaceUris);

                            if (targetId == null)
                            {
                                continue;
                            }

                            IList <IReference> referenceList = null;

                            if (!externalReferences.TryGetValue(targetId, out referenceList))
                            {
                                externalReferences[targetId] = referenceList = new List <IReference>();
                            }

                            ReferenceNode reverseReference = new ReferenceNode();

                            reverseReference.ReferenceTypeId = reference.ReferenceTypeId;
                            reverseReference.IsInverse       = !reference.IsInverse;
                            reverseReference.TargetId        = node.NodeId;

                            referenceList.Add(reverseReference);
                        }

                        continue;
                    }

                    // type definition and modelling rule references are one way.
                    if (reference.ReferenceTypeId != ReferenceTypeIds.HasTypeDefinition && reference.ReferenceTypeId != ReferenceTypeIds.HasModellingRule)
                    {
                        targetNode.ReferenceTable.Add(reference.ReferenceTypeId, !reference.IsInverse, node.NodeId);
                    }
                }

                // see if it is a type.
                if (m_typeTree != null)
                {
                    m_typeTree.Add(node);
                }
            }

            return(importedNodes);
        }
        /// <summary>
        /// Writes an LocalizedText to the stream.
        /// </summary>
        public void WriteLocalizedText(string fieldName, LocalizedText value)
        {
            if (BeginField(fieldName, value == null, true))
            {
                PushNamespace(Namespaces.OpcUaXsd);
                
                if (value != null)
                {
                    WriteString("Locale", value.Locale);
                    WriteString("Text", value.Text);
                }

                PopNamespace();
                
                EndField(fieldName);
            }
        }
        /// <summary>
        /// Constructs a object by specifying each property.
        /// </summary>
        /// <remarks>
        /// The innerException is used to construct the inner result.
        /// </remarks>
        public ServiceResult(
            StatusCode    code,
            string        symbolicId,
            string        namespaceUri,
            LocalizedText localizedText,
            string        additionalInfo,            
            Exception     innerException)
        {
            ServiceResult innerResult = new ServiceResult(innerException);

            // check if no new information provided.
            if (code.Code == innerResult.Code && symbolicId == null && localizedText == null && additionalInfo == null)
            {
                m_code           = innerResult.Code;
                m_symbolicId     = innerResult.SymbolicId;
                m_namespaceUri   = innerResult.NamespaceUri;
                m_localizedText  = innerResult.LocalizedText;
                m_additionalInfo = innerResult.AdditionalInfo;
                m_innerResult    = innerResult.InnerResult;
            }

            // make the exception the inner result.
            else
            {
                m_code           = code.Code;
                m_symbolicId     = symbolicId;
                m_namespaceUri   = namespaceUri;
                m_localizedText  = localizedText;
                m_additionalInfo = additionalInfo;
                m_innerResult    = innerResult;
            }
        }
 /// <summary>
 /// Constructs a object by specifying each property.
 /// </summary>
 public ServiceResult(
     StatusCode       code,
     XmlQualifiedName symbolicId,
     LocalizedText    localizedText)
 :
     this(code, (symbolicId != null) ? symbolicId.Name : null, (symbolicId != null) ? symbolicId.Namespace : null, localizedText, (string)null, (ServiceResult)null)
 {
 }
示例#18
0
        /// <summary>
        /// Initializes the node from the element.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="element">The element.</param>
        /// <param name="namespaceIndex">Index of the namespace.</param>
        public void Initialize(ISystemContext context, DaElement element, ushort namespaceIndex)
        {
            m_element = element;

            if (element == null)
            {
                return;
            }

            this.NodeId = DaModelUtils.ConstructIdForDaElement(element.ItemId, -1, namespaceIndex);
            this.BrowseName = new QualifiedName(element.Name, namespaceIndex);
            this.DisplayName = new LocalizedText(element.Name);

            // check if TimeZone is supported.
            if (element.TimeZone != null)
            {
                PropertyState property = this.AddProperty<Range>(Opc.Ua.BrowseNames.LocalTime, DataTypeIds.TimeZoneDataType, ValueRanks.Scalar);
                property.NodeId = DaModelUtils.ConstructIdForComponent(property, namespaceIndex);
                property.Value = new Range(element.HighIR, element.LowIR);
            }

            // set the TypeDefinition based on the ElementType.
            switch (element.ElementType)
            {
                case DaElementType.AnalogItem:
                {
                    this.TypeDefinitionId = Opc.Ua.VariableTypeIds.AnalogItemType;

                    // EURange is always present.
                    PropertyState property = this.AddProperty<Range>(Opc.Ua.BrowseNames.EURange, DataTypeIds.Range, ValueRanks.Scalar);
                    property.NodeId = DaModelUtils.ConstructIdForComponent(property, namespaceIndex); 
                    property.Value = new Range(element.HighEU, element.LowEU);

                    // check if InstrumentRange is supported.
                    if (element.HighIR != 0 || element.LowIR != 0)
                    {
                        property = this.AddProperty<Range>(Opc.Ua.BrowseNames.InstrumentRange, DataTypeIds.Range, ValueRanks.Scalar);
                        property.NodeId = DaModelUtils.ConstructIdForComponent(property, namespaceIndex);
                        property.Value = new Range(element.HighIR, element.LowIR);
                    }

                    // check if EngineeringUnits is supported.
                    if (element.EngineeringUnits != null)
                    {
                        property = this.AddProperty<EUInformation>(Opc.Ua.BrowseNames.EngineeringUnits, DataTypeIds.EUInformation, ValueRanks.Scalar);
                        property.NodeId = DaModelUtils.ConstructIdForComponent(property, namespaceIndex); 

                        // use the server's namespace uri to qualify the engineering units.
                        string namespaceUri = context.NamespaceUris.GetString(namespaceIndex);
                        property.Value = new EUInformation(element.EngineeringUnits, namespaceUri);
                    }

                    break;
                }

                case DaElementType.DigitalItem:
                {
                    this.TypeDefinitionId = Opc.Ua.VariableTypeIds.TwoStateDiscreteType;

                    // check if CloseLabel is supported.
                    if (element.CloseLabel != null)
                    {
                        PropertyState property = this.AddProperty<LocalizedText>(Opc.Ua.BrowseNames.TrueState, DataTypeIds.LocalizedText, ValueRanks.Scalar);
                        property.NodeId = DaModelUtils.ConstructIdForComponent(property, namespaceIndex); 
                        property.Value = element.CloseLabel;
                    }

                    // check if OpenLabel is supported.
                    if (element.OpenLabel != null)
                    {
                        PropertyState property = this.AddProperty<LocalizedText>(Opc.Ua.BrowseNames.FalseState, DataTypeIds.LocalizedText, ValueRanks.Scalar);
                        property.NodeId = DaModelUtils.ConstructIdForComponent(property, namespaceIndex); 
                        property.Value = element.OpenLabel;
                    }

                    break;
                }

                case DaElementType.EnumeratedItem:
                {
                    this.TypeDefinitionId = Opc.Ua.VariableTypeIds.MultiStateDiscreteType;

                    // check if EuInfo is supported.
                    if (element.EuInfo != null)
                    {
                        PropertyState property = this.AddProperty<LocalizedText[]>(Opc.Ua.BrowseNames.EnumStrings, DataTypeIds.LocalizedText, ValueRanks.OneDimension);
                        property.NodeId = DaModelUtils.ConstructIdForComponent(property, namespaceIndex); 

                        LocalizedText[] strings = new LocalizedText[element.EuInfo.Length];

                        for (int ii = 0; ii < strings.Length; ii++)
                        {
                            strings[ii] = element.EuInfo[ii];
                        }

                        property.Value = strings;
                    }

                    break;
                }
            }

            if (element.Description != null)
            {
                this.Description = element.Description;
            }

            this.Value = null;
            this.StatusCode = StatusCodes.BadWaitingForInitialData;
            this.Timestamp = DateTime.UtcNow;

            bool isArray = false;
            this.DataType = ComUtils.GetDataTypeId(element.DataType, out isArray);
            this.ValueRank = (isArray)?ValueRanks.OneOrMoreDimensions:ValueRanks.Scalar;

            this.AccessLevel = AccessLevels.None;

            if ((element.AccessRights & OpcRcw.Da.Constants.OPC_READABLE) != 0)
            {
                this.AccessLevel |= AccessLevels.CurrentRead;
            }

            if ((element.AccessRights & OpcRcw.Da.Constants.OPC_WRITEABLE) != 0)
            {
                this.AccessLevel |= AccessLevels.CurrentWrite;
            }

            this.UserAccessLevel = this.AccessLevel;
            this.MinimumSamplingInterval = element.ScanRate;
        }
示例#19
0
        /// <summary>
        /// Initializes the instance from an event notification.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="fields">The fields selected for the event notification.</param>
        /// <param name="e">The event notification.</param>
        /// <remarks>
        /// This method creates components based on the browse paths in the event field and sets
        /// the NodeId or Value based on values in the event notification.
        /// </remarks>
        public void Update(
            ISystemContext context,
            SimpleAttributeOperandCollection fields,
            EventFieldList e)
        {
            for (int ii = 0; ii < fields.Count; ii++)
            {
                SimpleAttributeOperand field = fields[ii];
                object value = e.EventFields[ii].Value;

                // check if value provided.
                if (value == null)
                {
                    continue;
                }

                // extract the NodeId for the event.
                if (field.BrowsePath.Count == 0)
                {
                    if (field.AttributeId == Attributes.NodeId)
                    {
                        this.NodeId = value as NodeId;
                        continue;
                    }
                }

                // extract the type definition for the event.
                if (field.BrowsePath.Count == 1)
                {
                    if (field.AttributeId == Attributes.Value)
                    {
                        if (field.BrowsePath[0] == BrowseNames.EventType)
                        {
                            m_typeDefinitionId = value as NodeId;
                            continue;
                        }
                    }
                }

                // save value for child node.
                NodeState parent = this;

                for (int jj = 0; jj < field.BrowsePath.Count; jj++)
                {
                    // find a predefined child identified by the browse name.
                    BaseInstanceState child = parent.CreateChild(context, field.BrowsePath[jj]);

                    // create a placeholder for unknown children.
                    if (child == null)
                    {
                        if (field.AttributeId == Attributes.Value)
                        {
                            child = new BaseDataVariableState(parent);
                        }
                        else
                        {
                            child = new BaseObjectState(parent);
                        }

                        parent.AddChild(child);
                    }

                    // ensure the browse name is set.
                    if (QualifiedName.IsNull(child.BrowseName))
                    {
                        child.BrowseName = field.BrowsePath[jj];
                    }

                    // ensure the display name is set.
                    if (LocalizedText.IsNullOrEmpty(child.DisplayName))
                    {
                        child.DisplayName = child.BrowseName.Name;
                    }

                    // process next element in path.
                    if (jj < field.BrowsePath.Count - 1)
                    {
                        parent = child;
                        continue;
                    }

                    // save the variable value.
                    if (field.AttributeId == Attributes.Value)
                    {
                        BaseVariableState variable = child as BaseVariableState;

                        if (variable != null && field.AttributeId == Attributes.Value)
                        {
                            try
                            {
                                variable.WrappedValue = e.EventFields[ii];
                            }
                            catch (Exception)
                            {
                                variable.Value = null;
                            }
                        }

                        break;
                    }

                    // save the node id.
                    child.NodeId = value as NodeId;
                }
            }
        }
示例#20
0
        /// <summary>
        /// Updates the effective state for the condition.
        /// </summary>
        /// <param name="context">The context.</param>
        protected override void UpdateEffectiveState(ISystemContext context)
        {
            if (!this.EnabledState.Id.Value)
            {
                base.UpdateEffectiveState(context);
                return;
            }

            StringBuilder builder = new StringBuilder();

            string locale = null;

            if (this.ActiveState.Value != null)
            {
                locale = this.ActiveState.Value.Locale;

                if (this.ActiveState.Id.Value)
                {
                    if (this.ActiveState.EffectiveDisplayName != null && !LocalizedText.IsNullOrEmpty(this.ActiveState.EffectiveDisplayName.Value))
                    {
                        builder.Append(this.ActiveState.EffectiveDisplayName.Value);
                    }
                    else
                    {
                        builder.Append(this.ActiveState.Value);
                    }
                }
                else
                {
                    builder.Append(this.ActiveState.Value);
                }
            }

            LocalizedText suppressedState = null;

            if (this.SuppressedState != null)
            {
                if (this.SuppressedState.Id.Value)
                {
                    suppressedState = this.SuppressedState.Value;
                }
            }

            if (this.ShelvingState != null)
            {
                if (this.ShelvingState.CurrentState.Id.Value != ObjectIds.ShelvedStateMachineType_Unshelved)
                {
                    suppressedState = this.ShelvingState.CurrentState.Value;
                }
            }

            if (suppressedState != null)
            {
                builder.Append(" | ");
                builder.Append(suppressedState);
            }

            LocalizedText ackState = null;

            if (ConfirmedState != null)
            {
                if (!this.ConfirmedState.Id.Value)
                {
                    ackState = this.ConfirmedState.Value;
                }
            }

            if (AckedState != null)
            {
                if (!this.AckedState.Id.Value)
                {
                    ackState = this.AckedState.Value;
                }
            }

            if (ackState != null)
            {
                builder.Append(" | ");
                builder.Append(ackState);
            }

            LocalizedText effectiveState = new LocalizedText(locale, builder.ToString());

            SetEffectiveSubState(context, effectiveState, DateTime.MinValue);
        }
示例#21
0
        /// <summary>
        /// Creates a deep copy of the value.
        /// </summary>
        /// <remarks>
        /// Creates a deep copy of the value.
        /// </remarks>
        /// <param name="value">The text to create an instance from</param>
        /// <exception cref="ArgumentNullException">Thrown when the value is null</exception>
        public LocalizedText(LocalizedText value) {
            if (value == null) throw new ArgumentNullException("value");

            m_locale = value.m_locale;
            m_text = value.m_text;
        }
 /// <summary>
 /// Constructs a object by specifying each property.
 /// </summary>
 /// <remarks>
 /// The innerException is used to construct the innerResult.
 /// </remarks>
 public ServiceResult(
     StatusCode    code,
     LocalizedText localizedText,            
     Exception     innerException)
 :
     this(code, null, null, localizedText, null, innerException)
 {
 }
示例#23
0
        /// <summary>
        /// Reads an LocalizedText from the stream.
        /// </summary>
        public LocalizedText ReadLocalizedText(string fieldName)
        {
            if (BeginField(fieldName, true))
            {                
                PushNamespace(Namespaces.OpcUaXsd);
                
                bool isNil = false;
                string text = null;
                string locale = null;

                if (BeginField("Locale", true, out isNil))
                {
                    locale = ReadString(null);
                    EndField("Locale");
                }
                else if (!isNil)
                {
                    locale = String.Empty;
                }

                if (BeginField("Text", true, out isNil))
                {
                    text = ReadString(null);
                    EndField("Text");
                }                
                else if (!isNil)
                {
                    text = String.Empty;
                }

                LocalizedText value = new LocalizedText(locale, text);

                PopNamespace();
                
                EndField(fieldName);
                return value;
            }

            return LocalizedText.Null;
        }
 /// <summary>
 /// Constructs a object from an exception.
 /// </summary>
 /// <remarks>
 /// The defaultCode and defaultLocalizedText parameters are ignored for ServiceResultExceptions.
 /// </remarks>
 public ServiceResult(
     Exception     exception,
     uint          defaultCode,
     LocalizedText defaultLocalizedText)
 :
     this(exception, defaultCode, null, null, defaultLocalizedText)
 {
 }
 /// <summary>
 /// Initializes the instance with the default values.
 /// </summary>
 protected override void Initialize(ISystemContext context)
 {
     SuperTypeId = Opc.Ua.NodeId.Create(Opc.Ua.VariableTypes.BaseVariableType, Opc.Ua.Namespaces.OpcUa, context.NamespaceUris);
     NodeId = Opc.Ua.NodeId.Create(Opc.Ua.VariableTypes.PropertyType, Opc.Ua.Namespaces.OpcUa, context.NamespaceUris);
     BrowseName = Opc.Ua.QualifiedName.Create(Opc.Ua.BrowseNames.PropertyType, Opc.Ua.Namespaces.OpcUa, context.NamespaceUris);
     DisplayName = new LocalizedText(Opc.Ua.BrowseNames.PropertyType, String.Empty, Opc.Ua.BrowseNames.PropertyType);
     Description = null;
     WriteMask = AttributeWriteMask.None;
     UserWriteMask = AttributeWriteMask.None;
     IsAbstract = false;
     Value = null;
     DataType = Opc.Ua.NodeId.Create(Opc.Ua.DataTypes.BaseDataType, Opc.Ua.Namespaces.OpcUa, context.NamespaceUris);
     ValueRank = ValueRanks.Any;
     ArrayDimensions = null;
 }
示例#26
0
        /// <summary>
        /// Write the value for any non-value attribute.
        /// </summary>
        protected override ServiceResult WriteNonValueAttribute(
            ISystemContext context,
            uint attributeId,
            object value)
        {
            ServiceResult result = null;

            switch (attributeId)
            {
            case Attributes.InverseName:
            {
                LocalizedText inverseName = value as LocalizedText;

                if (inverseName == null && value != null)
                {
                    return(StatusCodes.BadTypeMismatch);
                }

                if ((WriteMask & AttributeWriteMask.InverseName) == 0)
                {
                    return(StatusCodes.BadNotWritable);
                }

                if (OnWriteInverseName != null)
                {
                    result = OnWriteInverseName(context, this, ref inverseName);
                }

                if (ServiceResult.IsGood(result))
                {
                    InverseName = inverseName;
                }

                return(result);
            }

            case Attributes.Symmetric:
            {
                bool?symmetricRef = value as bool?;

                if (symmetricRef == null)
                {
                    return(StatusCodes.BadTypeMismatch);
                }

                if ((WriteMask & AttributeWriteMask.Symmetric) == 0)
                {
                    return(StatusCodes.BadNotWritable);
                }

                bool symmetric = symmetricRef.Value;

                if (OnWriteSymmetric != null)
                {
                    result = OnWriteSymmetric(context, this, ref symmetric);
                }

                if (ServiceResult.IsGood(result))
                {
                    Symmetric = symmetric;
                }

                return(result);
            }
            }

            return(base.WriteNonValueAttribute(context, attributeId, value));
        }
 /// <summary>
 /// Constructs a object by specifying each property.
 /// </summary>
 public ServiceResult(
     StatusCode    code,
     LocalizedText localizedText)
 :
     this(code, (string)null, (string)null, localizedText, (string)null, (ServiceResult)null)
 {
 }
        /// <summary>
        /// Called when the Confirm method is called.
        /// </summary>
        /// <param name="context">The system context.</param>
        /// <param name="method">The method being called.</param>
        /// <param name="objectId">The id of the object.</param>
        /// <param name="eventId">The identifier for the event which is the target for the comment.</param>
        /// <param name="comment">The comment.</param>
        /// <returns>Any error.</returns>
        protected virtual ServiceResult OnConfirmCalled(
            ISystemContext context,
            MethodState method,
            NodeId objectId,
            byte[] eventId,
            LocalizedText comment)
        {
            ServiceResult error = ProcessBeforeConfirm(context, eventId, comment);

            if (ServiceResult.IsGood(error))
            {
                SetConfirmedState(context, true);
                SetComment(context, comment, GetCurrentUserId(context));
            }

            if (this.AreEventsMonitored)
            {
                // report a state change event.
                if (ServiceResult.IsGood(error))
                {
                    ReportStateChange(context, false);
                }

                // raise the audit event.
                AuditConditionConfirmEventState e = new AuditConditionConfirmEventState(null);

                TranslationInfo info = new TranslationInfo(
                    "AuditConditionConfirm",
                    "en-US",
                    "The Confirm method was called.");

                e.Initialize(
                    context,
                    this,
                    EventSeverity.Low,
                    new LocalizedText(info),
                    ServiceResult.IsGood(error),
                    DateTime.UtcNow);

                e.SourceName.Value = "Attribute/Call";

                e.MethodId = new PropertyState<NodeId>(e);
                e.MethodId.Value = method.NodeId;

                e.InputArguments = new PropertyState<object[]>(e);
                e.InputArguments.Value = new object[] { eventId, comment };

                ReportEvent(context, e);
            }

            return error;
        }
 /// <summary>
 /// Constructs a object by specifying each property.
 /// </summary>
 /// <remarks>
 /// The innerException is used to construct the innerResult.
 /// </remarks>
 public ServiceResult(
     StatusCode    code,
     string        symbolicId,
     string        namespaceUri,
     LocalizedText localizedText,            
     Exception     innerException)
 :
     this(code, symbolicId, namespaceUri, localizedText, null, innerException)
 {
 }
        /// <summary>
        /// Does any processing before adding a comment to a condition.
        /// </summary>
        /// <param name="context">The system context.</param>
        /// <param name="eventId">The identifier for the event which is the target for the comment.</param>
        /// <param name="comment">The comment.</param>
        protected virtual ServiceResult ProcessBeforeConfirm(
            ISystemContext context,
            byte[] eventId,
            LocalizedText comment)
        {
            if (eventId == null)
            {
                return StatusCodes.BadEventIdUnknown;
            }

            if (!this.EnabledState.Id.Value)
            {
                return StatusCodes.BadConditionDisabled;
            }

            if (OnConfirm != null)
            {
                try
                {
                    return OnConfirm(context, this, eventId, comment);
                }
                catch (Exception e)
                {
                    return ServiceResult.Create(e, StatusCodes.BadUnexpectedError, "Unexpected error confirming a Condition.");
                }
            }

            return ServiceResult.Good;
        }
        /// <summary>
        /// Constructs a object from an exception.
        /// </summary>
        /// <remarks>
        /// The code, symbolicId, namespaceUri and localizedText parameters are ignored for ServiceResultExceptions.
        /// </remarks>
        public ServiceResult(
            Exception     e,
            uint          defaultCode,
            string        defaultSymbolicId,
            string        defaultNamespaceUri,
            LocalizedText defaultLocalizedText)
        {
            ServiceResultException sre = e as ServiceResultException;

			if (sre != null)
			{
				m_code           = sre.StatusCode;
			    m_namespaceUri   = sre.NamespaceUri;
			    m_symbolicId     = sre.SymbolicId;
				m_localizedText  = sre.LocalizedText;
                m_innerResult    = sre.Result.InnerResult;

                if (LocalizedText.IsNullOrEmpty(m_localizedText))
                {
                    m_localizedText = defaultLocalizedText;
                }
			}
            else
            {
                m_code           = defaultCode;
                m_symbolicId     = defaultSymbolicId;
                m_namespaceUri   = defaultNamespaceUri;
                m_localizedText  = defaultLocalizedText;            
            }
                
            m_additionalInfo = BuildExceptionTrace(e);
        }
        /// <summary>
        /// Creates an object from a key and a LocalizedText.
        /// </summary>
        public TranslationInfo(string key, LocalizedText text)
        {
            m_key = key;

            if (text != null)
            {
                m_text = text.Text;
                m_locale = text.Locale;
            }
        }
		/// <summary>
		/// Initializes the object with a status code and a diagnostic info structure.
		/// </summary>
		public ServiceResult(StatusCode code, int index, DiagnosticInfoCollection diagnosticInfos, IList<string> stringTable)
		{
			m_code = (uint)code;

            if (index >= 0 && diagnosticInfos != null && index < diagnosticInfos.Count)
            {
                DiagnosticInfo diagnosticInfo = diagnosticInfos[index];
                
                if (diagnosticInfo != null)
                {
				    m_namespaceUri = LookupString(stringTable, diagnosticInfo.NamespaceUri);
				    m_symbolicId = LookupString(stringTable, diagnosticInfo.SymbolicId);
				    
                    string locale = LookupString(stringTable, diagnosticInfo.Locale);
				    string localizedText  = LookupString(stringTable, diagnosticInfo.LocalizedText);
                    m_localizedText  = new LocalizedText(locale, localizedText);

                    m_additionalInfo = diagnosticInfo.AdditionalInfo;

                    if (!StatusCode.IsGood(diagnosticInfo.InnerStatusCode))
                    {
                        m_innerResult = new ServiceResult(diagnosticInfo.InnerStatusCode, diagnosticInfo.InnerDiagnosticInfo, stringTable);
                    }
                }
            }
		}
示例#34
0
        /// <summary>
        /// Translates the discovery URLs based on the client url and returns an updated ApplicationDescription.
        /// </summary>
        /// <param name="clientUrl">The client URL.</param>
        /// <param name="description">The application description.</param>
        /// <param name="baseAddresses">The base addresses.</param>
        /// <param name="applicationName">The localized application name.</param>
        /// <returns>A copy of the application description</returns>
        protected ApplicationDescription TranslateApplicationDescription(
            Uri clientUrl,
            ApplicationDescription description,
            IList<BaseAddress> baseAddresses,
            LocalizedText applicationName)
        {
            // get the discovery urls.
            StringCollection discoveryUrls = new StringCollection();

            foreach (BaseAddress baseAddress in baseAddresses)
            {
                discoveryUrls.Add(GetBestDiscoveryUrl(clientUrl, baseAddress));
            }

            // copy the description.
            ApplicationDescription copy = new ApplicationDescription();

            copy.ApplicationName = description.ApplicationName;
            copy.ApplicationUri = description.ApplicationUri;
            copy.ApplicationType = description.ApplicationType;
            copy.ProductUri = description.ProductUri;
            copy.GatewayServerUri = description.DiscoveryProfileUri;
            copy.DiscoveryUrls = discoveryUrls;

            if (!LocalizedText.IsNullOrEmpty(applicationName))
            {
                copy.ApplicationName = applicationName;
            }

            // return the copy.
            return copy;
        }
示例#35
0
        /// <summary>
        /// Writes an LocalizedText to the stream.
        /// </summary>
        public void WriteLocalizedText(string fieldName, LocalizedText value)
        {
            if (UseReversibleEncoding)
            {
                PushStructure(fieldName);

                WriteSimpleField("Text", value.Text.ToString(), true);

                if (!String.IsNullOrEmpty(value.Locale))
                {
                    WriteSimpleField("Locale", value.Locale.ToString(), true);
                }

                PopStructure();
            }
            else
            {
                WriteSimpleField(fieldName, value.Text, true);
            }
        }
示例#36
0
        /// <summary>
        /// Updates the effective state for the condition.
        /// </summary>
        /// <param name="context">The context.</param>
        protected override void UpdateEffectiveState(ISystemContext context)
        {
            if (!this.EnabledState.Id.Value)
            {
                base.UpdateEffectiveState(context);
                return;
            }

            StringBuilder builder = new StringBuilder();

            string locale = null;

            if (this.ActiveState.Value != null)
            {
                locale = this.ActiveState.Value.Locale;

                if (this.ActiveState.Id.Value)
                {
                    if (this.ActiveState.EffectiveDisplayName != null && !LocalizedText.IsNullOrEmpty(this.ActiveState.EffectiveDisplayName.Value))
                    {
                        builder.Append(this.ActiveState.EffectiveDisplayName.Value);
                    }
                    else
                    {
                        builder.Append(this.ActiveState.Value);
                    }
                }
                else
                {
                    builder.Append(this.ActiveState.Value);
                }
            }

            LocalizedText suppressedState = null;

            if (this.SuppressedState != null)
            {
                if (this.SuppressedState.Id.Value)
                {
                    suppressedState = this.SuppressedState.Value;
                }
            }

            if (this.ShelvingState != null)
            {
                if (this.ShelvingState.CurrentState.Id.Value != ObjectIds.ShelvedStateMachineType_Unshelved)
                {
                    suppressedState = this.ShelvingState.CurrentState.Value;
                }
            }

            if (suppressedState != null)
            {
                builder.Append(" | ");
                builder.Append(suppressedState);
            }

            LocalizedText ackState = null;

            if (!this.ConfirmedState.Id.Value)
            {
                if (!this.ConfirmedState.Id.Value)
                {
                    ackState = this.ConfirmedState.Value;
                }
            }

            if (!this.AckedState.Id.Value)
            {
                if (!this.AckedState.Id.Value)
                {
                    ackState = this.AckedState.Value;
                }
            }

            if (ackState != null)
            {
                builder.Append(" | ");
                builder.Append(ackState);
            }

            LocalizedText effectiveState = new LocalizedText(locale, builder.ToString());

            SetEffectiveSubState(context, effectiveState, DateTime.MinValue);
        }
        /// <summary>
        /// Converts a value to a LocalizedText
        /// </summary>
        private static object ToLocalizedText(object value, BuiltInType sourceType)
        {            
            // check for array conversions.
            Array array = value as Array;

            if (array != null)
            {
                LocalizedText[] output = new LocalizedText[array.Length];

                for (int ii = 0; ii < array.Length; ii++)
                {
                    output[ii] = (LocalizedText)Cast(array.GetValue(ii), BuiltInType.LocalizedText);
                }

                return output;
            }

            // handle for supported conversions.
            switch (sourceType)
            {
                case BuiltInType.LocalizedText:
                {
                    return (LocalizedText)value; 
                }

                case BuiltInType.String:
                {
                    return new LocalizedText((string)value);
                }
            }

            // conversion not supported.
            return null;
        }
        /// <summary>
        /// Called when the Acknowledge method is called.
        /// </summary>
        /// <param name="context">The system context.</param>
        /// <param name="method">The method being called.</param>
        /// <param name="objectId">The id of the object.</param>
        /// <param name="eventId">The identifier for the event which is the target for the comment.</param>
        /// <param name="comment">The comment.</param>
        /// <returns>Any error.</returns>
        protected virtual ServiceResult OnAcknowledgeCalled(
            ISystemContext context,
            MethodState method,
            NodeId objectId,
            byte[] eventId,
            LocalizedText comment)
        {
            ServiceResult error = ProcessBeforeAcknowledge(context, eventId, comment);

            if (ServiceResult.IsGood(error))
            {
                AcknowledgeableConditionState branch = GetAcknowledgeableBranch(eventId);

                if (branch != null)
                {
                    branch.OnAcknowledgeCalled(context, method, objectId, eventId, comment);

                    if (SupportsConfirm())
                    {
                        ReplaceBranchEvent(eventId, branch);
                    }
                    else
                    {
                        RemoveBranchEvent(eventId);
                    }
                }
                else
                {
                    SetAcknowledgedState(context, true);

                    if (SupportsConfirm())
                    {
                        SetConfirmedState(context, false);
                    }
                }

                // If this is a branch, the comment goes to both the branch and the original event
                if (CanSetComment(comment))
                {
                    SetComment(context, comment, GetCurrentUserId(context));
                }

                UpdateRetainState();
            }

            if (EventsMonitored())
            {
                // report a state change event.
                if (ServiceResult.IsGood(error))
                {
                    ReportStateChange(context, false);
                }

                // raise the audit event.
                AuditConditionAcknowledgeEventState e = new AuditConditionAcknowledgeEventState(null);

                TranslationInfo info = new TranslationInfo(
                    "AuditConditionAcknowledge",
                    "en-US",
                    "The Acknowledge method was called.");

                e.Initialize(
                    context,
                    this,
                    EventSeverity.Low,
                    new LocalizedText(info),
                    ServiceResult.IsGood(error),
                    DateTime.UtcNow);

                e.SourceName.Value = "Attribute/Call";

                e.MethodId       = new PropertyState <NodeId>(e);
                e.MethodId.Value = method.NodeId;

                e.InputArguments       = new PropertyState <object[]>(e);
                e.InputArguments.Value = new object[] { eventId, comment };

                ReportEvent(context, e);
            }

            return(error);
        }