Class AvaStatisticsManagerComponent

java.lang.Object
edu.tufts.hrilab.diarc.DiarcComponent
edu.tufts.hrilab.ava.stats.AvaStatisticsManagerComponent

public class AvaStatisticsManagerComponent extends DiarcComponent
  • Field Details

  • Constructor Details

    • AvaStatisticsManagerComponent

      public AvaStatisticsManagerComponent()
  • Method Details

    • init

      protected void init()
      Description copied from class: DiarcComponent
      Perform any component initialization. This should not be used for setting local fields to default values as was the case in DIARC. This method is called after the constructor, and after parseArgs. Setting default values should be done in field declaration or in the constructor.
      Overrides:
      init in class DiarcComponent
    • postRegistrationInit

      protected void postRegistrationInit()
      Overrides:
      postRegistrationInit in class DiarcComponent
    • onGoalManagerRegistrationAvailable

      public void onGoalManagerRegistrationAvailable(ai.thinkingrobots.trade.TRADEServiceInfo registerService) throws ai.thinkingrobots.trade.TRADEException
      Called by TRADE when registerGoalManagerNotification becomes available (now or when joined). Registers our callback for GOAL_STATUS_CHANGE notifications.
      Throws:
      ai.thinkingrobots.trade.TRADEException
    • avaStatisticsGoalNotification

      public void avaStatisticsGoalNotification(GoalInfo info) throws ai.thinkingrobots.trade.TRADEException
      TRADE service name is unique so GoalViewerAdapter.getAvailableService("handleGoalNotification") stays unique.
      Throws:
      ai.thinkingrobots.trade.TRADEException
    • registerAvaStatisticsCallback

      public void registerAvaStatisticsCallback(ai.thinkingrobots.trade.TRADEServiceInfo service)
    • recordAvaStatisticsEvent

      public void recordAvaStatisticsEvent(AvaStatisticsEvent event)
      Records an event to the statistics CSV. Any component (e.g. AvaDisplayComponent) can call this to log MEDIA_PLAYBACK or other events without registering with AvaComponent.
    • onAvaStatisticsEvent

      public void onAvaStatisticsEvent(AvaStatisticsEvent event)
    • getAvailableStatisticIds

      public List<String> getAvailableStatisticIds()
      Returns statistic IDs in display order (option 1, 2, ... for list+option flow), grouped by category so ASL can list by section.
    • getCategoryNamesInOrder

      public List<String> getCategoryNamesInOrder()
      Category names in the order they should be announced (Mobility, Goals, Battery, Media).
    • getStatisticIdsInCategory

      public List<String> getStatisticIdsInCategory(String category)
      Statistic IDs in the given category (for grouped listing).
    • getStatisticDisplayName

      public String getStatisticDisplayName(String statisticId)
    • createStatisticValueTerm

      public Symbol createStatisticValueTerm(String statisticId, double value)
      Builds the value term for a statistic report: duration(...) for time_off_dock, distance(value, meters) for distance_traveled, count(N) for counts. Matches AVA patterns (period(number, timeUnit), etc.).
    • createStatisticsReportPredicate

      public Predicate createStatisticsReportPredicate(String statisticId, String startDateStr, String endDateStr, double value)
      Builds the full statisticsReport predicate for the language system: statisticsReport(statId, startDate, endDate, valueTerm) with valueTerm as a structured predicate (duration(...), distance(...), count(...)).
    • createStatisticsReportPredicateWithValueTerm

      public Predicate createStatisticsReportPredicateWithValueTerm(String statisticId, String startDateStr, String endDateStr, Symbol valueTerm)
      Builds statisticsReport with an arbitrary value term (e.g. mostFailedGoals(goal1, goal2, count(N)) for ties; last arg is always count). Use so RR can resolve refs inside the value term when generateResponse(predicate) is used.
    • getStatisticsReportPredicate

      public Predicate getStatisticsReportPredicate(String statisticId, long startMs, long endMs, String startDateStr, String endDateStr)
      Returns the report predicate for the given statistic over the period, for use with generateResponse. For numeric stats: queries the value and builds the report predicate. For drill-down/location stats: builds the report predicate from aggregated data. Returns null if no data for that statistic in that period.
    • parseDateToStartMs

      public long parseDateToStartMs(String dateStr)
      Parses a date string (YYYY-MM-DD) to start-of-day epoch ms in system default timezone. Inclusive start for analysis period.
    • parseDateToEndMs

      public long parseDateToEndMs(String dateStr)
      Parses a date string (YYYY-MM-DD) to end-of-day epoch ms in system default timezone. Inclusive end for analysis period.
    • queryStatistics

      public double queryStatistics(String statisticId, long startMs, long endMs)
      Queries the statistics CSV for the given statistic over [startMs, endMs] (inclusive). Returns a numeric value: counts as whole number (e.g. 10.0), time off dock in minutes, distance in meters, average battery 0-100, media playback in minutes.
    • getMostFailedGoalReport

      public Predicate getMostFailedGoalReport(long startMs, long endMs, String startDateStr, String endDateStr)
    • getLeastFailedGoalReport

      public Predicate getLeastFailedGoalReport(long startMs, long endMs, String startDateStr, String endDateStr)
    • getMostCanceledGoalReport

      public Predicate getMostCanceledGoalReport(long startMs, long endMs, String startDateStr, String endDateStr)
    • getMostVisitedLocationReport

      public Predicate getMostVisitedLocationReport(long startMs, long endMs, String startDateStr, String endDateStr)
    • getLocationsVisitedCountReport

      public Predicate getLocationsVisitedCountReport(long startMs, long endMs, String startDateStr, String endDateStr)
    • getMostFrequentEscortDestinationReport

      public Predicate getMostFrequentEscortDestinationReport(long startMs, long endMs, String startDateStr, String endDateStr)