001package com.ctre.phoenix.sensors; 002 003public enum AbsoluteSensorRange{ 004 /** 005 * Express the absolute position as an unsigned value. 006 * E.g. [0,+1) rotations or [0,360) deg. 007 */ 008 Unsigned_0_to_360 (0), 009 /** 010 * Express the absolute position as an signed value. 011 * E.g. [-0.5,+0.5) rotations or [-180,+180) deg. 012 */ 013 Signed_PlusMinus180 (1); 014 015 public final int value; 016 017 /** 018 * Create AbsoluteSensorRange of initValue 019 * @param initValue Value of AbsoluteSensorRange 020 */ 021 AbsoluteSensorRange(int initValue) 022 { 023 this.value = initValue; 024 } 025 026 /** 027 * @return string representation of AbsoluteSensorRange 028 */ 029 public String toString() { 030 switch (value) { 031 case 0: return "Unsigned: 0 to 360 deg (positive full rotation"; 032 case 1: return "Signed: -180 to 180 deg (plus/minus half a rotation)"; 033 default: return "InvalidValue"; 034 } 035 } 036 /** public lookup to convert int to enum */ 037 public static AbsoluteSensorRange valueOf(int value) { 038 switch (value) { 039 default: // no break 040 case 0: return AbsoluteSensorRange.Unsigned_0_to_360; 041 case 1: return AbsoluteSensorRange.Signed_PlusMinus180; 042 } 043 } 044}