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.configs; 008 009import com.ctre.phoenix6.StatusCode; 010import com.ctre.phoenix6.configs.jni.ConfigJNI; 011import com.ctre.phoenix6.spns.*; 012import com.ctre.phoenixpro.signals.*; 013 014/** 015 * Configs that directly affect motor-output. 016 * <p> 017 * Includes Motor Invert and various limit features. 018 * 019 * @deprecated Classes in the phoenixpro package will be removed in 2024. 020 * Users should instead use classes from the phoenix6 package. 021 */ 022@Deprecated(forRemoval = true) 023public class HardwareLimitSwitchConfigs implements ParentConfiguration 024{ 025 /** 026 * Determines if limit is normally-open (default) or normally-closed. 027 * 028 */ 029 public ForwardLimitTypeValue ForwardLimitType = ForwardLimitTypeValue.NormallyOpen; 030 /** 031 * If enabled, the position is auto-set to a specific value, specified 032 * by ForwardLimitAutosetPositionValue 033 * 034 * <ul> 035 * <li> <b>Default Value:</b> False 036 * </ul> 037 */ 038 public boolean ForwardLimitAutosetPositionEnable = false; 039 /** 040 * The value to auto-set the position to. This has no effect if 041 * ForwardLimitAutosetPositionEnable is false. 042 * 043 * <ul> 044 * <li> <b>Minimum Value:</b> -3.4e+38 045 * <li> <b>Maximum Value:</b> 3.4e+38 046 * <li> <b>Default Value:</b> 0 047 * <li> <b>Units:</b> rotations 048 * </ul> 049 */ 050 public double ForwardLimitAutosetPositionValue = 0; 051 /** 052 * If enabled, motor output is set to neutral when forward limit 053 * switch is asseted and positive output is requested. 054 * 055 * <ul> 056 * <li> <b>Default Value:</b> True 057 * </ul> 058 */ 059 public boolean ForwardLimitEnable = true; 060 /** 061 * Determines where to poll the forward limit switch. This defaults 062 * to the limit switch pin on the limit switch connector. 063 * 064 */ 065 public ForwardLimitSourceValue ForwardLimitSource = ForwardLimitSourceValue.LimitSwitchPin; 066 /** 067 * Device ID of the device if using remote limit switch features. 068 * 069 * <ul> 070 * <li> <b>Minimum Value:</b> 0 071 * <li> <b>Maximum Value:</b> 62 072 * <li> <b>Default Value:</b> 0 073 * <li> <b>Units:</b> 074 * </ul> 075 */ 076 public int ForwardLimitRemoteSensorID = 0; 077 /** 078 * Determines if limit is normally-open (default) or normally-closed. 079 * 080 */ 081 public ReverseLimitTypeValue ReverseLimitType = ReverseLimitTypeValue.NormallyOpen; 082 /** 083 * If enabled, the position is auto-set to a specific value, specified 084 * by ReverseLimitAutosetPositionValue 085 * 086 * <ul> 087 * <li> <b>Default Value:</b> False 088 * </ul> 089 */ 090 public boolean ReverseLimitAutosetPositionEnable = false; 091 /** 092 * The value to auto-set the position to. This has no effect if 093 * ReverseLimitAutosetPositionEnable is false. 094 * 095 * <ul> 096 * <li> <b>Minimum Value:</b> -3.4e+38 097 * <li> <b>Maximum Value:</b> 3.4e+38 098 * <li> <b>Default Value:</b> 0 099 * <li> <b>Units:</b> rotations 100 * </ul> 101 */ 102 public double ReverseLimitAutosetPositionValue = 0; 103 /** 104 * If enabled, motor output is set to neutral when reverse limit 105 * switch is asseted and positive output is requested. 106 * 107 * <ul> 108 * <li> <b>Default Value:</b> True 109 * </ul> 110 */ 111 public boolean ReverseLimitEnable = true; 112 /** 113 * Determines where to poll the reverse limit switch. This defaults 114 * to the limit switch pin on the limit switch connector. 115 * 116 */ 117 public ReverseLimitSourceValue ReverseLimitSource = ReverseLimitSourceValue.LimitSwitchPin; 118 /** 119 * Device ID of the device if using remote limit switch features. 120 * 121 * <ul> 122 * <li> <b>Minimum Value:</b> 0 123 * <li> <b>Maximum Value:</b> 62 124 * <li> <b>Default Value:</b> 0 125 * <li> <b>Units:</b> 126 * </ul> 127 */ 128 public int ReverseLimitRemoteSensorID = 0; 129 130 @Override 131 public String toString() 132 { 133 String ss = "Config Group: HardwareLimitSwitch\n"; 134 ss += "Name: \"ForwardLimitType\" Value: \"" + ForwardLimitType + "\"" + "\n"; 135 ss += "Name: \"ForwardLimitAutosetPositionEnable\" Value: \"" + ForwardLimitAutosetPositionEnable + "\"" + "\n"; 136 ss += "Name: \"ForwardLimitAutosetPositionValue\" Value: \"" + ForwardLimitAutosetPositionValue + "rotations\"" + "\n"; 137 ss += "Name: \"ForwardLimitEnable\" Value: \"" + ForwardLimitEnable + "\"" + "\n"; 138 ss += "Name: \"ForwardLimitSource\" Value: \"" + ForwardLimitSource + "\"" + "\n"; 139 ss += "Name: \"ForwardLimitRemoteSensorID\" Value: \"" + ForwardLimitRemoteSensorID + "\"" + "\n"; 140 ss += "Name: \"ReverseLimitType\" Value: \"" + ReverseLimitType + "\"" + "\n"; 141 ss += "Name: \"ReverseLimitAutosetPositionEnable\" Value: \"" + ReverseLimitAutosetPositionEnable + "\"" + "\n"; 142 ss += "Name: \"ReverseLimitAutosetPositionValue\" Value: \"" + ReverseLimitAutosetPositionValue + "rotations\"" + "\n"; 143 ss += "Name: \"ReverseLimitEnable\" Value: \"" + ReverseLimitEnable + "\"" + "\n"; 144 ss += "Name: \"ReverseLimitSource\" Value: \"" + ReverseLimitSource + "\"" + "\n"; 145 ss += "Name: \"ReverseLimitRemoteSensorID\" Value: \"" + ReverseLimitRemoteSensorID + "\"" + "\n"; 146 return ss; 147 } 148 149 /** 150 * 151 */ 152 public StatusCode deserialize(String string) 153 { 154 ForwardLimitType = ForwardLimitTypeValue.valueOf(ConfigJNI.Deserializeint(SpnValue.Config_ForwardLimitType.value, string)); 155 ForwardLimitAutosetPositionEnable = ConfigJNI.Deserializeboolean(SpnValue.Config_ForwardLimitAutosetPosEnable.value, string); 156 ForwardLimitAutosetPositionValue = ConfigJNI.Deserializedouble(SpnValue.Config_ForwardLimitAutosetPosValue.value, string); 157 ForwardLimitEnable = ConfigJNI.Deserializeboolean(SpnValue.Config_ForwardLimitEnable.value, string); 158 ForwardLimitSource = ForwardLimitSourceValue.valueOf(ConfigJNI.Deserializeint(SpnValue.Config_ForwardLimitSource.value, string)); 159 ForwardLimitRemoteSensorID = ConfigJNI.Deserializeint(SpnValue.Config_ForwardLimitRemoteSensorID.value, string); 160 ReverseLimitType = ReverseLimitTypeValue.valueOf(ConfigJNI.Deserializeint(SpnValue.Config_ReverseLimitType.value, string)); 161 ReverseLimitAutosetPositionEnable = ConfigJNI.Deserializeboolean(SpnValue.Config_ReverseLimitAutosetPosEnable.value, string); 162 ReverseLimitAutosetPositionValue = ConfigJNI.Deserializedouble(SpnValue.Config_ReverseLimitAutosetPosValue.value, string); 163 ReverseLimitEnable = ConfigJNI.Deserializeboolean(SpnValue.Config_ReverseLimitEnable.value, string); 164 ReverseLimitSource = ReverseLimitSourceValue.valueOf(ConfigJNI.Deserializeint(SpnValue.Config_ReverseLimitSource.value, string)); 165 ReverseLimitRemoteSensorID = ConfigJNI.Deserializeint(SpnValue.Config_ReverseLimitRemoteSensorID.value, string); 166 return StatusCode.OK; 167 } 168 169 /** 170 * 171 */ 172 public String serialize() 173 { 174 String ss = ""; 175 ss += ConfigJNI.Serializeint(1449, ForwardLimitType.value); 176 ss += ConfigJNI.Serializeboolean(1450, ForwardLimitAutosetPositionEnable); 177 ss += ConfigJNI.Serializedouble(1451, ForwardLimitAutosetPositionValue); 178 ss += ConfigJNI.Serializeboolean(1452, ForwardLimitEnable); 179 ss += ConfigJNI.Serializeint(1453, ForwardLimitSource.value); 180 ss += ConfigJNI.Serializeint(1454, ForwardLimitRemoteSensorID); 181 ss += ConfigJNI.Serializeint(1455, ReverseLimitType.value); 182 ss += ConfigJNI.Serializeboolean(1456, ReverseLimitAutosetPositionEnable); 183 ss += ConfigJNI.Serializedouble(1457, ReverseLimitAutosetPositionValue); 184 ss += ConfigJNI.Serializeboolean(1458, ReverseLimitEnable); 185 ss += ConfigJNI.Serializeint(1459, ReverseLimitSource.value); 186 ss += ConfigJNI.Serializeint(1460, ReverseLimitRemoteSensorID); 187 return ss; 188 } 189} 190