Brian Silverman | 1a67511 | 2016-02-20 20:42:49 -0500 | [diff] [blame^] | 1 | /*----------------------------------------------------------------------------*/ |
| 2 | /* Copyright (c) FIRST 2016. 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 | |
Brian Silverman | 26e4e52 | 2015-12-17 01:56:40 -0500 | [diff] [blame] | 8 | #include "HAL/Compressor.hpp" |
| 9 | #include "ctre/PCM.h" |
| 10 | #include <iostream> |
| 11 | |
| 12 | static const int NUM_MODULE_NUMBERS = 63; |
Brian Silverman | 1a67511 | 2016-02-20 20:42:49 -0500 | [diff] [blame^] | 13 | extern PCM *PCM_modules[NUM_MODULE_NUMBERS]; |
Brian Silverman | 26e4e52 | 2015-12-17 01:56:40 -0500 | [diff] [blame] | 14 | extern void initializePCM(int module); |
| 15 | |
Brian Silverman | 1a67511 | 2016-02-20 20:42:49 -0500 | [diff] [blame^] | 16 | extern "C" { |
| 17 | |
Brian Silverman | 26e4e52 | 2015-12-17 01:56:40 -0500 | [diff] [blame] | 18 | void *initializeCompressor(uint8_t module) { |
| 19 | initializePCM(module); |
| 20 | |
Brian Silverman | 1a67511 | 2016-02-20 20:42:49 -0500 | [diff] [blame^] | 21 | return PCM_modules[module]; |
Brian Silverman | 26e4e52 | 2015-12-17 01:56:40 -0500 | [diff] [blame] | 22 | } |
| 23 | |
| 24 | bool checkCompressorModule(uint8_t module) { |
| 25 | return module < NUM_MODULE_NUMBERS; |
| 26 | } |
| 27 | |
| 28 | bool getCompressor(void *pcm_pointer, int32_t *status) { |
| 29 | PCM *module = (PCM *)pcm_pointer; |
| 30 | bool value; |
| 31 | |
| 32 | *status = module->GetCompressor(value); |
| 33 | |
| 34 | return value; |
| 35 | } |
| 36 | |
| 37 | |
| 38 | void setClosedLoopControl(void *pcm_pointer, bool value, int32_t *status) { |
| 39 | PCM *module = (PCM *)pcm_pointer; |
| 40 | |
| 41 | *status = module->SetClosedLoopControl(value); |
| 42 | } |
| 43 | |
| 44 | |
| 45 | bool getClosedLoopControl(void *pcm_pointer, int32_t *status) { |
| 46 | PCM *module = (PCM *)pcm_pointer; |
| 47 | bool value; |
| 48 | |
| 49 | *status = module->GetClosedLoopControl(value); |
| 50 | |
| 51 | return value; |
| 52 | } |
| 53 | |
| 54 | |
| 55 | bool getPressureSwitch(void *pcm_pointer, int32_t *status) { |
| 56 | PCM *module = (PCM *)pcm_pointer; |
| 57 | bool value; |
| 58 | |
| 59 | *status = module->GetPressure(value); |
| 60 | |
| 61 | return value; |
| 62 | } |
| 63 | |
| 64 | |
| 65 | float getCompressorCurrent(void *pcm_pointer, int32_t *status) { |
| 66 | PCM *module = (PCM *)pcm_pointer; |
| 67 | float value; |
| 68 | |
| 69 | *status = module->GetCompressorCurrent(value); |
| 70 | |
| 71 | return value; |
| 72 | } |
| 73 | bool getCompressorCurrentTooHighFault(void *pcm_pointer, int32_t *status) { |
| 74 | PCM *module = (PCM *)pcm_pointer; |
| 75 | bool value; |
| 76 | |
| 77 | *status = module->GetCompressorCurrentTooHighFault(value); |
| 78 | |
| 79 | return value; |
| 80 | } |
| 81 | bool getCompressorCurrentTooHighStickyFault(void *pcm_pointer, int32_t *status) { |
| 82 | PCM *module = (PCM *)pcm_pointer; |
| 83 | bool value; |
| 84 | |
| 85 | *status = module->GetCompressorCurrentTooHighStickyFault(value); |
| 86 | |
| 87 | return value; |
| 88 | } |
| 89 | bool getCompressorShortedStickyFault(void *pcm_pointer, int32_t *status) { |
| 90 | PCM *module = (PCM *)pcm_pointer; |
| 91 | bool value; |
| 92 | |
| 93 | *status = module->GetCompressorShortedStickyFault(value); |
| 94 | |
| 95 | return value; |
| 96 | } |
| 97 | bool getCompressorShortedFault(void *pcm_pointer, int32_t *status) { |
| 98 | PCM *module = (PCM *)pcm_pointer; |
| 99 | bool value; |
| 100 | |
| 101 | *status = module->GetCompressorShortedFault(value); |
| 102 | |
| 103 | return value; |
| 104 | } |
| 105 | bool getCompressorNotConnectedStickyFault(void *pcm_pointer, int32_t *status) { |
| 106 | PCM *module = (PCM *)pcm_pointer; |
| 107 | bool value; |
| 108 | |
| 109 | *status = module->GetCompressorNotConnectedStickyFault(value); |
| 110 | |
| 111 | return value; |
| 112 | } |
| 113 | bool getCompressorNotConnectedFault(void *pcm_pointer, int32_t *status) { |
| 114 | PCM *module = (PCM *)pcm_pointer; |
| 115 | bool value; |
| 116 | |
| 117 | *status = module->GetCompressorNotConnectedFault(value); |
| 118 | |
| 119 | return value; |
| 120 | } |
| 121 | void clearAllPCMStickyFaults(void *pcm_pointer, int32_t *status) { |
| 122 | PCM *module = (PCM *)pcm_pointer; |
| 123 | |
| 124 | *status = module->ClearStickyFaults(); |
| 125 | } |
Brian Silverman | 1a67511 | 2016-02-20 20:42:49 -0500 | [diff] [blame^] | 126 | |
| 127 | } // extern "C" |