001/*----------------------------------------------------------------------------*/
002/* Copyright (c) FIRST 2016-2017. All Rights Reserved.                        */
003/* Open Source Software - may be modified and shared by FRC teams. The code   */
004/* must be accompanied by the FIRST BSD license file in the root directory of */
005/* the project.                                                               */
006/*----------------------------------------------------------------------------*/
007
008package edu.wpi.first.wpilibj;
009
010import edu.wpi.first.wpilibj.util.BaseSystemNotInitializedException;
011
012/**
013 * Support for high level usage reporting.
014 */
015@SuppressWarnings("JavadocMethod")
016public class HLUsageReporting {
017  private static Interface impl;
018
019  @SuppressWarnings("MethodName")
020  public static void SetImplementation(Interface implementation) {
021    impl = implementation;
022  }
023
024  public static void reportScheduler() {
025    if (impl != null) {
026      impl.reportScheduler();
027    } else {
028      throw new BaseSystemNotInitializedException(Interface.class, HLUsageReporting.class);
029    }
030  }
031
032  public static void reportPIDController(int num) {
033    if (impl != null) {
034      impl.reportPIDController(num);
035    } else {
036      throw new BaseSystemNotInitializedException(Interface.class, HLUsageReporting.class);
037    }
038  }
039
040  public static void reportSmartDashboard() {
041    if (impl != null) {
042      impl.reportSmartDashboard();
043    } else {
044      throw new BaseSystemNotInitializedException(Interface.class, HLUsageReporting.class);
045    }
046  }
047
048  public interface Interface {
049    void reportScheduler();
050
051    void reportPIDController(int num);
052
053    void reportSmartDashboard();
054  }
055
056  public static class Null implements Interface {
057    public void reportScheduler() {
058    }
059
060    @SuppressWarnings("PMD.UnusedFormalParameter")
061    public void reportPIDController(int num) {
062    }
063
064    public void reportSmartDashboard() {
065    }
066  }
067}