001/* 002 * Copyright (C) Cross The Road Electronics. All rights reserved. 003 * License information can be found in CTRE_LICENSE.txt 004 * For support and suggestions contact support@ctr-electronics.com or file 005 * an issue tracker at https://github.com/CrossTheRoadElec/Phoenix-Releases 006 */ 007package com.ctre.phoenix6.signals; 008 009import java.util.HashMap; 010 011/** 012 * Assess the status of the motor output with respect to load and supply. 013 * <p> 014 * This routine can be used to determine the general status of motor 015 * commutation. Off means that motor output is disabled. StaticBraking 016 * typically means the motor is in neutral-brake. Motoring means motor is 017 * loaded in a typical fashion, drawing current from the supply, and 018 * successfully turning the rotor in the direction of applied voltage. 019 * Discordant Motoring is the same as Motoring, expect the rotor is being 020 * backdriven as the motor output is not enough to defeat load forces. 021 * RegenBraking means the motor is braking in such a way where motor current is 022 * traveling back to the supply (typically a battery). 023 */ 024public enum MotorOutputStatusValue 025{ 026 Unknown(0), 027 Off(1), 028 StaticBraking(2), 029 Motoring(3), 030 DiscordantMotoring(4), 031 RegenBraking(5),; 032 033 public final int value; 034 035 MotorOutputStatusValue(int initValue) 036 { 037 this.value = initValue; 038 } 039 040 private static HashMap<Integer, MotorOutputStatusValue> _map = null; 041 static 042 { 043 _map = new HashMap<Integer, MotorOutputStatusValue>(); 044 for (MotorOutputStatusValue type : MotorOutputStatusValue.values()) 045 { 046 _map.put(type.value, type); 047 } 048 } 049 050 /** 051 * Gets MotorOutputStatusValue from specified value 052 * @param value Value of MotorOutputStatusValue 053 * @return MotorOutputStatusValue of specified value 054 */ 055 public static MotorOutputStatusValue valueOf(int value) 056 { 057 MotorOutputStatusValue retval = _map.get(value); 058 if (retval != null) return retval; 059 return MotorOutputStatusValue.values()[0]; 060 } 061}