Exemple #1
0
        /// <summary>
        /// Constructs a OpcResult object.
        /// </summary>
        /// <param name="resultID">The code returned by a   system function or OPC function. The code can be retrieved with the member function Code() and a description text can be retrieved with the member function <see cref="Description" />. </param>
        /// <param name="eFuncType">Specifies   the type of function which has returned the code. This parameter is used to create the code type which can be retrieved with the member function <see cref="Type" />. </param>
        /// <param name="caller">Object which   caused the error. Can be null</param>
        /// <returns></returns>
        internal OpcResult(OpcResult resultID, FuncCallType eFuncType, object caller)
        {
            _name    = null;
            _message = null;
            _code    = resultID.Code;
            _caller  = caller;
            _type    = CodeType.OpcSysCode;

            if (eFuncType == FuncCallType.SysFuncCall)
            {
                _type = CodeType.SysCode;                                              // System specific errror returned by a system function
            }
            else if ((((resultID.Code) >> 16) & 0x1fff) == 0x4)
            {                 // FACILITY_ITF                    0x4
                if (eFuncType == FuncCallType.DaFuncCall)
                {
                    _type = CodeType.DaCode;
                }
                else
                {
                    _type = CodeType.AeCode;
                }
            }
            else
            {
                _type = CodeType.OpcSysCode;                                           // System specific error returned by an OPC function
            }
        }
        /// <summary>
        /// Constructs a OpcResult object.
        /// </summary>
        /// <param name="resultId">The code returned by a   system function or OPC function. The code can be retrieved with the member function Code() and a description text can be retrieved with the member function <see cref="Description" />. </param>
        /// <param name="eFuncType">Specifies   the type of function which has returned the code. This parameter is used to create the code type which can be retrieved with the member function <see cref="Type" />. </param>
        /// <param name="caller">Object which   caused the error. Can be null</param>
        /// <returns></returns>
        internal OpcResult(OpcResult resultId, FuncCallType eFuncType, object caller)
        {
            name_    = null;
            message_ = null;
            code_    = resultId.Code;
            caller_  = caller;
            type_    = CodeType.OpcSysCode;

            if (eFuncType == FuncCallType.SysFuncCall)
            {
                type_ = CodeType.SysCode;                              // System specific error returned by a system function
            }
            else if ((((resultId.Code) >> 16) & 0x1fff) == 0x4)
            {     // FACILITY_ITF                    0x4
                if (eFuncType == FuncCallType.DaFuncCall)
                {
                    type_ = CodeType.DaCode;
                }
                else
                {
                    type_ = CodeType.AeCode;
                }
            }
            else
            {
                type_ = CodeType.OpcSysCode;                           // System specific error returned by an OPC function
            }
        }
Exemple #3
0
        /// <summary>
        /// Returns the localized text for the specified result code.
        /// </summary>
        /// <param name="locale">The locale name in the format "[languagecode]-[country/regioncode]".</param>
        /// <param name="resultId">The result code identifier.</param>
        /// <returns>A message localized for the best match for the requested locale.</returns>
        public virtual string GetErrorText(string locale, OpcResult resultId)
        {
            if (_server == null)
            {
                throw new OpcResultException(OpcResult.E_FAIL, "The server is not currently connected.");
            }

            return(_server.GetErrorText(locale ?? _locale, resultId));
        }
Exemple #4
0
        /// <summary>
        /// Initializes a result code with a general result code and a specific result code.
        /// </summary>
        internal OpcResult(OpcResult resultID, long code)
        {
            _name = resultID.Name;

            if (code > Int32.MaxValue)
            {
                code = -(((long)UInt32.MaxValue) + 1 - code);
            }

            _code    = (int)code;
            _type    = CodeType.OpcSysCode;
            _caller  = null;
            _message = null;
        }
        /// <summary>
        /// Initializes a result code with a general result code and a specific result code.
        /// </summary>
        internal OpcResult(OpcResult resultId, long code)
        {
            name_ = resultId.Name;

            if (code > Int32.MaxValue)
            {
                code = -(((long)UInt32.MaxValue) + 1 - code);
            }

            code_    = (int)code;
            type_    = CodeType.OpcSysCode;
            caller_  = null;
            message_ = null;
        }
Exemple #6
0
        /// <summary>
        /// Returns true if the target object is equal to the object.
        /// </summary>
        public override bool Equals(object target)
        {
            if (target != null && target.GetType() == typeof(OpcResult))
            {
                OpcResult resultID = (OpcResult)target;

                // compare by integer if both specify valid integers.
                if (resultID.Code != -1 && Code != -1)
                {
                    return((resultID.Code == Code) && (resultID.Name == Name));
                }

                // compare by name if both specify valid names.
                if (resultID.Name != null && Name != null)
                {
                    return(resultID.Name == Name);
                }
            }

            return(false);
        }
 /// <summary>
 /// Initialize object with the specified OpcItem, result code and diagnostic info.
 /// </summary>
 public OpcItemResult(OpcItem item, OpcResult resultId, string diagnosticInfo)
     : base(item)
 {
     Result         = resultId;
     DiagnosticInfo = diagnosticInfo;
 }
 /// <summary>
 /// Initialize object with the specified OpcItem and result code.
 /// </summary>
 public OpcItemResult(OpcItem item, OpcResult resultId)
     : base(item)
 {
     Result = resultId;
 }
 /// <summary>
 /// Initialize object with the specified item name, result code and diagnostic info.
 /// </summary>
 public OpcItemResult(string itemName, OpcResult resultId, string diagnosticInfo)
     : base(itemName)
 {
     Result         = resultId;
     DiagnosticInfo = diagnosticInfo;
 }
 /// <summary>
 /// Initializes the object with the specified item name and result code.
 /// </summary>
 public OpcItemResult(string itemName, OpcResult resultId)
     : base(itemName)
 {
     Result = resultId;
 }
 /// <remarks/>
 public OpcResultException(OpcResult result, string message, Exception e) : base(message + ": " + result.ToString() + Environment.NewLine, e)
 {
     result_ = result;
 }
 /// <remarks/>
 public OpcResultException(OpcResult result) : base(result.Description())
 {
     result_ = result;
 }