index.ts 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  1. export interface ErrorCode {
  2. code: number;
  3. msg: string;
  4. }
  5. /**
  6. * 根据错误码翻译错误信息
  7. * @param code
  8. * @param errorMsg
  9. * @returns
  10. */
  11. export function getErrorMessage(code: number, errorMsg?: string): string {
  12. const errorInfo = ERROR_CODE.find((item: ErrorCode) => item.code === code)
  13. return errorInfo ? errorInfo.msg : errorMsg || 'Server error'
  14. }
  15. // 暂时只添加航线错误
  16. export const ERROR_CODE = [
  17. {
  18. code: 314001,
  19. msg: 'The issued route task url is empty',
  20. },
  21. {
  22. code: 314002,
  23. msg: 'The issued route task md5 is empty',
  24. },
  25. {
  26. code: 314003,
  27. msg: 'MissionID is invalid',
  28. },
  29. {
  30. code: 314004,
  31. msg: 'Failed to send flight route task from cloud',
  32. },
  33. {
  34. code: 314005,
  35. msg: 'Route md5 check failed',
  36. },
  37. {
  38. code: 314006,
  39. msg: 'Timeout waiting for aircraft to upload route (waiting for gs_state)',
  40. },
  41. {
  42. code: 314007,
  43. msg: 'Failed to upload route to aircraft',
  44. },
  45. {
  46. code: 314008,
  47. msg: 'Timeout waiting for the aircraft to enter the route executable state',
  48. },
  49. {
  50. code: 314009,
  51. msg: 'Failed to open route mission',
  52. },
  53. {
  54. code: 314010,
  55. msg: 'Route execution failed',
  56. },
  57. {
  58. code: 316001,
  59. msg: 'Failed to set alternate point',
  60. },
  61. {
  62. code: 316002,
  63. msg: 'Alternate safety transfer altitude equipment failed',
  64. },
  65. {
  66. code: 316003,
  67. msg: 'Failed to set takeoff altitude. Remarks: The default safe takeoff height of the aircraft set by the current DJI Dock is: 1.8',
  68. },
  69. {
  70. code: 316004,
  71. msg: 'Failed to set runaway behavior',
  72. },
  73. {
  74. code: 316005,
  75. msg: 'Aircraft RTK convergence failed',
  76. },
  77. {
  78. code: 316013,
  79. msg: 'DJI Dock Moved',
  80. },
  81. {
  82. code: 316015,
  83. msg: 'The aircraft RTK convergence position is too far from the DJI Dock',
  84. },
  85. {
  86. code: 316007,
  87. msg: 'Set parameter timeout while waiting for aircraft to be ready',
  88. },
  89. {
  90. code: 316008,
  91. msg: 'Failed to gain control of aircraft',
  92. },
  93. {
  94. code: 316009,
  95. msg: 'Aircraft power is low',
  96. },
  97. {
  98. code: 316010,
  99. msg: 'After power on, the aircraft is not connected for more than 2 minutes (flight control OSD reception timeout)',
  100. },
  101. {
  102. code: 316011,
  103. msg: 'Landing Position Offset',
  104. },
  105. {
  106. code: 317001,
  107. msg: 'Failed to get the number of media files',
  108. },
  109. {
  110. code: 319001,
  111. msg: 'The task center is not currently idle',
  112. },
  113. {
  114. code: 319002,
  115. msg: 'dronenest communication timeout',
  116. },
  117. {
  118. code: 319999,
  119. msg: 'Unknown error, e.g. restart after crash',
  120. },
  121. {
  122. code: 321000,
  123. msg: 'Route execution failed, unknown error',
  124. },
  125. {
  126. code: 321257,
  127. msg: 'The route has already started and cannot be started again',
  128. },
  129. {
  130. code: 321258,
  131. msg: 'The route cannot be interrupted in this state',
  132. },
  133. {
  134. code: 321259,
  135. msg: 'The route has not started and cannot end the route',
  136. },
  137. {
  138. code: 321513,
  139. msg: 'Reach the height limit',
  140. },
  141. {
  142. code: 321514,
  143. msg: 'Reach the limit',
  144. },
  145. {
  146. code: 321515,
  147. msg: 'Crossing the restricted flight zone',
  148. },
  149. {
  150. code: 321516,
  151. msg: 'Low limit',
  152. },
  153. {
  154. code: 321517,
  155. msg: 'Obstacle Avoidance',
  156. },
  157. {
  158. code: 321769,
  159. msg: 'Weak GPS signal',
  160. },
  161. {
  162. code: 321770,
  163. msg: 'The current gear state cannot be executed, B control seizes the control, and the gear is switched',
  164. },
  165. {
  166. code: 321771,
  167. msg: 'The home point is not refreshed',
  168. },
  169. {
  170. code: 321772,
  171. msg: 'The current battery is too low to start the task',
  172. },
  173. {
  174. code: 321773,
  175. msg: 'Low battery return',
  176. },
  177. {
  178. code: 321776,
  179. msg: 'RTK not ready',
  180. },
  181. {
  182. code: 321778,
  183. msg: 'The aircraft is idling on the ground and is not allowed to start the route, thinking that the user is not ready.',
  184. },
  185. {
  186. code: 322282,
  187. msg: 'User interrupt (B control takeover)',
  188. },
  189. {
  190. code: 514100,
  191. msg: 'Command not supported',
  192. },
  193. {
  194. code: 514101,
  195. msg: 'Failed to close putter',
  196. },
  197. {
  198. code: 514102,
  199. msg: 'Failed to release putter',
  200. },
  201. {
  202. code: 514103,
  203. msg: 'Aircraft battery is low',
  204. },
  205. {
  206. code: 514104,
  207. msg: 'Failed to start charging',
  208. },
  209. {
  210. code: 514105,
  211. msg: 'Failed to stop charging',
  212. },
  213. {
  214. code: 514106,
  215. msg: 'Failed to restart the aircraft',
  216. },
  217. {
  218. code: 514107,
  219. msg: 'Failed to open hatch',
  220. },
  221. {
  222. code: 514108,
  223. msg: 'Failed to close hatch',
  224. },
  225. {
  226. code: 514109,
  227. msg: 'Failed to open the plane',
  228. },
  229. {
  230. code: 514110,
  231. msg: 'Failed to close the plane',
  232. },
  233. {
  234. code: 514111,
  235. msg: 'The aircraft failed to turn on the slow-rotating propeller in the cabin',
  236. },
  237. {
  238. code: 514112,
  239. msg: 'The aircraft failed to stop the slow-rotating propeller in the cabin',
  240. },
  241. {
  242. code: 514113,
  243. msg: 'Failed to establish wired connection with aircraft',
  244. },
  245. {
  246. code: 514114,
  247. msg: 'Get aircraft power status, command timed out, or return code is not 0',
  248. },
  249. {
  250. code: 514116,
  251. msg: 'The DJI Dock is busy and other control orders are being executed at the DJI Dock',
  252. },
  253. {
  254. code: 514117,
  255. msg: 'Check hatch status failed',
  256. },
  257. {
  258. code: 514118,
  259. msg: 'Check putter status failed',
  260. },
  261. {
  262. code: 514120,
  263. msg: 'DJI Dock and aircraft SDR connection failed',
  264. },
  265. {
  266. code: 514121,
  267. msg: 'Emergency stop state',
  268. },
  269. {
  270. code: 514122,
  271. msg: 'Failed to get the charging status of the aircraft (Failed to get the charging status, the flight mission can be executed, affecting charging and remote troubleshooting)',
  272. },
  273. {
  274. code: 514123,
  275. msg: 'Unable to power on due to low battery',
  276. },
  277. {
  278. code: 514124,
  279. msg: 'Failed to get battery information',
  280. },
  281. {
  282. code: 514125,
  283. msg: 'The battery is fully charged and cannot be charged',
  284. },
  285. {
  286. code: 514145,
  287. msg: 'Can not work while debugging on site',
  288. },
  289. {
  290. code: 514146,
  291. msg: 'Unable to work in remote debugging',
  292. },
  293. {
  294. code: 514147,
  295. msg: 'Unable to work in upgrade state',
  296. },
  297. {
  298. code: 514148,
  299. msg: 'Unable to execute new tasks in job state',
  300. },
  301. {
  302. code: 514150,
  303. msg: 'DJI Dock is automatically restarting',
  304. },
  305. ]