Fix usage reporting for new motor controllers and Analog output

Change-Id: I574e431ae551ecf8efc90c004abf14568f22c068
This commit is contained in:
Kevin O'Connor
2015-04-30 16:22:46 -04:00
parent 1e4e0bacde
commit 8b71ddc30f
14 changed files with 40 additions and 9 deletions

View File

@@ -95,6 +95,10 @@ namespace HALUsageReporting
kResourceType_HiTechnicAccel,
kResourceType_HiTechnicCompass,
kResourceType_SRF08,
kResourceType_AnalogOutput,
kResourceType_VictorSP,
kResourceType_TalonSRX,
kResourceType_CANTalonSRX,
};
enum tInstances

View File

@@ -51,6 +51,7 @@ public:
*/
virtual int32_t receiveMessage(uint32_t &messageID, uint8_t *data, uint8_t &dataSize) = 0;
#if defined(__linux)
/**
* This entry-point of the CANInterfacePlugin returns status of the CAN bus.
*
@@ -67,6 +68,7 @@ public:
* @return This should return 0 if all status was retrieved successfully or an error code if not.
*/
virtual int32_t getStatus(uint32_t &busOffCount, uint32_t &txFullCount, uint32_t &receiveErrorCount, uint32_t &transmitErrorCount) {return 0;}
#endif
};
/**

View File

@@ -26,6 +26,7 @@
#define WARN_CANSessionMux_NoToken 44087
#define ERR_CANSessionMux_NotAllowed -44088
#define ERR_CANSessionMux_NotInitialized -44089
#define ERR_CANSessionMux_SessionOverrun 44050
struct tCANStreamMessage{
uint32_t messageID;

View File

@@ -33,6 +33,7 @@
#endif
#define ERR_FRCSystem_NetCommNotResponding -44049
#define ERR_FRCSystem_NoDSConnection -44018
enum AllianceStationID_t {
kAllianceStationID_red1,
@@ -43,6 +44,13 @@ enum AllianceStationID_t {
kAllianceStationID_blue3,
};
enum MatchType_t {
kMatchType_none,
kMatchType_practice,
kMatchType_qualification,
kMatchType_elimination,
};
struct ControlWord_t {
#ifndef __vxworks
uint32_t enabled : 1;
@@ -91,7 +99,7 @@ extern "C" {
# if defined (__vxworks)
void EXPORT_FUNC setNewDataSem(SEM_ID);
# else
void EXPORT_FUNC setNewDataSem(pthread_mutex_t *);
void EXPORT_FUNC setNewDataSem(pthread_cond_t *);
# endif
#endif

View File

@@ -68,7 +68,11 @@ namespace nUsageReporting
kResourceType_HiTechnicColorSensor,
kResourceType_HiTechnicAccel,
kResourceType_HiTechnicCompass,
kResourceType_SRF08,
kResourceType_SRF08,
kResourceType_AnalogOutput,
kResourceType_VictorSP,
kResourceType_TalonSRX,
kResourceType_CANTalonSRX,
} tResourceType;
typedef enum

View File

@@ -40,7 +40,7 @@ void AnalogOutput::InitAnalogOutput(uint32_t channel) {
wpi_setErrorWithContext(status, getHALErrorMessage(status));
LiveWindow::GetInstance()->AddActuator("AnalogOutput", m_channel, this);
HALReport(HALUsageReporting::kResourceType_AnalogChannel, m_channel, 0);
HALReport(HALUsageReporting::kResourceType_AnalogOutput, m_channel);
}
/**

View File

@@ -164,7 +164,6 @@ void CANTalon::Set(float value, uint8_t syncGroup)
*/
void CANTalon::Disable()
{
// Until Modes other than throttle work, just disable by setting throttle to 0.0.
m_impl->SetModeSelect((int)CANTalon::kDisabled);
m_controlEnabled = false;
}
@@ -1171,6 +1170,7 @@ void CANTalon::ConfigFaultTime(float faultTime)
void CANTalon::ApplyControlMode(CANSpeedController::ControlMode mode)
{
m_controlMode = mode;
HALReport(HALUsageReporting::kResourceType_CANTalonSRX, m_deviceNumber+1, mode);
switch (mode) {
case kPercentVbus:
m_sendMode = kThrottle;

View File

@@ -28,7 +28,7 @@ void TalonSRX::InitTalonSRX() {
SetRaw(m_centerPwm);
SetZeroLatch();
HALReport(HALUsageReporting::kResourceType_Talon, GetChannel());
HALReport(HALUsageReporting::kResourceType_TalonSRX, GetChannel());
LiveWindow::GetInstance()->AddActuator("TalonSRX", GetChannel(), this);
}

View File

@@ -29,7 +29,7 @@ void VictorSP::InitVictorSP() {
SetRaw(m_centerPwm);
SetZeroLatch();
HALReport(HALUsageReporting::kResourceType_Talon, GetChannel());
HALReport(HALUsageReporting::kResourceType_VictorSP, GetChannel());
LiveWindow::GetInstance()->AddActuator("VictorSP", GetChannel(), this);
}

View File

@@ -60,7 +60,7 @@ public class AnalogOutput extends SensorBase implements LiveWindowSendable {
HALUtil.checkStatus(status.asIntBuffer());
LiveWindow.addSensor("AnalogOutput", channel, this);
UsageReporting.report(tResourceType.kResourceType_AnalogChannel, channel, 1);
UsageReporting.report(tResourceType.kResourceType_AnalogOutput, channel);
}
/**

View File

@@ -10,6 +10,8 @@ package edu.wpi.first.wpilibj;
import edu.wpi.first.wpilibj.hal.CanTalonSRX;
import edu.wpi.first.wpilibj.hal.CanTalonJNI;
import edu.wpi.first.wpilibj.communication.UsageReporting;
import edu.wpi.first.wpilibj.communication.FRCNetworkCommunicationsLibrary.tResourceType;
import edu.wpi.first.wpilibj.hal.SWIGTYPE_p_double;
import edu.wpi.first.wpilibj.hal.SWIGTYPE_p_int;
import edu.wpi.first.wpilibj.hal.SWIGTYPE_p_uint32_t;
@@ -456,6 +458,8 @@ public class CANTalon implements MotorSafety, PIDOutput, SpeedController {
m_controlEnabled = false;
// Disable until set() is called.
m_impl.SetModeSelect(ControlMode.Disabled.value);
UsageReporting.report(tResourceType.kResourceType_CANTalonSRX, m_deviceNumber + 1, controlMode.value);
}
public void changeControlMode(ControlMode controlMode) {
if(m_controlMode == controlMode){

View File

@@ -38,7 +38,7 @@ public class TalonSRX extends SafePWM implements SpeedController {
setZeroLatch();
LiveWindow.addActuator("TalonSRX", getChannel(), this);
UsageReporting.report(tResourceType.kResourceType_Talon, getChannel());
UsageReporting.report(tResourceType.kResourceType_TalonSRX, getChannel());
}
/**

View File

@@ -37,7 +37,7 @@ public class VictorSP extends SafePWM implements SpeedController {
setZeroLatch();
LiveWindow.addActuator("VictorSP", getChannel(), this);
UsageReporting.report(tResourceType.kResourceType_Talon, getChannel());
UsageReporting.report(tResourceType.kResourceType_VictorSP, getChannel());
}
/**

View File

@@ -157,6 +157,14 @@ public class FRCNetworkCommunicationsLibrary extends JNIWrapper {
public static final int kResourceType_HiTechnicCompass = 47;
/** <i>native declaration : src\main\include\NetworkCommunication\UsageReporting.h:58</i> */
public static final int kResourceType_SRF08 = 48;
/** <i>native declaration : src\main\include\NetworkCommunication\UsageReporting.h:59</i> */
public static final int kResourceType_AnalogOutput = 49;
/** <i>native declaration : src\main\include\NetworkCommunication\UsageReporting.h:60</i> */
public static final int kResourceType_VictorSP = 50;
/** <i>native declaration : src\main\include\NetworkCommunication\UsageReporting.h:61</i> */
public static final int kResourceType_TalonSRX = 51;
/** <i>native declaration : src\main\include\NetworkCommunication\UsageReporting.h:62</i> */
public static final int kResourceType_CANTalonSRX = 52;
};
/**
* <i>native declaration : src\main\include\NetworkCommunication\UsageReporting.h</i><br>