Beispiel #1
0
        /// <summary>
        /// Reads a lock object.
        /// </summary>
        public LockConditionState ReadLock(ISystemContext context, BaseObject source)
        {
            ushort namespaceIndex = (ushort)context.NamespaceUris.GetIndex(DsatsDemo.Namespaces.DsatsDemo);

            LockConditionState node = new LockConditionState(null);

            node.Create(
                context,
                new NodeId("Locks/" + source.BrowseName, namespaceIndex),
                new QualifiedName(source.BrowseName, namespaceIndex),
                null,
                true);

            if (source.DisplayName != null && source.DisplayName.Length > 0)
            {
                node.DisplayName = Import(source.DisplayName);
            }

            if (source.Description != null && source.Description.Length > 0)
            {
                node.Description = Import(source.Description);
            }

            node.SetEnableState(context, true);
            node.Unlock(context);

            node.ConditionName.Value = source.BrowseName;
            node.EventId.Value = Guid.NewGuid().ToByteArray();
            node.EventType.Value = node.TypeDefinitionId;
            node.SourceName.Value = BrowseNames.Rig;
            node.SourceNode.Value = new NodeId(Objects.Rig, namespaceIndex);
            node.Severity.Value = 100;
            node.Time.Value = DateTime.UtcNow;
            node.ReceiveTime.Value = DateTime.UtcNow;
            node.ConditionClassId.Value = Opc.Ua.ObjectTypeIds.BaseConditionClassType;
            node.ConditionClassName.Value = Opc.Ua.BrowseNames.BaseConditionClassType;
            node.Retain.Value = true;
            
            TranslationInfo state = new TranslationInfo(
                "LockConditionStateMessage",
                "en-US",
                "Lock object is now in the '{0}' state.",
                node.LockState.CurrentState);

            node.Message.Value = new Opc.Ua.LocalizedText(state);

            return node;
        }
Beispiel #2
0
        /// <summary>
        /// Reads a phase object.
        /// </summary>
        public PhaseState ReadPhase(ISystemContext context, BaseObject source)
        {
            ushort namespaceIndex = (ushort)context.NamespaceUris.GetIndex(DsatsDemo.Namespaces.DsatsDemo);

            PhaseState node = new PhaseState(null);

            node.Create(
                context,
                new NodeId("Phases/" + source.BrowseName, namespaceIndex), 
                new QualifiedName(source.BrowseName, namespaceIndex),
                null,
                true);

            if (source.DisplayName != null && source.DisplayName.Length > 0)
            {
                node.DisplayName = Import(source.DisplayName);
            }

            if (source.Description != null && source.Description.Length > 0)
            {
                node.Description = Import(source.Description);
            }

            return node;
        }