001// Copyright (c) FIRST and other WPILib contributors.
002// Open Source Software; you can modify and/or share it under the terms of
003// the WPILib BSD license file in the root directory of this project.
004
005package edu.wpi.first.hal;
006
007/** A wrapper for the HALControlWord bitfield. */
008public class ControlWord {
009  private boolean m_enabled;
010  private boolean m_autonomous;
011  private boolean m_test;
012  private boolean m_emergencyStop;
013  private boolean m_fmsAttached;
014  private boolean m_dsAttached;
015
016  /** Default constructor. */
017  public ControlWord() {}
018
019  void update(
020      boolean enabled,
021      boolean autonomous,
022      boolean test,
023      boolean emergencyStop,
024      boolean fmsAttached,
025      boolean dsAttached) {
026    m_enabled = enabled;
027    m_autonomous = autonomous;
028    m_test = test;
029    m_emergencyStop = emergencyStop;
030    m_fmsAttached = fmsAttached;
031    m_dsAttached = dsAttached;
032  }
033
034  /**
035   * Updates from an existing word.
036   *
037   * @param word word to update from
038   */
039  public void update(ControlWord word) {
040    m_enabled = word.m_enabled;
041    m_autonomous = word.m_autonomous;
042    m_test = word.m_test;
043    m_emergencyStop = word.m_emergencyStop;
044    m_fmsAttached = word.m_fmsAttached;
045    m_dsAttached = word.m_dsAttached;
046  }
047
048  /**
049   * Gets the Enabled flag.
050   *
051   * @return the Enabled flag
052   */
053  public boolean getEnabled() {
054    return m_enabled;
055  }
056
057  /**
058   * Gets the Autonomous mode flag.
059   *
060   * @return the Autonomous mode flag
061   */
062  public boolean getAutonomous() {
063    return m_autonomous;
064  }
065
066  /**
067   * Gets the Test mode flag.
068   *
069   * @return the Test mode flag
070   */
071  public boolean getTest() {
072    return m_test;
073  }
074
075  /**
076   * Gets the E-Stop flag.
077   *
078   * @return the E-Stop flag
079   */
080  public boolean getEStop() {
081    return m_emergencyStop;
082  }
083
084  /**
085   * Gets the FMS attached flag.
086   *
087   * @return the FMS attached flag
088   */
089  public boolean getFMSAttached() {
090    return m_fmsAttached;
091  }
092
093  /**
094   * Gets the DS attached flag.
095   *
096   * @return the DS attached flag
097   */
098  public boolean getDSAttached() {
099    return m_dsAttached;
100  }
101}