2016-01-02 03:02:34 -08:00
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
|
/* Copyright (c) FIRST 2016. All Rights Reserved. */
|
|
|
|
|
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
|
|
|
|
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
|
|
|
|
/* the project. */
|
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
|
|
2016-05-22 21:41:22 -07:00
|
|
|
#include "HAL/Compressor.h"
|
2016-05-25 22:38:11 -07:00
|
|
|
|
2014-05-29 14:25:09 -04:00
|
|
|
#include <iostream>
|
2016-05-25 22:38:11 -07:00
|
|
|
|
2016-05-20 17:30:37 -07:00
|
|
|
#include "ctre/PCM.h"
|
2014-05-29 14:25:09 -04:00
|
|
|
|
2014-07-02 15:15:56 -04:00
|
|
|
static const int NUM_MODULE_NUMBERS = 63;
|
2016-05-20 17:30:37 -07:00
|
|
|
extern PCM* PCM_modules[NUM_MODULE_NUMBERS];
|
2014-07-02 15:15:56 -04:00
|
|
|
extern void initializePCM(int module);
|
2014-05-29 14:25:09 -04:00
|
|
|
|
2015-11-26 00:08:32 -08:00
|
|
|
extern "C" {
|
|
|
|
|
|
2016-05-20 17:30:37 -07:00
|
|
|
void* initializeCompressor(uint8_t module) {
|
|
|
|
|
initializePCM(module);
|
|
|
|
|
|
|
|
|
|
return PCM_modules[module];
|
2014-05-29 14:25:09 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool checkCompressorModule(uint8_t module) {
|
2016-05-20 17:30:37 -07:00
|
|
|
return module < NUM_MODULE_NUMBERS;
|
2014-05-29 14:25:09 -04:00
|
|
|
}
|
|
|
|
|
|
2016-05-20 17:30:37 -07:00
|
|
|
bool getCompressor(void* pcm_pointer, int32_t* status) {
|
|
|
|
|
PCM* module = (PCM*)pcm_pointer;
|
|
|
|
|
bool value;
|
|
|
|
|
|
|
|
|
|
*status = module->GetCompressor(value);
|
|
|
|
|
|
|
|
|
|
return value;
|
2014-05-29 14:25:09 -04:00
|
|
|
}
|
|
|
|
|
|
2016-05-20 17:30:37 -07:00
|
|
|
void setClosedLoopControl(void* pcm_pointer, bool value, int32_t* status) {
|
|
|
|
|
PCM* module = (PCM*)pcm_pointer;
|
2014-05-29 14:25:09 -04:00
|
|
|
|
2016-05-20 17:30:37 -07:00
|
|
|
*status = module->SetClosedLoopControl(value);
|
2014-05-29 14:25:09 -04:00
|
|
|
}
|
|
|
|
|
|
2016-05-20 17:30:37 -07:00
|
|
|
bool getClosedLoopControl(void* pcm_pointer, int32_t* status) {
|
|
|
|
|
PCM* module = (PCM*)pcm_pointer;
|
|
|
|
|
bool value;
|
|
|
|
|
|
|
|
|
|
*status = module->GetClosedLoopControl(value);
|
2014-05-29 14:25:09 -04:00
|
|
|
|
2016-05-20 17:30:37 -07:00
|
|
|
return value;
|
2014-05-29 14:25:09 -04:00
|
|
|
}
|
|
|
|
|
|
2016-05-20 17:30:37 -07:00
|
|
|
bool getPressureSwitch(void* pcm_pointer, int32_t* status) {
|
|
|
|
|
PCM* module = (PCM*)pcm_pointer;
|
|
|
|
|
bool value;
|
2014-05-29 14:25:09 -04:00
|
|
|
|
2016-05-20 17:30:37 -07:00
|
|
|
*status = module->GetPressure(value);
|
|
|
|
|
|
|
|
|
|
return value;
|
2014-05-29 14:25:09 -04:00
|
|
|
}
|
|
|
|
|
|
2016-05-20 17:30:37 -07:00
|
|
|
float getCompressorCurrent(void* pcm_pointer, int32_t* status) {
|
|
|
|
|
PCM* module = (PCM*)pcm_pointer;
|
|
|
|
|
float value;
|
|
|
|
|
|
|
|
|
|
*status = module->GetCompressorCurrent(value);
|
2014-05-29 14:25:09 -04:00
|
|
|
|
2016-05-20 17:30:37 -07:00
|
|
|
return value;
|
2014-05-29 14:25:09 -04:00
|
|
|
}
|
2016-05-20 17:30:37 -07:00
|
|
|
bool getCompressorCurrentTooHighFault(void* pcm_pointer, int32_t* status) {
|
|
|
|
|
PCM* module = (PCM*)pcm_pointer;
|
|
|
|
|
bool value;
|
|
|
|
|
|
|
|
|
|
*status = module->GetCompressorCurrentTooHighFault(value);
|
|
|
|
|
|
|
|
|
|
return value;
|
2014-12-26 19:40:39 -05:00
|
|
|
}
|
2016-05-20 17:30:37 -07:00
|
|
|
bool getCompressorCurrentTooHighStickyFault(void* pcm_pointer,
|
|
|
|
|
int32_t* status) {
|
|
|
|
|
PCM* module = (PCM*)pcm_pointer;
|
|
|
|
|
bool value;
|
|
|
|
|
|
|
|
|
|
*status = module->GetCompressorCurrentTooHighStickyFault(value);
|
|
|
|
|
|
|
|
|
|
return value;
|
2014-12-26 19:40:39 -05:00
|
|
|
}
|
2016-05-20 17:30:37 -07:00
|
|
|
bool getCompressorShortedStickyFault(void* pcm_pointer, int32_t* status) {
|
|
|
|
|
PCM* module = (PCM*)pcm_pointer;
|
|
|
|
|
bool value;
|
|
|
|
|
|
|
|
|
|
*status = module->GetCompressorShortedStickyFault(value);
|
|
|
|
|
|
|
|
|
|
return value;
|
2014-12-26 19:40:39 -05:00
|
|
|
}
|
2016-05-20 17:30:37 -07:00
|
|
|
bool getCompressorShortedFault(void* pcm_pointer, int32_t* status) {
|
|
|
|
|
PCM* module = (PCM*)pcm_pointer;
|
|
|
|
|
bool value;
|
|
|
|
|
|
|
|
|
|
*status = module->GetCompressorShortedFault(value);
|
|
|
|
|
|
|
|
|
|
return value;
|
2014-12-26 19:40:39 -05:00
|
|
|
}
|
2016-05-20 17:30:37 -07:00
|
|
|
bool getCompressorNotConnectedStickyFault(void* pcm_pointer, int32_t* status) {
|
|
|
|
|
PCM* module = (PCM*)pcm_pointer;
|
|
|
|
|
bool value;
|
|
|
|
|
|
|
|
|
|
*status = module->GetCompressorNotConnectedStickyFault(value);
|
|
|
|
|
|
|
|
|
|
return value;
|
2014-12-26 19:40:39 -05:00
|
|
|
}
|
2016-05-20 17:30:37 -07:00
|
|
|
bool getCompressorNotConnectedFault(void* pcm_pointer, int32_t* status) {
|
|
|
|
|
PCM* module = (PCM*)pcm_pointer;
|
|
|
|
|
bool value;
|
|
|
|
|
|
|
|
|
|
*status = module->GetCompressorNotConnectedFault(value);
|
|
|
|
|
|
|
|
|
|
return value;
|
2014-12-26 19:40:39 -05:00
|
|
|
}
|
2016-05-20 17:30:37 -07:00
|
|
|
void clearAllPCMStickyFaults(void* pcm_pointer, int32_t* status) {
|
|
|
|
|
PCM* module = (PCM*)pcm_pointer;
|
|
|
|
|
|
|
|
|
|
*status = module->ClearStickyFaults();
|
2014-12-26 19:40:39 -05:00
|
|
|
}
|
2015-11-26 00:08:32 -08:00
|
|
|
|
|
|
|
|
} // extern "C"
|