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.

146 lines
4.0 KiB

  1. import { v4 as uuidv4 } from 'uuid'
  2. /**
  3. * autoRestart 如果该字段为true那么如果相机已启动调用此接口会自动重启相机如果该字段为false那么如果相机已启动调用此接口相机将继续工作同时返回错误
  4. * need_receipt 如果为false则不返回回执
  5. */
  6. const transformToString = data => {
  7. return JSON.stringify(data)
  8. }
  9. // 启动相机
  10. export const startCapture = transformToString({
  11. command: 'startCapture',
  12. autoRestart: true,
  13. messageId: uuidv4(),
  14. need_receipt: true,
  15. })
  16. // 停止相机
  17. export const stopCapture = transformToString({
  18. command: 'stopCapture',
  19. messageId: uuidv4(),
  20. need_receipt: true,
  21. })
  22. // 获取相机状态
  23. export const getCameraState = transformToString({
  24. command: 'getCameraState',
  25. messageId: uuidv4(),
  26. need_receipt: true,
  27. })
  28. /**
  29. * 拍照
  30. * 1. 图片拍照需要启动相机后才能拍照
  31. * 2. 拍照时间并非完全等于指令下发时间而是取后台程序上一张实时获取的照片
  32. * 3. 后台自动拍照间隙目前设置为300ms
  33. */
  34. export const takePhoto = transformToString({
  35. command: 'takePhoto',
  36. messageId: uuidv4(),
  37. need_receipt: true,
  38. })
  39. /**
  40. * 拍照并保存
  41. * filePrefix 图片保存前缀最终保存的图片格式为filePrefix+2022-07-26-12-51-46.tiff
  42. */
  43. export const takeAndSavePhoto = transformToString({
  44. command: 'takeAndSavePhoto',
  45. filePrefix: 'exprose1000/phto',
  46. messageId: uuidv4(),
  47. need_receipt: true,
  48. })
  49. // 加载相机配置
  50. // 该指令只加载配置,不保存配置
  51. export const loadCameraConfig = transformToString({
  52. command: 'loadCameraConfig',
  53. data: 'data:application/octet-stream;base64,IyB7MDVEOEMyOTQtRjI5NS00ZGZiLTlEMDEtMDk2QkQwNDA0OUY0fQojIEdlbkFwaSBwZXJzaXN0ZW5jZSBmaWxlICh2ZXJzaW9uIDMuMS4wKQojIERldmljZSA9IEJhc2xlcjo6R2lnRUNhbWVyYSAtLSBCYXNsZXIgZ2VuZXJpYyBHaWdFVmlzaW9uIGNhbWVyYSBpbnRlcmZhY2UgLS0gRGV2aWNlIHZlcnNpb24gPSAzLjguMCAtLSBQcm9kdWN0IEdVSUQg=',
  54. messageId: uuidv4(),
  55. filename: 'acA4112-8gm_40185942.pfs',
  56. need_receipt: true,
  57. })
  58. // 保存相机配置
  59. export const saveCameraConfig = transformToString({
  60. command: 'saveCameraConfig',
  61. messageId: uuidv4(),
  62. need_receipt: true,
  63. })
  64. // 启动相机识别
  65. export const startCharacterRecognition = transformToString({
  66. command: 'startCharacterRecognition',
  67. messageId: uuidv4(),
  68. need_receipt: true,
  69. })
  70. // 停止相机识别
  71. export const stopCharacterRecognition = transformToString({
  72. command: 'stopCharacterRecognition',
  73. messageId: uuidv4(),
  74. need_receipt: true,
  75. })
  76. // 获取识别结果
  77. export const getCharacterRecognitionResult = transformToString({
  78. command: 'getCharacterRecognitionResult',
  79. messageId: uuidv4(),
  80. need_receipt: true,
  81. })
  82. // 获取识别结果simple
  83. export const getCharacterRecognitionResultSimple = transformToString({
  84. command: 'getCharacterRecognitionResultSimple',
  85. messageId: uuidv4(),
  86. need_receipt: true,
  87. })
  88. // 机械臂控制接口 获取机械臂 连接信息 x y 位置
  89. export const getMechanicalArmState = transformToString({
  90. command: 'getMechanicalArmState',
  91. messageId: uuidv4(),
  92. need_receipt: true,
  93. })
  94. /**
  95. * 通道1亮度 = 模拟通道亮度*数字通道1亮度
  96. * 通道2亮度 = 模拟通道亮度*数字通道1亮度
  97. * 通道3亮度 = 模拟通道亮度*数字通道1亮度
  98. * 通道4亮度 = 模拟通道亮度*数字通道1亮度
  99. */
  100. //设置模拟通道亮度
  101. export const setFlashBrightnessAnalog = transformToString({
  102. command: 'setFlashBrightnessAnalog',
  103. brightness: 49282,
  104. messageId: uuidv4(),
  105. need_receipt: true,
  106. })
  107. // 设置数字通道亮度
  108. export const setFlashBrightnessDigital = channel => {
  109. return transformToString({
  110. command: 'setFlashBrightnessDigital',
  111. channel,
  112. brightness: 45497,
  113. messageId: uuidv4(),
  114. need_receipt: true,
  115. })
  116. }
  117. // 打开闪光灯
  118. export const openFlashLight = transformToString({
  119. command: 'openFlashLight',
  120. messageId: uuidv4(),
  121. need_receipt: true,
  122. })
  123. // 关闭闪光灯
  124. export const closeFlashLight = transformToString({
  125. command: 'CloseFlashLight',
  126. messageId: uuidv4(),
  127. need_receipt: true,
  128. })