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.phoenixpro.StatusCode; 010import com.ctre.phoenixpro.configs.jni.ConfigJNI; 011import com.ctre.phoenixpro.spns.*; 012 013/** 014 * Voltage-specific configs 015 * <p> 016 * Voltage-specific configs 017 */ 018public class VoltageConfigs implements ParentConfiguration 019{ 020 /** 021 * The time constant (in seconds) of the low-pass filter for the 022 * supply voltage. 023 * <p> 024 * This impacts the filtering for the reported supply voltage, and any 025 * control strategies that use the supply voltage (such as voltage 026 * control on a motor controller). 027 * 028 * <ul> 029 * <li> <b>Minimum Value:</b> 0.0 030 * <li> <b>Maximum Value:</b> 0.1 031 * <li> <b>Default Value:</b> 0 032 * <li> <b>Units:</b> sec 033 * </ul> 034 */ 035 public double SupplyVoltageTimeConstant = 0; 036 /** 037 * Maximum (forward) output during voltage based control modes. 038 * 039 * <ul> 040 * <li> <b>Minimum Value:</b> -16 041 * <li> <b>Maximum Value:</b> 16 042 * <li> <b>Default Value:</b> 16 043 * <li> <b>Units:</b> V 044 * </ul> 045 */ 046 public double PeakForwardVoltage = 16; 047 /** 048 * Minimum (reverse) output during voltage based control modes. 049 * 050 * <ul> 051 * <li> <b>Minimum Value:</b> -16 052 * <li> <b>Maximum Value:</b> 16 053 * <li> <b>Default Value:</b> -16 054 * <li> <b>Units:</b> V 055 * </ul> 056 */ 057 public double PeakReverseVoltage = -16; 058 059 @Override 060 public String toString() 061 { 062 String ss = "Config Group: Voltage\n"; 063 ss += "Name: \"SupplyVoltageTimeConstant\" Value: \"" + SupplyVoltageTimeConstant + "sec\"" + "\n"; 064 ss += "Name: \"PeakForwardVoltage\" Value: \"" + PeakForwardVoltage + "V\"" + "\n"; 065 ss += "Name: \"PeakReverseVoltage\" Value: \"" + PeakReverseVoltage + "V\"" + "\n"; 066 return ss; 067 } 068 069 /** 070 * 071 */ 072 public StatusCode deserialize(String string) 073 { 074 SupplyVoltageTimeConstant = ConfigJNI.Deserializedouble(SpnValue.Config_SupplyVLowpassTau.value, string); 075 PeakForwardVoltage = ConfigJNI.Deserializedouble(SpnValue.Config_PeakForwardV.value, string); 076 PeakReverseVoltage = ConfigJNI.Deserializedouble(SpnValue.Config_PeakReverseV.value, string); 077 return StatusCode.OK; 078 } 079 080 /** 081 * 082 */ 083 public String serialize() 084 { 085 String ss = ""; 086 ss += ConfigJNI.Serializedouble(1423, SupplyVoltageTimeConstant); 087 ss += ConfigJNI.Serializedouble(1433, PeakForwardVoltage); 088 ss += ConfigJNI.Serializedouble(1434, PeakReverseVoltage); 089 return ss; 090 } 091} 092