001package com.ctre.phoenix;
002
003/**
004 * Interface for uart gadgeteer devices
005 */
006public interface GadgeteerUartClient
007{
008        /**
009         * Device connected to gadgeteer
010         */
011        public enum GadgeteerProxyType{
012                /**
013                 * General Gadgeteer Proxy
014                 */
015                General(0), 
016                /**
017                 * Pigeon connected to gadgeteer
018                 */
019                Pigeon(1), 
020                /**
021                 * HERO connected to gadgeteer
022                 */
023                PC_HERO(2),
024                /**
025                 * Device unknown
026                 */
027                Unknown(-1);
028
029                private int value; 
030                private GadgeteerProxyType(int value) { this.value = value; }
031                
032                /**
033                 * Get GadgeteerProxyType of specified value
034                 * @param value Value of GadgeteerProxyType
035                 * @return GadgeteerProxyType of specified value
036                 */
037                public static GadgeteerProxyType valueOf(int value) {
038                        for (GadgeteerProxyType e : GadgeteerProxyType.values()) {
039                                if (e.value == value) {
040                                        return e;
041                                }
042                        }
043                        return Unknown;
044                }
045        };
046
047        /**
048         * Method of connection to gadgeteer
049         */
050        public enum GadgeteerConnection {
051                /**
052                 * Device not connected
053                 */
054                NotConnected (0),
055                /**
056                 * Device in process of connecting
057                 */
058                Connecting (1),
059                /**
060                 * Device is connected
061                 */
062                Connected (2),
063                /**
064                 * Device unknown
065                 */
066                Unknown(-1);
067                
068                private int value; 
069                private GadgeteerConnection(int value) { this.value = value; } 
070
071                /**
072                 * Get GadgeteerConnection of specified value
073                 * @param value Value of GadgeteerConnection
074                 * @return GadgeteerConnection of specified value
075                 */
076                public static GadgeteerConnection valueOf(int value) {
077                        for (GadgeteerConnection e : GadgeteerConnection.values()) {
078                                if (e.value == value) {
079                                        return e;
080                                }
081                        }
082                        return Unknown;
083                }
084        };
085
086        /**
087         * The status of the gadgeteer device
088         */
089        public static class GadgeteerUartStatus {
090                /** Type of gadgeteer */
091                public GadgeteerProxyType type;
092                /** Connection status */
093                public GadgeteerConnection conn;
094                /** Bitrate of connection */
095                public int bitrate;
096                /** Number of resets that have happened */
097                public int resetCount;
098        };
099
100        /**
101         * Gets gadgeteer status
102         * @param status status object to fill
103         * @return ErrorCode
104         */
105    int getGadgeteerStatus(GadgeteerUartStatus status);
106};
107