/* ========================================================================
* Copyright (c) 2005-2019 The OPC Foundation, Inc. All rights reserved.
*
* OPC Foundation MIT License 1.00
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* The complete license agreement can be found here:
* http://opcfoundation.org/License/MIT/1.00/
* ======================================================================*/
using System;
using System.Collections.Generic;
using System.Text;
using System.Reflection;
using System.Xml;
using System.Runtime.Serialization;
using Opc.Ua;
namespace MemoryBuffer
{
#region Object Identifiers
///
/// A class that declares constants for all Objects in the Model Design.
///
///
[System.CodeDom.Compiler.GeneratedCodeAttribute("Opc.Ua.ModelCompiler", "1.0.0.0")]
public static partial class Objects
{
///
/// The identifier for the MemoryBuffers Object.
///
public const uint MemoryBuffers = 1025;
}
#endregion
#region ObjectType Identifiers
///
/// A class that declares constants for all ObjectTypes in the Model Design.
///
///
[System.CodeDom.Compiler.GeneratedCodeAttribute("Opc.Ua.ModelCompiler", "1.0.0.0")]
public static partial class ObjectTypes
{
///
/// The identifier for the MemoryBufferType ObjectType.
///
public const uint MemoryBufferType = 1000;
}
#endregion
#region Variable Identifiers
///
/// A class that declares constants for all Variables in the Model Design.
///
///
[System.CodeDom.Compiler.GeneratedCodeAttribute("Opc.Ua.ModelCompiler", "1.0.0.0")]
public static partial class Variables
{
///
/// The identifier for the MemoryBufferType_StartAddress Variable.
///
public const uint MemoryBufferType_StartAddress = 1003;
///
/// The identifier for the MemoryBufferType_SizeInBytes Variable.
///
public const uint MemoryBufferType_SizeInBytes = 1004;
}
#endregion
#region VariableType Identifiers
///
/// A class that declares constants for all VariableTypes in the Model Design.
///
///
[System.CodeDom.Compiler.GeneratedCodeAttribute("Opc.Ua.ModelCompiler", "1.0.0.0")]
public static partial class VariableTypes
{
///
/// The identifier for the MemoryTagType VariableType.
///
public const uint MemoryTagType = 1018;
}
#endregion
#region Object Node Identifiers
///
/// A class that declares constants for all Objects in the Model Design.
///
///
[System.CodeDom.Compiler.GeneratedCodeAttribute("Opc.Ua.ModelCompiler", "1.0.0.0")]
public static partial class ObjectIds
{
///
/// The identifier for the MemoryBuffers Object.
///
public static readonly ExpandedNodeId MemoryBuffers = new ExpandedNodeId(MemoryBuffer.Objects.MemoryBuffers, MemoryBuffer.Namespaces.MemoryBuffer);
}
#endregion
#region ObjectType Node Identifiers
///
/// A class that declares constants for all ObjectTypes in the Model Design.
///
///
[System.CodeDom.Compiler.GeneratedCodeAttribute("Opc.Ua.ModelCompiler", "1.0.0.0")]
public static partial class ObjectTypeIds
{
///
/// The identifier for the MemoryBufferType ObjectType.
///
public static readonly ExpandedNodeId MemoryBufferType = new ExpandedNodeId(MemoryBuffer.ObjectTypes.MemoryBufferType, MemoryBuffer.Namespaces.MemoryBuffer);
}
#endregion
#region Variable Node Identifiers
///
/// A class that declares constants for all Variables in the Model Design.
///
///
[System.CodeDom.Compiler.GeneratedCodeAttribute("Opc.Ua.ModelCompiler", "1.0.0.0")]
public static partial class VariableIds
{
///
/// The identifier for the MemoryBufferType_StartAddress Variable.
///
public static readonly ExpandedNodeId MemoryBufferType_StartAddress = new ExpandedNodeId(MemoryBuffer.Variables.MemoryBufferType_StartAddress, MemoryBuffer.Namespaces.MemoryBuffer);
///
/// The identifier for the MemoryBufferType_SizeInBytes Variable.
///
public static readonly ExpandedNodeId MemoryBufferType_SizeInBytes = new ExpandedNodeId(MemoryBuffer.Variables.MemoryBufferType_SizeInBytes, MemoryBuffer.Namespaces.MemoryBuffer);
}
#endregion
#region VariableType Node Identifiers
///
/// A class that declares constants for all VariableTypes in the Model Design.
///
///
[System.CodeDom.Compiler.GeneratedCodeAttribute("Opc.Ua.ModelCompiler", "1.0.0.0")]
public static partial class VariableTypeIds
{
///
/// The identifier for the MemoryTagType VariableType.
///
public static readonly ExpandedNodeId MemoryTagType = new ExpandedNodeId(MemoryBuffer.VariableTypes.MemoryTagType, MemoryBuffer.Namespaces.MemoryBuffer);
}
#endregion
#region BrowseName Declarations
///
/// Declares all of the BrowseNames used in the Model Design.
///
public static partial class BrowseNames
{
///
/// The BrowseName for the MemoryBuffers component.
///
public const string MemoryBuffers = "MemoryBuffers";
///
/// The BrowseName for the MemoryBufferType component.
///
public const string MemoryBufferType = "MemoryBufferType";
///
/// The BrowseName for the MemoryTagType component.
///
public const string MemoryTagType = "MemoryTagType";
///
/// The BrowseName for the SizeInBytes component.
///
public const string SizeInBytes = "SizeInBytes";
///
/// The BrowseName for the StartAddress component.
///
public const string StartAddress = "StartAddress";
}
#endregion
#region Namespace Declarations
///
/// Defines constants for all namespaces referenced by the model design.
///
public static partial class Namespaces
{
///
/// The URI for the OpcUa namespace (.NET code namespace is 'Opc.Ua').
///
public const string OpcUa = "http://opcfoundation.org/UA/";
///
/// The URI for the OpcUaXsd namespace (.NET code namespace is 'Opc.Ua').
///
public const string OpcUaXsd = "http://opcfoundation.org/UA/2008/02/Types.xsd";
///
/// The URI for the MemoryBuffer namespace (.NET code namespace is 'MemoryBuffer').
///
public const string MemoryBuffer = "http://samples.org/UA/memorybuffer";
}
#endregion
#region MemoryTagState Class
#if (!OPCUA_EXCLUDE_MemoryTagState)
///
/// Stores an instance of the MemoryTagType VariableType.
///
///
[System.CodeDom.Compiler.GeneratedCodeAttribute("Opc.Ua.ModelCompiler", "1.0.0.0")]
public partial class MemoryTagState : BaseDataVariableState
{
#region Constructors
///
/// Initializes the type with its default attribute values.
///
public MemoryTagState(NodeState parent) : base(parent)
{
}
///
/// Returns the id of the default type definition node for the instance.
///
protected override NodeId GetDefaultTypeDefinitionId(NamespaceTable namespaceUris)
{
return Opc.Ua.NodeId.Create(MemoryBuffer.VariableTypes.MemoryTagType, MemoryBuffer.Namespaces.MemoryBuffer, namespaceUris);
}
///
/// Returns the id of the default data type node for the instance.
///
protected override NodeId GetDefaultDataTypeId(NamespaceTable namespaceUris)
{
return Opc.Ua.NodeId.Create(Opc.Ua.DataTypes.BaseDataType, Opc.Ua.Namespaces.OpcUa, namespaceUris);
}
///
/// Returns the id of the default value rank for the instance.
///
protected override int GetDefaultValueRank()
{
return ValueRanks.Scalar;
}
#if (!OPCUA_EXCLUDE_InitializationStrings)
///
/// Initializes the instance.
///
protected override void Initialize(ISystemContext context)
{
Initialize(context, InitializationString);
InitializeOptionalChildren(context);
}
///
/// Initializes the any option children defined for the instance.
///
protected override void InitializeOptionalChildren(ISystemContext context)
{
base.InitializeOptionalChildren(context);
}
#region Initialization String
private const string InitializationString =
"AQAAACIAAABodHRwOi8vc2FtcGxlcy5vcmcvVUEvbWVtb3J5YnVmZmVy/////xVggQACAAAAAQAVAAAA" +
"TWVtb3J5VGFnVHlwZUluc3RhbmNlAQH6AwEB+gMAGAEB/////wAAAAA=";
#endregion
#endif
#endregion
#region Public Properties
#endregion
#region Overridden Methods
#endregion
#region Private Fields
#endregion
}
#region MemoryTagState Class
///
/// A typed version of the MemoryTagType variable.
///
///
[System.CodeDom.Compiler.GeneratedCodeAttribute("Opc.Ua.ModelCompiler", "1.0.0.0")]
public class MemoryTagState : MemoryTagState
{
#region Constructors
///
/// Initializes the instance with its defalt attribute values.
///
public MemoryTagState(NodeState parent) : base(parent)
{
Value = default(T);
}
///
/// Initializes the instance with the default values.
///
protected override void Initialize(ISystemContext context)
{
base.Initialize(context);
Value = default(T);
DataType = Opc.Ua.TypeInfo.GetDataTypeId(typeof(T));
ValueRank = Opc.Ua.TypeInfo.GetValueRank(typeof(T));
}
#endregion
#region Public Members
///
/// The value of the variable.
///
public new T Value
{
get
{
return CheckTypeBeforeCast(base.Value, true);
}
set
{
base.Value = value;
}
}
#endregion
}
#endregion
#endif
#endregion
#region MemoryBufferState Class
#if (!OPCUA_EXCLUDE_MemoryBufferState)
///
/// Stores an instance of the MemoryBufferType ObjectType.
///
///
[System.CodeDom.Compiler.GeneratedCodeAttribute("Opc.Ua.ModelCompiler", "1.0.0.0")]
public partial class MemoryBufferState : BaseObjectState
{
#region Constructors
///
/// Initializes the type with its default attribute values.
///
public MemoryBufferState(NodeState parent) : base(parent)
{
}
///
/// Returns the id of the default type definition node for the instance.
///
protected override NodeId GetDefaultTypeDefinitionId(NamespaceTable namespaceUris)
{
return Opc.Ua.NodeId.Create(MemoryBuffer.ObjectTypes.MemoryBufferType, MemoryBuffer.Namespaces.MemoryBuffer, namespaceUris);
}
#if (!OPCUA_EXCLUDE_InitializationStrings)
///
/// Initializes the instance.
///
protected override void Initialize(ISystemContext context)
{
Initialize(context, InitializationString);
InitializeOptionalChildren(context);
}
///
/// Initializes the any option children defined for the instance.
///
protected override void InitializeOptionalChildren(ISystemContext context)
{
base.InitializeOptionalChildren(context);
}
#region Initialization String
private const string InitializationString =
"AQAAACIAAABodHRwOi8vc2FtcGxlcy5vcmcvVUEvbWVtb3J5YnVmZmVy/////wRggAABAAAAAQAYAAAA" +
"TWVtb3J5QnVmZmVyVHlwZUluc3RhbmNlAQHoAwEB6AP/////AgAAABVgqQoCAAAAAQAMAAAAU3RhcnRB" +
"ZGRyZXNzAQHrAwAuAETrAwAABwAAAAAAB/////8BAf////8AAAAAFWCpCgIAAAABAAsAAABTaXplSW5C" +
"eXRlcwEB7AMALgBE7AMAAAcAEAAAAAf/////AQH/////AAAAAA==";
#endregion
#endif
#endregion
#region Public Properties
///
/// A description for the StartAddress Property.
///
public PropertyState StartAddress
{
get
{
return m_startAddress;
}
set
{
if (!Object.ReferenceEquals(m_startAddress, value))
{
ChangeMasks |= NodeStateChangeMasks.Children;
}
m_startAddress = value;
}
}
///
/// A description for the SizeInBytes Property.
///
public PropertyState SizeInBytes
{
get
{
return m_sizeInBytes;
}
set
{
if (!Object.ReferenceEquals(m_sizeInBytes, value))
{
ChangeMasks |= NodeStateChangeMasks.Children;
}
m_sizeInBytes = value;
}
}
#endregion
#region Overridden Methods
///
/// Populates a list with the children that belong to the node.
///
/// The context for the system being accessed.
/// The list of children to populate.
public override void GetChildren(
ISystemContext context,
IList children)
{
if (m_startAddress != null)
{
children.Add(m_startAddress);
}
if (m_sizeInBytes != null)
{
children.Add(m_sizeInBytes);
}
base.GetChildren(context, children);
}
///
/// Finds the child with the specified browse name.
///
protected override BaseInstanceState FindChild(
ISystemContext context,
QualifiedName browseName,
bool createOrReplace,
BaseInstanceState replacement)
{
if (QualifiedName.IsNull(browseName))
{
return null;
}
BaseInstanceState instance = null;
switch (browseName.Name)
{
case MemoryBuffer.BrowseNames.StartAddress:
{
if (createOrReplace)
{
if (StartAddress == null)
{
if (replacement == null)
{
StartAddress = new PropertyState(this);
}
else
{
StartAddress = (PropertyState)replacement;
}
}
}
instance = StartAddress;
break;
}
case MemoryBuffer.BrowseNames.SizeInBytes:
{
if (createOrReplace)
{
if (SizeInBytes == null)
{
if (replacement == null)
{
SizeInBytes = new PropertyState(this);
}
else
{
SizeInBytes = (PropertyState)replacement;
}
}
}
instance = SizeInBytes;
break;
}
}
if (instance != null)
{
return instance;
}
return base.FindChild(context, browseName, createOrReplace, replacement);
}
#endregion
#region Private Fields
private PropertyState m_startAddress;
private PropertyState m_sizeInBytes;
#endregion
}
#endif
#endregion
}