Zenon Historian values

Zenon Historian values

Hello,

how can I get the last-minute data (timestamp and value) from a Zenon Historian using C# addin.

This code give me just the last value:
  1. 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());
                }
            }
        }
    }

Could somebody help me?

Thank you in advance.