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.phoenixpro.signals; 008 009import java.util.HashMap; 010 011/** 012 * Magnet health as measured by CANcoder. 013 * <p> 014 * Magnet health as measured by CANcoder. Red indicates too close or too far, 015 * Orange is adequate but with reduced accuracy, green is ideal. Invalid means 016 * the accuracy cannot be determined. 017 */ 018public enum MagnetHealthValue 019{ 020 Magnet_Red(1), 021 Magnet_Orange(2), 022 Magnet_Green(3), 023 Magnet_Invalid(0),; 024 025 public final int value; 026 027 MagnetHealthValue(int initValue) 028 { 029 this.value = initValue; 030 } 031 032 private static HashMap<Integer, MagnetHealthValue> _map = null; 033 static 034 { 035 _map = new HashMap<Integer, MagnetHealthValue>(); 036 for (MagnetHealthValue type : MagnetHealthValue.values()) 037 { 038 _map.put(type.value, type); 039 } 040 } 041 042 /** 043 * Gets MagnetHealthValue from specified value 044 * @param value Value of MagnetHealthValue 045 * @return MagnetHealthValue of specified value 046 */ 047 public static MagnetHealthValue valueOf(int value) 048 { 049 MagnetHealthValue retval = _map.get(value); 050 if(retval != null) return retval; 051 return MagnetHealthValue.values()[0]; 052 } 053}