public void DoSimulation(long counter, int index, Opc.Ua.Test.DataGenerator generator)
{
try
{
TagsChangedEventHandler onTagsChanged = null;
List<UnderlyingSystemTag> snapshots = new List<UnderlyingSystemTag>();
// update the tags.
lock (m_tags)
{
onTagsChanged = OnTagsChanged;
// do nothing if not monitored.
if (onTagsChanged == null)
{
return;
}
for (int ii = 0; ii < m_tags.Count; ii++)
{
UnderlyingSystemTag tag = m_tags[ii];
UpdateTagValue(tag, generator);
DataValue value = new DataValue();
value.Value = tag.Value;
value.StatusCode = StatusCodes.Good;
value.SourceTimestamp = tag.Timestamp;
if (counter % (8 + (index%4)) == 0)
{
UpdateTagMetadata(tag, generator);
}
snapshots.Add(tag.CreateSnapshot());
}
}
// report any tag changes after releasing the lock.
if (onTagsChanged != null)
{
onTagsChanged(snapshots);
}
}
catch (Exception e)
{
Utils.Trace(e, "Unexpected error running simulation for block {0}", m_name);
}
}
#endregion