Options
All
  • Public
  • Public/Protected
  • All
Menu

This class assigns UTC dates to readings based on their sequential reading ID and local time.

Internally it works based on the following principle. It knows that the sequential reading ID is monotonically increasing but the local time can reset to 0 every time there is a timeBreak in the data (e.g. the device reboots). So it constructs a series of TimeSegments which are ranges of reading IDs where there are not breaks. This means that each break ends the previous segment and starts the next segment.

Inside each segment there needs to be at least one anchor point where the UTC time and local time are both known. Once there is an anchor point in a given segment, all other readings in that segment can be assigned UTC times by looking at their local time offset from the anchor point.

If allowImprecise is passed, this class should still try to assign a UTC time to a reading even if it occurs in a segment with no anchor points by finding the first subsequent segment that does have an anchor point and back-calculating from there assuming that all breaks between segments were infinitely short.

Hierarchy

  • UTCAssigner

Index

Constructors

constructor

Properties

Private addedIDSet

addedIDSet: object

Type declaration

  • [key: number]: boolean

Private anchorPoints

anchorPoints: AnchorPoint[]

Private anchorPointsSorted

anchorPointsSorted: boolean

Private anchorStreams

anchorStreams: object

Type declaration

Private breakStreams

breakStreams: object

Type declaration

  • [key: number]: boolean

Private imprecise

imprecise: boolean

Private logger

logger: Category

Methods

addAnchorPoint

  • addAnchorPoint(readingID: number, uptime: number | null, utc: Date | null, isBreak?: boolean): void
  • Parameters

    • readingID: number
    • uptime: number | null
    • utc: Date | null
    • Default value isBreak: boolean = false

    Returns void

addAnchorsFromReport

addReading

assignUTCTimestamp

  • assignUTCTimestamp(readingID: number, uptime: number | null): Date
  • Assign a UTC date to a reading based on all previously added anchor and break points. If a UTC time cannot be assigned because there is insufficient data or because one of the options passed to the constructor does not allow it, throw an ArgumentError.

    Parameters

    • readingID: number
    • uptime: number | null

    Returns Date

Private bisectLeftAnchors

  • bisectLeftAnchors(readingID: number): number

Private ensureAnchorPointsSorted

  • ensureAnchorPointsSorted(): void

Private initBreakStreams

  • initBreakStreams(): void

markAnchorStream

  • Inform the UTCAssigner that whenever it sees a value in the given stream, it can infer that its value is explicitly a UTC timestamp. This allows the UTCAssigner to automatically call addAnchorPoint when it processes a streamer report that contains streams that could act as anchors.

    If the value of the stream cannot be directly interpreted as the number of seconds since the year 2000, you can pass an optional callable that will be called to determine the correct UTC timestamp.

    You can pass a literal string "rtc" or "epoch" for valueProcessor if you want the value to be treated as seconds since 1/1/2000 or seconds since 1/1/1970 respectively.

    Alternatively, you can pass a function that returns a Date.

    Parameters

    Returns void

Legend

  • Module
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Index signature
  • Type alias
  • Enumeration
  • Enumeration member
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Constructor
  • Property
  • Method
  • Index signature
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Accessor
  • Index signature
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Protected property
  • Protected method
  • Protected accessor
  • Private property
  • Private method
  • Private accessor
  • Static property
  • Static method

Generated using TypeDoc