Package dataMap

Class OfflineDataMap<TmapPoint extends OfflineDataMapPoint>

java.lang.Object
dataMap.OfflineDataMap<TmapPoint>
Direct Known Subclasses:
BinaryOfflineDataMap, DBOfflineDataMap, OfflineFileDataMap, TideManager.TideDataMap, WavFileDataMap

public abstract class OfflineDataMap<TmapPoint extends OfflineDataMapPoint> extends Object
Class which get's held within a PamDataBlock which provides summary information on data within that block when operating in viewer mode.

It is possible that some datablocks may own two of these things - one for database data and one for binary stored data.

Author:
Doug Gillespie
  • Field Details

  • Constructor Details

  • Method Details

    • getListIterator

      public Iterator<TmapPoint> getListIterator()
      Get an iterator over the map contents.

      Objects using this iterator should synchronise on the map object first.

      Returns:
      an iterator over the map contents.
    • getParentDataBlock

      public PamDataBlock getParentDataBlock()
      Returns:
      the parentDataBlock
    • setParentDataBlock

      public void setParentDataBlock(PamDataBlock parentDataBlock)
      Parameters:
      parentDataBlock - the parentDataBlock to set
    • clear

      public void clear()
      Clear the data map.
    • castMapPoint

      public TmapPoint castMapPoint(OfflineDataMapPoint mapPoint)
      This is an annoying little function that will cast data map points created in the offline file servers, which also use types but because they are constructed differently, the two classes don't realise they have the same type.
      Parameters:
      mapPoint -
      Returns:
      cast map point (throw exception if not possible)
    • addDataPoint

      public void addDataPoint(TmapPoint mapPoint)
      Add a new map point into the list.
      Parameters:
      mapPoint - new map point to add
    • getNumMapPoints

      public int getNumMapPoints()
      Returns:
      the total number of map points.
    • getNumMapPoints

      public int getNumMapPoints(long firstTime, long endTime)
      Get the number of map points AFTER or INCLUDING a given time
      Parameters:
      firstTime - time to start search.
      Returns:
      number of map points
    • sortMapPoints

      public void sortMapPoints()
      Sort all map points into ascending order based on start time.

      this should be called after all data have been loaded.

    • removeDuplicates

      public int removeDuplicates()
      Needed to sort out some damaged binary data maps which are corrupted by being opened in viewer while data still writing.
    • getDataMapName

      public String getDataMapName()
      Get the name of the data map - will default to the name of the underlying data store
      Returns:
      datamap name
    • sortRanges

      public void sortRanges()
      Called after de-serailisation of a data map so that the min and max times stored in this object (which is not serialised can be extracted from the list of data which WAS serialised.
    • getFirstDataTime

      public long getFirstDataTime()
      Returns:
      the firstDataTime
    • setFirstDataTime

      public void setFirstDataTime(long firstDataTime)
      Parameters:
      firstDataTime - the firstDataTime to set
    • getLastDataTime

      public long getLastDataTime()
      Returns:
      the lastDataTime
    • setLastDataTime

      public void setLastDataTime(long lastDataTime)
      Parameters:
      lastDataTime - the lastDataTime to set
    • getDataCount

      public int getDataCount()
      Returns:
      The total amount of data available.
    • getHighestPoint

      public double getHighestPoint(int vScaleType)
      Return the highest point on the map using the given scale
      Parameters:
      vScaleType - scale type
      Returns:
      the highest data value.
    • getMapStartTime

      public long getMapStartTime()
      Get the start time of the first datamap point or Long.minval
      Returns:
    • getMapEndTime

      public long getMapEndTime()
      Get the start time of the first datamap point or Long.minval
      Returns:
    • getLowestPoint

      public double getLowestPoint(int vScaleType)
      Returns:
      the lowestPoint
    • getLowestNonZeroPoint

      public double getLowestNonZeroPoint(int vScaleType)
      Returns:
      the lowestNonZeroPoint
    • scaleData

      public static double scaleData(double count, long duration, int scaleType)
    • getOfflineDataSource

      public OfflineDataStore getOfflineDataSource()
      Returns:
      the offlineDataSource
    • getSpecialDrawing

      public DataMapDrawing getSpecialDrawing()
      Returns:
      the specialDrawing
    • setSpecialDrawing

      public void setSpecialDrawing(DataMapDrawing specialDrawing)
      Parameters:
      specialDrawing - the specialDrawing to set
    • isInGap

      public int isInGap(long timeMillis)
      Work out where the time is within a map.
      Parameters:
      timeMillis - time
      Returns:
      integer field. one or more of

      NO_DATA

      BEFORE_FIRST

      AFTER_LAST

      POINT_START

      POINT_END

      IN_GAP

      IN_DATA

    • findMapPoint

      public TmapPoint findMapPoint(long timeMillis)
      find a map point for a given time in milliseconds
      Parameters:
      timeMillis - time in milliseconds
      Returns:
      a map point or null if none found.
    • getNextDataStart

      public long getNextDataStart(long timeMillis)
      Get the next data start point. i.e. the time of the start of a map point which is > timeMillis
      Parameters:
      timeMillis - current time in milliseconds
      Returns:
      start time of the next data start.
    • getPrevDataEnd

      public long getPrevDataEnd(long timeMillis)
      Get the previous data end point. i.e. the time of the end of a map point which is invalid input: '<' timeMillis
      Parameters:
      timeMillis - current time in milliseconds
      Returns:
      start time of the next data start.
    • getMapPoints

      public List<TmapPoint> getMapPoints()
      Returns:
      the mapPoints
    • getMapPoints

      public List<TmapPoint> getMapPoints(long dataStart, long dataEnd)
      Get a list of map points that cover the given times
      Parameters:
      dataStart - start time
      dataEnd - end time
      Returns:
      a list or null
    • getRootlessMapPoints

      public List<TmapPoint> getRootlessMapPoints()
    • setMapPoints

      public void setMapPoints(List<TmapPoint> mapPoints)
      Parameters:
      mapPoints - the mapPoints to set
    • compareLists

      public void compareLists(List<TmapPoint> list1, List<TmapPoint> list2)
      Compare two map point lists and see which of list1 are in list 2 and which of list 2 are in list 1. Assumes that both lists are sorted and that start times are unique.
      Parameters:
      list1 -
      list2 -
    • getLowestUID

      public Long getLowestUID()
      Returns:
      the lowestUID
    • setLowestUID

      public void setLowestUID(Long lowestUID)
      Parameters:
      lowestUID - the lowestUID to set
    • getHighestUID

      public Long getHighestUID()
      Returns:
      the highestUID
    • setHighestUID

      public void setHighestUID(Long highestUID)
      Parameters:
      highestUID - the highestUID to set
    • getMissingUIDs

      public long getMissingUIDs()
      Returns:
      the missingUIDs
    • setMissingUIDs

      public void setMissingUIDs(long missingUIDs)
      Parameters:
      missingUIDs - the missingUIDs to set
    • getLastMapPoint

      public TmapPoint getLastMapPoint()
    • newPamDataUnit

      public TmapPoint newPamDataUnit(PamDataUnit pamDataUnit)
      Called when new (not reloaded) data are added to a datablock so that the data map can update.
      Parameters:
      pamDataUnit -
      Returns:
      current data map point
    • updatedPamDataUnit

      public TmapPoint updatedPamDataUnit(PamDataUnit pamDataUnit)
      Called when new (not reloaded) data are updated in a datablock so that the data map can update.
      Parameters:
      pamDataUnit -
      Returns:
      current data map point
    • addDataMapObserver

      public void addDataMapObserver(DataMapObserver dataMapObserver)
      Add a data map observer to get notificatoins when data are updated.
      Parameters:
      dataMapObserver -
    • notifyMapObservers

      public void notifyMapObservers(OfflineDataMapPoint mapPoint)
      Notify datamap observers that a data point has changed / been added, etc.
      Parameters:
      mapPoint -
    • checkOverlaps

      public ArrayList<MapOverlap> checkOverlaps()
      Check to see if any data maps overlap in time.
      Returns:
      list of overlaps.