Package com.ed.data.history
Class ADataItem
java.lang.Object
com.ed.data.history.ADataItem
- Direct Known Subclasses:
DayDataItem
,HourDataItem
,MonthDataItem
,YearDataItem
Basis class for all history data types
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionabstract int
Compare datesboolean
byte[]
Get raw bytesint
getId()
Get IDabstract ADataItem
getInstance
(byte[] b) Factory, create objectabstract ADataItem
getInstance
(Date d) Factory, create empty objectstatic short
getS16Value
(byte[] ba, int ix) Read signed 16 bit value from byte arraystatic int
getS32Value
(byte[] ba, int ix) Read signed 32 bit value from byte arraystatic byte
getS8Value
(byte[] ba, int ix) Read signed 8 bit value from byte arrayabstract String
Get data block namegetTime()
Get data block timelong
Get data block timeabstract long
getTsEnd()
Get end of current time periodabstract long
Get start of current time periodstatic int
getU16Value
(byte[] ba, int ix) Read unsigned 16 bit value from byte arraystatic long
getU32Value
(byte[] ba, int ix) Read unsigned 16 bit value from byte arraystatic short
getU8Value
(byte[] ba, int ix) Read unsigned 8 bit value from byte arrayprotected final void
initDataItem
(byte[] ba) Load data from byte arrayboolean
isValid()
Check data block consistency (CS)static float
qXToFloat
(long qx, int fractBitsCnt, float fMax) Fixed point format conversionabstract Date
setNextTimePeriod
(int amount) Add timetoString()
static void
writeCs
(byte[] ba) Write valid check sum (byte 2 and 3)
-
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
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
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
Get data block name- Returns:
- name
-
getInstance
Factory, create object- Parameters:
b
- raw data- Returns:
- current data item
-
getInstance
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
Get data block time- Returns:
- data block time stamp
-
equals
-
toString
-
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, QxfractBitsCnt
- fractional part bit countfMax
- maximal value- Returns:
- floating point value
-
getS8Value
Read signed 8 bit value from byte array- Parameters:
ba
- input byte arrayix
- start index- Returns:
- value
- Throws:
Exception
- Index Out Of Bounds
-
getU8Value
Read unsigned 8 bit value from byte array- Parameters:
ba
- input byte arrayix
- start index- Returns:
- value
- Throws:
Exception
- Index Out Of Bounds
-
getS16Value
Read signed 16 bit value from byte array- Parameters:
ba
- input byte arrayix
- start index- Returns:
- value
- Throws:
Exception
- Index Out Of Bounds
-
getU16Value
Read unsigned 16 bit value from byte array- Parameters:
ba
- input byte arrayix
- start index- Returns:
- value
- Throws:
Exception
- Index Out Of Bounds
-
getS32Value
Read signed 32 bit value from byte array- Parameters:
ba
- input byte arrayix
- start index- Returns:
- value
- Throws:
Exception
- Index Out Of Bounds
-
getU32Value
Read unsigned 16 bit value from byte array- Parameters:
ba
- input byte arrayix
- 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
-