001// Copyright (c) FIRST and other WPILib contributors. 002// Open Source Software; you can modify and/or share it under the terms of 003// the WPILib BSD license file in the root directory of this project. 004 005package edu.wpi.first.hal; 006 007@SuppressWarnings("AbbreviationAsWordInName") 008public class PowerDistributionJNI extends JNIWrapper { 009 public static final int AUTOMATIC_TYPE = 0; 010 public static final int CTRE_TYPE = 1; 011 public static final int REV_TYPE = 2; 012 public static final int DEFAULT_MODULE = -1; 013 014 public static native int initialize(int module, int type); 015 016 public static native void free(int handle); 017 018 public static native int getModuleNumber(int handle); 019 020 public static native boolean checkModule(int module, int type); 021 022 public static native boolean checkChannel(int handle, int channel); 023 024 public static native int getType(int handle); 025 026 public static native int getNumChannels(int handle); 027 028 public static native double getTemperature(int handle); 029 030 public static native double getVoltage(int handle); 031 032 public static native double getChannelCurrent(int handle, int channel); 033 034 public static native void getAllCurrents(int handle, double[] currents); 035 036 public static native double getTotalCurrent(int handle); 037 038 public static native double getTotalPower(int handle); 039 040 public static native double getTotalEnergy(int handle); 041 042 public static native void resetTotalEnergy(int handle); 043 044 public static native void clearStickyFaults(int handle); 045 046 public static native boolean getSwitchableChannel(int handle); 047 048 public static native void setSwitchableChannel(int handle, boolean enabled); 049 050 public static native double getVoltageNoError(int handle); 051 052 public static native double getChannelCurrentNoError(int handle, int channel); 053 054 public static native double getTotalCurrentNoError(int handle); 055 056 public static native boolean getSwitchableChannelNoError(int handle); 057 058 public static native void setSwitchableChannelNoError(int handle, boolean enabled); 059 060 public static native int getFaultsNative(int handle); 061 062 public static PowerDistributionFaults getFaults(int handle) { 063 return new PowerDistributionFaults(getFaultsNative(handle)); 064 } 065 066 public static native int getStickyFaultsNative(int handle); 067 068 public static PowerDistributionStickyFaults getStickyFaults(int handle) { 069 return new PowerDistributionStickyFaults(getStickyFaultsNative(handle)); 070 } 071 072 public static native PowerDistributionVersion getVersion(int handle); 073}