Showing results 1 to 3 of 3

Thread: Problem with archives in VBA

  1. #1
    nblanquart Gast

    Default Problem with archives in VBA


    I'm trying to display a graph, using an archive. The values and the date come from an Oracle database and must be displayed at the right time.
    Everything seems to work, except the ApplyChanges

    Public Sub ModifyArchive()
    Dim obArchive               As Archive
    Dim obArchiveVariable       As ArchiveVariable
    Dim obArchiveFilter         As ArchiveFilter
    Dim obArchiveFilterVariable As ArchiveFilterVariable
    Dim obArchiveValues         As ArchiveValues
    Dim vStart                  As Variant               'Filter start time...
    Dim vEnd                    As Variant               'Filter end time...
    Dim idx                     As Integer
    On Error GoTo err:
    Set obArchive = thisProject.Archives.Item("COURBE_PREV_67")
    Set obArchiveVariable = obArchive.ArchiveVariables.Item(0)
    Set obArchiveFilter = obArchive.ArchiveFilters.CreateArchiveFilter
    StartDate = "01/09/2009 00:00:00"
    EndDate = "01/09/2029 00:00:00"
    vStart = DateDiff("s", vDateRef, StartDate)
    vEnd = DateDiff("s", vDateRef, EndDate)
    obArchiveFilter.StartTime = vStart
    obArchiveFilter.endTime = vEnd
    'SPONT state
    obArchiveFilter.StatusBit = &HFFFFFFFF
    obArchiveFilter.StatusMask = Not &H40000
    obArchiveFilter.AddArchiveVariable obArchiveVariable
    Set obArchiveFilterVariable = obArchiveFilter.ArchiveFilterVariables.Item(0)
    Set obArchiveValues = obArchiveFilterVariable.ArchiveValues
    ' obArchiveValues contains the current values from the archive
    ' we replace these values with the CurveArray vector values
    For idx = 0 To nbValues - 1
        obArchiveValues.Item(idx).Time = dateUTC(TimeArray(idx))
        obArchiveValues.Item(idx).Value = CurveArray(idx)
    Next idx
    Set obArchiveFilterVariable = Nothing
    Set obArchiveVariable = Nothing
    Set obArchiveValues = Nothing
    Set obArchive = Nothing
    End Sub

    Thanks if you can fix this problem!

  2. #2
    Join Date

    Default Re: Problem with archives in VBA

    Values can be written (modified/added) into an archive if an archive file does exists for the given time.

    - which archive scanning type is configured? (spontaneous?)
    - can you add archive values via the the picture type "archive revision" for the given time? (use the "paste" function/button)

    If archive values can be added via standard functions it is then also possible via VBA (as far as I can see your VBA code should be ok).


  3. #3

    Default Re: Problem with archives in VBA

    please note, that it may not always be possible to change / add a value into an archive which is still running.

Similar Threads

  1. Archives (RT) - Read batch information
    By herberto in forum VBA
    Replies: 4
    Last Post: 25th July 2011, 14:09
  2. Condensed (following) archives
    By markclemens in forum zenon Service Engine Supervisor
    Replies: 0
    Last Post: 14th September 2007, 07:30

Posting Rules

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