Parker Schuh | d3b7a887 | 2018-02-19 16:42:27 -0800 | [diff] [blame] | 1 | /*----------------------------------------------------------------------------*/ |
| 2 | /* Copyright (c) FIRST 2008-2017. All Rights Reserved. */ |
| 3 | /* Open Source Software - may be modified and shared by FRC teams. The code */ |
| 4 | /* must be accompanied by the FIRST BSD license file in the root directory of */ |
| 5 | /* the project. */ |
| 6 | /*----------------------------------------------------------------------------*/ |
| 7 | |
| 8 | #include "frc971/wpilib/ahal/SensorBase.h" |
| 9 | |
| 10 | #include "FRC_NetworkCommunication/LoadOut.h" |
Austin Schuh | f6b9463 | 2019-02-02 22:11:27 -0800 | [diff] [blame^] | 11 | #include "hal/AnalogInput.h" |
| 12 | #include "hal/AnalogOutput.h" |
| 13 | #include "hal/DIO.h" |
| 14 | #include "hal/HAL.h" |
| 15 | #include "hal/PDP.h" |
| 16 | #include "hal/PWM.h" |
| 17 | #include "hal/Ports.h" |
| 18 | #include "hal/Relay.h" |
| 19 | #include "hal/Solenoid.h" |
Parker Schuh | d3b7a887 | 2018-02-19 16:42:27 -0800 | [diff] [blame] | 20 | #include "frc971/wpilib/ahal/WPIErrors.h" |
| 21 | |
| 22 | namespace frc { |
| 23 | |
| 24 | const int kDigitalChannels = HAL_GetNumDigitalChannels(); |
| 25 | const int kAnalogInputs = HAL_GetNumAnalogInputs(); |
| 26 | const int kSolenoidChannels = HAL_GetNumSolenoidChannels(); |
| 27 | const int kSolenoidModules = HAL_GetNumPCMModules(); |
| 28 | const int kPwmChannels = HAL_GetNumPWMChannels(); |
| 29 | const int kRelayChannels = HAL_GetNumRelayHeaders(); |
| 30 | const int kPDPChannels = HAL_GetNumPDPChannels(); |
| 31 | |
| 32 | /** |
| 33 | * Check that the solenoid module number is valid. |
| 34 | * |
| 35 | * @return Solenoid module is valid and present |
| 36 | */ |
| 37 | bool CheckSolenoidModule(int moduleNumber) { |
| 38 | return HAL_CheckSolenoidModule(moduleNumber); |
| 39 | } |
| 40 | |
| 41 | /** |
| 42 | * Check that the digital channel number is valid. |
| 43 | * |
| 44 | * Verify that the channel number is one of the legal channel numbers. Channel |
| 45 | * numbers are 1-based. |
| 46 | * |
| 47 | * @return Digital channel is valid |
| 48 | */ |
| 49 | bool CheckDigitalChannel(int channel) { return HAL_CheckDIOChannel(channel); } |
| 50 | |
| 51 | /** |
| 52 | * Check that the relay channel number is valid. |
| 53 | * |
| 54 | * Verify that the channel number is one of the legal channel numbers. Channel |
| 55 | * numbers are 0-based. |
| 56 | * |
| 57 | * @return Relay channel is valid |
| 58 | */ |
| 59 | bool CheckRelayChannel(int channel) { return HAL_CheckRelayChannel(channel); } |
| 60 | |
| 61 | /** |
| 62 | * Check that the digital channel number is valid. |
| 63 | * |
| 64 | * Verify that the channel number is one of the legal channel numbers. Channel |
| 65 | * numbers are 1-based. |
| 66 | * |
| 67 | * @return PWM channel is valid |
| 68 | */ |
| 69 | bool CheckPWMChannel(int channel) { return HAL_CheckPWMChannel(channel); } |
| 70 | |
| 71 | /** |
| 72 | * Check that the analog input number is value. |
| 73 | * |
| 74 | * Verify that the analog input number is one of the legal channel numbers. |
| 75 | * Channel numbers are 0-based. |
| 76 | * |
| 77 | * @return Analog channel is valid |
| 78 | */ |
| 79 | bool CheckAnalogInputChannel(int channel) { |
| 80 | return HAL_CheckAnalogInputChannel(channel); |
| 81 | } |
| 82 | |
| 83 | /** |
| 84 | * Check that the analog output number is valid. |
| 85 | * |
| 86 | * Verify that the analog output number is one of the legal channel numbers. |
| 87 | * Channel numbers are 0-based. |
| 88 | * |
| 89 | * @return Analog channel is valid |
| 90 | */ |
| 91 | bool CheckAnalogOutputChannel(int channel) { |
| 92 | return HAL_CheckAnalogOutputChannel(channel); |
| 93 | } |
| 94 | |
| 95 | /** |
| 96 | * Verify that the solenoid channel number is within limits. |
| 97 | * |
| 98 | * @return Solenoid channel is valid |
| 99 | */ |
| 100 | bool CheckSolenoidChannel(int channel) { |
| 101 | return HAL_CheckSolenoidChannel(channel); |
| 102 | } |
| 103 | |
| 104 | /** |
| 105 | * Verify that the power distribution channel number is within limits. |
| 106 | * |
| 107 | * @return PDP channel is valid |
| 108 | */ |
| 109 | bool CheckPDPChannel(int channel) { return HAL_CheckPDPModule(channel); } |
| 110 | |
| 111 | } // namespace frc |