#region Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
//-----------------------------------------------------------------------------
// Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
// Web: https://www.technosoftware.com
//
// The source code in this file is covered under a dual-license scenario:
// - Owner of a purchased license: SCLA 1.0
// - GPL V3: everybody else
//
// SCLA license terms accompanied with this source code.
// See SCLA 1.0: https://technosoftware.com/license/Source_Code_License_Agreement.pdf
//
// GNU General Public License as published by the Free Software Foundation;
// version 3 of the License are accompanied with this source code.
// See https://technosoftware.com/license/GPLv3License.txt
//
// This source code is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
// or FITNESS FOR A PARTICULAR PURPOSE.
//-----------------------------------------------------------------------------
#endregion Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved
#region Using Directives
using System;
using System.Xml;
using System.Runtime.Serialization;
using System.Runtime.InteropServices;
#endregion
namespace Technosoftware.DaAeHdaClient
{
/// Contains an unique identifier for an OPC specific result code.
/// Most functions raises a OpcResultException if an error occur.
/// OpcResultException Class
[Serializable]
public struct OpcResult : ISerializable
{
#region Serialization Functions
///
/// A set of names for fields used in serialization.
///
private class Names
{
internal const string Name = "NA";
internal const string Namespace = "NS";
internal const string Code = "CO";
}
// During deserialization, SerializationInfo is passed to the class using the constructor provided for this purpose. Any visibility
// constraints placed on the constructor are ignored when the object is deserialized; so you can mark the class as public,
// protected, internal, or private. However, it is best practice to make the constructor protected unless the class is sealed, in which case
// the constructor should be marked private. The constructor should also perform thorough input validation. To avoid misuse by malicious code,
// the constructor should enforce the same security checks and permissions required to obtain an instance of the class using any other
// constructor.
///
/// Construct a server by de-serializing its URL from the stream.
///
public OpcResult(SerializationInfo info, StreamingContext context)
{
var name = (string)info.GetValue(Names.Name, typeof(string));
var ns = (string)info.GetValue(Names.Namespace, typeof(string));
name_ = new XmlQualifiedName(name, ns);
code_ = (int)info.GetValue(Names.Code, typeof(int));
type_ = CodeType.OpcSysCode;
caller_ = null;
message_ = null;
}
///
/// Serializes a server into a stream.
///
public void GetObjectData(SerializationInfo info, StreamingContext context)
{
if (name_ != null)
{
info.AddValue(Names.Name, name_.Name);
info.AddValue(Names.Namespace, name_.Namespace);
}
info.AddValue(Names.Code, code_);
}
#endregion
///
/// Specifies the type identifier of the result or error code.
///
public enum CodeType
{
///
/// System specific code (result/error) returned by a system function.
///
SysCode,
///
/// System specific code (result/error) returned by an OPC function.
///
OpcSysCode,
///
/// Data Access specific code (result/error) returned by an OPC function.
///
DaCode,
///
/// Alarms & Events specific code (result/error) returned by an OPC function.
///
AeCode,
///
/// XML-DA specific code (result/error) returned by an OPC function.
///
XdaCode
};
///
/// Specifies the type of function call which returned the result or error code. This enumeration values are used only by the constructor of the OpcResult object.
///
public enum FuncCallType
{
///
/// Identifies the code (result/error) passed to the constructor as a result of a system function.
///
SysFuncCall,
///
/// Identifies the code (result/error) passed to the constructor as a result of an OPC Data Access function.
///
DaFuncCall,
///
/// Identifies the code (result/error) passed to the constructor as a result of an OPC Alarms & Events function.
///
AeFuncCall,
};
///
/// Used for result codes identified by a qualified name.
///
public XmlQualifiedName Name => name_;
///
/// Used for result codes identified by a integer.
///
public int Code => code_;
///
/// Returns true if the objects are equal.
///
public static bool operator ==(OpcResult a, OpcResult b)
{
return a.Equals(b);
}
///
/// Returns true if the objects are not equal.
///
public static bool operator !=(OpcResult a, OpcResult b)
{
return !a.Equals(b);
}
///
/// Checks for the 'S_' prefix that indicates a success condition.
///
public bool Succeeded()
{
if (Code != -1) return (Code >= 0);
if (Name != null) return Name.Name.StartsWith("S_");
return false;
}
///
/// Checks for the 'E_' prefix that indicates an error condition.
///
public bool Failed()
{
if (Code != -1) return (Code < 0);
if (Name != null) return Name.Name.StartsWith("E_");
return false;
}
///
/// Retrieves the type identifier of the code passed to the constructor.
///
/// CodeType of the HRESULT code
internal CodeType Type()
{
return (type_);
}
///
/// Indicates whether the result code represents an error value.
///
/// This function returns true if the associated result code is an error code.
public bool IsError()
{
return (code_ < 0);
}
///
/// Indicates whether the result code represents an error value.
///
internal static bool IsError(int hResult)
{
return (hResult < 0);
}
///
/// Indicates whether the result code represents an error free value.
///
/// This function returns true if the associated result code is an error free value.
public bool IsSuccess()
{
return (code_ >= 0);
}
///
/// Indicates whether the result code represents an error free value.
///
internal static bool IsSuccess(int hResult)
{
return (hResult >= 0);
}
///
/// Indicates whether the result code represents an error value.
///
/// This function returns true if the associated result code is 0.
public bool IsOk()
{
return (code_ == 0);
}
///
/// Retrieves a text string with a description for the code stored in the OpcResult object.
///
/// This method returns the description for the code recorded within the OpcResult object. If no description text is
/// found, then a generic message "Server error 0x#dwErrorCode" is returned.
public string Description()
{
switch (type_)
{
case CodeType.DaCode:
if (caller_ != null)
{
message_ = ((Technosoftware.DaAeHdaClient.Da.TsCDaServer)caller_).GetErrorText(((Technosoftware.DaAeHdaClient.Da.TsCDaServer)caller_).GetLocale(), this);
}
else
{
message_ = $"Server error 0x{code_,0:X}";
}
break;
default:
message_ = GetSystemMessage(code_, LOCALE_SYSTEM_DEFAULT) ??
$"Server error 0x{code_,0:X}";
break;
}
return message_;
}
#region Constructors
///
/// Constructs a OpcResult object.
///
/// 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 .
/// 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 .
/// Object which caused the error. Can be null
///
public OpcResult(int hResult, FuncCallType eFuncType, object caller)
{
name_ = null;
message_ = null;
code_ = hResult;
caller_ = caller;
type_ = CodeType.OpcSysCode;
if (eFuncType == FuncCallType.SysFuncCall)
{
type_ = CodeType.SysCode; // System specific errror returned by a system function
}
else if ((((hResult) >> 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
}
}
///
/// Constructs a OpcResult object.
///
/// 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 .
/// 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 .
/// Object which caused the error. Can be null
///
public 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
}
}
///
/// Initializes a result code identified by a qualified name.
///
internal OpcResult(XmlQualifiedName name)
{
name_ = name;
message_ = null;
code_ = -1;
type_ = CodeType.XdaCode;
caller_ = null;
}
///
/// Initializes a result code identified by an integer.
///
public OpcResult(long code)
{
name_ = null;
message_ = null;
if (code > int.MaxValue)
{
code = -(((long)uint.MaxValue) + 1 - code);
}
code_ = (int)code;
type_ = CodeType.OpcSysCode;
caller_ = null;
}
///
/// Initializes a result code identified by a qualified name.
///
public OpcResult(string name, string ns)
{
name_ = new XmlQualifiedName(name, ns);
message_ = null;
code_ = -1;
type_ = CodeType.OpcSysCode;
caller_ = null;
}
///
/// Initializes a result code identified by a qualified name and a specific result code.
///
public OpcResult(string name, string ns, long code)
{
name_ = new XmlQualifiedName(name, ns);
if (code > int.MaxValue)
{
code = -(((long)uint.MaxValue) + 1 - code);
}
code_ = (int)code;
type_ = CodeType.OpcSysCode;
caller_ = null;
message_ = null;
}
///
/// Initializes a result code with a general result code and a specific result code.
///
public OpcResult(OpcResult resultId, long code)
{
name_ = resultId.Name;
if (code > int.MaxValue)
{
code = -(((long)uint.MaxValue) + 1 - code);
}
code_ = (int)code;
type_ = CodeType.OpcSysCode;
caller_ = null;
message_ = null;
}
#endregion
#region Private Methods
///
/// The constant used to selected the default locale.
///
internal const int LOCALE_SYSTEM_DEFAULT = 0x800;
///
/// The WIN32 user default locale.
///
public const int LOCALE_USER_DEFAULT = 0x400;
private const int MAX_MESSAGE_LENGTH = 1024;
private const uint FORMAT_MESSAGE_IGNORE_INSERTS = 0x00000200;
private const uint FORMAT_MESSAGE_FROM_SYSTEM = 0x00001000;
[DllImport("Kernel32.dll")]
private static extern int FormatMessageW(
int dwFlags,
IntPtr lpSource,
int dwMessageId,
int dwLanguageId,
IntPtr lpBuffer,
int nSize,
IntPtr Arguments);
[DllImport("Kernel32.dll")]
private static extern int GetSystemDefaultLangID();
[DllImport("Kernel32.dll")]
private static extern int GetUserDefaultLangID();
///
/// Retrieves the system message text for the specified error.
///
private static string GetSystemMessage(int error)
{
var buffer = Marshal.AllocCoTaskMem(MAX_MESSAGE_LENGTH);
var result = FormatMessageW(
(int)(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_FROM_SYSTEM),
IntPtr.Zero,
error,
0,
buffer,
MAX_MESSAGE_LENGTH - 1,
IntPtr.Zero);
var msg = Marshal.PtrToStringUni(buffer);
Marshal.FreeCoTaskMem(buffer);
if (msg != null && msg.Length > 0)
{
return msg;
}
return string.Format("0x{0,0:X}", error);
}
///
/// Retrieves the system message text for the specified error.
///
public static string GetSystemMessage(int error, int localeId)
{
int langId;
switch (localeId)
{
case LOCALE_SYSTEM_DEFAULT:
{
langId = GetSystemDefaultLangID();
break;
}
case LOCALE_USER_DEFAULT:
{
langId = GetUserDefaultLangID();
break;
}
default:
{
langId = (0xFFFF & localeId);
break;
}
}
var buffer = Marshal.AllocCoTaskMem(MAX_MESSAGE_LENGTH);
var result = FormatMessageW(
(int)FORMAT_MESSAGE_FROM_SYSTEM,
IntPtr.Zero,
error,
langId,
buffer,
MAX_MESSAGE_LENGTH - 1,
IntPtr.Zero);
if (result > 0)
{
var msg = Marshal.PtrToStringUni(buffer);
Marshal.FreeCoTaskMem(buffer);
if (!string.IsNullOrEmpty(msg))
{
return msg.Trim();
}
}
return $"0x{error:X8}";
}
#endregion
#region Object Method Overrides
///
/// Returns true if the target object is equal to the object.
///
public override bool Equals(object target)
{
if (target != null && (target is OpcResult))
{
var 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;
}
///
/// Formats the result identifier as a string.
///
public override string ToString()
{
if (Name != null) return Name.Name;
return $"0x{Code,0:X}";
}
///
/// Returns a useful hash code for the object.
///
public override int GetHashCode()
{
return base.GetHashCode();
}
#endregion
#region Private Members
private XmlQualifiedName name_;
private int code_;
private CodeType type_;
private object caller_;
private string message_;
#endregion
/// The function was successful (Return Code: 0x00000000).
public static readonly OpcResult S_OK = new OpcResult("S_OK", OpcNamespace.OPC_DATA_ACCESS, 0x00000000);
/// The function completed with an error (Return Code: 0x00000001).
public static readonly OpcResult S_FALSE = new OpcResult("S_FALSE", OpcNamespace.OPC_DATA_ACCESS, 0x00000001);
/// The function was unsuccessfull (Return Code: 0x80004005).
public static readonly OpcResult E_FAIL = new OpcResult("E_FAIL", OpcNamespace.OPC_DATA_ACCESS, 0x80004005);
/// The interface asked for is not supported by the server (Return Code: 0x80004002).
public static readonly OpcResult E_NOINTERFACE = new OpcResult("E_NOINTERFACE", OpcNamespace.OPC_DATA_ACCESS, 0x80004002);
/// The value of one or more parameters was not valid. This is generally used in place of a more specific error where it is expected that problems are unlikely or will be easy to identify (for example when there is only one parameter) (Return Code: 0x80070057).
public static readonly OpcResult E_INVALIDARG = new OpcResult("E_INVALIDARG", OpcNamespace.OPC_DATA_ACCESS, 0x80070057);
/// Function is not implemented (Return Code: 0x80004001).
public static readonly OpcResult E_NOTIMPL = new OpcResult("E_NOTIMPL", OpcNamespace.OPC_DATA_ACCESS, 0x80004001);
/// Not enough memory to complete the requested operation. This can happen any time the server needs to allocate memory to complete the requested operation (Return Code: 0x8007000E).
public static readonly OpcResult E_OUTOFMEMORY = new OpcResult("E_OUTOFMEMORY", OpcNamespace.OPC_DATA_ACCESS, 0x8007000E);
/// Return Code: 0x80004004
public static readonly OpcResult E_ABORT = new OpcResult("E_ABORT", OpcNamespace.OPC_DATA_ACCESS, 0x80004004);
/// NULL pointer argument.
public static readonly OpcResult E_POINTER = new OpcResult("E_POINTER", OpcNamespace.OPC_DATA_ACCESS, 0x80004003);
/// Cannot Unadvise - there is no existing connection (Return Code: 0x80040200).
public static readonly OpcResult CONNECT_E_NOCONNECTION = new OpcResult("CONNECT_E_NOCONNECTION", OpcNamespace.OPC_DATA_ACCESS, 0x80040200);
/// The operation took too long to complete.
public static readonly OpcResult E_TIMEDOUT = new OpcResult("E_TIMEDOUT", OpcNamespace.OPC_DATA_ACCESS);
/// General network error.
public static readonly OpcResult E_NETWORK_ERROR = new OpcResult("E_NETWORK_ERROR", OpcNamespace.OPC_DATA_ACCESS);
/// The server denies access (Return Code: 0x80070005).
public static readonly OpcResult E_ACCESS_DENIED = new OpcResult("E_ACCESS_DENIED", OpcNamespace.OPC_DATA_ACCESS, 0x80070005);
/// Invalid class string (Return Code: 0x800401F3).
public static readonly OpcResult CO_E_CLASSSTRING = new OpcResult("CO_E_CLASSSTRING", OpcNamespace.OPC_DATA_ACCESS, 0x800401F3);
/// The object application has been disconnected from the remoting system (Return Code: 0x800401FD).
public static readonly OpcResult CO_E_OBJNOTCONNECTED = new OpcResult("CO_E_OBJNOTCONNECTED", OpcNamespace.OPC_DATA_ACCESS, 0x800401fd);
///
/// The server does not support the requested function with the specified parameters.
///
public static readonly OpcResult E_NOTSUPPORTED = new OpcResult("E_NOTSUPPORTED", OpcNamespace.OPC_DATA_ACCESS);
///
/// Results codes for Data Access.
///
public class Da
{
/// Indicates that not every detected change has been returned for this item. This is an indicator that servers buffer reached its limit and had to purge out the oldest data. Only the most recent data is provided. The server should only remove the oldest data for those items that have newer samples available in the buffer. This will allow single samplings of older items to be returned to the client (Return Code: 0x00040404).
public static readonly OpcResult S_DATAQUEUEOVERFLOW = new OpcResult("S_DATAQUEUEOVERFLOW", OpcNamespace.OPC_DATA_ACCESS, 0x00040404);
/// The server does not support the requested data rate but will use the closest available rate (Return Code: 0x0004000D).
public static readonly OpcResult S_UNSUPPORTEDRATE = new OpcResult("S_UNSUPPORTEDRATE", OpcNamespace.OPC_DATA_ACCESS, 0x0004000D);
/// A value passed to WRITE was accepted but the output was clamped (Return Code: 0x0004000E).
public static readonly OpcResult S_CLAMP = new OpcResult("S_CLAMP", OpcNamespace.OPC_DATA_ACCESS, 0x0004000E);
/// The value of the handle is invalid.
/// Note: a client should never pass an invalid handle to a server. If this error occurs, it is due to a programming error in the client or possibly in the server (Return Code: 0xC0040001).
public static readonly OpcResult E_INVALIDHANDLE = new OpcResult("E_INVALIDHANDLE", OpcNamespace.OPC_DATA_ACCESS, 0xC0040001);
/// The item ID is not defined in the server address space (on add or validate) or no longer exists in the server address space (for read or write) (Returnd Code: 0xC0040007).
public static readonly OpcResult E_UNKNOWN_ITEM_NAME = new OpcResult("E_UNKNOWN_ITEM_NAME", OpcNamespace.OPC_DATA_ACCESS, 0xC0040007);
/// The item name does not conform the server's syntax.
public static readonly OpcResult E_INVALID_ITEM_NAME = new OpcResult("E_INVALID_ITEM_NAME", OpcNamespace.OPC_DATA_ACCESS);
/// The item path is no longer available in the server address space.
public static readonly OpcResult E_UNKNOWN_ITEM_PATH = new OpcResult("E_UNKNOWN_ITEM_PATH", OpcNamespace.OPC_DATA_ACCESS);
/// The item path does not conform the server's syntax
public static readonly OpcResult E_INVALID_ITEM_PATH = new OpcResult("E_INVALID_ITEM_PATH", OpcNamespace.OPC_DATA_ACCESS);
/// The passed property ID is not valid for the item (Return Code: 0xC0040203).
public static readonly OpcResult E_INVALID_PID = new OpcResult("E_INVALID_PID", OpcNamespace.OPC_DATA_ACCESS, 0xC0040203);
/// An invalid subscription handle was passed to the request.
public static readonly OpcResult E_NO_SUBSCRIPTION = new OpcResult("E_NO_SUBSCRIPTION", OpcNamespace.OPC_DATA_ACCESS_XML10);
/// The value is read only and may not be written to
public static readonly OpcResult E_READONLY = new OpcResult("E_READONLY", OpcNamespace.OPC_DATA_ACCESS);
/// The value is write-only and may not be read from or returned as part of a write response
public static readonly OpcResult E_WRITEONLY = new OpcResult("E_WRITEONLY", OpcNamespace.OPC_DATA_ACCESS);
/// The server cannot convert the data between the specified format/ requested data type and the canonical data type (Return Code: 0xC0040004).
public static readonly OpcResult E_BADTYPE = new OpcResult("E_BADTYPE", OpcNamespace.OPC_DATA_ACCESS, 0xC0040004);
/// The value was out of range (Return Code: 0xC004000B).
public static readonly OpcResult E_RANGE = new OpcResult("E_RANGE", OpcNamespace.OPC_DATA_ACCESS, 0xC004000B);
/// Duplicate name not allowed.
public static readonly OpcResult E_DUPLICATENAME = new OpcResult("E_DUPLICATENAME", OpcNamespace.OPC_DATA_ACCESS_XML10);
/// The filter string was not valid (Return Code: 0xC0040009).
public static readonly OpcResult E_INVALID_FILTER = new OpcResult("E_INVALID_FILTER", OpcNamespace.OPC_DATA_ACCESS, 0xC0040009);
/// The continuation point is not valid (Return Code: 0xC0040403).
public static readonly OpcResult E_INVALIDCONTINUATIONPOINT = new OpcResult("E_INVALIDCONTINUATIONPOINT", OpcNamespace.OPC_DATA_ACCESS, 0xC0040403);
/// The server does not support writing of quality and/or timestamp.
public static readonly OpcResult E_NO_WRITEQT = new OpcResult("E_NO_WRITEQT", OpcNamespace.OPC_DATA_ACCESS);
/// The item deadband has not been set for this item (Return Code: 0xC0040400).
public static readonly OpcResult E_NO_ITEM_DEADBAND = new OpcResult("E_NO_ITEM_DEADBAND", OpcNamespace.OPC_DATA_ACCESS, 0xC0040400);
///
public static readonly OpcResult E_NO_ITEM_SAMPLING = new OpcResult("E_NO_ITEM_SAMPLING", OpcNamespace.OPC_DATA_ACCESS);
/// The server does not support buffering of data items that are collected at a faster rate than the subscription update rate (Return Code: 0xC0040402)
public static readonly OpcResult E_NO_ITEM_BUFFERING = new OpcResult("E_NO_ITEM_BUFFERING", OpcNamespace.OPC_DATA_ACCESS, 0xC0040402);
//
//public static readonly OpcResult E_DUPPLICATE_FULLITEMNAME = new OpcResult("E_DUPPLICATE_FULLITEMNAME", Namespace.OPC_DATA_ACCESS_XML10);
}
///
/// Results codes for XML-DA.
///
public class Xda
{
/// The function was successful.
public static readonly OpcResult S_OK = new OpcResult("S_OK", OpcNamespace.OPC_DATA_ACCESS_XML10);
/// A value passed to WRITE was accepted but the output was clamped.
public static readonly OpcResult S_CLAMP = new OpcResult("S_CLAMP", OpcNamespace.OPC_DATA_ACCESS_XML10);
/// Indicates that not every detected change has been returned for this item. This is an indicator that servers buffer reached its limit and had to purge out the oldest data. Only the most recent data is provided. The server should only remove the oldest data for those items that have newer samples available in the buffer. This will allow single samplings of older items to be returned to the client.
public static readonly OpcResult S_DATAQUEUEOVERFLOW = new OpcResult("S_DATAQUEUEOVERFLOW", OpcNamespace.OPC_DATA_ACCESS_XML10);
/// The server does not support the requested data rate but will use the closest available rate.
public static readonly OpcResult S_UNSUPPORTEDRATE = new OpcResult("S_UNSUPPORTEDRATE", OpcNamespace.OPC_DATA_ACCESS_XML10);
/// The server denies access.
public static readonly OpcResult E_ACCESS_DENIED = new OpcResult("E_ACCESS_DENIED", OpcNamespace.OPC_DATA_ACCESS_XML10);
/// A refresh is currently in progress.
public static readonly OpcResult E_BUSY = new OpcResult("E_BUSY", OpcNamespace.OPC_DATA_ACCESS_XML10);
/// The function was unsuccessfull.
public static readonly OpcResult E_FAIL = new OpcResult("E_FAIL", OpcNamespace.OPC_DATA_ACCESS_XML10);
/// The continuation point is not valid.
public static readonly OpcResult E_INVALIDCONTINUATIONPOINT = new OpcResult("E_INVALIDCONTINUATIONPOINT", OpcNamespace.OPC_DATA_ACCESS_XML10);
/// The filter string is not valid.
public static readonly OpcResult E_INVALIDFILTER = new OpcResult("E_INVALIDFILTER", OpcNamespace.OPC_DATA_ACCESS_XML10);
/// The hold time is too long (determined by server).
public static readonly OpcResult E_INVALIDHOLDTIME = new OpcResult("E_INVALIDHOLDTIME", OpcNamespace.OPC_DATA_ACCESS_XML10);
/// The item name does not conform the server's syntax.
public static readonly OpcResult E_INVALIDITEMNAME = new OpcResult("E_INVALIDITEMNAME", OpcNamespace.OPC_DATA_ACCESS_XML10);
/// The item path does not conform the server's syntax
public static readonly OpcResult E_INVALIDITEMPATH = new OpcResult("E_INVALIDITEMPATH", OpcNamespace.OPC_DATA_ACCESS_XML10);
/// The passed property ID is not valid for the item.
public static readonly OpcResult E_INVALIDPID = new OpcResult("E_INVALIDPID", OpcNamespace.OPC_DATA_ACCESS_XML10);
/// An invalid subscription handle was passed to the request.
public static readonly OpcResult E_NO_SUBSCRIPTION = new OpcResult("E_NO_SUBSCRIPTION", OpcNamespace.OPC_DATA_ACCESS_XML10);
/// The server does not support the requested function with the specified parameters.
public static readonly OpcResult E_NOT_SUPPORTED = new OpcResult("E_NOT_SUPPORTED", OpcNamespace.OPC_DATA_ACCESS_XML10);
/// Not enough memory to complete the requested operation. This can happen any time the server needs to allocate memory to complete the requested operation.
public static readonly OpcResult E_OUTOFMEMORY = new OpcResult("E_OUTOFMEMORY", OpcNamespace.OPC_DATA_ACCESS_XML10);
/// The value was out of range.
public static readonly OpcResult E_RANGE = new OpcResult("E_RANGE", OpcNamespace.OPC_DATA_ACCESS_XML10);
/// The value is read only and may not be written to
public static readonly OpcResult E_READONLY = new OpcResult("E_READONLY", OpcNamespace.OPC_DATA_ACCESS_XML10);
/// The operation could not complete due to an abnormal server state.
public static readonly OpcResult E_SERVERSTATE = new OpcResult("E_SERVERSTATE", OpcNamespace.OPC_DATA_ACCESS_XML10);
/// The operation took too long to complete.
public static readonly OpcResult E_TIMEDOUT = new OpcResult("E_TIMEDOUT", OpcNamespace.OPC_DATA_ACCESS_XML10);
/// The item ID is not defined in the server address space (on add or validate) or no longer exists in the server address space (for read or write).
public static readonly OpcResult E_UNKNOWNITEMNAME = new OpcResult("E_UNKNOWNITEMNAME", OpcNamespace.OPC_DATA_ACCESS_XML10);
/// The item path is no longer available in the server address space.
public static readonly OpcResult E_UNKNOWNITEMPATH = new OpcResult("E_UNKNOWNITEMPATH", OpcNamespace.OPC_DATA_ACCESS_XML10);
/// The value is write-only and may not be read from or returned as part of a write response
public static readonly OpcResult E_WRITEONLY = new OpcResult("E_WRITEONLY", OpcNamespace.OPC_DATA_ACCESS_XML10);
/// The value of one or more parameters was not valid. This is generally used in place of a more specific error where it is expected that problems are unlikely or will be easy to identify (for example when there is only one parameter).
public static readonly OpcResult E_INVALIDARG = new OpcResult("E_INVALIDARG", OpcNamespace.OPC_DATA_ACCESS_XML10);
/// The server cannot convert the data between the specified format/ requested data type and the canonical data type.
public static readonly OpcResult E_BADTYPE = new OpcResult("E_BADTYPE", OpcNamespace.OPC_DATA_ACCESS_XML10);
/// Item whith this FullItemName was allready defined.
public static readonly OpcResult E_DUPPLICATE_FULLITEMNAME = new OpcResult("E_DUPPLICATE_FULLITEMNAME", OpcNamespace.OPC_DATA_ACCESS_XML10);
}
///
/// Results codes for Complex Data.
///
public class Cpx
{
///
/// The dictionary and/or type description for the item has changed.
///
public static readonly OpcResult E_TYPE_CHANGED = new OpcResult("E_TYPE_CHANGED", OpcNamespace.OPC_COMPLEX_DATA);
///
/// A data filter item with the specified name already exists.
///
public static readonly OpcResult E_FILTER_DUPLICATE = new OpcResult("E_FILTER_DUPLICATE", OpcNamespace.OPC_COMPLEX_DATA);
///
/// The data filter value does not conform to the server's syntax.
///
public static readonly OpcResult E_FILTER_INVALID = new OpcResult("E_FILTER_INVALID", OpcNamespace.OPC_COMPLEX_DATA);
///
/// An error occurred when the filter value was applied to the source data.
///
public static readonly OpcResult E_FILTER_ERROR = new OpcResult("E_FILTER_ERROR", OpcNamespace.OPC_COMPLEX_DATA);
///
/// The item value is empty because the data filter has excluded all fields.
///
public static readonly OpcResult S_FILTER_NO_DATA = new OpcResult("S_FILTER_NO_DATA", OpcNamespace.OPC_COMPLEX_DATA);
}
///
/// Results codes for Historical Data Access.
///
public class Hda
{
/// The server does not support writing of quality and/or timestamp.
public static readonly OpcResult E_MAXEXCEEDED = new OpcResult("E_MAXEXCEEDED", OpcNamespace.OPC_HISTORICAL_DATA_ACCESS);
/// There is no data within the specified parameters.
public static readonly OpcResult S_NODATA = new OpcResult("S_NODATA", OpcNamespace.OPC_HISTORICAL_DATA_ACCESS);
/// There is more data satisfying the query than was returned.
public static readonly OpcResult S_MOREDATA = new OpcResult("S_MOREDATA", OpcNamespace.OPC_HISTORICAL_DATA_ACCESS);
/// The aggregate requested is not valid.
public static readonly OpcResult E_INVALIDAGGREGATE = new OpcResult("E_INVALIDAGGREGATE", OpcNamespace.OPC_HISTORICAL_DATA_ACCESS);
/// The server only returns current values for the requested item attributes.
public static readonly OpcResult S_CURRENTVALUE = new OpcResult("S_CURRENTVALUE", OpcNamespace.OPC_HISTORICAL_DATA_ACCESS);
/// Additional data satisfying the query was found.
public static readonly OpcResult S_EXTRADATA = new OpcResult("S_EXTRADATA", OpcNamespace.OPC_HISTORICAL_DATA_ACCESS);
/// The server does not support this filter.
public static readonly OpcResult W_NOFILTER = new OpcResult("W_NOFILTER", OpcNamespace.OPC_HISTORICAL_DATA_ACCESS);
/// The server does not support this attribute.
public static readonly OpcResult E_UNKNOWNATTRID = new OpcResult("E_UNKNOWNATTRID", OpcNamespace.OPC_HISTORICAL_DATA_ACCESS);
/// The requested aggregate is not available for the specified item.
public static readonly OpcResult E_NOT_AVAIL = new OpcResult("E_NOT_AVAIL", OpcNamespace.OPC_HISTORICAL_DATA_ACCESS);
/// The supplied value for the attribute is not a correct data type.
public static readonly OpcResult E_INVALIDDATATYPE = new OpcResult("E_INVALIDDATATYPE", OpcNamespace.OPC_HISTORICAL_DATA_ACCESS);
/// Unable to insert - data already present.
public static readonly OpcResult E_DATAEXISTS = new OpcResult("E_DATAEXISTS", OpcNamespace.OPC_HISTORICAL_DATA_ACCESS);
/// The supplied attribute ID is not valid.
public static readonly OpcResult E_INVALIDATTRID = new OpcResult("E_INVALIDATTRID", OpcNamespace.OPC_HISTORICAL_DATA_ACCESS);
/// The server has no value for the specified time and item ID.
public static readonly OpcResult E_NODATAEXISTS = new OpcResult("E_NODATAEXISTS", OpcNamespace.OPC_HISTORICAL_DATA_ACCESS);
/// The requested insert occurred.
public static readonly OpcResult S_INSERTED = new OpcResult("S_INSERTED", OpcNamespace.OPC_HISTORICAL_DATA_ACCESS);
/// The requested replace occurred.
public static readonly OpcResult S_REPLACED = new OpcResult("S_REPLACED", OpcNamespace.OPC_HISTORICAL_DATA_ACCESS);
}
///
/// Results codes for Alarms and Events
///
public class Ae
{
/// The condition has already been acknowleged.
public static readonly OpcResult S_ALREADYACKED = new OpcResult("S_ALREADYACKED", OpcNamespace.OPC_ALARM_AND_EVENTS, 0x00040200);
/// The buffer time parameter was invalid.
public static readonly OpcResult S_INVALIDBUFFERTIME = new OpcResult("S_INVALIDBUFFERTIME", OpcNamespace.OPC_ALARM_AND_EVENTS, 0x00040201);
/// The max size parameter was invalid.
public static readonly OpcResult S_INVALIDMAXSIZE = new OpcResult("S_INVALIDMAXSIZE", OpcNamespace.OPC_ALARM_AND_EVENTS, 0x00040202);
/// The KeepAliveTime parameter was invalid.
public static readonly OpcResult S_INVALIDKEEPALIVETIME = new OpcResult("S_INVALIDKEEPALIVETIME", OpcNamespace.OPC_ALARM_AND_EVENTS, 0x00040203);
/// The string was not recognized as an area name.
public static readonly OpcResult E_INVALIDBRANCHNAME = new OpcResult("E_INVALIDBRANCHNAME", OpcNamespace.OPC_ALARM_AND_EVENTS, 0xC0040203);
/// The time does not match the latest active time.
public static readonly OpcResult E_INVALIDTIME = new OpcResult("E_INVALIDTIME", OpcNamespace.OPC_ALARM_AND_EVENTS, 0xC0040204);
/// A refresh is currently in progress.
public static readonly OpcResult E_BUSY = new OpcResult("E_BUSY", OpcNamespace.OPC_ALARM_AND_EVENTS, 0xC0040205);
/// Information is not available.
public static readonly OpcResult E_NOINFO = new OpcResult("E_NOINFO", OpcNamespace.OPC_ALARM_AND_EVENTS, 0xC0040206);
}
}
}