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 * What value the Signal 2 input (S2IN) needs to be for the CTR Electronics' 013 * CANdi™ to detect as Closed. 014 * <p> 015 * Devices using the S2 input as a remote limit switch will treat the switch as 016 * closed when the S2 input is this state. 017 */ 018public enum S2CloseStateValue 019{ 020 /** 021 * The S2 input will be treated as closed when it is not floating. 022 */ 023 CloseWhenNotFloating(0), 024 /** 025 * The S2 input will be treated as closed when it is floating. 026 */ 027 CloseWhenFloating(1), 028 /** 029 * The S2 input will be treated as closed when it is not High. 030 */ 031 CloseWhenNotHigh(2), 032 /** 033 * The S2 input will be treated as closed when it is High. 034 */ 035 CloseWhenHigh(3), 036 /** 037 * The S2 input will be treated as closed when it is not Low. 038 */ 039 CloseWhenNotLow(4), 040 /** 041 * The S2 input will be treated as closed when it is Low. 042 */ 043 CloseWhenLow(5),; 044 045 /** Unique integer value of this S2CloseStateValue. */ 046 public final int value; 047 048 S2CloseStateValue(int initValue) 049 { 050 this.value = initValue; 051 } 052 053 private static HashMap<Integer, S2CloseStateValue> _map = null; 054 static 055 { 056 _map = new HashMap<Integer, S2CloseStateValue>(); 057 for (S2CloseStateValue type : S2CloseStateValue.values()) 058 { 059 _map.put(type.value, type); 060 } 061 } 062 063 /** 064 * Gets S2CloseStateValue from specified value 065 * @param value Value of S2CloseStateValue 066 * @return S2CloseStateValue of specified value 067 */ 068 public static S2CloseStateValue valueOf(int value) 069 { 070 S2CloseStateValue retval = _map.get(value); 071 if (retval != null) return retval; 072 return S2CloseStateValue.values()[0]; 073 } 074}