Browse Source

封装与设备端的消息体

master
maochaoying 2 years ago
parent
commit
702ee38044
  1. 14
      package-lock.json
  2. 1
      package.json
  3. 146
      src/command/index.js
  4. 5
      yarn.lock

14
package-lock.json

@ -15,6 +15,7 @@
"postcss-px-to-viewport": "^1.1.1",
"tdesign-icons-vue-next": "^0.1.5",
"tdesign-vue-next": "^0.21.1",
"uuid": "^9.0.0",
"vue": "^3.2.37",
"vue-router": "^4.0.13"
},
@ -1679,6 +1680,14 @@
"browserslist": ">= 4.21.0"
}
},
"node_modules/uuid": {
"version": "9.0.0",
"resolved": "https://registry.npmmirror.com/uuid/-/uuid-9.0.0.tgz",
"integrity": "sha512-MXcSTerfPa4uqyzStbRoTgt5XIe3x5+42+q1sDuy3R5MDk66URdLMOZe5aPX/SQd+kuYAh0FdP/pO28IkQyTeg==",
"bin": {
"uuid": "dist/bin/uuid"
}
},
"node_modules/validator": {
"version": "13.9.0",
"resolved": "https://registry.npmmirror.com/validator/-/validator-13.9.0.tgz",
@ -2990,6 +2999,11 @@
"picocolors": "^1.0.0"
}
},
"uuid": {
"version": "9.0.0",
"resolved": "https://registry.npmmirror.com/uuid/-/uuid-9.0.0.tgz",
"integrity": "sha512-MXcSTerfPa4uqyzStbRoTgt5XIe3x5+42+q1sDuy3R5MDk66URdLMOZe5aPX/SQd+kuYAh0FdP/pO28IkQyTeg=="
},
"validator": {
"version": "13.9.0",
"resolved": "https://registry.npmmirror.com/validator/-/validator-13.9.0.tgz",

1
package.json

@ -16,6 +16,7 @@
"postcss-px-to-viewport": "^1.1.1",
"tdesign-icons-vue-next": "^0.1.5",
"tdesign-vue-next": "^0.21.1",
"uuid": "^9.0.0",
"vue": "^3.2.37",
"vue-router": "^4.0.13"
},

146
src/command/index.js

@ -0,0 +1,146 @@
import { v4 as uuidv4 } from 'uuid'
/**
* autoRestart 如果该字段为true那么如果相机已启动调用此接口会自动重启相机如果该字段为false那么如果相机已启动调用此接口相机将继续工作同时返回错误
* need_receipt 如果为false则不返回回执
*/
const transformToString = data => {
return JSON.stringify(data)
}
// 启动相机
export const startCapture = transformToString({
command: 'startCapture',
autoRestart: true,
messageId: uuidv4(),
need_receipt: true,
})
// 停止相机
export const stopCapture = transformToString({
command: 'stopCapture',
messageId: uuidv4(),
need_receipt: true,
})
// 获取相机状态
export const getCameraState = transformToString({
command: 'getCameraState',
messageId: uuidv4(),
need_receipt: true,
})
/**
* 拍照
* 1. 图片拍照需要启动相机后才能拍照
* 2. 拍照时间并非完全等于指令下发时间而是取后台程序上一张实时获取的照片
* 3. 后台自动拍照间隙目前设置为300ms
*/
export const takePhoto = transformToString({
command: 'takePhoto',
messageId: uuidv4(),
need_receipt: true,
})
/**
* 拍照并保存
* filePrefix 图片保存前缀最终保存的图片格式为filePrefix+2022-07-26-12-51-46.tiff
*/
export const takeAndSavePhoto = transformToString({
command: 'takeAndSavePhoto',
filePrefix: 'exprose1000/phto',
messageId: uuidv4(),
need_receipt: true,
})
// 加载相机配置
// 该指令只加载配置,不保存配置
export const loadCameraConfig = transformToString({
command: 'loadCameraConfig',
data: 'data:application/octet-stream;base64,IyB7MDVEOEMyOTQtRjI5NS00ZGZiLTlEMDEtMDk2QkQwNDA0OUY0fQojIEdlbkFwaSBwZXJzaXN0ZW5jZSBmaWxlICh2ZXJzaW9uIDMuMS4wKQojIERldmljZSA9IEJhc2xlcjo6R2lnRUNhbWVyYSAtLSBCYXNsZXIgZ2VuZXJpYyBHaWdFVmlzaW9uIGNhbWVyYSBpbnRlcmZhY2UgLS0gRGV2aWNlIHZlcnNpb24gPSAzLjguMCAtLSBQcm9kdWN0IEdVSUQg=',
messageId: uuidv4(),
filename: 'acA4112-8gm_40185942.pfs',
need_receipt: true,
})
// 保存相机配置
export const saveCameraConfig = transformToString({
command: 'saveCameraConfig',
messageId: uuidv4(),
need_receipt: true,
})
// 启动相机识别
export const startCharacterRecognition = transformToString({
command: 'startCharacterRecognition',
messageId: uuidv4(),
need_receipt: true,
})
// 停止相机识别
export const stopCharacterRecognition = transformToString({
command: 'stopCharacterRecognition',
messageId: uuidv4(),
need_receipt: true,
})
// 获取识别结果
export const getCharacterRecognitionResult = transformToString({
command: 'getCharacterRecognitionResult',
messageId: uuidv4(),
need_receipt: true,
})
// 获取识别结果simple
export const getCharacterRecognitionResultSimple = transformToString({
command: 'getCharacterRecognitionResultSimple',
messageId: uuidv4(),
need_receipt: true,
})
// 机械臂控制接口 获取机械臂 连接信息 x y 位置
export const getMechanicalArmState = transformToString({
command: 'getMechanicalArmState',
messageId: uuidv4(),
need_receipt: true,
})
/**
* 通道1亮度 = 模拟通道亮度*数字通道1亮度
* 通道2亮度 = 模拟通道亮度*数字通道1亮度
* 通道3亮度 = 模拟通道亮度*数字通道1亮度
* 通道4亮度 = 模拟通道亮度*数字通道1亮度
*/
//设置模拟通道亮度
export const setFlashBrightnessAnalog = transformToString({
command: 'setFlashBrightnessAnalog',
brightness: 49282,
messageId: uuidv4(),
need_receipt: true,
})
// 设置数字通道亮度
export const setFlashBrightnessDigital = channel => {
return transformToString({
command: 'setFlashBrightnessDigital',
channel,
brightness: 45497,
messageId: uuidv4(),
need_receipt: true,
})
}
// 打开闪光灯
export const openFlashLight = transformToString({
command: 'openFlashLight',
messageId: uuidv4(),
need_receipt: true,
})
// 关闭闪光灯
export const closeFlashLight = transformToString({
command: 'CloseFlashLight',
messageId: uuidv4(),
need_receipt: true,
})

5
yarn.lock

@ -1025,6 +1025,11 @@
"escalade" "^3.1.1"
"picocolors" "^1.0.0"
"uuid@^9.0.0":
"integrity" "sha512-MXcSTerfPa4uqyzStbRoTgt5XIe3x5+42+q1sDuy3R5MDk66URdLMOZe5aPX/SQd+kuYAh0FdP/pO28IkQyTeg=="
"resolved" "https://registry.npmmirror.com/uuid/-/uuid-9.0.0.tgz"
"version" "9.0.0"
"validator@^13.5.1":
"integrity" "sha512-B+dGG8U3fdtM0/aNK4/X8CXq/EcxU2WPrPEkJGslb47qyHsxmbggTWK0yEA4qnYVNF+nxNlN88o14hIcPmSIEA=="
"resolved" "https://registry.npmmirror.com/validator/-/validator-13.9.0.tgz"

Loading…
Cancel
Save