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 007public class PowerDistributionJNI extends JNIWrapper { 008 public static final int AUTOMATIC_TYPE = 0; 009 public static final int CTRE_TYPE = 1; 010 public static final int REV_TYPE = 2; 011 public static final int DEFAULT_MODULE = -1; 012 013 public static native int initialize(int module, int type); 014 015 public static native void free(int handle); 016 017 public static native int getModuleNumber(int handle); 018 019 public static native boolean checkModule(int module, int type); 020 021 public static native boolean checkChannel(int handle, int channel); 022 023 public static native int getType(int handle); 024 025 public static native int getNumChannels(int handle); 026 027 public static native double getTemperature(int handle); 028 029 public static native double getVoltage(int handle); 030 031 public static native double getChannelCurrent(int handle, int channel); 032 033 public static native void getAllCurrents(int handle, double[] currents); 034 035 public static native double getTotalCurrent(int handle); 036 037 public static native double getTotalPower(int handle); 038 039 public static native double getTotalEnergy(int handle); 040 041 public static native void resetTotalEnergy(int handle); 042 043 public static native void clearStickyFaults(int handle); 044 045 public static native boolean getSwitchableChannel(int handle); 046 047 public static native void setSwitchableChannel(int handle, boolean enabled); 048 049 public static native double getVoltageNoError(int handle); 050 051 public static native double getChannelCurrentNoError(int handle, int channel); 052 053 public static native double getTotalCurrentNoError(int handle); 054 055 public static native boolean getSwitchableChannelNoError(int handle); 056 057 public static native void setSwitchableChannelNoError(int handle, boolean enabled); 058 059 public static native int getFaultsNative(int handle); 060 061 public static PowerDistributionFaults getFaults(int handle) { 062 return new PowerDistributionFaults(getFaultsNative(handle)); 063 } 064 065 public static native int getStickyFaultsNative(int handle); 066 067 public static PowerDistributionStickyFaults getStickyFaults(int handle) { 068 return new PowerDistributionStickyFaults(getStickyFaultsNative(handle)); 069 } 070 071 public static native PowerDistributionVersion getVersion(int handle); 072}