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; 010 011/** 012 * Class for CANcoder, a CAN based magnetic encoder that provides absolute and 013 * relative position along with filtered velocity. 014 * 015 * This handles the configurations for the {@link com.ctre.phoenixpro.hardware.CANcoder} 016 */ 017public class CANcoderConfiguration implements ParentConfiguration 018{ 019 /** 020 * True if we should factory default newer unsupported configs, 021 * false to leave newer unsupported configs alone. 022 * <p> 023 * This flag addresses a corner case where the device may have 024 * firmware with newer configs that didn't exist when this 025 * version of the API was built. If this occurs and this 026 * flag is true, unsupported new configs will be factory 027 * defaulted to avoid unexpected behavior. 028 * <p> 029 * This is also the behavior in Phoenix 5, so this flag 030 * is defaulted to true to match. 031 */ 032 public boolean FutureProofConfigs = true; 033 034 035 /** 036 * Configs that affect the magnet sensor and how to interpret it. 037 * <p> 038 * Includes sensor range and other configs related to sensor. 039 */ 040 public MagnetSensorConfigs MagnetSensor = new MagnetSensorConfigs(); 041 042 @Override 043 public String toString() 044 { 045 String ss = ""; 046 ss += MagnetSensor.toString(); 047 return ss; 048 } 049 050 /** 051 * Get the serialized form of this configuration 052 * 053 * @return Serialized form of this config group 054 */ 055 public String serialize() 056 { 057 String ss = ""; 058 ss += MagnetSensor.serialize(); 059 return ss; 060 } 061 062 /** 063 * Take a string and deserialize it to this configuration 064 * 065 * @return Return code of the deserialize method 066 */ 067 public StatusCode deserialize(String string) 068 { 069 StatusCode err = StatusCode.OK; 070 err = MagnetSensor.deserialize(string); 071 return err; 072 } 073};