Skip to content

Commit

Permalink
Improve initalization of BaseVariableState (#1671)
Browse files Browse the repository at this point in the history
  • Loading branch information
mrsuciu committed Jan 20, 2022
1 parent 79e9463 commit cf95cb9
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions Stack/Opc.Ua.Core/Stack/State/BaseVariableState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public BaseVariableState(NodeState parent) : base(NodeClass.Variable, parent)
m_timestamp = DateTime.MinValue;
m_accessLevel = m_userAccessLevel = AccessLevels.CurrentRead;
m_copyPolicy = VariableCopyPolicy.CopyOnRead;
m_valueTouched = false;
m_statusCode = StatusCodes.BadWaitingForInitialData;
}
#endregion
Expand All @@ -61,14 +62,7 @@ protected override void Initialize(ISystemContext context, NodeState source)
m_userAccessLevel = instance.m_userAccessLevel;
m_minimumSamplingInterval = instance.m_minimumSamplingInterval;
m_historizing = instance.m_historizing;
// Allow initalization from variable states with status code BadWaitingForInitialData
if (instance.m_statusCode == StatusCodes.BadWaitingForInitialData)
{
m_statusCode = StatusCodes.Good;
}else
{
m_statusCode = instance.m_statusCode;
}
m_valueTouched = instance.m_valueTouched;

if (instance.m_arrayDimensions != null)
{
Expand Down Expand Up @@ -473,14 +467,14 @@ public object Value
ChangeMasks |= NodeStateChangeMasks.Value;
}

if ((m_value == null) && (StatusCode == StatusCodes.BadWaitingForInitialData))
if (!m_valueTouched)
{
StatusCode = StatusCodes.Good;
}

m_value = value;


m_valueTouched = true;
}
}

Expand Down Expand Up @@ -2017,6 +2011,7 @@ public override void SetStatusCode(ISystemContext context, StatusCode statusCode
private object m_value;
private bool m_isValueType;
private DateTime m_timestamp;
private bool m_valueTouched;
private StatusCode m_statusCode;
private NodeId m_dataType;
private int m_valueRank;
Expand Down

0 comments on commit cf95cb9

Please sign in to comment.