Class ADataItem

java.lang.Object
com.ed.data.history.ADataItem
Direct Known Subclasses:
DayDataItem, HourDataItem, MonthDataItem, YearDataItem

public abstract class ADataItem extends Object
Basis class for all history data types
  • Constructor Details

    • ADataItem

      public ADataItem()
  • Method Details

    • initDataItem

      protected final void initDataItem(byte[] ba)
      Load data from byte array
      Parameters:
      ba - raw bytes (embedded data format)
    • compareTo

      public abstract int compareTo(Date t)
      Compare dates
      Parameters:
      t - Date to compare with data block time stamp
      Returns:
      0 - same time period, -1 - parameter is older than current data block 1 - parameter is younger than current data block
    • setNextTimePeriod

      public abstract Date setNextTimePeriod(int amount)
      Add time
      Parameters:
      amount - of time periods to add
      Returns:
      new date
    • getTsStart

      public abstract long getTsStart()
      Get start of current time period
      Returns:
      time period start, time stamp [ms]
    • getTsEnd

      public abstract long getTsEnd()
      Get end of current time period
      Returns:
      time period start, time stamp [ms]
    • getTabName

      public abstract String getTabName()
      Get data block name
      Returns:
      name
    • getInstance

      public abstract ADataItem getInstance(byte[] b)
      Factory, create object
      Parameters:
      b - raw data
      Returns:
      current data item
    • getInstance

      public abstract ADataItem getInstance(Date d)
      Factory, create empty object
      Parameters:
      d - by time
      Returns:
      current data item
    • isValid

      public boolean isValid()
      Check data block consistency (CS)
      Returns:
      true if data block consistent
    • getId

      public int getId()
      Get ID
      Returns:
      data block id (embedded ring buffer index)
    • getTimestamp

      public long getTimestamp()
      Get data block time
      Returns:
      data block time stamp [ms]
    • getTime

      public Date getTime()
      Get data block time
      Returns:
      data block time stamp
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getDlByts

      public byte[] getDlByts()
      Get raw bytes
      Returns:
      raw bytes
    • qXToFloat

      public static float qXToFloat(long qx, int fractBitsCnt, float fMax)
      Fixed point format conversion
      Parameters:
      qx - fixed point value, Qx
      fractBitsCnt - fractional part bit count
      fMax - maximal value
      Returns:
      floating point value
    • getS8Value

      public static byte getS8Value(byte[] ba, int ix) throws Exception
      Read signed 8 bit value from byte array
      Parameters:
      ba - input byte array
      ix - start index
      Returns:
      value
      Throws:
      Exception - Index Out Of Bounds
    • getU8Value

      public static short getU8Value(byte[] ba, int ix) throws Exception
      Read unsigned 8 bit value from byte array
      Parameters:
      ba - input byte array
      ix - start index
      Returns:
      value
      Throws:
      Exception - Index Out Of Bounds
    • getS16Value

      public static short getS16Value(byte[] ba, int ix) throws Exception
      Read signed 16 bit value from byte array
      Parameters:
      ba - input byte array
      ix - start index
      Returns:
      value
      Throws:
      Exception - Index Out Of Bounds
    • getU16Value

      public static int getU16Value(byte[] ba, int ix) throws Exception
      Read unsigned 16 bit value from byte array
      Parameters:
      ba - input byte array
      ix - start index
      Returns:
      value
      Throws:
      Exception - Index Out Of Bounds
    • getS32Value

      public static int getS32Value(byte[] ba, int ix) throws Exception
      Read signed 32 bit value from byte array
      Parameters:
      ba - input byte array
      ix - start index
      Returns:
      value
      Throws:
      Exception - Index Out Of Bounds
    • getU32Value

      public static long getU32Value(byte[] ba, int ix) throws Exception
      Read unsigned 16 bit value from byte array
      Parameters:
      ba - input byte array
      ix - start index
      Returns:
      value
      Throws:
      Exception - Index Out Of Bounds
    • writeCs

      public static void writeCs(byte[] ba)
      Write valid check sum (byte 2 and 3)
      Parameters:
      ba - destination byte buffer