com.gtosoft.libvoyager.util
Class NetworkStats

java.lang.Object
  extended by com.gtosoft.libvoyager.util.NetworkStats

public class NetworkStats
extends java.lang.Object


Constructor Summary
NetworkStats(DashDB ddb)
           
 
Method Summary
 java.lang.String getDataByHeader(java.lang.String header)
          Returns the most recent data bytes stored for the given header If no data is being held for the given header, we return a blank string NOT null.
 java.lang.String getIDList()
           
 java.util.Set<java.lang.String> getIDSet()
           
 long getIntervalDuration()
           
 java.util.Set<java.lang.String> getNodeAddressList()
          Goes to the internal store of PIDs (collected during passive mode) and extracts the set of nodes that are transmitting "COMM ACTIVE" signals.
static java.lang.String getNodeTypeByAddress(java.lang.String nodeAddress)
           
 long getNumMessagesProcessed()
           
 long getPIDAge(java.lang.String PIDWithSigs)
          Returns the number of seconds that have elapsed since the given PIDwithSigs was seen.
 long getPIDChangeRate(java.lang.String header)
          Returns the rate of change (changes per minute) for the given header.
 int getPIDCount()
          Returns the number of PIDs which we've managed to set data for.
 long getPIDsPerMinute()
          Returns the number of PIDs being processed per minute.
 long getPIDTransmitRate(java.lang.String header)
           
 GeneralStats getStats()
           
 java.lang.String getStatsString()
           
 long getTimeSinceLastNewPID()
           
 boolean mkdir(java.lang.String directory)
          Create the specified directory (the last part of the path only, not the whole tree).
 boolean setLogging(boolean trueOrFalse)
          controls whether we'll be logging packets to file or not.
 void setPidChangeLogThreshold(int logIfLessThanThisNumChangesPerMin)
           
 void setPIDDataByHeader(java.lang.String header, java.lang.String newData)
          THIS METHOD IS THE ENTRYPOINT FOR DATA INTO THE NETWORKSTATS CLASS.
 java.util.LinkedHashMap<java.lang.String,java.lang.Double> sortHashMapByValuesD(java.util.HashMap<java.lang.String,java.lang.Double> passedMap)
           
 java.lang.String startMonitorSession()
           
 long stopMonitorSession()
          stops logging monitor session data to the DB by setting a global variable that the event handler sees and stops using.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NetworkStats

public NetworkStats(DashDB ddb)
Method Detail

mkdir

public boolean mkdir(java.lang.String directory)
Create the specified directory (the last part of the path only, not the whole tree).

Parameters:
directory - - directory, for example: /sdcard/Dash
Returns:
- returns true on success, false otherwise.

setLogging

public boolean setLogging(boolean trueOrFalse)
controls whether we'll be logging packets to file or not.

Parameters:
trueOrFalse - - set to true if you want to log packets to the sdcard.
Returns:

setPIDDataByHeader

public void setPIDDataByHeader(java.lang.String header,
                               java.lang.String newData)
THIS METHOD IS THE ENTRYPOINT FOR DATA INTO THE NETWORKSTATS CLASS. Sets the current data point for a given PID and also updates variables for stats. This method is called by the entrypoint method as soon as the header and data parts are separated.

Parameters:
pid - - PID of the data point
data - - Data payload for the given PID.

getTimeSinceLastNewPID

public long getTimeSinceLastNewPID()
Returns:
- returns the number of seconds since a new PID was seen.

getPIDAge

public long getPIDAge(java.lang.String PIDWithSigs)
Returns the number of seconds that have elapsed since the given PIDwithSigs was seen.

Parameters:
PIDWithSigs - - the PID and any significant data bytes as defined in the dataPoint table of the Dash DB.
Returns:
- returns number of seconds.

getIntervalDuration

public long getIntervalDuration()

getPIDsPerMinute

public long getPIDsPerMinute()
Returns the number of PIDs being processed per minute.

Returns:
- number PIDs we're processing per minute, according to the current stats.

getNodeAddressList

public java.util.Set<java.lang.String> getNodeAddressList()
Goes to the internal store of PIDs (collected during passive mode) and extracts the set of nodes that are transmitting "COMM ACTIVE" signals.

Returns:
- returns a set wich each entry containing a single string representation of a node's address.

getStatsString

public java.lang.String getStatsString()

getPIDChangeRate

public long getPIDChangeRate(java.lang.String header)
Returns the rate of change (changes per minute) for the given header.

Parameters:
header -
Returns:
- returns the number of changes per minute.

getPIDTransmitRate

public long getPIDTransmitRate(java.lang.String header)
Parameters:
header -
Returns:
- returns the rate (in transmits per minute) at which this PID is transmitted, assuming no packet loss.

getPIDCount

public int getPIDCount()
Returns the number of PIDs which we've managed to set data for.

Returns:

getNumMessagesProcessed

public long getNumMessagesProcessed()

startMonitorSession

public java.lang.String startMonitorSession()
Parameters:
secondsToSettleIn -
Returns:
- returns the newly created monitor session ID associated with all packets captured.

stopMonitorSession

public long stopMonitorSession()
stops logging monitor session data to the DB by setting a global variable that the event handler sees and stops using.

Returns:
- returns the number of messages processed during the monitor interval.

getNodeTypeByAddress

public static java.lang.String getNodeTypeByAddress(java.lang.String nodeAddress)

setPidChangeLogThreshold

public void setPidChangeLogThreshold(int logIfLessThanThisNumChangesPerMin)

getDataByHeader

public java.lang.String getDataByHeader(java.lang.String header)
Returns the most recent data bytes stored for the given header If no data is being held for the given header, we return a blank string NOT null.

Parameters:
header -
Returns:
- returns up to 8 hex data bytes as a string.

getStats

public GeneralStats getStats()

getIDList

public java.lang.String getIDList()
Returns:
- returns a list of PIDs, preferribly sorted from most frequently transmitted, to least frequent.

getIDSet

public java.util.Set<java.lang.String> getIDSet()
Returns:
- returns a (newly allocated) Set of CAN IDs which we have observed thus far. We allocate a new set for you so that there's no chance of a concurrent read/modification exception while you're accsesing the set.

sortHashMapByValuesD

public java.util.LinkedHashMap<java.lang.String,java.lang.Double> sortHashMapByValuesD(java.util.HashMap<java.lang.String,java.lang.Double> passedMap)