Logic of archiveMask

Forum Home Forums Development and Integration Logic of archiveMask

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #15376
    showmustgoon
    Participant

    I need to customize an event that supports both real-time and historical queries. If I add a new type in the Archives table in sequence and ensure that the archiveMask covers that bit when calling WriteEvent, will that work? I’m not entirely sure if this is the best implementation.

    I’m uncertain about the calculation rules of archiveMask. Is it calculated based on the sequential order of entries in the Archives table? So, does this mean that the Archives table can cover up to 32 entries at most? Is my understanding correct?

    #15378
    manjey73
    Participant

    Yes, the number of bits is limited for archives and events. But you can create the necessary ones yourself from the code, only the code should do checks when creating, since the code that you assume may be occupied by another or has already been created.

    #15382
    showmustgoon
    Participant

    And…..archiveBit?
    I just noticed that when writing an Event, archiveMask is used, but when getting Event, archiveBit is used. This should be the reason why I can’t read the events I wrote. I am now tracking the logic of archiveBit.

    #15383
    showmustgoon
    Participant

    I think I finally figured it out.
    When writing, it’s possible to write to multiple archives simultaneously, so using a mask is appropriate.
    However, when reading, you can only read from a single archive, so a bit is used.
    Additionally, I made another mistake: I used the maximum and minimum values of DateTime as parameters for TimeRange, which caused an overflow.

    My test code is as follows, and the archiveMask and archiveBit used for writing and reading correspond to each other.

    
    if (DateTime.Now-LastTime>=TimeSpan.FromSeconds(10))
            {
                LastTime=DateTime.Now;
                ServerContext.WriteEvent(16,new Event
                {
                    Timestamp = DateTime.UtcNow,
                    CnlNum = 1,
                     DeviceNum = 1,
                    CnlVal = 11,
                     CnlStat = CnlStatusID.Defined,
                    Text = "123321",
                    Data = new byte[]
                    {0x00,0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09 },
                    // Position = 0
                });
               var r= ServerContext.GetEvents(4, new TimeRange(DateTime.Today.AddDays(-2),DateTime.Today.AddDays(2), true), null);
               Log.WriteMessage($"Custom Events{r.Count},{string.Join(",",r.Select(x=>x.Timestamp))}",LogMessageType.Info);
            }
    
    #15391
    Mikhail
    Moderator

    When writing, it’s possible to write to multiple archives simultaneously, so using a mask is appropriate.
    However, when reading, you can only read from a single archive, so a bit is used.

    Correct.
    Also check the ArchiveMask class.

    #15392
    Mikhail
    Moderator

    So, does this mean that the Archives table can cover up to 32 entries at most?

    31, because the archive mask is signed integer.

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.