00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039 #include <RmpFault.h>
00040
00041 #include <cstdarg>
00042 #include <stdexcept>
00043 #include <vector>
00044
00045 namespace segway
00046 {
00047 void InitializeFaultDecodeList(FaultDecodeList& rDecodeList, unsigned int argumentCount, ...)
00048 {
00049 rDecodeList.clear();
00050
00051 va_list argumentList;
00052 va_start(argumentList, argumentCount);
00053
00054 for (unsigned int i = 0; i < argumentCount; ++i)
00055 {
00056 std::string argument(va_arg(argumentList, const char*));
00057 rDecodeList.push_back(argument);
00058 }
00059
00060 va_end(argumentList);
00061 }
00062
00063 const uint32_t& FaultPacking::GetShift() const
00064 {
00065 return m_Shift;
00066 }
00067
00068 const uint32_t& FaultPacking::GetMask() const
00069 {
00070 return m_Mask;
00071 }
00072
00073 const FaultGroup& FaultPacking::GetGroup() const
00074 {
00075 return m_Group;
00076 }
00077
00078 struct RmpFault::Impl
00079 {
00080 static Impl& Instance()
00081 {
00082 static Impl instance;
00083
00084 return instance;
00085 }
00086
00087 Impl();
00088
00089 ~Impl();
00090
00091 FeedbackTypeList m_FeedbackTypeList;
00092 std::vector<FaultPackingList> m_FaultPackingTable;
00093 std::vector<FaultDecodeList> m_FaultDecodeTable;
00094 };
00095
00096 const FeedbackTypeList& RmpFault::GetFaultFeedbackEntryList()
00097 {
00098 return Impl::Instance().m_FeedbackTypeList;
00099 }
00100
00101 const FaultPackingList& RmpFault::GetFaultPackingList(UserDefinedFeedbackType feedbackType)
00102 {
00103 return Impl::Instance().m_FaultPackingTable[feedbackType];
00104 }
00105
00106 const FaultDecodeList& RmpFault::GetFaultDecodeList(FaultGroup faultGroup)
00107 {
00108 return Impl::Instance().m_FaultDecodeTable[faultGroup];
00109 }
00110
00111 RmpFault::Impl::Impl()
00112 {
00113 m_FeedbackTypeList.push_back(FAULT_STATUS_WORD_1);
00114 m_FeedbackTypeList.push_back(FAULT_STATUS_WORD_2);
00115 m_FeedbackTypeList.push_back(FAULT_STATUS_WORD_3);
00116 m_FeedbackTypeList.push_back(FAULT_STATUS_WORD_4);
00117
00118 FaultPackingList word0Packing;
00119 word0Packing.push_back(FaultPacking(0, 0x00000FFF, ARCHITECTURE));
00120 word0Packing.push_back(FaultPacking(12, 0xFFFFF000, CRITICAL));
00121
00122 FaultPackingList word1Packing;
00123 word1Packing.push_back(FaultPacking(0, 0x0000FFFF, COMM));
00124 word1Packing.push_back(FaultPacking(16, 0x000F0000, INTERNAL));
00125
00126 FaultPackingList word2Packing;
00127 word2Packing.push_back(FaultPacking(0, 0x0000FFFF, SENSORS));
00128 word2Packing.push_back(FaultPacking(16, 0xFFFF0000, BSA));
00129
00130 FaultPackingList word3Packing;
00131 word3Packing.push_back(FaultPacking(0, 0xFFFFFFFF, MCU));
00132
00133 m_FaultPackingTable.push_back(word0Packing);
00134 m_FaultPackingTable.push_back(word1Packing);
00135 m_FaultPackingTable.push_back(word2Packing);
00136 m_FaultPackingTable.push_back(word3Packing);
00137
00138 FaultDecodeList transientFaultList;
00139
00140 FaultDecodeList architectureFaultList;
00141 InitializeFaultDecodeList(architectureFaultList, 12,
00142 "ARCHITECT_FAULT_SPI_RECEIVE",
00143 "ARCHITECT_FAULT_SPI_TRANSMIT",
00144 "ARCHITECT_FAULT_SPI_RECEIVE_OVERRUN",
00145 "ARCHITECT_FAULT_SPI_RX_BUFFER_OBVERRUN",
00146 "ARCHITECT_FAULT_COMMANDED_SAFETY_SHUTDOWN",
00147 "ARCHITECT_FAULT_COMMANDED_DISABLE",
00148 "ARCHITECT_FAULT_KILL_SWITCH_ACTIVE",
00149 "ARCHITECT_FAULT_FRAM_CONFIG_INIT_FAILED",
00150 "ARCHITECT_FAULT_FRAM_CONFIG_SET_FAILED",
00151 "ARCHITECT_FAULT_BAD_MODEL_IDENTIFIER",
00152 "ARCHITECT_FAULT_BAD_CCU_HW_REV",
00153 "ARCHITECT_FAULT_DECEL_SWITCH_ACTIVE");
00154
00155 FaultDecodeList criticalFaultList;
00156 InitializeFaultDecodeList(criticalFaultList, 13,
00157 "CRITICAL_FAULT_INIT",
00158 "CRITICAL_FAULT_INIT_UIP_COMM",
00159 "CRITICAL_FAULT_INIT_PROPULSION",
00160 "CRITICAL_FAULT_INIT_TIMEOUT",
00161 "CRITICAL_FAULT_FORW_SPEED_LIMITER_HAZARD",
00162 "CRITICAL_FAULT_AFT_SPEED_LIMITER_HAZARD",
00163 "CRITICAL_FAULT_CHECK_STARTUP",
00164 "CRITICAL_FAULT_APP_VELOCITY_CTL_FAILED",
00165 "CRITICAL_FAULT_APP_POSITION_CTL_FAILED",
00166 "CRITICAL_FAULT_ABB_SHUTDOWN",
00167 "CRITICAL_FAULT_AP_MODE_TRANS_TIMEOUT",
00168 "CRITICAL_FAULT_PITCH_ANGLE_EXCEEDED",
00169 "CRITICAL_FAULT_ROLL_ANGLE_EXCEEDED");
00170
00171 FaultDecodeList commFaultList;
00172 InitializeFaultDecodeList(commFaultList, 7,
00173 "COMM_FAULT_UIP_MISSING_UIP_DATA",
00174 "COMM_FAULT_UIP_UNKOWN_MESSAGE_RECEIVER",
00175 "COMM_FAULT_UIP_BAD_CHECKSUM",
00176 "COMM_FAULT_UIP_TRANSMIT",
00177 "COMM_FAULT_UI_BAD_MOTION_CMD",
00178 "COMM_FAULT_UI_UNKNOWN_CMD",
00179 "COMM_FAULT_UI_BAD_PACKET_CHECKSUM");
00180
00181 FaultDecodeList internalFaultList;
00182 InitializeFaultDecodeList(internalFaultList, 2,
00183 "INTERNAL_FAULT_HIT_DEFAULT_CONDITION",
00184 "INTERNAL_FAULT_HIT_SPECIAL_CASE");
00185
00186 FaultDecodeList sensorFaultList;
00187 InitializeFaultDecodeList(sensorFaultList, 10,
00188 "SENSOR_FAULT_2P5V_VREF_RANGE_FAULT",
00189 "SENSOR_FAULT_7P2V_VBAT_RANGE_FAULT",
00190 "SENSOR_FAULT_7P2V_VBAT_WARNING",
00191 "SENSOR_FAULT_7P2V_BAT_INBALANCE_FAULT",
00192 "SENSOR_FAULT_7P2V_BAT_TEMPARATURE_FAULT",
00193 "SENSOR_FAULT_DIGITAL_INPUT",
00194 "SENSOR_FAULT_RANGE",
00195 "SENSOR_FAULT_DEFAULT",
00196 "SENSOR_FAULT_5V_MONITOR_RANGE_FAULT",
00197 "SENSOR_FAULT_12V_MONITOR_RANGE_FAULT");
00198
00199
00200 FaultDecodeList bsaFaultList;
00201 InitializeFaultDecodeList(bsaFaultList, 11,
00202 "BSA_FAULT_SIDE_A_MISSING_BSA_DATA",
00203 "BSA_FAULT_SIDE_B_MISSING_BSA_DATA",
00204 "BSA_FAULT_UNKNOWN_MESSAGE_RECEIVED",
00205 "BSA_FAULT_TRANSMIT_A_FAILED",
00206 "BSA_FAULT_TRANSMIT_B_FAILED",
00207 "BSA_FAULT_DEFAULT",
00208 "BSA_FAULT_SIDE_A_RATE_SENSOR_SATURATED",
00209 "BSA_FAULT_SIDE_B_RATE_SENSOR_SATURATED",
00210 "BSA_FAULT_SIDE_A_TILT_SENSOR_SATURATED",
00211 "BSA_FAULT_SIDE_B_TILT_SENSOR_SATURATED",
00212 "PSE_FAULT_COMPARISON");
00213
00214 FaultDecodeList mcuFaultList;
00215 InitializeFaultDecodeList(mcuFaultList, 21,
00216 "MCU_FAULT_MCU_0_IS_DEGRADED",
00217 "MCU_FAULT_MCU_0_IS_FAILED",
00218 "MCU_FAULT_MCU_0_REQUESTS_REDUCE_PERFORMANCE",
00219 "MCU_FAULT_MCU_0_REQUESTS_ZERO_SPEED",
00220 "MCU_FAULT_MCU_1_IS_DEGRADED",
00221 "MCU_FAULT_MCU_1_IS_FAILED",
00222 "MCU_FAULT_MCU_1_REQUESTS_REDUCE_PERFORMANCE",
00223 "MCU_FAULT_MCU_1_REQUESTS_ZERO_SPEED",
00224 "MCU_FAULT_MCU_2_IS_DEGRADED",
00225 "MCU_FAULT_MCU_2_IS_FAILED",
00226 "MCU_FAULT_MCU_2_REQUESTS_REDUCE_PERFORMANCE",
00227 "MCU_FAULT_MCU_2_REQUESTS_ZERO_SPEED",
00228 "MCU_FAULT_MCU_3_IS_DEGRADED",
00229 "MCU_FAULT_MCU_3_IS_FAILED",
00230 "MCU_FAULT_MCU_3_REQUESTS_REDUCE_PERFORMANCE",
00231 "MCU_FAULT_MCU_3_REQUESTS_ZERO_SPEED",
00232 "MCU_FAULT_MISSING_MCU_0_DATA",
00233 "MCU_FAULT_MISSING_MCU_1_DATA",
00234 "MCU_FAULT_MISSING_MCU_2_DATA",
00235 "MCU_FAULT_MISSING_MCU_3_DATA",
00236 "MCU_FAULT_UNKNOWN_MESSAGE_RECEIVED");
00237
00238
00239 m_FaultDecodeTable.push_back(transientFaultList);
00240 m_FaultDecodeTable.push_back(criticalFaultList);
00241 m_FaultDecodeTable.push_back(commFaultList);
00242 m_FaultDecodeTable.push_back(sensorFaultList);
00243 m_FaultDecodeTable.push_back(bsaFaultList);
00244 m_FaultDecodeTable.push_back(mcuFaultList);
00245 m_FaultDecodeTable.push_back(architectureFaultList);
00246 m_FaultDecodeTable.push_back(internalFaultList);
00247 }
00248
00249 RmpFault::Impl::~Impl()
00250 {}
00251
00252 }