Hi!
Try this example from the help file in zenon 8.10:
Code:
using System;
using Scada.AddIn.Contracts;
using Scada.AddIn.Contracts.Historian;
using System.Diagnostics;
namespace Samples
{
[AddInExtension("Historian.RuntimeArchiveValue", "Project Wizard to create a filter, add variables to it and print out the values", "Samples")]
public class ProjectWizardExtension_Historian_RuntimeArchiveValue : IProjectWizardExtension
{
public void Run(IProject context, IBehavior behavior)
{
IRuntimeArchive runtimeArchive = context.RuntimeArchiveCollection[0];
if (runtimeArchive == null)
{
//There is no archive, the user will be informed...
Debug.Print("No archive available!");
return;
}
IRuntimeArchiveFilter ArchiveFilter = runtimeArchive.FilterCollection.Create();
for (int i = 0; i < runtimeArchive.VariableCollection.Count; ++i)
{
//Add every archive variable to the archive filter
ArchiveFilter.AddVariable(runtimeArchive.VariableCollection[i]);
}
IRuntimeArchiveFilterVariableCollection ArchiveVariables = ArchiveFilter.Query();
//Get the first available filtered variable
IRuntimeArchiveFilterVariable ArchiveFilterVariable = ArchiveVariables[0];
if (ArchiveFilterVariable == null)
{
//If there is no variable available, inform the user
Debug.Print("No filtered archive variable available!");
return;
}
ArchiveFilterVariable.ArchiveValueCollection.Create();
IRuntimeArchiveValue ArchiveValue = ArchiveFilterVariable.ArchiveValueCollection[0];
if (ArchiveValue == null)
{
//No value available
Debug.Print("No value available!");
}
else
{
//Output some information of the value
Debug.Print("Date / Time: " + ArchiveValue.Time.ToString());
Debug.Print("Recorded Value: " + ArchiveValue.Value);
Debug.Print("State: &H" + ArchiveValue.HigherState.ToString());
}
}
}
}
Remember that your AddIn might have an effect on the performance, if it handles a large amount of data!