A8000
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

166 lines
4.0 KiB

8 months ago
8 months ago
8 months ago
8 months ago
1 month ago
  1. //声明设备控制系列接口
  2. import apiClient from '../../utils/axios'
  3. //开始
  4. export const startWork = async () => {
  5. try {
  6. const res = await apiClient.post('/api/v1/app/deviceCtrl/startWork')
  7. return res.data
  8. } catch (error) {
  9. console.log('设备启动报错', error)
  10. }
  11. }
  12. //暂停
  13. export const pauseWork = async () => {
  14. try {
  15. const res = await apiClient.post('/api/v1/app/deviceCtrl/pauseWork')
  16. return res.data
  17. } catch (error) {
  18. console.log('设备暂停报错', error)
  19. }
  20. }
  21. //继续
  22. export const continueWork = async () => {
  23. try {
  24. const res = await apiClient.post('/api/v1/app/deviceCtrl/continueWork')
  25. return res.data
  26. } catch (error) {
  27. console.log('设备继续报错', error)
  28. }
  29. }
  30. //停止
  31. export const stopWork = async () => {
  32. try {
  33. const res = await apiClient.post('/api/v1/app/deviceCtrl/stopWork')
  34. return res.data
  35. } catch (error) {
  36. console.log('设备停止报错', error)
  37. }
  38. }
  39. export const getDeviceWorkState = async () => {
  40. try {
  41. const res = await apiClient.post('/api/v1/app/deviceState/getDeviceWorkState')
  42. return res.data
  43. } catch (error) {
  44. console.log('设备停止报错', error)
  45. }
  46. }
  47. //获取设备信息
  48. export const getDeviceIp = async () => {
  49. try {
  50. const res = await apiClient.post('/api/v1/app/osCtrl/getIp')
  51. return res.data
  52. } catch (error) {
  53. console.log('设备信息获取报错', error)
  54. }
  55. }
  56. export type DeviceInfo = {
  57. appVersion: string;
  58. mcuVersion: string;
  59. sn: string;
  60. ip: string;
  61. assetId: string;
  62. }
  63. export const getDeviceInfo = async () => {
  64. try {
  65. const res = await apiClient.post('/api/v1/app/DeviceInfo/getDeviceInfo')
  66. return res.data
  67. } catch (error) {
  68. console.log('设备信息获取报错', error)
  69. }
  70. }
  71. //获取设备工作状态
  72. export const getDeviceStatus = async () => {
  73. try {
  74. const res = await apiClient.post('/api/v1/app/osCtrl/getDeviceWorkState')
  75. return res.data
  76. } catch (error) {
  77. console.log('设备状态获取报错', error)
  78. }
  79. }
  80. //获取一个设备事件
  81. export const pollAppEvent = async () => {
  82. try {
  83. const res = await apiClient.post('/api/v1/app/AppEventBus/pollAppEvent')
  84. return res.data
  85. } catch (error) {
  86. console.log('单个设备事件获取报错', error)
  87. }
  88. }
  89. //获取所有的事件
  90. export const pollAllAppEvents = async () => {
  91. try {
  92. const res = await apiClient.post('/api/v1/app/AppEventBus/pollAllAppEvents')
  93. return res.data
  94. } catch (error) {
  95. console.log('全部设备事件获取报错', error)
  96. }
  97. }
  98. //蜂鸣器打开
  99. export const openBuzzer = async () => {
  100. try {
  101. const res = await apiClient.post('/api/v1/app/osCtrl/startBeepWarning')
  102. return res.data
  103. } catch (error) {
  104. console.log('蜂鸣器打开报错', error)
  105. }
  106. }
  107. //蜂鸣器关闭
  108. export const closeBuzzer = async () => {
  109. try {
  110. const res = await apiClient.post('/api/v1/app/osCtrl/stopBeepWarning')
  111. return res.data
  112. } catch (error) {
  113. console.log('蜂鸣器关闭报错', error)
  114. }
  115. }
  116. // 清除报警
  117. export const clearFlagState = async (flagType: string) => {
  118. try {
  119. const res = await apiClient.post(`/api/v1/app/FlagStateMgr/clearFlagState?flagKey=${flagType}`)
  120. return res.data
  121. } catch (error) {
  122. console.log('关闭报警失败', error)
  123. }
  124. }
  125. // 清除所有报警
  126. export const clearAllFlagState = async () => {
  127. try {
  128. const res = await apiClient.post(`/api/v1/app/FlagStateMgr/clearAllFlagState`)
  129. return res.data
  130. } catch (error) {
  131. console.log('关闭报警失败', error)
  132. }
  133. }
  134. //失通设备
  135. export const disableDevice = async () => {
  136. try {
  137. const res = await apiClient.post(`/api/v1/app/deviceExCtrl/disableDevice`)
  138. return res.data
  139. } catch (error) {
  140. console.log('失能设备失败', error)
  141. }
  142. }
  143. // MCU详细版本信息
  144. export const getMcuVersionDetailInfo = async () => {
  145. try {
  146. const res = await apiClient.post('/api/v1/app/DeviceInfo/getMcuVersionDetail')
  147. return res.data
  148. } catch (error) {
  149. console.log('MCU详细版本信息获取报错', error)
  150. }
  151. }