001 /*----------------------------------------------------------------------------*/ 002 /* Copyright (c) FIRST 2008-2012. 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 008 package edu.wpi.first.wpilibj.communication; 009 010 import com.sun.cldc.jna.Function; 011 import com.sun.cldc.jna.NativeLibrary; 012 import com.sun.cldc.jna.Pointer; 013 014 /** 015 * 016 * @author mwills 017 */ 018 public final class UsageReporting { 019 020 private UsageReporting() { 021 } 022 //reporting version 023 public static final int kUsageReporting_version = 1; 024 //resources 025 public static final int kResourceType_Controller = 0; 026 public static final int kResourceType_Module = 1; 027 public static final int kResourceType_Language = 2; 028 public static final int kResourceType_CANPlugin = 3; 029 public static final int kResourceType_Accelerometer = 4; 030 public static final int kResourceType_ADXL345 = 5; 031 public static final int kResourceType_AnalogChannel = 6; 032 public static final int kResourceType_AnalogTrigger = 7; 033 public static final int kResourceType_AnalogTriggerOutput = 8; 034 public static final int kResourceType_CANJaguar = 9; 035 public static final int kResourceType_Compressor = 10; 036 public static final int kResourceType_Counter = 11; 037 public static final int kResourceType_Dashboard = 12; 038 public static final int kResourceType_DigitalInput = 13; 039 public static final int kResourceType_DigitalOutput = 14; 040 public static final int kResourceType_DriverStationCIO = 15; 041 public static final int kResourceType_DriverStationEIO = 16; 042 public static final int kResourceType_DriverStationLCD = 17; 043 public static final int kResourceType_Encoder = 18; 044 public static final int kResourceType_GearTooth = 19; 045 public static final int kResourceType_Gyro = 20; 046 public static final int kResourceType_I2C = 21; 047 public static final int kResourceType_Framework = 22; 048 public static final int kResourceType_Jaguar = 23; 049 public static final int kResourceType_Joystick = 24; 050 public static final int kResourceType_Kinect = 25; 051 public static final int kResourceType_KinectStick = 26; 052 public static final int kResourceType_PIDController = 27; 053 public static final int kResourceType_Preferences = 28; 054 public static final int kResourceType_PWM = 29; 055 public static final int kResourceType_Relay = 30; 056 public static final int kResourceType_RobotDrive = 31; 057 public static final int kResourceType_SerialPort = 32; 058 public static final int kResourceType_Servo = 33; 059 public static final int kResourceType_Solenoid = 34; 060 public static final int kResourceType_SPI = 35; 061 public static final int kResourceType_Task = 36; 062 public static final int kResourceType_Ultrasonic = 37; 063 public static final int kResourceType_Victor = 38; 064 public static final int kResourceType_Button = 39; 065 public static final int kResourceType_Command = 40; 066 public static final int kResourceType_AxisCamera = 41; 067 public static final int kResourceType_PCVideoServer = 42; 068 public static final int kResourceType_SmartDashboard = 43; 069 public static final int kResourceType_Talon = 44; 070 public static final int kResourceType_HiTechnicColorSensor = 45; 071 public static final int kResourceType_HiTechnicAccel = 46; 072 public static final int kResourceType_HiTechnicCompass = 47; 073 public static final int kResourceType_SRF08 = 48; 074 //languages 075 public static final int kLanguage_LabVIEW = 1; 076 public static final int kLanguage_CPlusPlus = 2; 077 public static final int kLanguage_Java = 3; 078 public static final int kLanguage_Python = 4; 079 //CAN 080 public static final int kCANPlugin_BlackJagBridge = 1; 081 public static final int kCANPlugin_2CAN = 2; 082 //Framework 083 public static final int kFramework_Iterative = 1; 084 public static final int kFramework_Simple = 2; 085 //Robot Drive types 086 public static final int kRobotDrive_ArcadeStandard = 1; 087 public static final int kRobotDrive_ArcadeButtonSpin = 2; 088 public static final int kRobotDrive_ArcadeRatioCurve = 3; 089 public static final int kRobotDrive_Tank = 4; 090 public static final int kRobotDrive_MecanumPolar = 5; 091 public static final int kRobotDrive_MecanumCartesian = 6; 092 //DS Compatible IO 093 public static final int kDriverStationCIO_Analog = 1; 094 public static final int kDriverStationCIO_DigitalIn = 2; 095 public static final int kDriverStationCIO_DigitalOut = 3; 096 //DS Enhanced IO 097 public static final int kDriverStationEIO_Acceleration = 1; 098 public static final int kDriverStationEIO_AnalogIn = 2; 099 public static final int kDriverStationEIO_AnalogOut = 3; 100 public static final int kDriverStationEIO_Button = 4; 101 public static final int kDriverStationEIO_LED = 5; 102 public static final int kDriverStationEIO_DigitalIn = 6; 103 public static final int kDriverStationEIO_DigitalOut = 7; 104 public static final int kDriverStationEIO_FixedDigitalOut = 8; 105 public static final int kDriverStationEIO_PWM = 9; 106 public static final int kDriverStationEIO_Encoder = 10; 107 public static final int kDriverStationEIO_TouchSlider = 11; 108 //Accelerometer connection types 109 public static final int kADXL345_SPI = 1; 110 public static final int kADXL345_I2C = 2; 111 //Commands 112 public static final int kCommand_Scheduler = 1; 113 //Smart Dashboard 114 public static final int kSmartDashboard_Instance = 1; 115 116 private static final Function nUsageReporting_reportFn = NativeLibrary.getDefaultInstance().getFunction("FRC_NetworkCommunication_nUsageReporting_report"); 117 118 /** 119 * Report the usage of a resource of interest. 120 * 121 * @param resource one of the values in the tResourceType above (max value 51). 122 * @param instanceNumber an index that identifies the resource instance. 123 */ 124 public static void report(int resource, int instanceNumber) { 125 report(resource, instanceNumber, 0); 126 } 127 /** 128 * Report the usage of a resource of interest. 129 * 130 * @param resource one of the values in the tResourceType above (max value 51). 131 * @param instanceNumber an index that identifies the resource instance. 132 * @param context an optional additional context number for some cases (such as module number). Set to 0 to omit. 133 */ 134 public static void report(int resource, int instanceNumber, int context) { 135 report(resource, instanceNumber, context, null); 136 } 137 /** 138 * Report the usage of a resource of interest. 139 * 140 * @param resource one of the values in the tResourceType above (max value 51). 141 * @param instanceNumber an index that identifies the resource instance. 142 * @param context an optional additional context number for some cases (such as module number). Set to 0 to omit. 143 * @param feature a string to be included describing features in use on a specific resource. Setting the same resource more than once allows you to change the feature string. 144 */ 145 public static void report(int resource, int instanceNumber, int context, String feature) { 146 if (feature != null) { 147 Pointer featureStringPointer = Pointer.createStringBuffer(feature); 148 nUsageReporting_reportFn.call4(resource, instanceNumber, context, featureStringPointer); 149 //featureStringPointer.free();//TODO check to see if this can get called or not 150 } else { 151 nUsageReporting_reportFn.call4(resource, instanceNumber, context, Pointer.NULL()); 152 } 153 } 154 }