Skip to content

Instantly share code, notes, and snippets.

@Snegovikufa
Created August 26, 2013 02:31
Show Gist options
  • Save Snegovikufa/6337658 to your computer and use it in GitHub Desktop.
Save Snegovikufa/6337658 to your computer and use it in GitHub Desktop.
OPC UA how to read raw history values
private void ReadRaw(bool isReadModified)
{
ReadRawModifiedDetails details = new ReadRawModifiedDetails();
details.StartTime = DateTime.MinValue;
details.EndTime = DateTime.MinValue;
details.IsReadModified = isReadModified;
details.NumValuesPerNode = 0;
details.ReturnBounds = ReturnBoundsCK.Checked;
if (StartTimeCK.Checked)
{
details.StartTime = StartTimeDP.Value.ToUniversalTime();
}
if (EndTimeCK.Checked)
{
details.EndTime = EndTimeDP.Value.ToUniversalTime();
}
if (MaxReturnValuesCK.Checked)
{
details.NumValuesPerNode = (uint)MaxReturnValuesNP.Value;
}
HistoryReadValueId nodeToRead = new HistoryReadValueId();
nodeToRead.NodeId = m_nodeId;
if (m_result != null)
{
nodeToRead.ContinuationPoint = m_result.ContinuationPoint;
}
HistoryReadValueIdCollection nodesToRead = new HistoryReadValueIdCollection();
nodesToRead.Add(nodeToRead);
HistoryReadResultCollection results = null;
DiagnosticInfoCollection diagnosticInfos = null;
m_session.HistoryRead(
null,
new ExtensionObject(details),
TimestampsToReturn.Source,
false,
nodesToRead,
out results,
out diagnosticInfos);
Session.ValidateResponse(results, nodesToRead);
Session.ValidateDiagnosticInfos(diagnosticInfos, nodesToRead);
if (StatusCode.IsBad(results[0].StatusCode))
{
throw new ServiceResultException(results[0].StatusCode);
}
m_result = results[0];
ShowResults();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment