From 6d9ad7e2b39b8d3fae3fd14905ce9a36ecf0fb90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E6=95=AC?= <43266613+wutiange@users.noreply.github.com> Date: Fri, 12 Jan 2024 17:06:41 +0800 Subject: [PATCH] Fix/test question (#12) * feat: add global loading * fix: unconnected burn-in model always upgrades * fix: file name too long, UI error * feat: configurable client ID * feat: internationalization * fix: timeout undefined error * feat: concurrent data processing * fix: user prompted without selecting serial port * feat: xiao Single-step execution * feat: disconnect first before switching * feat: add come to v2 support * feat: come to update uniform_type * fix: burned but not deduced --- src/hooks/senseCraftAIComesToFlash.ts | 89 +++++++++---------- src/locale/en-US.ts | 3 + src/locale/en-US/process.ts | 2 + src/locale/zh-CN.ts | 3 + src/locale/zh-CN/process.ts | 2 + src/pages/components/Navbar.vue | 47 +++++++--- src/pages/setup/config/components/Config.vue | 45 +++++++--- src/pages/setup/process/components/Config.vue | 10 ++- src/pages/setup/process/components/Device.vue | 13 ++- .../setup/process/grove_ai_we2/Device.vue | 2 +- .../setup/process/xiao_esp32s3/Device.vue | 30 ++++--- src/pages/utils/components/Tools.vue | 4 + src/sscma/atclient.ts | 3 +- src/sscma/constants.ts | 2 +- src/sscma/device.ts | 5 +- src/sscma/grove_ai_we2/deviceHimax.ts | 76 ++++++++-------- src/sscma/xiao_esp32s3/Flasher.ts | 22 ++--- src/utils/flash.ts | 2 + 18 files changed, 211 insertions(+), 149 deletions(-) diff --git a/src/hooks/senseCraftAIComesToFlash.ts b/src/hooks/senseCraftAIComesToFlash.ts index 7409b5b..71d0baa 100644 --- a/src/hooks/senseCraftAIComesToFlash.ts +++ b/src/hooks/senseCraftAIComesToFlash.ts @@ -11,9 +11,14 @@ export async function fetchConstant() { .then((res) => res.data); } -export async function fetchModelDetail(modelId: string, needParams?: string[]) { +export async function fetchModelDetail( + modelId: string, + token: string, + needParams?: string[] +) { const response: Record = await fetch( - `https://sensecraft.seeed.cc/aiserverapi/model/view_model?model_id=${modelId}` + `https://sensecraft.seeed.cc/aiserverapi/model/view_model?model_id=${modelId}`, + { headers: { Authorization: token } } ).then((res) => res.json()); if (response?.code !== '0') { throw new Error(response.msg); @@ -39,28 +44,18 @@ export async function fetchModelFileUrl(modelId: string, token: string) { const useSenseCraftAIComesToFlash = () => { const route = useRoute(); const deviceStore = useDeviceStore(); - const { id: modelId, token } = route.query ?? {}; + const { id: modelId, token, uniform_type: uniformType } = route.query ?? {}; const handleSenseCraftAI = async () => { if (!(modelId && token && route.name === 'process')) { return {}; } const [ - [ - modelImg, - deviceTypes, - labels, - description, - size, - name, - aiFramework, - modelFormat, - ], + [modelImg, labels, description, size, name, aiFramework, modelFormat], modelFile, constant, ] = await Promise.all([ - fetchModelDetail(modelId as string, [ + fetchModelDetail(modelId as string, token as string, [ 'pic_url', - 'uniform_types', 'labels', 'description', 'model_size', @@ -71,41 +66,37 @@ const useSenseCraftAIComesToFlash = () => { fetchModelFileUrl(modelId as string, token as string), fetchConstant(), ]); - if (deviceTypes.length > 0) { - const deviceType: string = deviceTypes[0]; - const deviceKeyToId: Record = { - '32': DeviceType.XiaoEsp32s3, - }; - if (typeof deviceKeyToId[deviceType] === 'string') { - deviceStore.setDeviceTypeById(deviceKeyToId[deviceType]); - } - deviceStore.setComeToSenseCraftAI({ - model: { - description, - classes: - labels?.reduce( - ( - arr: string[], - e: { object_id: string; object_name: string } - ) => { - arr[Number(e.object_id)] = e.object_name; - return arr; - }, - [] - ) ?? [], - algorithm: constant.ai_framework_array[aiFramework as string], - name, - version: modelFile.version ?? '1.0.0', - category: modelFile.algorithm[0].algorithm_name ?? 'Object Detection', - model_type: constant.model_format_array[modelFormat], - size, - modelImg, - isCustom: true, - }, - modelUrl: modelFile.arguments.url, - }); - deviceStore.setFlashWay(FlashWayType.ComeToSenseCraftAI); + const deviceType: string = uniformType as string; + const deviceKeyToId: Record = { + '32': DeviceType.XiaoEsp32s3, + '36': DeviceType.GroveAIWE2, + }; + if (typeof deviceKeyToId[deviceType] === 'string') { + deviceStore.setDeviceTypeById(deviceKeyToId[deviceType]); } + deviceStore.setComeToSenseCraftAI({ + model: { + description, + classes: + labels?.reduce( + (arr: string[], e: { object_id: string; object_name: string }) => { + arr[Number(e.object_id)] = e.object_name; + return arr; + }, + [] + ) ?? [], + algorithm: constant.ai_framework_array[aiFramework as string], + name, + version: modelFile.version ?? '1.0.0', + category: modelFile.algorithm[0].algorithm_name ?? 'Object Detection', + model_type: constant.model_format_array[modelFormat], + size, + modelImg, + isCustom: true, + }, + modelUrl: modelFile.arguments.url, + }); + deviceStore.setFlashWay(FlashWayType.ComeToSenseCraftAI); return null; }; onMounted(async () => { diff --git a/src/locale/en-US.ts b/src/locale/en-US.ts index 5e068b0..eb3c95c 100644 --- a/src/locale/en-US.ts +++ b/src/locale/en-US.ts @@ -18,6 +18,9 @@ export default { 'menu.faq': 'FAQ', 'navbar.docs': 'Docs', 'navbar.action.locale': 'Switch to English', + 'navbar.swap.confirm.text': + 'Switching while connected will cause the current connection to be disconnected. Are you sure you want to switch?', + 'navbar.switch': 'Switch', 'confirm': 'Confirm', 'cancel': 'Cancel', 'config.save.success': 'Save Success', diff --git a/src/locale/en-US/process.ts b/src/locale/en-US/process.ts index c87e166..b00e6b2 100644 --- a/src/locale/en-US/process.ts +++ b/src/locale/en-US/process.ts @@ -17,11 +17,13 @@ export default { 'workplace.config.mqtt': 'MQTT', 'workplace.config.mqtt.host': 'Host', 'workplace.config.mqtt.port': 'Port', + 'workplace.config.mqtt.clientId': 'clientId', 'workplace.config.mqtt.username': 'Username', 'workplace.config.mqtt.password': 'Password', 'workplace.config.mqtt.ssl': 'SSL', 'workplace.config.mqtt.message.host': 'Please enter host', 'workplace.config.mqtt.message.port': 'Please enter port', + 'workplace.config.mqtt.message.clientId': 'Please enter clientId', 'workplace.config.mqtt.message.username': 'Please enter username', 'workplace.config.mqtt.message.password': 'Please enter password', 'workplace.output.title': 'Output', diff --git a/src/locale/zh-CN.ts b/src/locale/zh-CN.ts index efa087f..644b0fd 100644 --- a/src/locale/zh-CN.ts +++ b/src/locale/zh-CN.ts @@ -18,6 +18,9 @@ export default { 'menu.faq': '常见问题', 'navbar.docs': '文档中心', 'navbar.action.locale': '切换为中文', + 'navbar.swap.confirm.text': + '当处于连接状态下切换会导致当前连接断开,确定切换嘛?', + 'navbar.switch': '切换', 'confirm': '确定', 'cancel': '取消', 'config.save.success': '保存成功', diff --git a/src/locale/zh-CN/process.ts b/src/locale/zh-CN/process.ts index 1ea816a..b04ffb7 100644 --- a/src/locale/zh-CN/process.ts +++ b/src/locale/zh-CN/process.ts @@ -16,11 +16,13 @@ export default { 'workplace.config.mqtt': 'MQTT配置', 'workplace.config.mqtt.host': '主机', 'workplace.config.mqtt.port': '端口', + 'workplace.config.mqtt.clientId': '客户端ID', 'workplace.config.mqtt.username': '用户名', 'workplace.config.mqtt.password': '密码', 'workplace.config.mqtt.ssl': 'SSL', 'workplace.config.mqtt.message.host': '请输入主机', 'workplace.config.mqtt.message.port': '请输入端口', + 'workplace.config.mqtt.message.clientId': '请输入客户端ID', 'workplace.config.mqtt.message.username': '请输入用户名', 'workplace.config.mqtt.message.password': '请输入密码', 'workplace.output.title': '输出', diff --git a/src/pages/components/Navbar.vue b/src/pages/components/Navbar.vue index 646b149..bcf5d77 100644 --- a/src/pages/components/Navbar.vue +++ b/src/pages/components/Navbar.vue @@ -133,7 +133,7 @@ {{ deviceType.name @@ -161,11 +161,20 @@ > + + {{ $t('navbar.swap.confirm.text') }} +