mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-26 01:51:41 +00:00
Artifact artf3925 : PCM : Can't find any user facing java/C++ API for getting/clearing PCM faults
Change-Id: If5cb5b08f685158c5317233c4d9bc8e688138df7
This commit is contained in:
@@ -23,6 +23,14 @@ extern "C" {
|
||||
|
||||
bool getPressureSwitch(void *pcm_pointer, int32_t *status);
|
||||
float getCompressorCurrent(void *pcm_pointer, int32_t *status);
|
||||
|
||||
bool getCompressorCurrentTooHighFault(void *pcm_pointer, int32_t *status);
|
||||
bool getCompressorCurrentTooHighStickyFault(void *pcm_pointer, int32_t *status);
|
||||
bool getCompressorShortedStickyFault(void *pcm_pointer, int32_t *status);
|
||||
bool getCompressorShortedFault(void *pcm_pointer, int32_t *status);
|
||||
bool getCompressorNotConnectedStickyFault(void *pcm_pointer, int32_t *status);
|
||||
bool getCompressorNotConnectedFault(void *pcm_pointer, int32_t *status);
|
||||
void clearAllPCMStickyFaults(void *pcm_pointer, int32_t *status);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -13,4 +13,9 @@ extern "C"
|
||||
|
||||
bool getSolenoid(void* solenoid_port_pointer, int32_t *status);
|
||||
void setSolenoid(void* solenoid_port_pointer, bool value, int32_t *status);
|
||||
|
||||
int getPCMSolenoidBlackList(void* solenoid_port_pointer, int32_t *status);
|
||||
bool getPCMSolenoidVoltageStickyFault(void* solenoid_port_pointer, int32_t *status);
|
||||
bool getPCMSolenoidVoltageFault(void* solenoid_port_pointer, int32_t *status);
|
||||
void clearAllPCMStickyFaults_sol(void *solenoid_port_pointer, int32_t *status);
|
||||
}
|
||||
|
||||
@@ -61,4 +61,56 @@ float getCompressorCurrent(void *pcm_pointer, int32_t *status) {
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
bool getCompressorCurrentTooHighFault(void *pcm_pointer, int32_t *status) {
|
||||
PCM *module = (PCM *)pcm_pointer;
|
||||
bool value;
|
||||
|
||||
*status = module->GetCompressorCurrentTooHighFault(value);
|
||||
|
||||
return value;
|
||||
}
|
||||
bool getCompressorCurrentTooHighStickyFault(void *pcm_pointer, int32_t *status) {
|
||||
PCM *module = (PCM *)pcm_pointer;
|
||||
bool value;
|
||||
|
||||
*status = module->GetCompressorCurrentTooHighStickyFault(value);
|
||||
|
||||
return value;
|
||||
}
|
||||
bool getCompressorShortedStickyFault(void *pcm_pointer, int32_t *status) {
|
||||
PCM *module = (PCM *)pcm_pointer;
|
||||
bool value;
|
||||
|
||||
*status = module->GetCompressorShortedStickyFault(value);
|
||||
|
||||
return value;
|
||||
}
|
||||
bool getCompressorShortedFault(void *pcm_pointer, int32_t *status) {
|
||||
PCM *module = (PCM *)pcm_pointer;
|
||||
bool value;
|
||||
|
||||
*status = module->GetCompressorShortedFault(value);
|
||||
|
||||
return value;
|
||||
}
|
||||
bool getCompressorNotConnectedStickyFault(void *pcm_pointer, int32_t *status) {
|
||||
PCM *module = (PCM *)pcm_pointer;
|
||||
bool value;
|
||||
|
||||
*status = module->GetCompressorNotConnectedStickyFault(value);
|
||||
|
||||
return value;
|
||||
}
|
||||
bool getCompressorNotConnectedFault(void *pcm_pointer, int32_t *status) {
|
||||
PCM *module = (PCM *)pcm_pointer;
|
||||
bool value;
|
||||
|
||||
*status = module->GetCompressorNotConnectedFault(value);
|
||||
|
||||
return value;
|
||||
}
|
||||
void clearAllPCMStickyFaults(void *pcm_pointer, int32_t *status) {
|
||||
PCM *module = (PCM *)pcm_pointer;
|
||||
|
||||
*status = module->ClearStickyFaults();
|
||||
}
|
||||
|
||||
@@ -52,3 +52,33 @@ void setSolenoid(void* solenoid_port_pointer, bool value, int32_t *status) {
|
||||
|
||||
port->module->SetSolenoid(port->pin, value);
|
||||
}
|
||||
|
||||
int getPCMSolenoidBlackList(void* solenoid_port_pointer, int32_t *status){
|
||||
solenoid_port_t* port = (solenoid_port_t*) solenoid_port_pointer;
|
||||
UINT8 value;
|
||||
|
||||
*status = port->module->GetSolenoidBlackList(value);
|
||||
|
||||
return value;
|
||||
}
|
||||
bool getPCMSolenoidVoltageStickyFault(void* solenoid_port_pointer, int32_t *status){
|
||||
solenoid_port_t* port = (solenoid_port_t*) solenoid_port_pointer;
|
||||
bool value;
|
||||
|
||||
*status = port->module->GetSolenoidStickyFault(value);
|
||||
|
||||
return value;
|
||||
}
|
||||
bool getPCMSolenoidVoltageFault(void* solenoid_port_pointer, int32_t *status){
|
||||
solenoid_port_t* port = (solenoid_port_t*) solenoid_port_pointer;
|
||||
bool value;
|
||||
|
||||
*status = port->module->GetSolenoidFault(value);
|
||||
|
||||
return value;
|
||||
}
|
||||
void clearAllPCMStickyFaults_sol(void *solenoid_port_pointer, int32_t *status){
|
||||
solenoid_port_t* port = (solenoid_port_t*) solenoid_port_pointer;
|
||||
|
||||
*status = port->module->ClearStickyFaults();
|
||||
}
|
||||
|
||||
@@ -32,6 +32,14 @@ public:
|
||||
void SetClosedLoopControl(bool on);
|
||||
bool GetClosedLoopControl();
|
||||
|
||||
bool GetCompressorCurrentTooHighFault();
|
||||
bool GetCompressorCurrentTooHighStickyFault();
|
||||
bool GetCompressorShortedStickyFault();
|
||||
bool GetCompressorShortedFault();
|
||||
bool GetCompressorNotConnectedStickyFault();
|
||||
bool GetCompressorNotConnectedFault();
|
||||
void ClearAllPCMStickyFaults();
|
||||
|
||||
void UpdateTable();
|
||||
void StartLiveWindowMode();
|
||||
void StopLiveWindowMode();
|
||||
|
||||
@@ -31,6 +31,8 @@ public:
|
||||
virtual ~DoubleSolenoid();
|
||||
virtual void Set(Value value);
|
||||
virtual Value Get();
|
||||
bool IsFwdSolenoidBlackListed();
|
||||
bool IsRevSolenoidBlackListed();
|
||||
|
||||
void ValueChanged(ITable* source, const std::string& key, EntryValue value, bool isNew);
|
||||
void UpdateTable();
|
||||
|
||||
@@ -23,6 +23,7 @@ public:
|
||||
virtual ~Solenoid();
|
||||
virtual void Set(bool on);
|
||||
virtual bool Get();
|
||||
bool IsBlackListed();
|
||||
|
||||
void ValueChanged(ITable* source, const std::string& key, EntryValue value, bool isNew);
|
||||
void UpdateTable();
|
||||
|
||||
@@ -20,6 +20,10 @@ public:
|
||||
virtual ~SolenoidBase();
|
||||
uint8_t GetAll();
|
||||
|
||||
uint8_t GetPCMSolenoidBlackList();
|
||||
bool GetPCMSolenoidVoltageStickyFault();
|
||||
bool GetPCMSolenoidVoltageFault();
|
||||
void ClearAllPCMStickyFaults();
|
||||
protected:
|
||||
explicit SolenoidBase(uint8_t pcmID);
|
||||
void Set(uint8_t value, uint8_t mask);
|
||||
|
||||
@@ -129,6 +129,123 @@ bool Compressor::GetClosedLoopControl() {
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if PCM is in fault state : Compressor Drive is
|
||||
* disabled due to compressor current being too high.
|
||||
*/
|
||||
bool Compressor::GetCompressorCurrentTooHighFault() {
|
||||
int32_t status = 0;
|
||||
bool value;
|
||||
|
||||
value = getCompressorCurrentTooHighFault(m_pcm_pointer, &status);
|
||||
|
||||
if(status) {
|
||||
wpi_setWPIError(Timeout);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
/**
|
||||
* @return true if PCM sticky fault is set : Compressor Drive is
|
||||
* disabled due to compressor current being too high.
|
||||
*/
|
||||
bool Compressor::GetCompressorCurrentTooHighStickyFault() {
|
||||
int32_t status = 0;
|
||||
bool value;
|
||||
|
||||
value = getCompressorCurrentTooHighStickyFault(m_pcm_pointer, &status);
|
||||
|
||||
if(status) {
|
||||
wpi_setWPIError(Timeout);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
/**
|
||||
* @return true if PCM sticky fault is set : Compressor output
|
||||
* appears to be shorted.
|
||||
*/
|
||||
bool Compressor::GetCompressorShortedStickyFault() {
|
||||
int32_t status = 0;
|
||||
bool value;
|
||||
|
||||
value = getCompressorShortedStickyFault(m_pcm_pointer, &status);
|
||||
|
||||
if(status) {
|
||||
wpi_setWPIError(Timeout);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
/**
|
||||
* @return true if PCM is in fault state : Compressor output
|
||||
* appears to be shorted.
|
||||
*/
|
||||
bool Compressor::GetCompressorShortedFault() {
|
||||
int32_t status = 0;
|
||||
bool value;
|
||||
|
||||
value = getCompressorShortedFault(m_pcm_pointer, &status);
|
||||
|
||||
if(status) {
|
||||
wpi_setWPIError(Timeout);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
/**
|
||||
* @return true if PCM sticky fault is set : Compressor does not
|
||||
* appear to be wired, i.e. compressor is
|
||||
* not drawing enough current.
|
||||
*/
|
||||
bool Compressor::GetCompressorNotConnectedStickyFault() {
|
||||
int32_t status = 0;
|
||||
bool value;
|
||||
|
||||
value = getCompressorNotConnectedStickyFault(m_pcm_pointer, &status);
|
||||
|
||||
if(status) {
|
||||
wpi_setWPIError(Timeout);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
/**
|
||||
* @return true if PCM is in fault state : Compressor does not
|
||||
* appear to be wired, i.e. compressor is
|
||||
* not drawing enough current.
|
||||
*/
|
||||
bool Compressor::GetCompressorNotConnectedFault() {
|
||||
int32_t status = 0;
|
||||
bool value;
|
||||
|
||||
value = getCompressorNotConnectedFault(m_pcm_pointer, &status);
|
||||
|
||||
if(status) {
|
||||
wpi_setWPIError(Timeout);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
/**
|
||||
* Clear ALL sticky faults inside PCM that Compressor is wired to.
|
||||
*
|
||||
* If a sticky fault is set, then it will be persistently cleared. Compressor drive
|
||||
* maybe momentarily disable while flags are being cleared. Care should be
|
||||
* taken to not call this too frequently, otherwise normal compressor
|
||||
* functionality may be prevented.
|
||||
*
|
||||
* If no sticky faults are set then this call will have no effect.
|
||||
*/
|
||||
void Compressor::ClearAllPCMStickyFaults() {
|
||||
int32_t status = 0;
|
||||
|
||||
clearAllPCMStickyFaults(m_pcm_pointer, &status);
|
||||
|
||||
if(status) {
|
||||
wpi_setWPIError(Timeout);
|
||||
}
|
||||
}
|
||||
void Compressor::UpdateTable() {
|
||||
if(m_table) {
|
||||
m_table->PutBoolean("Enabled", Enabled());
|
||||
|
||||
@@ -138,6 +138,32 @@ DoubleSolenoid::Value DoubleSolenoid::Get()
|
||||
if (value & m_reverseMask) return kReverse;
|
||||
return kOff;
|
||||
}
|
||||
/**
|
||||
* Check if the forward solenoid is blacklisted.
|
||||
* If a solenoid is shorted, it is added to the blacklist and
|
||||
* disabled until power cycle, or until faults are cleared.
|
||||
* @see ClearAllPCMStickyFaults()
|
||||
*
|
||||
* @return If solenoid is disabled due to short.
|
||||
*/
|
||||
bool DoubleSolenoid::IsFwdSolenoidBlackListed()
|
||||
{
|
||||
int blackList = GetPCMSolenoidBlackList();
|
||||
return (blackList & m_forwardMask) ? 1 : 0;
|
||||
}
|
||||
/**
|
||||
* Check if the reverse solenoid is blacklisted.
|
||||
* If a solenoid is shorted, it is added to the blacklist and
|
||||
* disabled until power cycle, or until faults are cleared.
|
||||
* @see ClearAllPCMStickyFaults()
|
||||
*
|
||||
* @return If solenoid is disabled due to short.
|
||||
*/
|
||||
bool DoubleSolenoid::IsRevSolenoidBlackListed()
|
||||
{
|
||||
int blackList = GetPCMSolenoidBlackList();
|
||||
return (blackList & m_reverseMask) ? 1 : 0;
|
||||
}
|
||||
|
||||
void DoubleSolenoid::ValueChanged(ITable* source, const std::string& key, EntryValue value, bool isNew) {
|
||||
Value lvalue = kOff;
|
||||
|
||||
@@ -102,7 +102,19 @@ bool Solenoid::Get()
|
||||
uint8_t value = GetAll() & ( 1 << m_channel);
|
||||
return (value != 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if solenoid is blacklisted.
|
||||
* If a solenoid is shorted, it is added to the blacklist and
|
||||
* disabled until power cycle, or until faults are cleared.
|
||||
* @see ClearAllPCMStickyFaults()
|
||||
*
|
||||
* @return If solenoid is disabled due to short.
|
||||
*/
|
||||
bool Solenoid::IsBlackListed()
|
||||
{
|
||||
int value = GetPCMSolenoidBlackList() & ( 1 << m_channel);
|
||||
return (value != 0);
|
||||
}
|
||||
|
||||
void Solenoid::ValueChanged(ITable* source, const std::string& key, EntryValue value, bool isNew) {
|
||||
Set(value.b);
|
||||
|
||||
@@ -64,3 +64,52 @@ uint8_t SolenoidBase::GetAll()
|
||||
}
|
||||
return value;
|
||||
}
|
||||
/**
|
||||
* Reads complete solenoid blacklist for all 8 solenoids as a single byte.
|
||||
*
|
||||
* If a solenoid is shorted, it is added to the blacklist and
|
||||
* disabled until power cycle, or until faults are cleared.
|
||||
* @see ClearAllPCMStickyFaults()
|
||||
*
|
||||
* @return The solenoid blacklist of all 8 solenoids on the module.
|
||||
*/
|
||||
uint8_t SolenoidBase::GetPCMSolenoidBlackList()
|
||||
{
|
||||
int32_t status = 0;
|
||||
return getPCMSolenoidBlackList(m_ports[0], &status);
|
||||
}
|
||||
/**
|
||||
* @return true if PCM sticky fault is set : The common
|
||||
* highside solenoid voltage rail is too low,
|
||||
* most likely a solenoid channel is shorted.
|
||||
*/
|
||||
bool SolenoidBase::GetPCMSolenoidVoltageStickyFault()
|
||||
{
|
||||
int32_t status = 0;
|
||||
return getPCMSolenoidVoltageStickyFault(m_ports[0], &status);
|
||||
}
|
||||
/**
|
||||
* @return true if PCM is in fault state : The common
|
||||
* highside solenoid voltage rail is too low,
|
||||
* most likely a solenoid channel is shorted.
|
||||
*/
|
||||
bool SolenoidBase::GetPCMSolenoidVoltageFault()
|
||||
{
|
||||
int32_t status = 0;
|
||||
return getPCMSolenoidVoltageFault(m_ports[0], &status);
|
||||
}
|
||||
/**
|
||||
* Clear ALL sticky faults inside PCM that Compressor is wired to.
|
||||
*
|
||||
* If a sticky fault is set, then it will be persistently cleared. Compressor drive
|
||||
* maybe momentarily disable while flags are being cleared. Care should be
|
||||
* taken to not call this too frequently, otherwise normal compressor
|
||||
* functionality may be prevented.
|
||||
*
|
||||
* If no sticky faults are set then this call will have no effect.
|
||||
*/
|
||||
void SolenoidBase::ClearAllPCMStickyFaults()
|
||||
{
|
||||
int32_t status = 0;
|
||||
return clearAllPCMStickyFaults_sol(m_ports[0], &status);
|
||||
}
|
||||
|
||||
@@ -139,6 +139,103 @@ public class Compressor extends SensorBase implements LiveWindowSendable {
|
||||
return on;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if PCM is in fault state : Compressor Drive is
|
||||
* disabled due to compressor current being too high.
|
||||
*/
|
||||
public boolean getCompressorCurrentTooHighFault() {
|
||||
ByteBuffer status = ByteBuffer.allocateDirect(4);
|
||||
status.order(ByteOrder.LITTLE_ENDIAN);
|
||||
|
||||
boolean retval = CompressorJNI.getCompressorCurrentTooHighFault(m_pcm, status.asIntBuffer());
|
||||
HALUtil.checkStatus(status.asIntBuffer());
|
||||
|
||||
return retval;
|
||||
}
|
||||
/**
|
||||
* @return true if PCM sticky fault is set : Compressor Drive is
|
||||
* disabled due to compressor current being too high.
|
||||
*/
|
||||
public boolean getCompressorCurrentTooHighStickyFault() {
|
||||
ByteBuffer status = ByteBuffer.allocateDirect(4);
|
||||
status.order(ByteOrder.LITTLE_ENDIAN);
|
||||
|
||||
boolean retval = CompressorJNI.getCompressorCurrentTooHighStickyFault(m_pcm, status.asIntBuffer());
|
||||
HALUtil.checkStatus(status.asIntBuffer());
|
||||
|
||||
return retval;
|
||||
}
|
||||
/**
|
||||
* @return true if PCM sticky fault is set : Compressor output
|
||||
* appears to be shorted.
|
||||
*/
|
||||
public boolean getCompressorShortedStickyFault() {
|
||||
ByteBuffer status = ByteBuffer.allocateDirect(4);
|
||||
status.order(ByteOrder.LITTLE_ENDIAN);
|
||||
|
||||
boolean retval = CompressorJNI.getCompressorShortedStickyFault(m_pcm, status.asIntBuffer());
|
||||
HALUtil.checkStatus(status.asIntBuffer());
|
||||
|
||||
return retval;
|
||||
}
|
||||
/**
|
||||
* @return true if PCM is in fault state : Compressor output
|
||||
* appears to be shorted.
|
||||
*/
|
||||
public boolean getCompressorShortedFault() {
|
||||
ByteBuffer status = ByteBuffer.allocateDirect(4);
|
||||
status.order(ByteOrder.LITTLE_ENDIAN);
|
||||
|
||||
boolean retval = CompressorJNI.getCompressorShortedFault(m_pcm, status.asIntBuffer());
|
||||
HALUtil.checkStatus(status.asIntBuffer());
|
||||
|
||||
return retval;
|
||||
}
|
||||
/**
|
||||
* @return true if PCM sticky fault is set : Compressor does not
|
||||
* appear to be wired, i.e. compressor is
|
||||
* not drawing enough current.
|
||||
*/
|
||||
public boolean getCompressorNotConnectedStickyFault() {
|
||||
ByteBuffer status = ByteBuffer.allocateDirect(4);
|
||||
status.order(ByteOrder.LITTLE_ENDIAN);
|
||||
|
||||
boolean retval = CompressorJNI.getCompressorNotConnectedStickyFault(m_pcm, status.asIntBuffer());
|
||||
HALUtil.checkStatus(status.asIntBuffer());
|
||||
|
||||
return retval;
|
||||
}
|
||||
/**
|
||||
* @return true if PCM is in fault state : Compressor does not
|
||||
* appear to be wired, i.e. compressor is
|
||||
* not drawing enough current.
|
||||
*/
|
||||
public boolean getCompressorNotConnectedFault() {
|
||||
ByteBuffer status = ByteBuffer.allocateDirect(4);
|
||||
status.order(ByteOrder.LITTLE_ENDIAN);
|
||||
|
||||
boolean retval = CompressorJNI.getCompressorNotConnectedFault(m_pcm, status.asIntBuffer());
|
||||
HALUtil.checkStatus(status.asIntBuffer());
|
||||
|
||||
return retval;
|
||||
}
|
||||
/**
|
||||
* Clear ALL sticky faults inside PCM that Compressor is wired to.
|
||||
*
|
||||
* If a sticky fault is set, then it will be persistently cleared. Compressor drive
|
||||
* maybe momentarily disable while flags are being cleared. Care should be
|
||||
* taken to not call this too frequently, otherwise normal compressor
|
||||
* functionality may be prevented.
|
||||
*
|
||||
* If no sticky faults are set then this call will have no effect.
|
||||
*/
|
||||
public void clearAllPCMStickyFaults() {
|
||||
ByteBuffer status = ByteBuffer.allocateDirect(4);
|
||||
status.order(ByteOrder.LITTLE_ENDIAN);
|
||||
|
||||
CompressorJNI.clearAllPCMStickyFaults(m_pcm, status.asIntBuffer());
|
||||
HALUtil.checkStatus(status.asIntBuffer());
|
||||
}
|
||||
@Override
|
||||
public void startLiveWindowMode() {
|
||||
}
|
||||
|
||||
@@ -143,6 +143,30 @@ public class DoubleSolenoid extends SolenoidBase implements LiveWindowSendable {
|
||||
if ((value & m_reverseMask) != 0) return Value.kReverse;
|
||||
return Value.kOff;
|
||||
}
|
||||
/**
|
||||
* Check if the forward solenoid is blacklisted.
|
||||
* If a solenoid is shorted, it is added to the blacklist and
|
||||
* disabled until power cycle, or until faults are cleared.
|
||||
* @see clearAllPCMStickyFaults()
|
||||
*
|
||||
* @return If solenoid is disabled due to short.
|
||||
*/
|
||||
public boolean isFwdSolenoidBlackListed() {
|
||||
int blackList = getPCMSolenoidBlackList();
|
||||
return ((blackList & m_forwardMask) != 0);
|
||||
}
|
||||
/**
|
||||
* Check if the reverse solenoid is blacklisted.
|
||||
* If a solenoid is shorted, it is added to the blacklist and
|
||||
* disabled until power cycle, or until faults are cleared.
|
||||
* @see clearAllPCMStickyFaults()
|
||||
*
|
||||
* @return If solenoid is disabled due to short.
|
||||
*/
|
||||
public boolean isRevSolenoidBlackListed() {
|
||||
int blackList = getPCMSolenoidBlackList();
|
||||
return ((blackList & m_reverseMask) != 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Live Window code, only does anything if live window is activated.
|
||||
|
||||
@@ -101,7 +101,18 @@ public class Solenoid extends SolenoidBase implements LiveWindowSendable {
|
||||
int value = getAll() & ( 1 << m_channel);
|
||||
return (value != 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if solenoid is blacklisted.
|
||||
* If a solenoid is shorted, it is added to the blacklist and
|
||||
* disabled until power cycle, or until faults are cleared.
|
||||
* @see clearAllPCMStickyFaults()
|
||||
*
|
||||
* @return If solenoid is disabled due to short.
|
||||
*/
|
||||
public boolean isBlackListed() {
|
||||
int value = getPCMSolenoidBlackList() & ( 1 << m_channel);
|
||||
return (value != 0);
|
||||
}
|
||||
/*
|
||||
* Live Window code, only does anything if live window is activated.
|
||||
*/
|
||||
|
||||
@@ -69,4 +69,63 @@ public abstract class SolenoidBase extends SensorBase {
|
||||
HALUtil.checkStatus(status);
|
||||
return value;
|
||||
}
|
||||
/**
|
||||
* Reads complete solenoid blacklist for all 8 solenoids as a single byte.
|
||||
*
|
||||
* If a solenoid is shorted, it is added to the blacklist and
|
||||
* disabled until power cycle, or until faults are cleared.
|
||||
* @see clearAllPCMStickyFaults()
|
||||
*
|
||||
* @return The solenoid blacklist of all 8 solenoids on the module.
|
||||
*/
|
||||
public byte getPCMSolenoidBlackList() {
|
||||
IntBuffer status = ByteBuffer.allocateDirect(4).asIntBuffer();
|
||||
|
||||
byte retval = SolenoidJNI.getPCMSolenoidBlackList(m_ports[0], status);
|
||||
HALUtil.checkStatus(status);
|
||||
|
||||
return retval;
|
||||
}
|
||||
/**
|
||||
* @return true if PCM sticky fault is set : The common
|
||||
* highside solenoid voltage rail is too low,
|
||||
* most likely a solenoid channel is shorted.
|
||||
*/
|
||||
public boolean getPCMSolenoidVoltageStickyFault() {
|
||||
IntBuffer status = ByteBuffer.allocateDirect(4).asIntBuffer();
|
||||
|
||||
boolean retval = SolenoidJNI.getPCMSolenoidVoltageStickyFault(m_ports[0], status);
|
||||
HALUtil.checkStatus(status);
|
||||
|
||||
return retval;
|
||||
}
|
||||
/**
|
||||
* @return true if PCM is in fault state : The common
|
||||
* highside solenoid voltage rail is too low,
|
||||
* most likely a solenoid channel is shorted.
|
||||
*/
|
||||
public boolean getPCMSolenoidVoltageFault() {
|
||||
IntBuffer status = ByteBuffer.allocateDirect(4).asIntBuffer();
|
||||
|
||||
boolean retval = SolenoidJNI.getPCMSolenoidVoltageFault(m_ports[0], status);
|
||||
HALUtil.checkStatus(status);
|
||||
|
||||
return retval;
|
||||
}
|
||||
/**
|
||||
* Clear ALL sticky faults inside PCM that Compressor is wired to.
|
||||
*
|
||||
* If a sticky fault is set, then it will be persistently cleared. Compressor drive
|
||||
* maybe momentarily disable while flags are being cleared. Care should be
|
||||
* taken to not call this too frequently, otherwise normal compressor
|
||||
* functionality may be prevented.
|
||||
*
|
||||
* If no sticky faults are set then this call will have no effect.
|
||||
*/
|
||||
public void clearAllPCMStickyFaults() {
|
||||
IntBuffer status = ByteBuffer.allocateDirect(4).asIntBuffer();
|
||||
|
||||
SolenoidJNI.clearAllPCMStickyFaults(m_ports[0], status);
|
||||
HALUtil.checkStatus(status);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,4 +14,12 @@ public class CompressorJNI extends JNIWrapper {
|
||||
|
||||
public static native boolean getPressureSwitch(ByteBuffer pcm_pointer, IntBuffer status);
|
||||
public static native float getCompressorCurrent(ByteBuffer pcm_pointer, IntBuffer status);
|
||||
|
||||
public static native boolean getCompressorCurrentTooHighFault(ByteBuffer pcm_pointer, IntBuffer status);
|
||||
public static native boolean getCompressorCurrentTooHighStickyFault(ByteBuffer pcm_pointer, IntBuffer status);
|
||||
public static native boolean getCompressorShortedStickyFault(ByteBuffer pcm_pointer, IntBuffer status);
|
||||
public static native boolean getCompressorShortedFault(ByteBuffer pcm_pointer, IntBuffer status);
|
||||
public static native boolean getCompressorNotConnectedStickyFault(ByteBuffer pcm_pointer, IntBuffer status);
|
||||
public static native boolean getCompressorNotConnectedFault(ByteBuffer pcm_pointer, IntBuffer status);
|
||||
public static native void clearAllPCMStickyFaults(ByteBuffer pcm_pointer, IntBuffer status);
|
||||
}
|
||||
|
||||
@@ -7,4 +7,9 @@ public class SolenoidJNI extends JNIWrapper {
|
||||
public static native ByteBuffer getPortWithModule(byte module, byte channel);
|
||||
public static native void setSolenoid(ByteBuffer port, byte on, IntBuffer status);
|
||||
public static native byte getSolenoid(ByteBuffer port, IntBuffer status);
|
||||
|
||||
public static native byte getPCMSolenoidBlackList(ByteBuffer pcm_pointer, IntBuffer status);
|
||||
public static native boolean getPCMSolenoidVoltageStickyFault(ByteBuffer pcm_pointer, IntBuffer status);
|
||||
public static native boolean getPCMSolenoidVoltageFault(ByteBuffer pcm_pointer, IntBuffer status);
|
||||
public static native void clearAllPCMStickyFaults(ByteBuffer pcm_pointer, IntBuffer status);
|
||||
}
|
||||
|
||||
@@ -100,3 +100,99 @@ JNIEXPORT jfloat JNICALL Java_edu_wpi_first_wpilibj_hal_CompressorJNI_getCompres
|
||||
return getCompressorCurrent(*pcm_pointer, status_pointer);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_CompressorJNI
|
||||
* Method: getCompressorCurrentTooHighFault
|
||||
* Signature: (Ljava/nio/ByteBuffer;Ljava/nio/IntBuffer;)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_edu_wpi_first_wpilibj_hal_CompressorJNI_getCompressorCurrentTooHighFault
|
||||
(JNIEnv *env, jclass, jobject pcm_pointer_object, jobject status)
|
||||
{
|
||||
VoidPointer *pcm_pointer = (VoidPointer *)env->GetDirectBufferAddress(pcm_pointer_object);
|
||||
jint *status_pointer = (jint *)env->GetDirectBufferAddress(status);
|
||||
|
||||
return getCompressorCurrentTooHighFault(*pcm_pointer, status_pointer);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_CompressorJNI
|
||||
* Method: getCompressorCurrentTooHighStickyFault
|
||||
* Signature: (Ljava/nio/ByteBuffer;Ljava/nio/IntBuffer;)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_edu_wpi_first_wpilibj_hal_CompressorJNI_getCompressorCurrentTooHighStickyFault
|
||||
(JNIEnv *env, jclass, jobject pcm_pointer_object, jobject status)
|
||||
{
|
||||
VoidPointer *pcm_pointer = (VoidPointer *)env->GetDirectBufferAddress(pcm_pointer_object);
|
||||
jint *status_pointer = (jint *)env->GetDirectBufferAddress(status);
|
||||
|
||||
return getCompressorCurrentTooHighStickyFault(*pcm_pointer, status_pointer);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_CompressorJNI
|
||||
* Method: getCompressorShortedStickyFault
|
||||
* Signature: (Ljava/nio/ByteBuffer;Ljava/nio/IntBuffer;)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_edu_wpi_first_wpilibj_hal_CompressorJNI_getCompressorShortedStickyFault
|
||||
(JNIEnv *env, jclass, jobject pcm_pointer_object, jobject status)
|
||||
{
|
||||
VoidPointer *pcm_pointer = (VoidPointer *)env->GetDirectBufferAddress(pcm_pointer_object);
|
||||
jint *status_pointer = (jint *)env->GetDirectBufferAddress(status);
|
||||
|
||||
return getCompressorShortedStickyFault(*pcm_pointer, status_pointer);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_CompressorJNI
|
||||
* Method: getCompressorShortedFault
|
||||
* Signature: (Ljava/nio/ByteBuffer;Ljava/nio/IntBuffer;)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_edu_wpi_first_wpilibj_hal_CompressorJNI_getCompressorShortedFault
|
||||
(JNIEnv *env, jclass, jobject pcm_pointer_object, jobject status)
|
||||
{
|
||||
VoidPointer *pcm_pointer = (VoidPointer *)env->GetDirectBufferAddress(pcm_pointer_object);
|
||||
jint *status_pointer = (jint *)env->GetDirectBufferAddress(status);
|
||||
|
||||
return getCompressorShortedFault(*pcm_pointer, status_pointer);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_CompressorJNI
|
||||
* Method: getCompressorNotConnectedStickyFault
|
||||
* Signature: (Ljava/nio/ByteBuffer;Ljava/nio/IntBuffer;)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_edu_wpi_first_wpilibj_hal_CompressorJNI_getCompressorNotConnectedStickyFault
|
||||
(JNIEnv *env, jclass, jobject pcm_pointer_object, jobject status)
|
||||
{
|
||||
VoidPointer *pcm_pointer = (VoidPointer *)env->GetDirectBufferAddress(pcm_pointer_object);
|
||||
jint *status_pointer = (jint *)env->GetDirectBufferAddress(status);
|
||||
|
||||
return getCompressorNotConnectedStickyFault(*pcm_pointer, status_pointer);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_CompressorJNI
|
||||
* Method: getCompressorNotConnectedFault
|
||||
* Signature: (Ljava/nio/ByteBuffer;Ljava/nio/IntBuffer;)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_edu_wpi_first_wpilibj_hal_CompressorJNI_getCompressorNotConnectedFault
|
||||
(JNIEnv *env, jclass, jobject pcm_pointer_object, jobject status)
|
||||
{
|
||||
VoidPointer *pcm_pointer = (VoidPointer *)env->GetDirectBufferAddress(pcm_pointer_object);
|
||||
jint *status_pointer = (jint *)env->GetDirectBufferAddress(status);
|
||||
|
||||
return getCompressorNotConnectedFault(*pcm_pointer, status_pointer);
|
||||
}
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_CompressorJNI
|
||||
* Method: clearAllPCMStickyFaults
|
||||
* Signature: (Ljava/nio/ByteBuffer;Ljava/nio/IntBuffer;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CompressorJNI_clearAllPCMStickyFaults
|
||||
(JNIEnv *env, jclass, jobject pcm_pointer_object, jobject status)
|
||||
{
|
||||
VoidPointer *pcm_pointer = (VoidPointer *)env->GetDirectBufferAddress(pcm_pointer_object);
|
||||
jint *status_pointer = (jint *)env->GetDirectBufferAddress(status);
|
||||
|
||||
clearAllPCMStickyFaults(*pcm_pointer, status_pointer);
|
||||
}
|
||||
|
||||
@@ -89,3 +89,57 @@ JNIEXPORT jbyte JNICALL Java_edu_wpi_first_wpilibj_hal_SolenoidJNI_getSolenoid
|
||||
|
||||
return getSolenoid(*solenoid_port_pointer, status_pointer);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_SolenoidJNI
|
||||
* Method: getPCMSolenoidBlackList
|
||||
* Signature: (Ljava/nio/ByteBuffer;Ljava/nio/IntBuffer;)B
|
||||
*/
|
||||
JNIEXPORT jbyte JNICALL Java_edu_wpi_first_wpilibj_hal_SolenoidJNI_getPCMSolenoidBlackList
|
||||
(JNIEnv *env, jclass, jobject solenoid_port, jobject status)
|
||||
{
|
||||
|
||||
VoidPointer *solenoid_port_pointer = (VoidPointer *)env->GetDirectBufferAddress(solenoid_port);
|
||||
jint *status_pointer = (jint*)env->GetDirectBufferAddress(status);
|
||||
|
||||
return getPCMSolenoidBlackList(*solenoid_port_pointer, status_pointer);
|
||||
}
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_SolenoidJNI
|
||||
* Method: getPCMSolenoidVoltageStickyFault
|
||||
* Signature: (Ljava/nio/ByteBuffer;Ljava/nio/IntBuffer;)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_edu_wpi_first_wpilibj_hal_SolenoidJNI_getPCMSolenoidVoltageStickyFault
|
||||
(JNIEnv *env, jclass, jobject solenoid_port, jobject status)
|
||||
{
|
||||
VoidPointer *solenoid_port_pointer = (VoidPointer *)env->GetDirectBufferAddress(solenoid_port);
|
||||
jint *status_pointer = (jint *)env->GetDirectBufferAddress(status);
|
||||
|
||||
return getPCMSolenoidVoltageStickyFault(*solenoid_port_pointer, status_pointer);
|
||||
}
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_SolenoidJNI
|
||||
* Method: getPCMSolenoidVoltageFault
|
||||
* Signature: (Ljava/nio/ByteBuffer;Ljava/nio/IntBuffer;)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_edu_wpi_first_wpilibj_hal_SolenoidJNI_getPCMSolenoidVoltageFault
|
||||
(JNIEnv *env, jclass, jobject solenoid_port, jobject status)
|
||||
{
|
||||
VoidPointer *solenoid_port_pointer = (VoidPointer *)env->GetDirectBufferAddress(solenoid_port);
|
||||
jint *status_pointer = (jint *)env->GetDirectBufferAddress(status);
|
||||
|
||||
return getPCMSolenoidVoltageFault(*solenoid_port_pointer, status_pointer);
|
||||
}
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_SolenoidJNI
|
||||
* Method: clearAllPCMStickyFaults
|
||||
* Signature: (Ljava/nio/ByteBuffer;Ljava/nio/IntBuffer;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SolenoidJNI_clearAllPCMStickyFaults
|
||||
(JNIEnv *env, jclass, jobject solenoid_port, jobject status)
|
||||
{
|
||||
VoidPointer *solenoid_port_pointer = (VoidPointer *)env->GetDirectBufferAddress(solenoid_port);
|
||||
jint *status_pointer = (jint *)env->GetDirectBufferAddress(status);
|
||||
|
||||
clearAllPCMStickyFaults_sol(*solenoid_port_pointer, status_pointer);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user