Opc.Ua.ServiceResult.Create C# (CSharp) Method

Create() public static method

Creates a new instance of a ServiceResult
public static Create ( uint code, string format ) : ServiceResult
code uint
format string
return ServiceResult
        public static ServiceResult Create(uint code, string format, params object[] args)
        {
            if (format == null)
            {
                return new ServiceResult(code);
            }

            if (args == null || args.Length == 0)
            {
                return new ServiceResult(code, format);
            }

            return new ServiceResult(code, Utils.Format(format, args));
        }

Same methods

ServiceResult::Create ( Exception e, TranslationInfo translation, uint defaultCode ) : ServiceResult
ServiceResult::Create ( Exception e, uint defaultCode, string format ) : ServiceResult
ServiceResult::Create ( uint code, TranslationInfo translation ) : ServiceResult

Usage Example

コード例 #1
0
        /// <summary>
        /// Checks that the filter is valid.
        /// </summary>
        public ServiceResult Validate()
        {
            // check deadband type enumeration.
            if ((int)DeadbandType < (int)Opc.Ua.DeadbandType.None ||
                (int)DeadbandType > (int)Opc.Ua.DeadbandType.Percent)
            {
                return(ServiceResult.Create(
                           StatusCodes.BadDeadbandFilterInvalid,
                           "Deadband type '{0}' is not recognized.",
                           DeadbandType));
            }

            // check data change trigger enumeration.
            if ((int)Trigger < (int)DataChangeTrigger.Status ||
                (int)Trigger > (int)DataChangeTrigger.StatusValueTimestamp)
            {
                return(ServiceResult.Create(
                           StatusCodes.BadDeadbandFilterInvalid,
                           "Deadband trigger '{0}' is not recognized.",
                           Trigger));
            }

            // deadband value must always be greater than 0.
            if (DeadbandValue < 0)
            {
                return(ServiceResult.Create(
                           StatusCodes.BadDeadbandFilterInvalid,
                           "Deadband value '{0}' cannot be less than zero.",
                           DeadbandValue));
            }

            // deadband percentage must be less than 100.
            if ((int)DeadbandType == (int)Opc.Ua.DeadbandType.Percent)
            {
                if (DeadbandValue > 100)
                {
                    return(ServiceResult.Create(
                               StatusCodes.BadDeadbandFilterInvalid,
                               "Percentage deadband value '{0}' cannot be greater than 100.",
                               DeadbandValue));
                }
            }

            // passed initial validation.
            return(ServiceResult.Good);
        }
All Usage Examples Of Opc.Ua.ServiceResult::Create