當前位置: 首頁>>代碼示例>>C#>>正文


C# Ua.StatusCode類代碼示例

本文整理匯總了C#中Opc.Ua.StatusCode的典型用法代碼示例。如果您正苦於以下問題:C# StatusCode類的具體用法?C# StatusCode怎麽用?C# StatusCode使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


StatusCode類屬於Opc.Ua命名空間,在下文中一共展示了StatusCode類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: ServiceResult

 /// <summary>
 /// Constructs a object by specifying each property.
 /// </summary>
 public ServiceResult(
     StatusCode    code,
     ServiceResult innerResult)
 :
     this(code, null, null, null, null, innerResult)
 {
 }        
開發者ID:OPCFoundation,項目名稱:UA-.NETStandardLibrary,代碼行數:10,代碼來源:ServiceResult.cs

示例2: ToCode

        /// <summary>
        /// Converts a code to a numeric value.
        /// </summary>
        public static uint ToCode(StatusCode statusCode)
        {
            if (statusCode == null)
            {
                return StatusCodes.Good;
            }

            return statusCode.Code;
        }
開發者ID:yuriik83,項目名稱:UA-.NET,代碼行數:12,代碼來源:StatusCode.cs

示例3: IsBad

        /// <summary>
        /// Checks if the status code is bad.
        /// </summary>
        public static bool IsBad(StatusCode statusCode)
        {
            if ((ToCode(statusCode) & 0x80000000) != 0)
            {
                return true;
            }

            return false;
        }
開發者ID:yuriik83,項目名稱:UA-.NET,代碼行數:12,代碼來源:StatusCode.cs

示例4: OnDataChange

        /// <summary>
        /// Updates the variable after receiving a notification that it has changed in the underlying system.
        /// </summary>
        public void OnDataChange(BaseVariableState variable, object value, StatusCode statusCode, DateTime timestamp)
        {
            lock (Lock)
            {
                variable.Value = value;
                variable.StatusCode = statusCode;
                variable.Timestamp = timestamp;

                // notifies any monitored items that the value has changed.
                variable.ClearChangeMasks(SystemContext, false);
            }
        }
開發者ID:yuriik83,項目名稱:UA-.NET,代碼行數:15,代碼來源:TestDataNodeManager.cs

示例5: OnChangeLockByWrite

        public ServiceResult OnChangeLockByWrite(
            ISystemContext context,
            NodeState node,
            NumericRange indexRange,
            QualifiedName dataEncoding,
            ref object value,
            ref StatusCode statusCode,
            ref DateTime timestamp)
        {
            DsatsDemo.LockConditionState condition = null;

            BaseInstanceState instance = node as BaseInstanceState;

            if (instance.Parent != null)
            {
                condition = instance.Parent as DsatsDemo.LockConditionState;
            }

            if (condition == null)
            {
                return StatusCodes.BadNotWritable;
            }

            string lockState = value as string;

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

            if (lockState == "Locked")
            {
                ServiceResult result = OnRequestLock(context, condition.Request, condition.NodeId, new object[0], new object[0]);
                value = condition.LockStateAsString.Value;
                return result;
            }

            else if (lockState == "Unlocked")
            {
                ServiceResult result = OnReleaseLock(context, condition.Request, condition.NodeId, new object[0], new object[0]);
                value = condition.LockStateAsString.Value;
                return result;
            }

            return StatusCodes.BadTypeMismatch;
        }
開發者ID:yuriik83,項目名稱:UA-.NET,代碼行數:46,代碼來源:DsatsDemoNodeManager.cs

示例6: AddValue

        /// <summary>
        /// Adds a value to the grid.
        /// </summary>
        private void AddValue(DataValue value, ModificationInfo modificationInfo)
        {
            DataRow row = m_dataset.Tables[0].NewRow();

            row[0] = m_nextId++;
            row[1] = value.SourceTimestamp.ToLocalTime().ToString("HH:mm:ss.fff");
            row[2] = value.WrappedValue;
            row[3] = new StatusCode(value.StatusCode.Code);

            if (value.WrappedValue.TypeInfo != null)
            {
                row[4] = value.WrappedValue.TypeInfo.BuiltInType.ToString();
            }
            else
            {
                row[4] = String.Empty;
            }

            m_dataset.Tables[0].Rows.Add(row);
        }
開發者ID:yuriik83,項目名稱:UA-.NET,代碼行數:23,代碼來源:SubscribeDlg.cs

示例7: OnUserScalarValue2

        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;
        }
開發者ID:OPCFoundation,項目名稱:UA-.NET,代碼行數:38,代碼來源:MethodTestState.cs

示例8: OnUserArrayValue2

        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;
        }
開發者ID:OPCFoundation,項目名稱:UA-.NET,代碼行數:38,代碼來源:MethodTestState.cs

示例9: WriteTagValue

        /// <summary>
        /// Handles a write operation for an individual tag.
        /// </summary>
        public ServiceResult WriteTagValue(
            ISystemContext context,
            NodeState node,
            NumericRange indexRange,
            QualifiedName dataEncoding,
            ref object value,
            ref StatusCode statusCode,
            ref DateTime timestamp)
        {
            MemoryTagState tag = node as MemoryTagState;

            if (tag == null)
            {
                return StatusCodes.BadNodeIdUnknown;
            }

            if (NumericRange.Empty != indexRange)
            {
                return StatusCodes.BadIndexRangeInvalid;
            }

            if (!QualifiedName.IsNull(dataEncoding))
            {
                return StatusCodes.BadDataEncodingInvalid;
            }

            if (statusCode != StatusCodes.Good)
            {
                return StatusCodes.BadWriteNotSupported;
            }

            if (timestamp != DateTime.MinValue)
            {
                return StatusCodes.BadWriteNotSupported;
            }

            bool changed = false;
            int offset = (int)tag.Offset;

            lock (m_dataLock)
            {
                if (offset < 0 || offset >= m_buffer.Length)
                {
                    return StatusCodes.BadNodeIdUnknown;
                }

                if (m_buffer == null)
                {
                    return StatusCodes.BadOutOfService;
                }

                byte[] bytes = null;

                switch (m_elementType)
                {
                    case BuiltInType.UInt32:
                    {
                        uint? valueToWrite = value as uint?;

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

                        bytes = BitConverter.GetBytes(valueToWrite.Value);
                        break;
                    }

                    case BuiltInType.Double:
                    {
                        double? valueToWrite = value as double?;

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

                        bytes = BitConverter.GetBytes(valueToWrite.Value);
                        break;
                    }

                    default:
                    {
                        return StatusCodes.BadNodeIdUnknown;
                    }
                }

                for (int ii = 0; ii < bytes.Length; ii++)
                {
                    if (!changed)
                    {
                        if (m_buffer[offset + ii] != bytes[ii])
                        {
                            changed = true;
                        }
                    }

//.........這裏部分代碼省略.........
開發者ID:yuriik83,項目名稱:UA-.NET,代碼行數:101,代碼來源:MemoryBufferState.cs

示例10: ReadTagValue

        /// <summary>
        /// Handles the read operation for an invidual tag.
        /// </summary>
        public ServiceResult ReadTagValue(
            ISystemContext context,
            NodeState node,
            NumericRange indexRange,
            QualifiedName dataEncoding,
            ref object value,
            ref StatusCode statusCode,
            ref DateTime timestamp)
        {
            MemoryTagState tag = node as MemoryTagState;

            if (tag == null)
            {
                return StatusCodes.BadNodeIdUnknown;
            }

            if (NumericRange.Empty != indexRange)
            {
                return StatusCodes.BadIndexRangeInvalid;
            }

            if (!QualifiedName.IsNull(dataEncoding))
            {
                return StatusCodes.BadDataEncodingInvalid;
            }

            int offset = (int)tag.Offset;

            lock (m_dataLock)
            {
                if (offset < 0 || offset >= m_buffer.Length)
                {
                    return StatusCodes.BadNodeIdUnknown;
                }

                if (m_buffer == null)
                {
                    return StatusCodes.BadOutOfService;
                }

                value = GetValueAtOffset(offset).Value;
            }

            statusCode = StatusCodes.Good;
            timestamp = m_lastScanTime;

            return ServiceResult.Good;
        }
開發者ID:yuriik83,項目名稱:UA-.NET,代碼行數:51,代碼來源:MemoryBufferState.cs

示例11: WriteStatusCode

        /// <summary>
        /// Writes an StatusCode to the stream.
        /// </summary>
        public void WriteStatusCode(string fieldName, StatusCode value)
        {
            if (value == StatusCodes.Good)
            {
                WriteSimpleField(fieldName, null, false);
                return;
            }

            var text = StatusCode.LookupSymbolicId(value.CodeBits);
            text += ":0x";
            text += value.Code.ToString("X8", CultureInfo.InvariantCulture);

            WriteSimpleField(fieldName, text, true);
        }
開發者ID:OPCFoundation,項目名稱:UA-.NET,代碼行數:17,代碼來源:JsonEncoder.cs

示例12: DoDeviceRead

        /// <summary>
        /// Generates a new value each time the value is read.
        /// </summary>
        private ServiceResult DoDeviceRead(
            ISystemContext context,
            NodeState node,
            NumericRange indexRange,
            QualifiedName dataEncoding,
            ref object value,
            ref StatusCode statusCode,
            ref DateTime timestamp)
        {
            BaseVariableState variable = node as BaseVariableState;

            if (variable == null)
            {
                return ServiceResult.Good;
            }

            if (!SimulationActive.Value)
            {
                return ServiceResult.Good;
            }

            TestDataSystem system = context.SystemHandle as TestDataSystem;

            if (system == null)
            {
                return StatusCodes.BadOutOfService;
            }

            try
            {
                value = system.ReadValue(variable);

                statusCode = StatusCodes.Good;
                timestamp = DateTime.UtcNow;

                ServiceResult error = BaseVariableState.ApplyIndexRangeAndDataEncoding(
                    context,
                    indexRange,
                    dataEncoding,
                    ref value);

                if (ServiceResult.IsBad(error))
                {
                    statusCode = error.StatusCode;
                }
                
                return ServiceResult.Good;
            }
            catch (Exception e)
            {
                return new ServiceResult(e);
            }
        }       
開發者ID:OPCFoundation,項目名稱:UA-.NET,代碼行數:56,代碼來源:TestDataObjectState.cs

示例13: WriteValueAttribute

        /// <summary>
        /// Write the value for the value attribute.
        /// </summary>
        protected override ServiceResult WriteValueAttribute(
            ISystemContext context,
            NumericRange indexRange,
            object value,
            StatusCode statusCode,
            DateTime sourceTimestamp)
        {
            ServiceResult result = null;

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

            // ensure the source timestamp has a valid value.
            if (sourceTimestamp == DateTime.MinValue)
            {
                sourceTimestamp = DateTime.UtcNow;
            }

            // index range writes not supported.
            if (indexRange != NumericRange.Empty)
            {
                return StatusCodes.BadIndexRangeInvalid;
            }

            // verify data type.
            TypeInfo typeInfo = TypeInfo.IsInstanceOfDataType(
                value,
                m_dataType,
                m_valueRank,
                context.NamespaceUris,
                context.TypeTable);

            if (typeInfo == null || typeInfo == TypeInfo.Unknown)
            {
                return StatusCodes.BadTypeMismatch;
            }

            // check for simple write value handler.
            if (OnSimpleWriteValue != null)
            {
                result = OnSimpleWriteValue(
                    context,
                    this,
                    ref value);

                if (ServiceResult.IsBad(result))
                {
                    return result;
                }
            }

            // update cached values.
            Value = value;

            return ServiceResult.Good;
        }
開發者ID:yuriik83,項目名稱:UA-.UWP-Universal-Windows-Platform,代碼行數:61,代碼來源:BaseVariableTypeState.cs

示例14: FormatQuality

        /// <summary>
        /// Formats a StatusCide as string for serilization or display.
        /// </summary>
        public static string FormatQuality(StatusCode statusCode)
        {
            StringBuilder buffer = new StringBuilder();
            buffer.AppendFormat(System.Globalization.CultureInfo.InvariantCulture, "{0}", new StatusCode(statusCode.CodeBits));

            if ((statusCode.AggregateBits & AggregateBits.Interpolated) != 0)
            {
                buffer.Append(", Interpolated");
            }

            if ((statusCode.AggregateBits & AggregateBits.Calculated) != 0)
            {
                buffer.Append(", Calculated");
            }

            if ((statusCode.AggregateBits & AggregateBits.Partial) != 0)
            {
                buffer.Append(", Partial");
            }

            if ((statusCode.AggregateBits & AggregateBits.MultipleValues) != 0)
            {
                buffer.Append(", MultipleValues");
            }

            return buffer.ToString();
        }
開發者ID:yuriik83,項目名稱:UA-.NET,代碼行數:30,代碼來源:TestDataHelpers.cs

示例15: OnChangePhaseByWrite

        private ServiceResult OnChangePhaseByWrite(
            ISystemContext context,
            NodeState node,
            NumericRange indexRange,
            QualifiedName dataEncoding,
            ref object value,
            ref StatusCode statusCode,
            ref DateTime timestamp)
        {
            string phase = value as string;

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

            List<IReference> references = new List<IReference>();
            m_rig.Phases.GetReferences(context, references, Opc.Ua.ReferenceTypeIds.Organizes, false);

            foreach (IReference reference in references)
            {
                if (reference.TargetId.ToString().Contains(phase))
                {
                    return OnChangePhase(context, m_rig.ChangePhase, m_rig.NodeId, (NodeId)reference.TargetId);
                }
            }

            return StatusCodes.BadTypeMismatch;
        }
開發者ID:yuriik83,項目名稱:UA-.NET,代碼行數:29,代碼來源:DsatsDemoNodeManager.cs


注:本文中的Opc.Ua.StatusCode類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。