agentworkshop 0.7.39 → 0.7.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.AgentWorkShop/prompts/host-tools.json +55 -0
- package/.output/.AgentWorkShop/prompts/host-tools.json +55 -0
- package/.output/nitro.json +1 -1
- package/.output/public/_nuxt/88GOowgO2.js +1 -0
- package/.output/public/_nuxt/{BNT8gYU92.js → BC9wjTJK2.js} +2 -2
- package/.output/public/_nuxt/{CY9LbPCI.js → BN16aRdQ.js} +1 -1
- package/.output/public/_nuxt/BWVhZntO.js +1 -0
- package/.output/public/_nuxt/{HBLJ-wei.js → BXxH0UQE.js} +1 -1
- package/.output/public/_nuxt/{zIGh7R49.js → BneN7fbu.js} +1 -1
- package/.output/public/_nuxt/BsROmY89.js +1 -0
- package/.output/public/_nuxt/{DUrecWPx.js → C0ZrS1KL.js} +2 -2
- package/.output/public/_nuxt/{C_OLzD09.js → C4oW1HsE.js} +1 -1
- package/.output/public/_nuxt/{CUDwzgLV.js → C4s_niy-.js} +9 -9
- package/.output/public/_nuxt/CFxtLwjp.js +1 -0
- package/.output/public/_nuxt/{Cec0Ua3F.js → CS50LB_l.js} +1 -1
- package/.output/public/_nuxt/CssgYAAL2.js +1 -0
- package/.output/public/_nuxt/D6mbFA-a.js +1 -0
- package/.output/public/_nuxt/D98NH8kG.js +1 -0
- package/.output/public/_nuxt/DGIuvyRN2.js +1 -0
- package/.output/public/_nuxt/DGbd-UiG.js +1 -0
- package/.output/public/_nuxt/{CojCTLKD.js → DGj-WEBg.js} +1 -1
- package/.output/public/_nuxt/{DDShH71m.js → DS8qj8EL.js} +1 -1
- package/.output/public/_nuxt/DTFCy6h-.js +1 -0
- package/.output/public/_nuxt/{DrYV5i68.js → DUjW5Yq5.js} +1 -1
- package/.output/public/_nuxt/{45zuyAso.js → D_OTvQza.js} +1 -1
- package/.output/public/_nuxt/Dap5PmTL.js +2 -0
- package/.output/public/_nuxt/Dqw1lpr-.js +1 -0
- package/.output/public/_nuxt/DvLxILQP.js +1 -0
- package/.output/public/_nuxt/IREZ1eC2.js +1 -0
- package/.output/public/_nuxt/TownView.f-YOdXRs.css +1 -0
- package/.output/public/_nuxt/_id_.D9ymtHB5.css +1 -0
- package/.output/public/_nuxt/_id_.jf-_8E_c.css +1 -0
- package/.output/public/_nuxt/_wsId_.B4WiqkIS.css +1 -0
- package/.output/public/_nuxt/agents.ZD0rVdHE.css +1 -0
- package/.output/public/_nuxt/aml.BN8ZEW4h.css +1 -0
- package/.output/public/_nuxt/builds/latest.json +1 -1
- package/.output/public/_nuxt/builds/meta/78a295bb-2072-48a4-8b46-6d545fdae743.json +1 -0
- package/.output/public/_nuxt/ca4TJ3Op.js +1 -0
- package/.output/public/_nuxt/channel-templates.BOtahzPi.css +1 -0
- package/.output/public/_nuxt/daq.DjSgY94l.css +1 -0
- package/.output/public/_nuxt/dcw.8Y7FqCVN.css +1 -0
- package/.output/public/_nuxt/default.J32SgqFY.css +1 -0
- package/.output/public/_nuxt/entry.bdm0tv6M.css +1 -0
- package/.output/public/_nuxt/eqq3wWQF.js +18 -0
- package/.output/public/_nuxt/logs.BpKzmKsh.css +1 -0
- package/.output/public/_nuxt/monitor.D9pe7qN6.css +1 -0
- package/.output/public/_nuxt/pages.D7aSDlUI.css +1 -0
- package/.output/public/_nuxt/permissions.DwTVlFe6.css +1 -0
- package/.output/public/_nuxt/plugins.sb4nDGqr.css +1 -0
- package/.output/public/_nuxt/{Cbq-mryP.js → qr6R6Ha1.js} +1 -1
- package/.output/public/_nuxt/settings.BTgR-NiE.css +1 -0
- package/.output/public/_nuxt/teams.CxnxKVVs.css +1 -0
- package/.output/public/_nuxt/tokens.BFY7qv4f.css +1 -0
- package/.output/public/_nuxt/{town.DKIAhKnx.css → town.BBXZmeoP.css} +1 -1
- package/.output/public/_nuxt/users.DLgZ1D0h.css +1 -0
- package/.output/public/_nuxt/workshop.CR_QzeAN.css +1 -0
- package/.output/public/_nuxt/{BzHEilTt.js → xh3_vYcu.js} +1 -1
- package/.output/public/_nuxt/yF0aYMF1.js +4 -0
- package/.output/server/chunks/_/entity.mjs.map +1 -1
- package/.output/server/chunks/_/nitro.mjs +2355 -1362
- package/.output/server/chunks/_/nitro.mjs.map +1 -1
- package/.output/server/chunks/build/{TownView-jVazYOjN.mjs → TownView--otsnr_7.mjs} +290 -208
- package/.output/server/chunks/build/TownView--otsnr_7.mjs.map +1 -0
- package/.output/server/chunks/build/{_id_-CfVosNg3.mjs → _id_-Brv-JSvr.mjs} +142 -141
- package/.output/server/chunks/build/_id_-Brv-JSvr.mjs.map +1 -0
- package/.output/server/chunks/build/{_id_-Hwr4rZpr.mjs → _id_-D9pl1OZy.mjs} +38 -36
- package/.output/server/chunks/build/_id_-D9pl1OZy.mjs.map +1 -0
- package/.output/server/chunks/build/{_wsId_-BVg3bB77.mjs → _wsId_-BASfDf0s.mjs} +295 -261
- package/.output/server/chunks/build/{_wsId_-BVg3bB77.mjs.map → _wsId_-BASfDf0s.mjs.map} +1 -1
- package/.output/server/chunks/build/{agents-Bvin73QY.mjs → agents-CLQqJF2y.mjs} +21 -27
- package/.output/server/chunks/build/agents-CLQqJF2y.mjs.map +1 -0
- package/.output/server/chunks/build/{aml-BCSJCdX7.mjs → aml-_7FdFL2p.mjs} +109 -109
- package/.output/server/chunks/build/{aml-BCSJCdX7.mjs.map → aml-_7FdFL2p.mjs.map} +1 -1
- package/.output/server/chunks/build/api-error-dul30BYQ.mjs.map +1 -1
- package/.output/server/chunks/build/{channel-templates-BTq8570n.mjs → channel-templates-p6SZNjlM.mjs} +19 -19
- package/.output/server/chunks/build/{channel-templates-BTq8570n.mjs.map → channel-templates-p6SZNjlM.mjs.map} +1 -1
- package/.output/server/chunks/build/{daq-C03Uu5UE.mjs → daq-DkMvD8sg.mjs} +193 -126
- package/.output/server/chunks/build/daq-DkMvD8sg.mjs.map +1 -0
- package/.output/server/chunks/build/{dcw-6vEYVeje.mjs → dcw-C1jgVJkO.mjs} +46 -46
- package/.output/server/chunks/build/{dcw-6vEYVeje.mjs.map → dcw-C1jgVJkO.mjs.map} +1 -1
- package/.output/server/chunks/build/{default-CZmZFpqH.mjs → default-BE4r0FZN.mjs} +152 -58
- package/.output/server/chunks/build/{default-CZmZFpqH.mjs.map → default-BE4r0FZN.mjs.map} +1 -1
- package/.output/server/chunks/build/{logs-B-xhuqln.mjs → logs--dByNyhw.mjs} +35 -35
- package/.output/server/chunks/build/{logs-B-xhuqln.mjs.map → logs--dByNyhw.mjs.map} +1 -1
- package/.output/server/chunks/build/{monitor-CyfDt4nR.mjs → monitor-C0okQaXz.mjs} +33 -33
- package/.output/server/chunks/build/{monitor-CyfDt4nR.mjs.map → monitor-C0okQaXz.mjs.map} +1 -1
- package/.output/server/chunks/build/{pages-BO7yZsXA.mjs → pages-B0bUWnC6.mjs} +35 -19
- package/.output/server/chunks/build/pages-B0bUWnC6.mjs.map +1 -0
- package/.output/server/chunks/build/{permissions-B52oOmaO.mjs → permissions-68SsNjex.mjs} +12 -12
- package/.output/server/chunks/build/{permissions-B52oOmaO.mjs.map → permissions-68SsNjex.mjs.map} +1 -1
- package/.output/server/chunks/build/{plugins-CUWmMdyt.mjs → plugins-lGlUr1lj.mjs} +17 -17
- package/.output/server/chunks/build/{plugins-CUWmMdyt.mjs.map → plugins-lGlUr1lj.mjs.map} +1 -1
- package/.output/server/chunks/build/{settings-DoQ2Oq3P.mjs → settings-Ddd1qx2Z.mjs} +50 -47
- package/.output/server/chunks/build/settings-Ddd1qx2Z.mjs.map +1 -0
- package/.output/server/chunks/build/{teams-2kz3CusY.mjs → teams-MEDLZdMn.mjs} +38 -34
- package/.output/server/chunks/build/teams-MEDLZdMn.mjs.map +1 -0
- package/.output/server/chunks/build/{tokens-BbWLqtVz.mjs → tokens-C7fTM5C2.mjs} +14 -14
- package/.output/server/chunks/build/{tokens-BbWLqtVz.mjs.map → tokens-C7fTM5C2.mjs.map} +1 -1
- package/.output/server/chunks/build/{town-BOl6hs9B.mjs → town-CoQdblbZ.mjs} +38 -12
- package/.output/server/chunks/build/town-CoQdblbZ.mjs.map +1 -0
- package/.output/server/chunks/build/{useDaqStream-CIBaiGAl.mjs → useDaqStream-DfCFpb3p.mjs} +9 -3
- package/.output/server/chunks/build/useDaqStream-DfCFpb3p.mjs.map +1 -0
- package/.output/server/chunks/build/{useDcwStream-CBbiYnWe.mjs → useDcwStream-UPiX-3iO.mjs} +11 -2
- package/.output/server/chunks/build/useDcwStream-UPiX-3iO.mjs.map +1 -0
- package/.output/server/chunks/build/useResponsive-BKDMGTHs.mjs +49 -0
- package/.output/server/chunks/build/useResponsive-BKDMGTHs.mjs.map +1 -0
- package/.output/server/chunks/build/{users-fohSmF-J.mjs → users-Cfd5-l2-.mjs} +6 -6
- package/.output/server/chunks/build/{users-fohSmF-J.mjs.map → users-Cfd5-l2-.mjs.map} +1 -1
- package/.output/server/chunks/build/{workshop-DX5-ldc4.mjs → workshop-BL5bhfs0.mjs} +15 -15
- package/.output/server/chunks/build/{workshop-DX5-ldc4.mjs.map → workshop-BL5bhfs0.mjs.map} +1 -1
- package/.output/server/chunks/build/{workspaces-BuydxM-3.mjs → workspaces-Bgz5Ekwp.mjs} +18 -3
- package/.output/server/chunks/build/workspaces-Bgz5Ekwp.mjs.map +1 -0
- package/.output/server/chunks/routes/api/system/config-groups/_id_.patch.mjs.map +1 -1
- package/.output/server/chunks/routes/api/system/index.patch.mjs.map +1 -1
- package/.output/server/chunks/routes/api/system/index.post.mjs.map +1 -1
- package/.output/server/chunks/routes/api/system/settings/events.get.mjs.map +1 -1
- package/.output/server/chunks/routes/api/workshop/agent-tools/invoke.post.mjs +6 -2
- package/.output/server/chunks/routes/api/workshop/agent-tools/invoke.post.mjs.map +1 -1
- package/.output/server/chunks/routes/api/workshop/aml/datasets/_id_.get.mjs +2 -1
- package/.output/server/chunks/routes/api/workshop/aml/datasets/_id_.get.mjs.map +1 -1
- package/.output/server/chunks/routes/api/workshop/channel-templates/_id/instantiate.post.mjs +1 -1
- package/.output/server/chunks/routes/api/workshop/channels.post.mjs +3 -3
- package/.output/server/chunks/routes/api/workshop/daq/index.post.mjs.map +1 -1
- package/.output/server/chunks/routes/api/workshop/daq/templates/_key_.delete.mjs.map +1 -1
- package/.output/server/chunks/routes/api/workshop/daq/templates/_key_.patch.mjs.map +1 -1
- package/.output/server/chunks/routes/api/workshop/dcw/_id/write.post.mjs +3 -2
- package/.output/server/chunks/routes/api/workshop/dcw/_id/write.post.mjs.map +1 -1
- package/.output/server/chunks/routes/api/workshop/dcw/_id_.delete.mjs +2 -1
- package/.output/server/chunks/routes/api/workshop/dcw/_id_.delete.mjs.map +1 -1
- package/.output/server/chunks/routes/api/workshop/dcw/index2.post.mjs +8 -6
- package/.output/server/chunks/routes/api/workshop/dcw/index2.post.mjs.map +1 -1
- package/.output/server/chunks/routes/api/workshop/dcw/index3.post.mjs +5 -5
- package/.output/server/chunks/routes/api/workshop/dcw/index3.post.mjs.map +1 -1
- package/.output/server/chunks/routes/api/workshop/dcw/index4.get.mjs +14 -4
- package/.output/server/chunks/routes/api/workshop/dcw/index4.get.mjs.map +1 -1
- package/.output/server/chunks/routes/api/workshop/dcw/index4.post.mjs +4 -4
- package/.output/server/chunks/routes/api/workshop/dcw/index4.post.mjs.map +1 -1
- package/.output/server/chunks/routes/api/workshop/dcw/index5.get.mjs +4 -3
- package/.output/server/chunks/routes/api/workshop/dcw/index5.get.mjs.map +1 -1
- package/.output/server/chunks/routes/api/workshop/dcw/index5.post.mjs +31 -0
- package/.output/server/chunks/routes/api/workshop/dcw/index5.post.mjs.map +1 -0
- package/.output/server/chunks/routes/api/workshop/dcw/index6.get.mjs +28 -0
- package/.output/server/chunks/routes/api/workshop/dcw/index6.get.mjs.map +1 -0
- package/.output/server/chunks/routes/api/workshop/dcw/lines/_id/start.post.mjs +1 -1
- package/.output/server/chunks/routes/api/workshop/dcw/lines/_id/stop.post.mjs +1 -1
- package/.output/server/chunks/routes/api/workshop/dcw/lines/_id_.patch.mjs.map +1 -1
- package/.output/server/chunks/routes/api/workshop/dcw/params/_id/read.post.mjs +32 -0
- package/.output/server/chunks/routes/api/workshop/dcw/params/_id/read.post.mjs.map +1 -0
- package/.output/server/chunks/routes/api/workshop/dcw/params/_id/write.post.mjs +34 -0
- package/.output/server/chunks/routes/api/workshop/dcw/params/_id/write.post.mjs.map +1 -0
- package/.output/server/chunks/routes/api/workshop/dcw/params/_id_.delete.mjs +33 -0
- package/.output/server/chunks/routes/api/workshop/dcw/params/_id_.delete.mjs.map +1 -0
- package/.output/server/chunks/routes/api/workshop/dcw/params/_id_.patch.mjs +34 -0
- package/.output/server/chunks/routes/api/workshop/dcw/params/_id_.patch.mjs.map +1 -0
- package/.output/server/chunks/routes/api/workshop/dcw/templates/_key_.delete.mjs +1 -1
- package/.output/server/chunks/routes/api/workshop/dcw/templates/_key_.patch.mjs +1 -1
- package/.output/server/chunks/routes/api/workshop/harnesses/_id/providers.get.mjs +1 -1
- package/.output/server/chunks/routes/api/workshop/harnesses.get.mjs +1 -1
- package/.output/server/chunks/routes/api/workshop/hitl/pending.get.mjs +1 -1
- package/.output/server/chunks/routes/api/workshop/hitl/respond.post.mjs +1 -1
- package/.output/server/chunks/routes/api/workshop/index.put.mjs +1 -1
- package/.output/server/chunks/routes/api/workshop/index5.get.mjs +3 -1
- package/.output/server/chunks/routes/api/workshop/index5.get.mjs.map +1 -1
- package/.output/server/chunks/routes/api/workshop/index6.get.mjs +5 -1
- package/.output/server/chunks/routes/api/workshop/index6.get.mjs.map +1 -1
- package/.output/server/chunks/routes/api/workshop/index9.get.mjs +3 -1
- package/.output/server/chunks/routes/api/workshop/index9.get.mjs.map +1 -1
- package/.output/server/chunks/routes/api/workshop/plugins/_name/disable.post.mjs +1 -1
- package/.output/server/chunks/routes/api/workshop/plugins/_name/enable.post.mjs +1 -1
- package/.output/server/chunks/routes/api/workshop/scene/layouts/_channelId_.delete.mjs +1 -1
- package/.output/server/chunks/routes/api/workshop/scene/layouts/_channelId_.put.mjs +1 -1
- package/.output/server/chunks/routes/api/workshop/workspaces/_id/channel-templates/_tplId_.post.mjs +1 -1
- package/.output/server/chunks/routes/renderer.mjs +3 -3
- package/.output/server/chunks/virtual/entry.mjs +51 -25
- package/.output/server/chunks/virtual/precomputed.mjs +1 -1
- package/.output/server/package.json +1 -1
- package/README-zh.md +203 -39
- package/README.md +739 -591
- package/app/app.vue +9 -3
- package/app/assets/css/main.css +517 -7
- package/app/components/AppHeader.vue +98 -7
- package/app/components/AppSidebar.vue +117 -11
- package/app/components/AwChart.vue +2 -1
- package/app/components/workshop/AgentInspectorDrawer.vue +6 -6
- package/app/components/workshop/AgentLanesView.vue +52 -1
- package/app/components/workshop/AssetLibrary.vue +4 -2
- package/app/components/workshop/ChannelSessionList.vue +4 -2
- package/app/components/workshop/Composer.vue +96 -0
- package/app/components/workshop/DaqNodeRow.vue +19 -0
- package/app/components/workshop/DaqTemplateIcon.vue +33 -0
- package/app/components/workshop/DeviceTwinPanel.vue +37 -35
- package/app/components/workshop/EventBlock.vue +3 -3
- package/app/components/workshop/InspectorPanel.vue +47 -11
- package/app/components/workshop/LiveAgentBar.vue +34 -0
- package/app/components/workshop/TaskBoardView.vue +83 -33
- package/app/components/workshop/TranscriptTimeline.vue +56 -0
- package/app/components/workshop/blocks/ClusterError.vue +1 -1
- package/app/components/workshop/blocks/ClusterRoute.vue +3 -1
- package/app/components/workshop/blocks/ClusterStatus.vue +2 -2
- package/app/components/workshop/blocks/ClusterStream.vue +8 -2
- package/app/components/workshop/town/ModelPreview3D.vue +1 -1
- package/app/components/workshop/town/TownView.vue +507 -82
- package/app/composables/useResponsive.ts +88 -0
- package/app/composables/useRouteMeta.ts +3 -0
- package/app/composables/workshop/useDaqStream.ts +7 -4
- package/app/composables/workshop/useDcwStream.ts +8 -2
- package/app/composables/workshop/useVisibleInterval.ts +2 -2
- package/app/composables/workshop/useWorkshopApi.ts +1 -1
- package/app/layouts/default.vue +46 -2
- package/app/pages/aml/index.vue +712 -616
- package/app/pages/daq/[id].vue +12 -7
- package/app/pages/daq/index.vue +216 -13
- package/app/pages/dcw/[id].vue +117 -32
- package/app/pages/dcw/index.vue +83 -23
- package/app/pages/index.vue +35 -1
- package/app/pages/logs/index.vue +147 -13
- package/app/pages/monitor.vue +56 -12
- package/app/pages/permissions/index.vue +34 -0
- package/app/pages/plugins/index.vue +35 -4
- package/app/pages/settings.vue +90 -21
- package/app/pages/tokens.vue +23 -0
- package/app/pages/town.vue +50 -5
- package/app/pages/users.vue +23 -0
- package/app/pages/workshop/agents.vue +92 -2
- package/app/pages/workshop/channel-templates.vue +53 -0
- package/app/pages/workshop/index.vue +14 -0
- package/app/pages/workshop/teams.vue +66 -6
- package/app/pages/workshop/w/[wsId].vue +202 -14
- package/app/plugins/aw-plugins.client.ts +13 -8
- package/app/stores/app.ts +33 -1
- package/app/stores/workshop/user.ts +1 -1
- package/app/stores/workshop/workspaces.ts +18 -2
- package/app/utils/api-error.ts +1 -1
- package/cli/commands/build.mjs +8 -1
- package/docker-compose.yml +6 -0
- package/docs/cli.en.md +2 -2
- package/docs/cli.md +2 -2
- package/docs/plugins.en.md +33 -1
- package/docs/plugins.md +29 -1
- package/docs/sdk.en.md +1 -1
- package/docs/sdk.md +1 -1
- package/i18n/locales/en.ts +2 -0
- package/i18n/locales/zh-CN.ts +2 -0
- package/nuxt.config.ts +31 -0
- package/package.json +11 -2
- package/scripts/_dbg-param-map-e2e.ts +242 -0
- package/scripts/_dbg-param-map-rest-smoke.mjs +73 -0
- package/scripts/_dbg-param-real-scenario.mjs +153 -0
- package/scripts/_loop-biax-campaign.mjs +124 -0
- package/scripts/api-live-e2e.mjs +40 -8
- package/scripts/capture-walkthrough.mjs +232 -0
- package/scripts/render-walkthrough-figure.mjs +46 -0
- package/scripts/seed-walkthrough-fixture.mjs +143 -0
- package/scripts/test-plugin-hardening.mjs +8 -0
- package/scripts/test-serial-bridge.mjs +418 -0
- package/scripts/ui/admin-shots.mjs +46 -0
- package/scripts/ui/audit-layout.mjs +301 -0
- package/scripts/ui/bump-microfont.mjs +39 -0
- package/scripts/ui/e2e-interactive.mjs +328 -0
- package/scripts/ui/lib.mjs +198 -0
- package/scripts/ui/linkcheck2.mjs +37 -0
- package/scripts/ui/live-render-check.mjs +72 -0
- package/scripts/ui/md-lint.mjs +80 -0
- package/scripts/ui/perf-audit.mjs +132 -0
- package/scripts/ui/readme-assets.mjs +30 -0
- package/scripts/ui/readme-shots.mjs +42 -0
- package/scripts/ui/record.mjs +225 -0
- package/scripts/ui/seed-admin.mjs +68 -0
- package/scripts/ui/seed-demo.mjs +83 -0
- package/scripts/ui/seed-industrial-demo.mjs +171 -0
- package/scripts/ui/shot-hero.mjs +25 -0
- package/scripts/ui/shots.mjs +75 -0
- package/scripts/ui/sim-ui-shot.mjs +16 -0
- package/scripts/ui/verify-nav.mjs +51 -0
- package/scripts/ui/verify-responsive.mjs +285 -0
- package/server/api/system/config-groups/[id].patch.ts +1 -1
- package/server/api/system/config-groups/index.post.ts +1 -1
- package/server/api/system/settings/events.get.ts +1 -1
- package/server/api/system/settings/index.patch.ts +1 -1
- package/server/api/workshop/agent-tools/invoke.post.ts +16 -2
- package/server/api/workshop/aml/datasets/[id].get.ts +8 -1
- package/server/api/workshop/daq/index.get.ts +3 -1
- package/server/api/workshop/daq/infra/reconnect.post.ts +1 -1
- package/server/api/workshop/daq/templates/[key].delete.ts +1 -0
- package/server/api/workshop/daq/templates/[key].patch.ts +1 -0
- package/server/api/workshop/daq/templates/index.post.ts +1 -0
- package/server/api/workshop/dcw/[id]/write.post.ts +10 -2
- package/server/api/workshop/dcw/[id].delete.ts +5 -2
- package/server/api/workshop/dcw/index.get.ts +5 -0
- package/server/api/workshop/dcw/lines/[id].patch.ts +1 -1
- package/server/api/workshop/dcw/params/[id]/read.post.ts +17 -0
- package/server/api/workshop/dcw/params/[id]/write.post.ts +21 -0
- package/server/api/workshop/dcw/params/[id].delete.ts +19 -0
- package/server/api/workshop/dcw/params/[id].patch.ts +23 -0
- package/server/api/workshop/dcw/params/index.get.ts +27 -0
- package/server/api/workshop/dcw/params/index.post.ts +25 -0
- package/server/api/workshop/permissions/index.get.ts +3 -1
- package/server/plugins/aw-plugins.ts +23 -10
- package/server/plugins/dev-stability-guard.ts +3 -1
- package/server/plugins/system-config.ts +6 -1
- package/server/plugins-builtin/serial-bridge/client.mjs +210 -0
- package/server/plugins-builtin/serial-bridge/drivers.mjs +409 -0
- package/server/plugins-builtin/serial-bridge/i18n.json +62 -0
- package/server/plugins-builtin/serial-bridge/index.mjs +247 -0
- package/server/plugins-builtin/serial-bridge/lib.mjs +208 -0
- package/server/plugins-builtin/serial-bridge/rtu.mjs +168 -0
- package/server/services/system-config.ts +28 -9
- package/server/services/workshop/agents/adapters/one-shot-cli-agent.ts +2 -1
- package/server/services/workshop/agents/agent-interface.ts +8 -6
- package/server/services/workshop/agents/base-agent.ts +18 -4
- package/server/services/workshop/agents/claude-agent.ts +7 -3
- package/server/services/workshop/agents/codex-agent.ts +3 -3
- package/server/services/workshop/agents/dsh-agent.ts +3 -3
- package/server/services/workshop/agents/goose-agent.ts +0 -1
- package/server/services/workshop/agents/harness-terminal.ts +14 -1
- package/server/services/workshop/agents/hermes-agent.ts +4 -2
- package/server/services/workshop/agents/host-tool-bridge.ts +5 -1
- package/server/services/workshop/agents/industrial-context.ts +4 -1
- package/server/services/workshop/agents/industrial-tools.ts +164 -6
- package/server/services/workshop/agents/omp-agent.ts +15 -9
- package/server/services/workshop/agents/opencode-agent.ts +47 -21
- package/server/services/workshop/agents/qwen-agent.ts +10 -5
- package/server/services/workshop/aml/entity.ts +3 -1
- package/server/services/workshop/aml/python-runtime.ts +3 -2
- package/server/services/workshop/daq/bus/mqtt.adapter.ts +8 -4
- package/server/services/workshop/daq/daq-controller.ts +25 -5
- package/server/services/workshop/daq/daq-runtime.ts +5 -3
- package/server/services/workshop/daq/drivers.ts +141 -11
- package/server/services/workshop/daq/host-ports.ts +3 -2
- package/server/services/workshop/daq/storage/timescale.adapter.ts +3 -1
- package/server/services/workshop/db/channel.repo.ts +4 -0
- package/server/services/workshop/db/ops.repo.ts +5 -2
- package/server/services/workshop/db/retention.ts +8 -3
- package/server/services/workshop/dcw/dcw-controller.ts +147 -16
- package/server/services/workshop/dcw/dcw-product.repo.ts +38 -1
- package/server/services/workshop/dcw/dcw-runtime.ts +3 -2
- package/server/services/workshop/dcw/drivers.ts +90 -4
- package/server/services/workshop/dcw/param-conversion.ts +78 -0
- package/server/services/workshop/dcw/param-limits.ts +142 -0
- package/server/services/workshop/dcw/param-map.repo.ts +305 -0
- package/server/services/workshop/dcw/plugin-bridge.ts +45 -0
- package/server/services/workshop/dcw/recipe-rollback-manager.ts +13 -7
- package/server/services/workshop/plugins/host.mjs +30 -0
- package/server/services/workshop/runtime/agent-runtime.ts +4 -0
- package/server/services/workshop/runtime/manager.ts +9 -2
- package/server/services/workshop/settings.ts +4 -2
- package/server/types/pg.d.ts +49 -0
- package/server/utils/stability-severity.ts +13 -2
- package/shared/config/groups.mjs +22 -1
- package/shared/config/home.d.mts +28 -0
- package/shared/daq-protocol.ts +15 -0
- package/shared/dcw-protocol.ts +136 -0
- package/uno.config.ts +12 -1
- package/.output/public/_nuxt/8NMOXZOV.js +0 -1
- package/.output/public/_nuxt/BFkgkW8u.js +0 -4
- package/.output/public/_nuxt/C5gUkRwn.js +0 -1
- package/.output/public/_nuxt/CM12FuB42.js +0 -1
- package/.output/public/_nuxt/CZiw7sEV.js +0 -1
- package/.output/public/_nuxt/Cc_9VzD42.js +0 -1
- package/.output/public/_nuxt/CdPzkOMV.js +0 -1
- package/.output/public/_nuxt/CmsOtOAA2.js +0 -1
- package/.output/public/_nuxt/D1YDxZpZ.js +0 -1
- package/.output/public/_nuxt/D20Yamr4.js +0 -1
- package/.output/public/_nuxt/DAe0h2MB.js +0 -1
- package/.output/public/_nuxt/DmqknNvV.js +0 -18
- package/.output/public/_nuxt/DnUuIR83.js +0 -1
- package/.output/public/_nuxt/S_fVQwJK.js +0 -1
- package/.output/public/_nuxt/TownView.0oLiQgTC.css +0 -1
- package/.output/public/_nuxt/_id_.D-SYuyZb.css +0 -1
- package/.output/public/_nuxt/_id_.hma_BU6T.css +0 -1
- package/.output/public/_nuxt/_wsId_.B12v3PhY.css +0 -1
- package/.output/public/_nuxt/agents.BV70ioCv.css +0 -1
- package/.output/public/_nuxt/ahgEJu2R.js +0 -1
- package/.output/public/_nuxt/aml.COEKNNqK.css +0 -1
- package/.output/public/_nuxt/builds/meta/4457d63f-0866-4cea-b320-04a321f24795.json +0 -1
- package/.output/public/_nuxt/channel-templates.C-M5nKcC.css +0 -1
- package/.output/public/_nuxt/daq.B3265ZDn.css +0 -1
- package/.output/public/_nuxt/dcw.DLYZqEhT.css +0 -1
- package/.output/public/_nuxt/default.BXI_fZUi.css +0 -1
- package/.output/public/_nuxt/entry.BB-Eeh-J.css +0 -1
- package/.output/public/_nuxt/logs.CqFyMrJw.css +0 -1
- package/.output/public/_nuxt/monitor.B--1dPzs.css +0 -1
- package/.output/public/_nuxt/pages.ooEzrMm9.css +0 -1
- package/.output/public/_nuxt/permissions.B1pjGChZ.css +0 -1
- package/.output/public/_nuxt/plugins.5e5chZ67.css +0 -1
- package/.output/public/_nuxt/pz2JDAM7.js +0 -2
- package/.output/public/_nuxt/settings.Dm3M0RLy.css +0 -1
- package/.output/public/_nuxt/teams.BC75EGnR.css +0 -1
- package/.output/public/_nuxt/tokens.xRb1fSPU.css +0 -1
- package/.output/public/_nuxt/users.CXnP2E08.css +0 -1
- package/.output/public/_nuxt/workshop.Jk5HxWPE.css +0 -1
- package/.output/server/chunks/build/TownView-jVazYOjN.mjs.map +0 -1
- package/.output/server/chunks/build/_id_-CfVosNg3.mjs.map +0 -1
- package/.output/server/chunks/build/_id_-Hwr4rZpr.mjs.map +0 -1
- package/.output/server/chunks/build/agents-Bvin73QY.mjs.map +0 -1
- package/.output/server/chunks/build/daq-C03Uu5UE.mjs.map +0 -1
- package/.output/server/chunks/build/pages-BO7yZsXA.mjs.map +0 -1
- package/.output/server/chunks/build/settings-DoQ2Oq3P.mjs.map +0 -1
- package/.output/server/chunks/build/teams-2kz3CusY.mjs.map +0 -1
- package/.output/server/chunks/build/town-BOl6hs9B.mjs.map +0 -1
- package/.output/server/chunks/build/useDaqStream-CIBaiGAl.mjs.map +0 -1
- package/.output/server/chunks/build/useDcwStream-CBbiYnWe.mjs.map +0 -1
- package/.output/server/chunks/build/workspaces-BuydxM-3.mjs.map +0 -1
- /package/.output/public/_nuxt/{36oeS8_R2.js → 36oeS8_R.js} +0 -0
- /package/.output/public/_nuxt/{CYWVXZTS.js → CYWVXZTS2.js} +0 -0
|
@@ -0,0 +1,409 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* serial-bridge —— 驱动工厂(串口读/写驱动;连接池 + 队列化事务)。
|
|
3
|
+
*
|
|
4
|
+
* createSerialDrivers({ openRtu, openLine, isAvailable, log }) 与具体串口实现解耦:
|
|
5
|
+
* - openRtu(cfg) → modbus-serial 客户端(RTU over 串口;connectRTUBuffered)
|
|
6
|
+
* - openLine(cfg) → { writeLine, close, latest } 行协议端口(serialport + readline)
|
|
7
|
+
* 测试脚本注入假 opener 即可覆盖 sample/write/readback 全契约,无需真实硬件。
|
|
8
|
+
*
|
|
9
|
+
* 池语义与内置 modbus-tcp 驱动一致(同链路串行化、连续故障驱逐、空闲回收):
|
|
10
|
+
* - 池 key = mode|path@baud,parity,dataBits,stopBits(同一物理链路多节点复用);
|
|
11
|
+
* - withConn 队列:单事务硬超时(半开串口防悬挂),超时作废连接;
|
|
12
|
+
* - 连续 3 次故障 → 驱逐,下次采样重建(自愈)。
|
|
13
|
+
*/
|
|
14
|
+
import {
|
|
15
|
+
classifySerialError,
|
|
16
|
+
decodeRegisters,
|
|
17
|
+
encodeWords,
|
|
18
|
+
engToRaw,
|
|
19
|
+
extractLineValue,
|
|
20
|
+
normalizeSerialConfig,
|
|
21
|
+
rawToEng,
|
|
22
|
+
registerOffset,
|
|
23
|
+
WORDS_OF,
|
|
24
|
+
} from './lib.mjs'
|
|
25
|
+
|
|
26
|
+
/** 空闲连接回收(10 分钟未用断开;采样周期最长 60s,足够保守) */
|
|
27
|
+
const IDLE_MS = 600_000
|
|
28
|
+
/** 采/控共用链路积压保护(与内置 modbus 驱动同阈值) */
|
|
29
|
+
const PENDING_SKIP = 8
|
|
30
|
+
|
|
31
|
+
// ============================================================
|
|
32
|
+
// 驱动目录自描述(前端动态参数表单;DriverConfigField 同形)
|
|
33
|
+
// ============================================================
|
|
34
|
+
|
|
35
|
+
export const SERIAL_READ_FIELDS = [
|
|
36
|
+
{ key: 'mode', label: '协议模式', type: 'select', default: 'modbus-rtu', options: [
|
|
37
|
+
{ value: 'modbus-rtu', label: 'Modbus RTU(RS-485/232)' },
|
|
38
|
+
{ value: 'ascii-line', label: 'ASCII 行(每行一个数值/JSON)' },
|
|
39
|
+
] },
|
|
40
|
+
{ key: 'path', label: '串口路径(path)', type: 'string', required: true, placeholder: 'COM3', hint: 'Windows 如 COM3;Linux 如 /dev/ttyUSB0' },
|
|
41
|
+
{ key: 'baudRate', label: '波特率', type: 'number', default: 9600, hint: '与设备一致(常见 9600/19200/115200)' },
|
|
42
|
+
{ key: 'parity', label: '校验位', type: 'select', default: 'none', options: [
|
|
43
|
+
{ value: 'none', label: '无(None)' },
|
|
44
|
+
{ value: 'even', label: '偶校验(Even)' },
|
|
45
|
+
{ value: 'odd', label: '奇校验(Odd)' },
|
|
46
|
+
] },
|
|
47
|
+
{ key: 'dataBits', label: '数据位', type: 'select', default: 8, options: [
|
|
48
|
+
{ value: 7, label: '7' },
|
|
49
|
+
{ value: 8, label: '8' },
|
|
50
|
+
] },
|
|
51
|
+
{ key: 'stopBits', label: '停止位', type: 'select', default: 1, options: [
|
|
52
|
+
{ value: 1, label: '1' },
|
|
53
|
+
{ value: 2, label: '2' },
|
|
54
|
+
] },
|
|
55
|
+
{ key: 'unitId', label: '从站地址(unitId)', type: 'number', default: 1, hint: 'Modbus RTU 从站地址 1~247' },
|
|
56
|
+
{ key: 'register', label: '寄存器地址', type: 'number', required: true, placeholder: '40001', hint: '4xxxx=保持寄存器(FC03);3xxxx=输入寄存器(FC04)' },
|
|
57
|
+
{ key: 'registerType', label: '寄存器区', type: 'select', default: 'holding', options: [
|
|
58
|
+
{ value: 'holding', label: '保持寄存器(4x)' },
|
|
59
|
+
{ value: 'input', label: '输入寄存器(3x)' },
|
|
60
|
+
] },
|
|
61
|
+
{ key: 'dataType', label: '数据类型', type: 'select', default: 'float32', options: [
|
|
62
|
+
{ value: 'int16', label: 'int16(1 寄存器)' },
|
|
63
|
+
{ value: 'uint16', label: 'uint16(1 寄存器)' },
|
|
64
|
+
{ value: 'int32', label: 'int32(2 寄存器)' },
|
|
65
|
+
{ value: 'uint32', label: 'uint32(2 寄存器)' },
|
|
66
|
+
{ value: 'float32', label: 'float32(2 寄存器,常用)' },
|
|
67
|
+
] },
|
|
68
|
+
{ key: 'byteOrder', label: '字节序', type: 'select', default: 'big', options: [
|
|
69
|
+
{ value: 'big', label: '大端(AB CD)' },
|
|
70
|
+
{ value: 'little', label: '小端(CD AB)' },
|
|
71
|
+
{ value: 'wordSwap', label: '字交换(CD AB / 交换单字)' },
|
|
72
|
+
] },
|
|
73
|
+
{ key: 'scale', label: '缩放系数', type: 'number', default: 1, hint: '原始值 × scale = 工程量(如 0.1)' },
|
|
74
|
+
{ key: 'jsonPath', label: '取值路径(ASCII 模式)', type: 'string', placeholder: 'data.temp', hint: 'ASCII 行为 JSON 时按路径取数值;裸数字留空' },
|
|
75
|
+
{ key: 'staleMs', label: '数据保鲜窗 ms(ASCII 模式)', type: 'number', default: 30000, hint: '超过该时长未收到新行视为停发,采样跳帧(不重复消费陈旧值)' },
|
|
76
|
+
]
|
|
77
|
+
|
|
78
|
+
export const SERIAL_WRITE_FIELDS = [
|
|
79
|
+
{ key: 'mode', label: '协议模式', type: 'select', default: 'modbus-rtu', options: [
|
|
80
|
+
{ value: 'modbus-rtu', label: 'Modbus RTU(写保持寄存器,带回读)' },
|
|
81
|
+
{ value: 'ascii-line', label: 'ASCII 行(发 {v} 模板行,无回读)' },
|
|
82
|
+
] },
|
|
83
|
+
{ key: 'path', label: '串口路径(path)', type: 'string', required: true, placeholder: 'COM3', hint: 'Windows 如 COM3;Linux 如 /dev/ttyUSB0' },
|
|
84
|
+
{ key: 'baudRate', label: '波特率', type: 'number', default: 9600 },
|
|
85
|
+
{ key: 'parity', label: '校验位', type: 'select', default: 'none', options: [
|
|
86
|
+
{ value: 'none', label: '无(None)' },
|
|
87
|
+
{ value: 'even', label: '偶校验(Even)' },
|
|
88
|
+
{ value: 'odd', label: '奇校验(Odd)' },
|
|
89
|
+
] },
|
|
90
|
+
{ key: 'dataBits', label: '数据位', type: 'select', default: 8, options: [{ value: 7, label: '7' }, { value: 8, label: '8' }] },
|
|
91
|
+
{ key: 'stopBits', label: '停止位', type: 'select', default: 1, options: [{ value: 1, label: '1' }, { value: 2, label: '2' }] },
|
|
92
|
+
{ key: 'unitId', label: '从站地址(unitId)', type: 'number', default: 1 },
|
|
93
|
+
{ key: 'register', label: '寄存器地址', type: 'number', required: true, placeholder: '40001', hint: '写保持寄存器(FC06/FC16)+ 同址回读校验' },
|
|
94
|
+
{ key: 'dataType', label: '数据类型', type: 'select', default: 'float32', options: [
|
|
95
|
+
{ value: 'int16', label: 'int16(1 寄存器,FC06)' },
|
|
96
|
+
{ value: 'uint16', label: 'uint16(1 寄存器,FC06)' },
|
|
97
|
+
{ value: 'int32', label: 'int32(2 寄存器,FC16)' },
|
|
98
|
+
{ value: 'uint32', label: 'uint32(2 寄存器,FC16)' },
|
|
99
|
+
{ value: 'float32', label: 'float32(2 寄存器,FC16)' },
|
|
100
|
+
] },
|
|
101
|
+
{ key: 'byteOrder', label: '字节序', type: 'select', default: 'big', options: [
|
|
102
|
+
{ value: 'big', label: '大端(AB CD)' },
|
|
103
|
+
{ value: 'little', label: '小端(CD AB)' },
|
|
104
|
+
{ value: 'wordSwap', label: '字交换(CD AB / 交换单字)' },
|
|
105
|
+
] },
|
|
106
|
+
{ key: 'rawMin', label: '原始量程下限(可选)', type: 'number', placeholder: '0', hint: '工程量↔原始值线性映射;两值都填才启用' },
|
|
107
|
+
{ key: 'rawMax', label: '原始量程上限(可选)', type: 'number', placeholder: '27648', hint: '如西门子 0~27648 对应 4~20mA' },
|
|
108
|
+
{ key: 'engMin', label: '工程量程下限(可选)', type: 'number', placeholder: '0', hint: '缺省取节点工艺量程 min' },
|
|
109
|
+
{ key: 'engMax', label: '工程量程上限(可选)', type: 'number', placeholder: '100', hint: '缺省取节点工艺量程 max' },
|
|
110
|
+
{ key: 'writeTemplate', label: 'ASCII 写模板(可选)', type: 'string', placeholder: 'SET {v}\\n', hint: 'ascii-line 模式下发行模板;{v} 替换为数值,\\n 自动补行尾' },
|
|
111
|
+
]
|
|
112
|
+
|
|
113
|
+
// ============================================================
|
|
114
|
+
// 连接池 + 队列化事务
|
|
115
|
+
// ============================================================
|
|
116
|
+
|
|
117
|
+
function connKey(cfg) {
|
|
118
|
+
return `${cfg.mode}|${cfg.path}@${cfg.baudRate},${cfg.parity},${cfg.dataBits},${cfg.stopBits}`
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* 创建串口驱动组(每插件装载一次;热重载 dispose 时 closeAll 回收全部串口)。
|
|
123
|
+
*/
|
|
124
|
+
export function createSerialDrivers({ openRtu, openLine, isAvailable, log = console }) {
|
|
125
|
+
const pool = new Map()
|
|
126
|
+
let sweep = null
|
|
127
|
+
|
|
128
|
+
async function closeConn(conn) {
|
|
129
|
+
try {
|
|
130
|
+
if (conn.kind === 'rtu') await withTimeout(conn.client.close?.(), 500)
|
|
131
|
+
else await withTimeout(conn.line.close(), 500)
|
|
132
|
+
}
|
|
133
|
+
catch { /* 已断 */ }
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
function withTimeout(p, ms) {
|
|
137
|
+
return Promise.race([
|
|
138
|
+
Promise.resolve(p),
|
|
139
|
+
new Promise(r => setTimeout(() => r(), ms)),
|
|
140
|
+
])
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/** 获取(或建立)串口连接;半开/死连接重建 + 在飞建连去重(串口独占,并发首连
|
|
144
|
+
* 若各开各的,后写池者覆盖前者 → 前一条串口无人持有永久泄漏,Windows 独占打开还会
|
|
145
|
+
* 直接报错。同键并发复用同一条建连任务,与内置 OPC UA 驱动同方案)。 */
|
|
146
|
+
const inflight = new Map()
|
|
147
|
+
async function getConn(cfg) {
|
|
148
|
+
const key = connKey(cfg)
|
|
149
|
+
const existing = pool.get(key)
|
|
150
|
+
const healthy = existing
|
|
151
|
+
&& (existing.kind === 'rtu' ? existing.client.isOpen !== false : existing.line.alive() !== false)
|
|
152
|
+
if (existing && healthy) {
|
|
153
|
+
existing.lastUsed = Date.now()
|
|
154
|
+
return existing
|
|
155
|
+
}
|
|
156
|
+
if (existing) {
|
|
157
|
+
pool.delete(key)
|
|
158
|
+
await closeConn(existing)
|
|
159
|
+
}
|
|
160
|
+
const pending = inflight.get(key)
|
|
161
|
+
if (pending) return pending
|
|
162
|
+
const task = (async () => (cfg.mode === 'modbus-rtu'
|
|
163
|
+
? { kind: 'rtu', client: await openRtu(cfg), lastUsed: Date.now(), tail: Promise.resolve(), pending: 0, errors: 0 }
|
|
164
|
+
: { kind: 'line', line: await openLine(cfg), lastUsed: Date.now(), tail: Promise.resolve(), pending: 0, errors: 0 }))()
|
|
165
|
+
inflight.set(key, task)
|
|
166
|
+
try {
|
|
167
|
+
const conn = await task
|
|
168
|
+
// 竞态二次校验:建连期间若已有连接入池,关闭本次新建并复用既有
|
|
169
|
+
const raced = pool.get(key)
|
|
170
|
+
if (raced && raced !== conn) {
|
|
171
|
+
await closeConn(conn)
|
|
172
|
+
return raced
|
|
173
|
+
}
|
|
174
|
+
pool.set(key, conn)
|
|
175
|
+
return conn
|
|
176
|
+
}
|
|
177
|
+
finally {
|
|
178
|
+
inflight.delete(key)
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* 连接级排队执行:单事务硬超时(默认 3s)——半开串口(拔线/对端掉电)时底层
|
|
184
|
+
* 回调永不返回,超时后作废连接并重置队列,防止单条死链堵死同串口全部节点。
|
|
185
|
+
*/
|
|
186
|
+
function withConn(conn, fn, timeoutMs = 3000) {
|
|
187
|
+
conn.pending++
|
|
188
|
+
const run = conn.tail.then(() => fn(), () => fn())
|
|
189
|
+
let dead = false
|
|
190
|
+
const guarded = Promise.race([
|
|
191
|
+
run,
|
|
192
|
+
new Promise((_, rej) => setTimeout(() => {
|
|
193
|
+
dead = true
|
|
194
|
+
rej(new Error(`串口响应超时(${timeoutMs}ms)——检查接线/波特率/从站地址`))
|
|
195
|
+
}, timeoutMs)),
|
|
196
|
+
])
|
|
197
|
+
void guarded.catch(() => { /* 超时分支先 reject,防 unhandled */ })
|
|
198
|
+
conn.tail = guarded.then(
|
|
199
|
+
() => { conn.pending-- },
|
|
200
|
+
() => { conn.pending-- },
|
|
201
|
+
).then(() => {
|
|
202
|
+
if (dead) {
|
|
203
|
+
conn.tail = Promise.resolve()
|
|
204
|
+
// 超时即作废:关闭并移出池,下次采样重建
|
|
205
|
+
for (const [k, c] of pool) if (c === conn) pool.delete(k)
|
|
206
|
+
closeConn(conn).catch(() => {})
|
|
207
|
+
}
|
|
208
|
+
})
|
|
209
|
+
return guarded
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/** 连续故障驱逐(自愈):同链路 3 次失败后断开重建 */
|
|
213
|
+
function bumpErrors(conn, cfg, err) {
|
|
214
|
+
conn.errors++
|
|
215
|
+
if (conn.errors >= 3) {
|
|
216
|
+
log.warn(`串口链路连续故障,重建: ${connKey(cfg)}(${err?.message ?? err})`)
|
|
217
|
+
for (const [k, c] of pool) if (c === conn) pool.delete(k)
|
|
218
|
+
closeConn(conn).catch(() => {})
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
// 空闲回收 sweep(单例;工厂随插件热重载整体销毁)
|
|
223
|
+
if (!sweep) {
|
|
224
|
+
sweep = setInterval(() => {
|
|
225
|
+
const now = Date.now()
|
|
226
|
+
for (const [key, conn] of pool) {
|
|
227
|
+
if (now - conn.lastUsed > IDLE_MS && conn.pending === 0) {
|
|
228
|
+
pool.delete(key)
|
|
229
|
+
closeConn(conn).catch(() => {})
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
}, 120_000)
|
|
233
|
+
sweep.unref?.()
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
async function closeAll() {
|
|
237
|
+
clearInterval(sweep)
|
|
238
|
+
sweep = null
|
|
239
|
+
const entries = [...pool]
|
|
240
|
+
pool.clear()
|
|
241
|
+
for (const [, conn] of entries) await closeConn(conn)
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
function poolSnapshot() {
|
|
245
|
+
return [...pool.entries()].map(([key, c]) => ({
|
|
246
|
+
key,
|
|
247
|
+
kind: c.kind,
|
|
248
|
+
lastUsedAt: c.lastUsed,
|
|
249
|
+
pending: c.pending,
|
|
250
|
+
errors: c.errors,
|
|
251
|
+
}))
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
// ---------- 读路径(采样 / 测试) ----------
|
|
255
|
+
|
|
256
|
+
async function readOnce(cfg, conn) {
|
|
257
|
+
if (conn.kind === 'rtu') {
|
|
258
|
+
const area = cfg.registerType
|
|
259
|
+
const offset = registerOffset(cfg.register, area)
|
|
260
|
+
const words = WORDS_OF[cfg.dataType] ?? 2
|
|
261
|
+
const res = area === 'input'
|
|
262
|
+
? await conn.client.readInputRegisters(offset, words)
|
|
263
|
+
: await conn.client.readHoldingRegisters(offset, words)
|
|
264
|
+
const raw = decodeRegisters(res.data ?? res.buffer ?? [], cfg.dataType, cfg.byteOrder)
|
|
265
|
+
return { value: raw * cfg.scale, raw }
|
|
266
|
+
}
|
|
267
|
+
// ascii-line:最新行 + 保鲜窗(停发即 null,不重复消费陈旧值)
|
|
268
|
+
const latest = conn.line.latest()
|
|
269
|
+
if (!latest || !latest.text) return { value: null, raw: null }
|
|
270
|
+
if (Date.now() - latest.at > cfg.staleMs) return { value: null, raw: null, stale: true }
|
|
271
|
+
const v = extractLineValue(latest.text, cfg.jsonPath)
|
|
272
|
+
return { value: v == null ? null : v * cfg.scale, raw: v }
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
const readDriver = {
|
|
276
|
+
kind: 'serial',
|
|
277
|
+
meta: { label: '串口 Serial(RS-232/485)', status: 'real', configFields: SERIAL_READ_FIELDS },
|
|
278
|
+
available: () => Promise.resolve(Boolean(isAvailable())),
|
|
279
|
+
async sample({ driverConfig }) {
|
|
280
|
+
const { cfg, errors } = normalizeSerialConfig(driverConfig)
|
|
281
|
+
if (errors.length) throw new Error(errors[0])
|
|
282
|
+
const conn = await getConn(cfg)
|
|
283
|
+
if (conn.pending > PENDING_SKIP) return null
|
|
284
|
+
conn.lastUsed = Date.now()
|
|
285
|
+
return withConn(conn, async () => {
|
|
286
|
+
try {
|
|
287
|
+
const r = await readOnce(cfg, conn)
|
|
288
|
+
conn.errors = 0
|
|
289
|
+
return r.value
|
|
290
|
+
}
|
|
291
|
+
catch (err) {
|
|
292
|
+
bumpErrors(conn, cfg, err)
|
|
293
|
+
throw new Error(classifySerialError(err), { cause: err })
|
|
294
|
+
}
|
|
295
|
+
}, cfg.timeoutMs)
|
|
296
|
+
},
|
|
297
|
+
async test(driverConfig) {
|
|
298
|
+
const t0 = Date.now()
|
|
299
|
+
const { cfg, errors } = normalizeSerialConfig(driverConfig)
|
|
300
|
+
if (errors.length) return { ok: false, message: errors.join(';') }
|
|
301
|
+
try {
|
|
302
|
+
const conn = await getConn(cfg)
|
|
303
|
+
const r = await withConn(conn, () => readOnce(cfg, conn), cfg.timeoutMs)
|
|
304
|
+
conn.errors = 0
|
|
305
|
+
if (r.value == null) {
|
|
306
|
+
return {
|
|
307
|
+
ok: true,
|
|
308
|
+
message: cfg.mode === 'ascii-line'
|
|
309
|
+
? `串口已打开 ${cfg.path}@${cfg.baudRate}(保鲜窗内暂无新鲜数据行;设备上报后采样即开始)`
|
|
310
|
+
: `串口已打开 ${cfg.path}@${cfg.baudRate},读数为空`,
|
|
311
|
+
latencyMs: Date.now() - t0,
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
return {
|
|
315
|
+
ok: true,
|
|
316
|
+
message: `串口连接成功,读取 ${cfg.mode === 'modbus-rtu' ? `${cfg.register}(原始 ${r.raw})` : `行 ${String(r.raw)}`} = ${r.value}`,
|
|
317
|
+
sampleValue: r.value,
|
|
318
|
+
latencyMs: Date.now() - t0,
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
catch (err) {
|
|
322
|
+
return { ok: false, message: `串口连接失败: ${classifySerialError(err)}` }
|
|
323
|
+
}
|
|
324
|
+
},
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
// ---------- 写路径(写 + 回读校验 / 周期读) ----------
|
|
328
|
+
|
|
329
|
+
const writeDriver = {
|
|
330
|
+
kind: 'serial',
|
|
331
|
+
meta: { label: '串口 Serial 写(RS-232/485)', status: 'real', configFields: SERIAL_WRITE_FIELDS },
|
|
332
|
+
available: () => Promise.resolve(Boolean(isAvailable())),
|
|
333
|
+
async write(input) {
|
|
334
|
+
const { cfg, errors } = normalizeSerialConfig(input.driverConfig)
|
|
335
|
+
if (errors.length) return { ok: false, message: errors.join(';'), raw: null, readback: null }
|
|
336
|
+
if (cfg.mode === 'ascii-line') {
|
|
337
|
+
// ASCII 写:发模板行(无协议回读;诚实标注)
|
|
338
|
+
try {
|
|
339
|
+
const conn = await getConn(cfg)
|
|
340
|
+
const line = String(cfg.writeTemplate || '{v}').replace('{v}', String(input.eng))
|
|
341
|
+
await withConn(conn, () => conn.line.writeLine(line), cfg.timeoutMs)
|
|
342
|
+
return { ok: true, message: `已发送「${line.trim()}」到 ${cfg.path}(ascii-line 无回读,建议配合数采节点校验)`, raw: input.eng, readback: null }
|
|
343
|
+
}
|
|
344
|
+
catch (err) {
|
|
345
|
+
return { ok: false, message: `串口写入失败: ${classifySerialError(err)}`, raw: null, readback: null }
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
try {
|
|
349
|
+
const conn = await getConn(cfg)
|
|
350
|
+
return await withConn(conn, async () => {
|
|
351
|
+
const raw = engToRaw(input.eng, input.driverConfig, input.domain)
|
|
352
|
+
const words = encodeWords(raw, cfg.dataType, cfg.byteOrder)
|
|
353
|
+
const offset = registerOffset(cfg.register, 'holding')
|
|
354
|
+
if (words.length === 1) await conn.client.writeRegister(offset, words[0])
|
|
355
|
+
else await conn.client.writeRegisters(offset, words)
|
|
356
|
+
// 回读校验:同址读回 → 解码 → 换算回工程量 → 死区容差比较(与内置写驱动同语义)
|
|
357
|
+
const back = await conn.client.readHoldingRegisters(offset, words.length)
|
|
358
|
+
const rawBack = decodeRegisters(back.data ?? back.buffer ?? [], cfg.dataType, cfg.byteOrder)
|
|
359
|
+
const engBack = rawToEng(rawBack, input.driverConfig, input.domain)
|
|
360
|
+
const ok = Math.abs(engBack - input.eng) <= Math.max(input.tolerance, 1e-9)
|
|
361
|
+
conn.errors = 0
|
|
362
|
+
return {
|
|
363
|
+
ok,
|
|
364
|
+
message: ok
|
|
365
|
+
? `写入成功:${input.eng} → raw ${Number(raw.toFixed(4))},回读 ${Number(engBack.toFixed(4))} 一致`
|
|
366
|
+
: `回读不一致:写入 ${input.eng},回读 ${Number(engBack.toFixed(4))}(容差 ${input.tolerance})`,
|
|
367
|
+
raw,
|
|
368
|
+
readback: engBack,
|
|
369
|
+
}
|
|
370
|
+
}, cfg.timeoutMs)
|
|
371
|
+
}
|
|
372
|
+
catch (err) {
|
|
373
|
+
return { ok: false, message: `串口写入失败: ${classifySerialError(err)}`, raw: null, readback: null }
|
|
374
|
+
}
|
|
375
|
+
},
|
|
376
|
+
async read(input) {
|
|
377
|
+
const { cfg, errors } = normalizeSerialConfig(input.driverConfig)
|
|
378
|
+
if (errors.length) return { ok: false, message: errors.join(';'), eng: null, raw: null }
|
|
379
|
+
try {
|
|
380
|
+
const conn = await getConn(cfg)
|
|
381
|
+
const r = await withConn(conn, () => readOnce(cfg, conn), cfg.timeoutMs)
|
|
382
|
+
if (r.value == null) return { ok: true, message: '串口无新鲜数据', eng: null, raw: null }
|
|
383
|
+
return {
|
|
384
|
+
ok: true,
|
|
385
|
+
message: cfg.mode === 'modbus-rtu' ? `读取 raw ${r.raw} = ${r.value}` : `读取行值 ${r.value}`,
|
|
386
|
+
eng: r.value,
|
|
387
|
+
raw: r.raw,
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
catch (err) {
|
|
391
|
+
return { ok: false, message: classifySerialError(err), eng: null, raw: null }
|
|
392
|
+
}
|
|
393
|
+
},
|
|
394
|
+
async test(driverConfig) {
|
|
395
|
+
const t0 = Date.now()
|
|
396
|
+
const { cfg, errors } = normalizeSerialConfig(driverConfig)
|
|
397
|
+
if (errors.length) return { ok: false, message: errors.join(';') }
|
|
398
|
+
if (cfg.mode === 'ascii-line' && cfg.writeTemplate === '') return { ok: false, message: 'ascii-line 模式缺少写模板 writeTemplate' }
|
|
399
|
+
const r = await writeDriver.read({ domain: { min: 0, max: 100 }, driverConfig })
|
|
400
|
+
if (!r.ok) return { ok: false, message: `串口连接失败: ${r.message}` }
|
|
401
|
+
return {
|
|
402
|
+
ok: true,
|
|
403
|
+
message: `串口连接成功(${Date.now() - t0}ms;${cfg.mode === 'modbus-rtu' ? '读回读链路正常' : 'ascii 行链路正常'};未执行写入测试,避免误触发真实设备动作)`,
|
|
404
|
+
}
|
|
405
|
+
},
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
return { readDriver, writeDriver, closeAll, poolSnapshot, getConn }
|
|
409
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
{
|
|
2
|
+
"zh-CN": {
|
|
3
|
+
"panel": {
|
|
4
|
+
"title": "串口通信(serial-bridge)",
|
|
5
|
+
"refresh": "刷新",
|
|
6
|
+
"available": "协议栈就绪(serialport)",
|
|
7
|
+
"unavailable": "serialport 未安装 —— npm i serialport 后重启服务即恢复",
|
|
8
|
+
"ports": "系统串口",
|
|
9
|
+
"noports": "未发现串口设备(插入 USB 转 485/232 后刷新)",
|
|
10
|
+
"path": "端口",
|
|
11
|
+
"manufacturer": "厂商",
|
|
12
|
+
"serialNumber": "序列号",
|
|
13
|
+
"probe": "连接探针",
|
|
14
|
+
"probe_hint": "按给定参数开串口读一次(不落库);通过后即可按同参数创建数采/写控节点",
|
|
15
|
+
"mode": "协议模式",
|
|
16
|
+
"baud": "波特率",
|
|
17
|
+
"unit": "从站",
|
|
18
|
+
"register": "寄存器",
|
|
19
|
+
"sendLine": "探测行(ASCII)",
|
|
20
|
+
"run_probe": "测试连接",
|
|
21
|
+
"probing": "测试中…",
|
|
22
|
+
"links": "打开的链路",
|
|
23
|
+
"nolinks": "暂无打开的串口链路(创建串口节点并开始采集后出现)",
|
|
24
|
+
"link": "链路",
|
|
25
|
+
"pending": "在途",
|
|
26
|
+
"errors": "错误",
|
|
27
|
+
"lastUsed": "最近使用",
|
|
28
|
+
"nodes": "串口数采节点",
|
|
29
|
+
"nonodes": "暂无串口数采节点(数采中心 → 添加节点 → 协议选「串口 Serial ⌁」)"
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
"en": {
|
|
33
|
+
"panel": {
|
|
34
|
+
"title": "Serial Communication (serial-bridge)",
|
|
35
|
+
"refresh": "Refresh",
|
|
36
|
+
"available": "Protocol stack ready (serialport)",
|
|
37
|
+
"unavailable": "serialport not installed — run npm i serialport and restart",
|
|
38
|
+
"ports": "System serial ports",
|
|
39
|
+
"noports": "No serial devices found (plug in a USB-RS485/232 adapter and refresh)",
|
|
40
|
+
"path": "Port",
|
|
41
|
+
"manufacturer": "Manufacturer",
|
|
42
|
+
"serialNumber": "Serial No.",
|
|
43
|
+
"probe": "Connection probe",
|
|
44
|
+
"probe_hint": "Opens the port and reads once (nothing persisted); once it passes, create DAQ/write nodes with the same parameters",
|
|
45
|
+
"mode": "Mode",
|
|
46
|
+
"baud": "Baud",
|
|
47
|
+
"unit": "Unit",
|
|
48
|
+
"register": "Register",
|
|
49
|
+
"sendLine": "Probe line (ASCII)",
|
|
50
|
+
"run_probe": "Test connection",
|
|
51
|
+
"probing": "Testing…",
|
|
52
|
+
"links": "Open links",
|
|
53
|
+
"nolinks": "No open serial links yet (appears once a serial node starts sampling)",
|
|
54
|
+
"link": "Link",
|
|
55
|
+
"pending": "Pending",
|
|
56
|
+
"errors": "Errors",
|
|
57
|
+
"lastUsed": "Last used",
|
|
58
|
+
"nodes": "Serial DAQ nodes",
|
|
59
|
+
"nonodes": "No serial DAQ nodes yet (DAQ console → Add node → pick \"Serial ⌁\")"
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|