Page 1 of 2 1 2 LastLast
Showing results 1 to 10 of 13

Thread: IArchive reference

  1. #1
    Join Date
    02.02.2022
    Posts
    26

    Default IArchive reference

    I am trying to access archive data from AddIns and I've found some examples in the help tab. 
    They use IArchiveFilterVariable data type and by adding "using Scada.AddIn.Contracts;" is not working.
    I've tried with all the posible extensions that are available from typing "." after Contracts and none seems to work.

    Thanks in advanced,



  2. #2
    Join Date
    18.12.2017
    Posts
    55

    Default Re: IArchive reference

    Hi!

    If you check the Object Model for Addin, there is a summary in the top of the description of each object.
    For example:

    IRuntimeArchiveFilterVariableCollection

    Summary

    Returns an "ArchiveFilterVariables" object, containing a collection of the filtered archive variables.

    Namespace: Scada.AddIn.Contracts.Historian

    Assembly: Scada.AddIn.Contracts (in Scada.AddIn.Contracts.dll) Version=10.0.0.0


    Try with "using Scada.AddIn.Contracts.Historian;"

  3. #3
    Join Date
    02.02.2022
    Posts
    26

    Default Re: IArchive reference

    Yup I've seen this one now. But it does not work for the IArchive datatype only works for the IRuntimeArchive datatype.
    Eitherway I am using the IRuntimeArchive to develop my code and its kinda working.

    Thanks,

  4. #4
    Join Date
    02.02.2022
    Posts
    26

    Default Re: IArchive reference

    Hi!

    So, I am now able to see all archives of my projects and filter any variable.
    But I am not able to query the value list for a variable that have been inserted into the .arx file.

    Is this even posible via AddIn?

    Thnks in advanced as always,

  5. #5
    Join Date
    02.02.2022
    Posts
    26

    Default Re: IArchive reference

    Hi!

    This is my code, hope it helps to further understand my question.

    Thnxs
    Attached Thumbnails Attached Thumbnails Captura.PNG  

  6. #6
    Join Date
    18.12.2017
    Posts
    55

    Default Re: IArchive reference

    Hi!

    I think you want to apply the filter before reading values.

    Attached Thumbnails Attached Thumbnails filter.png  

  7. #7
    Join Date
    02.02.2022
    Posts
    26

    Default Re: IArchive reference

    Hi!

    Not working still. 
    I've tried to retrive the values using this new method showed on the image attached and applying the filter before but still null.



    Thxs,

    Attached Thumbnails Attached Thumbnails Captura2.PNG  

  8. #8
    Join Date
    18.12.2017
    Posts
    55

    Default Re: IArchive reference

    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!

  9. #9
    Join Date
    02.02.2022
    Posts
    26

    Default Re: IArchive reference

    Hi, I've used the code and it gets me to a similar place.

    Find attached a screenshot of a screen with the archive displayed to ensure that there is data stored and a screenshot of the addin debug where it is not existant. 

    Thnxs for the support,
    Attached Thumbnails Attached Thumbnails Captura3.PNG   Captura4.PNG  

  10. #10
    Join Date
    10.12.2007
    Posts
    280

    Default AW: Re: IArchive reference

    You missed this part:



    Code:
                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();





Similar Threads

  1. Passing variables to an array by reference
    By jesus_michel in forum Engineering Studio Logic & Logic Service (former zenon Logic Workbench & Runtime)
    Replies: 3
    Last Post: 27th February 2018, 18:23
  2. VBA macroses reference table
    By stolyarov_as in forum VBA
    Replies: 3
    Last Post: 30th October 2011, 23:47
  3. How to reference zenrt32.tbl in VS?
    By jens1199 in forum VSTA
    Replies: 5
    Last Post: 28th September 2010, 12:53
  4. Empty Cross Reference List
    By mastr in forum Engineering Studio & Service Engine (former zenon Editor & Runtime)
    Replies: 3
    Last Post: 2nd June 2009, 15:49

Posting Rules

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •