001/*
002 *  Software License Agreement
003 *
004 * Copyright (C) Cross The Road Electronics.  All rights
005 * reserved.
006 * 
007 * Cross The Road Electronics (CTRE) licenses to you the right to 
008 * use, publish, and distribute copies of CRF (Cross The Road) firmware files (*.crf) and Software
009 * API Libraries ONLY when in use with Cross The Road Electronics hardware products.
010 * 
011 * THE SOFTWARE AND DOCUMENTATION ARE PROVIDED "AS IS" WITHOUT
012 * WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT
013 * LIMITATION, ANY WARRANTY OF MERCHANTABILITY, FITNESS FOR A
014 * PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT SHALL
015 * CROSS THE ROAD ELECTRONICS BE LIABLE FOR ANY INCIDENTAL, SPECIAL, 
016 * INDIRECT OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF
017 * PROCUREMENT OF SUBSTITUTE GOODS, TECHNOLOGY OR SERVICES, ANY CLAIMS
018 * BY THIRD PARTIES (INCLUDING BUT NOT LIMITED TO ANY DEFENSE
019 * THEREOF), ANY CLAIMS FOR INDEMNITY OR CONTRIBUTION, OR OTHER
020 * SIMILAR COSTS, WHETHER ASSERTED ON THE BASIS OF CONTRACT, TORT
021 * (INCLUDING NEGLIGENCE), BREACH OF WARRANTY, OR OTHERWISE
022 */
023package com.ctre.phoenix.unmanaged;
024
025/**
026 * Handles enabling when used in a non-FRC manner
027 */
028public class Unmanaged {
029    /**
030     * Feed the robot enable.
031     * This function does nothing on a roborio during FRC use.
032     * <p>
033     * If running an application in simulation, creating a WPI_*
034     * object automatically enables actuators.
035     * Otherwise, call this to enable actuators.
036     * 
037     * @param timeoutMs Timeout before disabling
038     */
039    public static void feedEnable(int timeoutMs) {
040        UnmanagedJNI.JNI_FeedEnable(timeoutMs);
041    }
042
043    /**
044     * @return true if non-FRC enabled
045     */
046    public static boolean getEnableState() {
047        return  UnmanagedJNI.JNI_GetEnableState();
048    }
049
050    /**
051     * @return Phoenix version
052     */
053    public static int getPhoenixVersion() {
054        return UnmanagedJNI.JNI_GetPhoenixVersion();
055    }
056
057    /**
058     * Calling this function will load and start
059     * the Phoenix background tasks.
060     * 
061     * This can be useful if you need the
062     * Enable/Disable functionality for CAN devices
063     * but aren't using any of the CAN device classes.
064     * 
065     * This function does NOT need to be called if
066     * you are using any of the Phoenix CAN device classes.
067     */
068    public static void loadPhoenix() {
069        UnmanagedJNI.JNI_LoadPhoenix();
070    }
071
072    /**
073     * Sets the duration of the delay before starting 
074     * the Phoenix diagnostics server.
075     * 
076     * @param startTimeSeconds Magnitude of the delay (in seconds) before
077     *                  starting the server.
078     *                  A value of 0 will start the server immediately.
079     *                  A negative value will signal the server 
080     *                      to shutdown or never start.
081     */
082    public static void setPhoenixDiagnosticsStartTime(int startTimeSeconds){
083        UnmanagedJNI.JNI_SetPhoenixDiagnosticsStartTime(startTimeSeconds);
084    }
085}