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 public final int value; 046 047 S2CloseStateValue(int initValue) 048 { 049 this.value = initValue; 050 } 051 052 private static HashMap<Integer, S2CloseStateValue> _map = null; 053 static 054 { 055 _map = new HashMap<Integer, S2CloseStateValue>(); 056 for (S2CloseStateValue type : S2CloseStateValue.values()) 057 { 058 _map.put(type.value, type); 059 } 060 } 061 062 /** 063 * Gets S2CloseStateValue from specified value 064 * @param value Value of S2CloseStateValue 065 * @return S2CloseStateValue of specified value 066 */ 067 public static S2CloseStateValue valueOf(int value) 068 { 069 S2CloseStateValue retval = _map.get(value); 070 if (retval != null) return retval; 071 return S2CloseStateValue.values()[0]; 072 } 073}