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.*; 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 */ 019public class MotorOutputConfigs implements ParentConfiguration 020{ 021 /** 022 * Invert state of the device 023 * 024 */ 025 public InvertedValue Inverted = InvertedValue.CounterClockwise_Positive; 026 /** 027 * The state of the motor controller bridge when output is neutral or 028 * disabled. 029 * 030 */ 031 public NeutralModeValue NeutralMode = NeutralModeValue.Coast; 032 /** 033 * Configures the output deadband percentage. 034 * 035 * <ul> 036 * <li> <b>Minimum Value:</b> 0.0 037 * <li> <b>Maximum Value:</b> 0.25 038 * <li> <b>Default Value:</b> 0 039 * <li> <b>Units:</b> fractional 040 * </ul> 041 */ 042 public double DutyCycleNeutralDeadband = 0; 043 /** 044 * Maximum (forward) output during duty cycle based control modes. 045 * 046 * <ul> 047 * <li> <b>Minimum Value:</b> -1.0 048 * <li> <b>Maximum Value:</b> 1.0 049 * <li> <b>Default Value:</b> 1 050 * <li> <b>Units:</b> fractional 051 * </ul> 052 */ 053 public double PeakForwardDutyCycle = 1; 054 /** 055 * Minimum (reverse) output during duty cycle based control modes. 056 * 057 * <ul> 058 * <li> <b>Minimum Value:</b> -1.0 059 * <li> <b>Maximum Value:</b> 1.0 060 * <li> <b>Default Value:</b> -1 061 * <li> <b>Units:</b> fractional 062 * </ul> 063 */ 064 public double PeakReverseDutyCycle = -1; 065 066 @Override 067 public String toString() 068 { 069 String ss = "Config Group: MotorOutput\n"; 070 ss += "Name: \"Inverted\" Value: \"" + Inverted + "\"" + "\n"; 071 ss += "Name: \"NeutralMode\" Value: \"" + NeutralMode + "\"" + "\n"; 072 ss += "Name: \"DutyCycleNeutralDeadband\" Value: \"" + DutyCycleNeutralDeadband + "fractional\"" + "\n"; 073 ss += "Name: \"PeakForwardDutyCycle\" Value: \"" + PeakForwardDutyCycle + "fractional\"" + "\n"; 074 ss += "Name: \"PeakReverseDutyCycle\" Value: \"" + PeakReverseDutyCycle + "fractional\"" + "\n"; 075 return ss; 076 } 077 078 /** 079 * 080 */ 081 public StatusCode deserialize(String string) 082 { 083 Inverted = InvertedValue.valueOf(ConfigJNI.Deserializeint(SpnValue.Config_Inverted.value, string)); 084 NeutralMode = NeutralModeValue.valueOf(ConfigJNI.Deserializeint(SpnValue.Config_NeutralMode.value, string)); 085 DutyCycleNeutralDeadband = ConfigJNI.Deserializedouble(SpnValue.Config_DutyCycleNeutralDB.value, string); 086 PeakForwardDutyCycle = ConfigJNI.Deserializedouble(SpnValue.Config_PeakForwardDC.value, string); 087 PeakReverseDutyCycle = ConfigJNI.Deserializedouble(SpnValue.Config_PeakReverseDC.value, string); 088 return StatusCode.OK; 089 } 090 091 /** 092 * 093 */ 094 public String serialize() 095 { 096 String ss = ""; 097 ss += ConfigJNI.Serializeint(1422, Inverted.value); 098 ss += ConfigJNI.Serializeint(1425, NeutralMode.value); 099 ss += ConfigJNI.Serializedouble(1426, DutyCycleNeutralDeadband); 100 ss += ConfigJNI.Serializedouble(1431, PeakForwardDutyCycle); 101 ss += ConfigJNI.Serializedouble(1432, PeakReverseDutyCycle); 102 return ss; 103 } 104} 105