Files
UA-.NETStandard/SampleApplications/Samples/Opc.Ua.Sample/MemoryBuffer/MemoryBuffer.Classes.cs
T
Alin Moldovean 81832f71a3 Update UA-Nodesets and generated code (#925)
* Update generated code and UA-nodeset files for 1.04.5 Errata

* Update UA-Nodeset files and generated code of Sample projects with latest version of ModelCompiler
2020-03-20 14:43:25 +02:00

388 lines
12 KiB
C#

/* ========================================================================
* 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.Xml;
using System.Runtime.Serialization;
using Opc.Ua;
namespace MemoryBuffer
{
#region MemoryTagState Class
#if (!OPCUA_EXCLUDE_MemoryTagState)
/// <summary>
/// Stores an instance of the MemoryTagType VariableType.
/// </summary>
/// <exclude />
[System.CodeDom.Compiler.GeneratedCodeAttribute("Opc.Ua.ModelCompiler", "1.0.0.0")]
public partial class MemoryTagState : BaseDataVariableState
{
#region Constructors
/// <summary>
/// Initializes the type with its default attribute values.
/// </summary>
public MemoryTagState(NodeState parent) : base(parent)
{
}
/// <summary>
/// Returns the id of the default type definition node for the instance.
/// </summary>
protected override NodeId GetDefaultTypeDefinitionId(NamespaceTable namespaceUris)
{
return Opc.Ua.NodeId.Create(MemoryBuffer.VariableTypes.MemoryTagType, MemoryBuffer.Namespaces.MemoryBuffer, namespaceUris);
}
/// <summary>
/// Returns the id of the default data type node for the instance.
/// </summary>
protected override NodeId GetDefaultDataTypeId(NamespaceTable namespaceUris)
{
return Opc.Ua.NodeId.Create(Opc.Ua.DataTypes.BaseDataType, Opc.Ua.Namespaces.OpcUa, namespaceUris);
}
/// <summary>
/// Returns the id of the default value rank for the instance.
/// </summary>
protected override int GetDefaultValueRank()
{
return ValueRanks.Scalar;
}
#if (!OPCUA_EXCLUDE_InitializationStrings)
/// <summary>
/// Initializes the instance.
/// </summary>
protected override void Initialize(ISystemContext context)
{
Initialize(context, InitializationString);
InitializeOptionalChildren(context);
}
/// <summary>
/// Initializes the instance with a node.
/// </summary>
protected override void Initialize(ISystemContext context, NodeState source)
{
InitializeOptionalChildren(context);
base.Initialize(context, source);
}
/// <summary>
/// Initializes the any option children defined for the instance.
/// </summary>
protected override void InitializeOptionalChildren(ISystemContext context)
{
base.InitializeOptionalChildren(context);
}
#region Initialization String
private const string InitializationString =
"AQAAACIAAABodHRwOi8vc2FtcGxlcy5vcmcvVUEvbWVtb3J5YnVmZmVy/////xVgiQICAAAAAQAVAAAA" +
"TWVtb3J5VGFnVHlwZUluc3RhbmNlAQH6AwEB+gP6AwAAABj+////AQH/////AAAAAA==";
#endregion
#endif
#endregion
#region Public Properties
#endregion
#region Overridden Methods
#endregion
#region Private Fields
#endregion
}
#region MemoryTagState<T> Class
/// <summary>
/// A typed version of the MemoryTagType variable.
/// </summary>
/// <exclude />
[System.CodeDom.Compiler.GeneratedCodeAttribute("Opc.Ua.ModelCompiler", "1.0.0.0")]
public class MemoryTagState<T> : MemoryTagState
{
#region Constructors
/// <summary>
/// Initializes the instance with its defalt attribute values.
/// </summary>
public MemoryTagState(NodeState parent) : base(parent)
{
Value = default(T);
}
/// <summary>
/// Initializes the instance with the default values.
/// </summary>
protected override void Initialize(ISystemContext context)
{
base.Initialize(context);
Value = default(T);
DataType = TypeInfo.GetDataTypeId(typeof(T));
ValueRank = TypeInfo.GetValueRank(typeof(T));
}
/// <summary>
/// Initializes the instance with a node.
/// </summary>
protected override void Initialize(ISystemContext context, NodeState source)
{
InitializeOptionalChildren(context);
base.Initialize(context, source);
}
#endregion
#region Public Members
/// <summary>
/// The value of the variable.
/// </summary>
public new T Value
{
get
{
return CheckTypeBeforeCast<T>(base.Value, true);
}
set
{
base.Value = value;
}
}
#endregion
}
#endregion
#endif
#endregion
#region MemoryBufferState Class
#if (!OPCUA_EXCLUDE_MemoryBufferState)
/// <summary>
/// Stores an instance of the MemoryBufferType ObjectType.
/// </summary>
/// <exclude />
[System.CodeDom.Compiler.GeneratedCodeAttribute("Opc.Ua.ModelCompiler", "1.0.0.0")]
public partial class MemoryBufferState : BaseObjectState
{
#region Constructors
/// <summary>
/// Initializes the type with its default attribute values.
/// </summary>
public MemoryBufferState(NodeState parent) : base(parent)
{
}
/// <summary>
/// Returns the id of the default type definition node for the instance.
/// </summary>
protected override NodeId GetDefaultTypeDefinitionId(NamespaceTable namespaceUris)
{
return Opc.Ua.NodeId.Create(MemoryBuffer.ObjectTypes.MemoryBufferType, MemoryBuffer.Namespaces.MemoryBuffer, namespaceUris);
}
#if (!OPCUA_EXCLUDE_InitializationStrings)
/// <summary>
/// Initializes the instance.
/// </summary>
protected override void Initialize(ISystemContext context)
{
Initialize(context, InitializationString);
InitializeOptionalChildren(context);
}
/// <summary>
/// Initializes the instance with a node.
/// </summary>
protected override void Initialize(ISystemContext context, NodeState source)
{
InitializeOptionalChildren(context);
base.Initialize(context, source);
}
/// <summary>
/// Initializes the any option children defined for the instance.
/// </summary>
protected override void InitializeOptionalChildren(ISystemContext context)
{
base.InitializeOptionalChildren(context);
}
#region Initialization String
private const string InitializationString =
"AQAAACIAAABodHRwOi8vc2FtcGxlcy5vcmcvVUEvbWVtb3J5YnVmZmVy/////wRggAIBAAAAAQAYAAAA" +
"TWVtb3J5QnVmZmVyVHlwZUluc3RhbmNlAQHoAwEB6APoAwAA/////wIAAAAVYKkKAgAAAAEADAAAAFN0" +
"YXJ0QWRkcmVzcwEB6wMALgBE6wMAAAcAAAAAAAf/////AQH/////AAAAABVgqQoCAAAAAQALAAAAU2l6" +
"ZUluQnl0ZXMBAewDAC4AROwDAAAHABAAAAAH/////wEB/////wAAAAA=";
#endregion
#endif
#endregion
#region Public Properties
/// <remarks />
public PropertyState<uint> StartAddress
{
get
{
return m_startAddress;
}
set
{
if (!Object.ReferenceEquals(m_startAddress, value))
{
ChangeMasks |= NodeStateChangeMasks.Children;
}
m_startAddress = value;
}
}
/// <remarks />
public PropertyState<uint> SizeInBytes
{
get
{
return m_sizeInBytes;
}
set
{
if (!Object.ReferenceEquals(m_sizeInBytes, value))
{
ChangeMasks |= NodeStateChangeMasks.Children;
}
m_sizeInBytes = value;
}
}
#endregion
#region Overridden Methods
/// <summary>
/// Populates a list with the children that belong to the node.
/// </summary>
/// <param name="context">The context for the system being accessed.</param>
/// <param name="children">The list of children to populate.</param>
public override void GetChildren(
ISystemContext context,
IList<BaseInstanceState> children)
{
if (m_startAddress != null)
{
children.Add(m_startAddress);
}
if (m_sizeInBytes != null)
{
children.Add(m_sizeInBytes);
}
base.GetChildren(context, children);
}
/// <summary>
/// Finds the child with the specified browse name.
/// </summary>
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<uint>(this);
}
else
{
StartAddress = (PropertyState<uint>)replacement;
}
}
}
instance = StartAddress;
break;
}
case MemoryBuffer.BrowseNames.SizeInBytes:
{
if (createOrReplace)
{
if (SizeInBytes == null)
{
if (replacement == null)
{
SizeInBytes = new PropertyState<uint>(this);
}
else
{
SizeInBytes = (PropertyState<uint>)replacement;
}
}
}
instance = SizeInBytes;
break;
}
}
if (instance != null)
{
return instance;
}
return base.FindChild(context, browseName, createOrReplace, replacement);
}
#endregion
#region Private Fields
private PropertyState<uint> m_startAddress;
private PropertyState<uint> m_sizeInBytes;
#endregion
}
#endif
#endregion
}