2016-01-02 03:02:34 -08:00
|
|
|
/*----------------------------------------------------------------------------*/
|
2017-01-01 01:05:57 -07:00
|
|
|
/* Copyright (c) FIRST 2016-2017. All Rights Reserved. */
|
2016-01-02 03:02:34 -08:00
|
|
|
/* 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
|
|
|
|
2016-07-02 08:22:44 -07:00
|
|
|
#include "HAL/Errors.h"
|
2016-07-13 20:29:28 -07:00
|
|
|
#include "HAL/handles/HandlesInternal.h"
|
2017-08-18 21:35:53 -07:00
|
|
|
#include "MockData/PCMDataInternal.h"
|
2016-07-02 23:19:14 -07:00
|
|
|
#include "PortsInternal.h"
|
2014-05-29 14:25:09 -04:00
|
|
|
|
2016-07-02 08:22:44 -07:00
|
|
|
using namespace hal;
|
|
|
|
|
|
2015-11-26 00:08:32 -08:00
|
|
|
extern "C" {
|
|
|
|
|
|
2016-07-12 10:45:14 -07:00
|
|
|
HAL_CompressorHandle HAL_InitializeCompressor(int32_t module, int32_t* status) {
|
2016-07-02 08:22:44 -07:00
|
|
|
// As compressors can have unlimited objects, just create a
|
|
|
|
|
// handle with the module number as the index.
|
|
|
|
|
|
2017-08-18 21:35:53 -07:00
|
|
|
SimPCMData[module].SetCompressorInitialized(true);
|
2016-07-12 10:45:14 -07:00
|
|
|
return (HAL_CompressorHandle)createHandle(static_cast<int16_t>(module),
|
2017-06-30 16:28:28 -07:00
|
|
|
HAL_HandleEnum::Compressor, 0);
|
2014-05-29 14:25:09 -04:00
|
|
|
}
|
|
|
|
|
|
2016-07-12 10:45:14 -07:00
|
|
|
HAL_Bool HAL_CheckCompressorModule(int32_t module) {
|
2016-07-20 22:47:29 -07:00
|
|
|
return module < kNumPCMModules && module >= 0;
|
2016-07-09 00:24:26 -07:00
|
|
|
}
|
2014-05-29 14:25:09 -04:00
|
|
|
|
2016-08-12 13:45:28 -07:00
|
|
|
HAL_Bool HAL_GetCompressor(HAL_CompressorHandle compressorHandle,
|
2016-07-12 10:45:14 -07:00
|
|
|
int32_t* status) {
|
2016-07-02 08:22:44 -07:00
|
|
|
int16_t index =
|
2017-06-30 16:28:28 -07:00
|
|
|
getHandleTypedIndex(compressorHandle, HAL_HandleEnum::Compressor, 0);
|
2016-07-02 08:22:44 -07:00
|
|
|
if (index == InvalidHandleIndex) {
|
2016-07-03 17:27:06 -07:00
|
|
|
*status = HAL_HANDLE_ERROR;
|
2016-07-02 08:22:44 -07:00
|
|
|
return false;
|
|
|
|
|
}
|
2016-05-20 17:30:37 -07:00
|
|
|
|
2017-08-18 21:35:53 -07:00
|
|
|
return SimPCMData[index].GetCompressorOn();
|
2014-05-29 14:25:09 -04:00
|
|
|
}
|
|
|
|
|
|
2016-08-12 13:45:28 -07:00
|
|
|
void HAL_SetCompressorClosedLoopControl(HAL_CompressorHandle compressorHandle,
|
2016-07-12 10:45:14 -07:00
|
|
|
HAL_Bool value, int32_t* status) {
|
2016-07-02 08:22:44 -07:00
|
|
|
int16_t index =
|
2017-06-30 16:28:28 -07:00
|
|
|
getHandleTypedIndex(compressorHandle, HAL_HandleEnum::Compressor, 0);
|
2016-07-02 08:22:44 -07:00
|
|
|
if (index == InvalidHandleIndex) {
|
2016-07-03 17:27:06 -07:00
|
|
|
*status = HAL_HANDLE_ERROR;
|
2016-07-02 08:22:44 -07:00
|
|
|
return;
|
|
|
|
|
}
|
2014-05-29 14:25:09 -04:00
|
|
|
|
2017-08-18 21:35:53 -07:00
|
|
|
SimPCMData[index].SetClosedLoopEnabled(value);
|
2014-05-29 14:25:09 -04:00
|
|
|
}
|
|
|
|
|
|
2016-07-12 10:45:14 -07:00
|
|
|
HAL_Bool HAL_GetCompressorClosedLoopControl(
|
2016-08-12 13:45:28 -07:00
|
|
|
HAL_CompressorHandle compressorHandle, int32_t* status) {
|
2016-07-02 08:22:44 -07:00
|
|
|
int16_t index =
|
2017-06-30 16:28:28 -07:00
|
|
|
getHandleTypedIndex(compressorHandle, HAL_HandleEnum::Compressor, 0);
|
2016-07-02 08:22:44 -07:00
|
|
|
if (index == InvalidHandleIndex) {
|
2016-07-03 17:27:06 -07:00
|
|
|
*status = HAL_HANDLE_ERROR;
|
2016-07-02 08:22:44 -07:00
|
|
|
return false;
|
|
|
|
|
}
|
2014-05-29 14:25:09 -04:00
|
|
|
|
2017-08-18 21:35:53 -07:00
|
|
|
return SimPCMData[index].GetClosedLoopEnabled();
|
2014-05-29 14:25:09 -04:00
|
|
|
}
|
|
|
|
|
|
2016-08-12 13:45:28 -07:00
|
|
|
HAL_Bool HAL_GetCompressorPressureSwitch(HAL_CompressorHandle compressorHandle,
|
2016-07-12 10:45:14 -07:00
|
|
|
int32_t* status) {
|
2016-07-02 08:22:44 -07:00
|
|
|
int16_t index =
|
2017-06-30 16:28:28 -07:00
|
|
|
getHandleTypedIndex(compressorHandle, HAL_HandleEnum::Compressor, 0);
|
2016-07-02 08:22:44 -07:00
|
|
|
if (index == InvalidHandleIndex) {
|
2016-07-03 17:27:06 -07:00
|
|
|
*status = HAL_HANDLE_ERROR;
|
2016-07-02 08:22:44 -07:00
|
|
|
return false;
|
|
|
|
|
}
|
2014-05-29 14:25:09 -04:00
|
|
|
|
2017-08-18 21:35:53 -07:00
|
|
|
return SimPCMData[index].GetPressureSwitch();
|
2014-05-29 14:25:09 -04:00
|
|
|
}
|
|
|
|
|
|
2016-08-12 13:45:28 -07:00
|
|
|
double HAL_GetCompressorCurrent(HAL_CompressorHandle compressorHandle,
|
2016-07-12 10:45:14 -07:00
|
|
|
int32_t* status) {
|
2016-07-02 08:22:44 -07:00
|
|
|
int16_t index =
|
2017-06-30 16:28:28 -07:00
|
|
|
getHandleTypedIndex(compressorHandle, HAL_HandleEnum::Compressor, 0);
|
2016-07-02 08:22:44 -07:00
|
|
|
if (index == InvalidHandleIndex) {
|
2016-07-03 17:27:06 -07:00
|
|
|
*status = HAL_HANDLE_ERROR;
|
2016-07-02 08:22:44 -07:00
|
|
|
return 0;
|
|
|
|
|
}
|
2014-05-29 14:25:09 -04:00
|
|
|
|
2017-08-18 21:35:53 -07:00
|
|
|
return SimPCMData[index].GetCompressorCurrent();
|
2014-05-29 14:25:09 -04:00
|
|
|
}
|
2016-07-12 10:45:14 -07:00
|
|
|
HAL_Bool HAL_GetCompressorCurrentTooHighFault(
|
2016-08-12 13:45:28 -07:00
|
|
|
HAL_CompressorHandle compressorHandle, int32_t* status) {
|
2017-08-18 21:35:53 -07:00
|
|
|
return false;
|
2014-12-26 19:40:39 -05:00
|
|
|
}
|
2016-07-12 10:45:14 -07:00
|
|
|
HAL_Bool HAL_GetCompressorCurrentTooHighStickyFault(
|
2016-08-12 13:45:28 -07:00
|
|
|
HAL_CompressorHandle compressorHandle, int32_t* status) {
|
2017-08-18 21:35:53 -07:00
|
|
|
return false;
|
2014-12-26 19:40:39 -05:00
|
|
|
}
|
2016-07-12 10:45:14 -07:00
|
|
|
HAL_Bool HAL_GetCompressorShortedStickyFault(
|
2016-08-12 13:45:28 -07:00
|
|
|
HAL_CompressorHandle compressorHandle, int32_t* status) {
|
2017-08-18 21:35:53 -07:00
|
|
|
return false;
|
2014-12-26 19:40:39 -05:00
|
|
|
}
|
2016-08-12 13:45:28 -07:00
|
|
|
HAL_Bool HAL_GetCompressorShortedFault(HAL_CompressorHandle compressorHandle,
|
2016-07-12 10:45:14 -07:00
|
|
|
int32_t* status) {
|
2017-08-18 21:35:53 -07:00
|
|
|
return false;
|
2014-12-26 19:40:39 -05:00
|
|
|
}
|
2016-07-12 10:45:14 -07:00
|
|
|
HAL_Bool HAL_GetCompressorNotConnectedStickyFault(
|
2016-08-12 13:45:28 -07:00
|
|
|
HAL_CompressorHandle compressorHandle, int32_t* status) {
|
2017-08-18 21:35:53 -07:00
|
|
|
return false;
|
2014-12-26 19:40:39 -05:00
|
|
|
}
|
2016-07-12 10:45:14 -07:00
|
|
|
HAL_Bool HAL_GetCompressorNotConnectedFault(
|
2016-08-12 13:45:28 -07:00
|
|
|
HAL_CompressorHandle compressorHandle, int32_t* status) {
|
2017-08-18 21:35:53 -07:00
|
|
|
return false;
|
2014-12-26 19:40:39 -05:00
|
|
|
}
|
2015-11-26 00:08:32 -08:00
|
|
|
} // extern "C"
|