@windypro-rourou/dsh-eda 0.1.4 → 0.1.5
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/README.md +1 -1
- package/lib/capabilities.js +3 -2
- package/lib/client.js +33 -0
- package/lib/index.js +89 -2
- package/package.json +10 -1
- package/skill/INDEX.md +10 -8
- package/skill/README.md +125 -0
- package/skill/README.zh-Hans.md +125 -0
- package/skill/SKILL.md +746 -746
- package/skill/format/index.md +152 -152
- package/skill/format/pcb/3d.md +166 -166
- package/skill/format/pcb/attr.md +63 -63
- package/skill/format/pcb/common.md +306 -306
- package/skill/format/pcb/component.md +132 -132
- package/skill/format/pcb/dimension.md +58 -58
- package/skill/format/pcb/index.md +17 -17
- package/skill/format/pcb/obj.md +43 -43
- package/skill/format/pcb/pad_via.md +151 -151
- package/skill/format/pcb/panel.md +64 -64
- package/skill/format/pcb/partition.md +43 -43
- package/skill/format/pcb/primitive.md +196 -196
- package/skill/format/pcb/rule.md +71 -71
- package/skill/format/pcb/shape.md +441 -441
- package/skill/format/pcb/text.md +62 -62
- package/skill/format/project/blob.md +30 -30
- package/skill/format/project/common.md +42 -42
- package/skill/format/project/group.md +62 -62
- package/skill/format/project/index.md +12 -12
- package/skill/format/project/instance.md +32 -32
- package/skill/format/project/meta.md +189 -189
- package/skill/format/project/variant.md +30 -30
- package/skill/format/schematic/attr.md +41 -41
- package/skill/format/schematic/common.md +47 -47
- package/skill/format/schematic/component.md +91 -91
- package/skill/format/schematic/index.md +14 -14
- package/skill/format/schematic/obj.md +41 -41
- package/skill/format/schematic/pin.md +59 -59
- package/skill/format/schematic/shape.md +231 -231
- package/skill/format/schematic/structure.md +53 -53
- package/skill/format/schematic/table.md +109 -109
- package/skill/format/schematic/text.md +47 -47
- package/skill/format/schematic/wire.md +132 -132
- package/skill/guide/ancillary-projects/easyeda-api-sdk.md +1 -0
- package/skill/guide/ancillary-projects/pro-api-types.md +5 -5
- package/skill/guide/ancillary-projects.md +10 -10
- package/skill/guide/cli.md +1510 -0
- package/skill/guide/error-handling.md +38 -38
- package/skill/guide/extension-json.md +135 -135
- package/skill/guide/extensions-marketplace.md +61 -61
- package/skill/guide/how-to-start.md +316 -301
- package/skill/guide/i18n.md +57 -57
- package/skill/guide/index.md +7 -7
- package/skill/guide/inline-frame.md +20 -20
- package/skill/guide/invoke-apis.md +81 -81
- package/skill/guide/stability.md +37 -37
- package/skill/references/_index.md +471 -398
- package/skill/references/_quick-reference.md +3103 -3028
- package/skill/references/classes/DMT_Board.md +537 -533
- package/skill/references/classes/DMT_EditorControl.md +1736 -1736
- package/skill/references/classes/DMT_Event.md +356 -356
- package/skill/references/classes/DMT_Folder.md +775 -775
- package/skill/references/classes/DMT_Panel.md +531 -531
- package/skill/references/classes/DMT_Pcb.md +579 -575
- package/skill/references/classes/DMT_Project.md +734 -573
- package/skill/references/classes/DMT_Schematic.md +1482 -1477
- package/skill/references/classes/DMT_SelectControl.md +96 -96
- package/skill/references/classes/DMT_Team.md +172 -172
- package/skill/references/classes/DMT_Workspace.md +198 -198
- package/skill/references/classes/EDA.md +1001 -961
- package/skill/references/classes/IPCB_ComplexPolygon.md +299 -299
- package/skill/references/classes/IPCB_Polygon.md +175 -175
- package/skill/references/classes/IPCB_PrimitiveArc.md +1901 -1901
- package/skill/references/classes/IPCB_PrimitiveAttribute.md +2993 -2993
- package/skill/references/classes/IPCB_PrimitiveComponent.md +2624 -2627
- package/skill/references/classes/IPCB_PrimitiveComponentPad.md +410 -410
- package/skill/references/classes/IPCB_PrimitiveDimension.md +1419 -1419
- package/skill/references/classes/IPCB_PrimitiveFill.md +1325 -1325
- package/skill/references/classes/IPCB_PrimitiveImage.md +1461 -1461
- package/skill/references/classes/IPCB_PrimitiveLine.md +1639 -1639
- package/skill/references/classes/IPCB_PrimitiveObject.md +1700 -1700
- package/skill/references/classes/IPCB_PrimitivePad.md +3155 -3155
- package/skill/references/classes/IPCB_PrimitivePolyline.md +1193 -1193
- package/skill/references/classes/IPCB_PrimitivePour.md +1858 -1858
- package/skill/references/classes/IPCB_PrimitivePoured.md +556 -556
- package/skill/references/classes/IPCB_PrimitiveRegion.md +1332 -1332
- package/skill/references/classes/IPCB_PrimitiveString.md +2315 -2315
- package/skill/references/classes/IPCB_PrimitiveVia.md +1588 -1588
- package/skill/references/classes/ISCH_PrimitiveArc.md +1676 -1676
- package/skill/references/classes/ISCH_PrimitiveAttribute.md +2541 -2541
- package/skill/references/classes/ISCH_PrimitiveBus.md +973 -973
- package/skill/references/classes/ISCH_PrimitiveCbbSymbolComponent.md +260 -260
- package/skill/references/classes/ISCH_PrimitiveCircle.md +1392 -1392
- package/skill/references/classes/ISCH_PrimitiveComponent.md +2910 -2913
- package/skill/references/classes/ISCH_PrimitiveComponentPin.md +155 -155
- package/skill/references/classes/ISCH_PrimitiveObject.md +960 -960
- package/skill/references/classes/ISCH_PrimitivePin.md +2402 -2402
- package/skill/references/classes/ISCH_PrimitivePolygon.md +1028 -1028
- package/skill/references/classes/ISCH_PrimitiveRectangle.md +1777 -1777
- package/skill/references/classes/ISCH_PrimitiveText.md +1771 -1771
- package/skill/references/classes/ISCH_PrimitiveWire.md +973 -973
- package/skill/references/classes/LIB_3DModel.md +782 -780
- package/skill/references/classes/LIB_Cbb.md +957 -957
- package/skill/references/classes/LIB_Classification.md +969 -965
- package/skill/references/classes/LIB_Device.md +1222 -1221
- package/skill/references/classes/LIB_Footprint.md +1298 -1153
- package/skill/references/classes/LIB_LibrariesList.md +361 -329
- package/skill/references/classes/LIB_PanelLibrary.md +855 -855
- package/skill/references/classes/LIB_SelectControl.md +89 -89
- package/skill/references/classes/LIB_SimulationModel.md +807 -821
- package/skill/references/classes/LIB_Symbol.md +1341 -1195
- package/skill/references/classes/PCB_Document.md +1770 -1754
- package/skill/references/classes/PCB_Drc.md +3379 -3375
- package/skill/references/classes/PCB_Event.md +1166 -1081
- package/skill/references/classes/PCB_ImageTool.md +363 -0
- package/skill/references/classes/PCB_Layer.md +1915 -1911
- package/skill/references/classes/PCB_ManufactureData.md +2968 -2968
- package/skill/references/classes/PCB_MathPolygon.md +916 -785
- package/skill/references/classes/PCB_Net.md +1128 -1128
- package/skill/references/classes/PCB_Primitive.md +217 -217
- package/skill/references/classes/PCB_PrimitiveArc.md +820 -894
- package/skill/references/classes/PCB_PrimitiveAttribute.md +635 -717
- package/skill/references/classes/PCB_PrimitiveComponent.md +1050 -1050
- package/skill/references/classes/PCB_PrimitiveDimension.md +789 -833
- package/skill/references/classes/PCB_PrimitiveFill.md +783 -861
- package/skill/references/classes/PCB_PrimitiveImage.md +803 -875
- package/skill/references/classes/PCB_PrimitiveLine.md +787 -858
- package/skill/references/classes/PCB_PrimitiveObject.md +796 -800
- package/skill/references/classes/PCB_PrimitivePad.md +947 -944
- package/skill/references/classes/PCB_PrimitivePolyline.md +744 -819
- package/skill/references/classes/PCB_PrimitivePour.md +808 -845
- package/skill/references/classes/PCB_PrimitivePoured.md +363 -363
- package/skill/references/classes/PCB_PrimitiveRegion.md +765 -799
- package/skill/references/classes/PCB_PrimitiveString.md +828 -910
- package/skill/references/classes/PCB_PrimitiveVia.md +761 -765
- package/skill/references/classes/PCB_RayTracerEngine.md +603 -263
- package/skill/references/classes/PCB_SelectControl.md +495 -495
- package/skill/references/classes/PCB_Tool.md +9 -0
- package/skill/references/classes/PNL_Document.md +83 -83
- package/skill/references/classes/SCH_Document.md +797 -809
- package/skill/references/classes/SCH_Drc.md +246 -242
- package/skill/references/classes/SCH_Event.md +583 -583
- package/skill/references/classes/SCH_ManufactureData.md +1209 -1205
- package/skill/references/classes/SCH_Net.md +200 -200
- package/skill/references/classes/SCH_Netlist.md +191 -191
- package/skill/references/classes/SCH_Primitive.md +337 -337
- package/skill/references/classes/SCH_PrimitiveArc.md +686 -692
- package/skill/references/classes/SCH_PrimitiveAttribute.md +579 -590
- package/skill/references/classes/SCH_PrimitiveBus.md +618 -624
- package/skill/references/classes/SCH_PrimitiveCircle.md +667 -683
- package/skill/references/classes/SCH_PrimitiveComponent.md +2256 -2240
- package/skill/references/classes/SCH_PrimitiveObject.md +666 -666
- package/skill/references/classes/SCH_PrimitivePin.md +737 -754
- package/skill/references/classes/SCH_PrimitivePolygon.md +621 -627
- package/skill/references/classes/SCH_PrimitiveRectangle.md +715 -731
- package/skill/references/classes/SCH_PrimitiveText.md +736 -746
- package/skill/references/classes/SCH_PrimitiveWire.md +701 -703
- package/skill/references/classes/SCH_SelectControl.md +520 -520
- package/skill/references/classes/SCH_SimulationEngine.md +133 -133
- package/skill/references/classes/SCH_Utils.md +121 -121
- package/skill/references/classes/SYS_ClientUrl.md +173 -173
- package/skill/references/classes/SYS_Dialog.md +825 -825
- package/skill/references/classes/SYS_Environment.md +640 -502
- package/skill/references/classes/SYS_ExternalApi.md +246 -0
- package/skill/references/classes/SYS_FileManager.md +1664 -1686
- package/skill/references/classes/SYS_FileSystem.md +1366 -1171
- package/skill/references/classes/SYS_FontManager.md +224 -224
- package/skill/references/classes/SYS_FormatConversion.md +349 -349
- package/skill/references/classes/SYS_HeaderMenu.md +480 -479
- package/skill/references/classes/SYS_Help.md +141 -0
- package/skill/references/classes/SYS_I18n.md +861 -861
- package/skill/references/classes/SYS_IFrame.md +541 -535
- package/skill/references/classes/SYS_LoadingAndProgressBar.md +246 -246
- package/skill/references/classes/SYS_Log.md +422 -424
- package/skill/references/classes/SYS_Math.md +1565 -1565
- package/skill/references/classes/SYS_Message.md +363 -363
- package/skill/references/classes/SYS_MessageBox.md +285 -285
- package/skill/references/classes/SYS_MessageBus.md +1618 -1618
- package/skill/references/classes/SYS_PanelControl.md +696 -696
- package/skill/references/classes/SYS_RightClickMenu.md +175 -175
- package/skill/references/classes/SYS_Setting.md +134 -85
- package/skill/references/classes/SYS_ShortcutKey.md +623 -623
- package/skill/references/classes/SYS_Storage.md +484 -484
- package/skill/references/classes/SYS_Timer.md +447 -447
- package/skill/references/classes/SYS_ToastMessage.md +194 -194
- package/skill/references/classes/SYS_Tool.md +317 -241
- package/skill/references/classes/SYS_Unit.md +594 -594
- package/skill/references/classes/SYS_WebSocket.md +401 -401
- package/skill/references/classes/SYS_Window.md +849 -850
- package/skill/references/enums/EDMT_EditorDocumentType.md +324 -278
- package/skill/references/enums/EDMT_EditorSplitScreenDirection.md +51 -47
- package/skill/references/enums/EDMT_EditorTabEventType.md +68 -62
- package/skill/references/enums/EDMT_IndicatorMarkerType.md +90 -80
- package/skill/references/enums/EDMT_ItemType.md +181 -157
- package/skill/references/enums/EDMT_ProjectCollaborationMode.md +51 -47
- package/skill/references/enums/EDMT_ProjectFileFormat.md +60 -0
- package/skill/references/enums/EDMT_ProjectReadyState.md +82 -0
- package/skill/references/enums/ELIB_DeviceJlcLibraryCategory.md +51 -47
- package/skill/references/enums/ELIB_LibraryType.md +129 -113
- package/skill/references/enums/ELIB_PreviewType.md +77 -69
- package/skill/references/enums/ELIB_SimulationModelType.md +51 -47
- package/skill/references/enums/ELIB_SymbolType.md +142 -124
- package/skill/references/enums/EPCB_AutoRoutingCornerStyle.md +51 -47
- package/skill/references/enums/EPCB_AutoRoutingExistingPrimitiveMode.md +51 -47
- package/skill/references/enums/EPCB_AutoRoutingOptimization.md +51 -47
- package/skill/references/enums/EPCB_DocumentCanvasUpdateCalculationActiveStatus.md +51 -47
- package/skill/references/enums/EPCB_DocumentRatlineCalculatingActiveStatus.md +55 -51
- package/skill/references/enums/EPCB_InactiveLayerDisplayMode.md +64 -58
- package/skill/references/enums/EPCB_LayerColorConfiguration.md +90 -80
- package/skill/references/enums/EPCB_LayerId.md +1169 -881
- package/skill/references/enums/EPCB_LayerStatus.md +64 -58
- package/skill/references/enums/EPCB_LayerType.md +129 -113
- package/skill/references/enums/EPCB_MouseEventType.md +64 -58
- package/skill/references/enums/EPCB_NetEventType.md +64 -58
- package/skill/references/enums/EPCB_PcbPlateType.md +51 -47
- package/skill/references/enums/EPCB_PdfOutputMethod.md +64 -58
- package/skill/references/enums/EPCB_PrimitiveArcInteractiveMode.md +51 -47
- package/skill/references/enums/EPCB_PrimitiveDimensionType.md +64 -58
- package/skill/references/enums/EPCB_PrimitiveEventType.md +64 -58
- package/skill/references/enums/EPCB_PrimitiveFillMode.md +68 -62
- package/skill/references/enums/EPCB_PrimitivePadHeatWeldingConnectionMethod.md +64 -58
- package/skill/references/enums/EPCB_PrimitivePadHoleType.md +64 -58
- package/skill/references/enums/EPCB_PrimitivePadShapeType.md +90 -80
- package/skill/references/enums/EPCB_PrimitivePadType.md +64 -58
- package/skill/references/enums/EPCB_PrimitivePourFillMethod.md +64 -58
- package/skill/references/enums/EPCB_PrimitiveRegionRuleType.md +107 -95
- package/skill/references/enums/EPCB_PrimitiveStringAlignMode.md +142 -124
- package/skill/references/enums/EPCB_PrimitiveType.md +233 -201
- package/skill/references/enums/EPCB_PrimitiveViaType.md +64 -58
- package/skill/references/enums/ESCH_DynamicSimulationEnginePullEventType.md +116 -102
- package/skill/references/enums/ESCH_DynamicSimulationEnginePushEventType.md +90 -80
- package/skill/references/enums/ESCH_ExportDocumentFileType.md +64 -58
- package/skill/references/enums/ESCH_MouseEventType.md +51 -47
- package/skill/references/enums/ESCH_PrimitiveComponentType.md +142 -124
- package/skill/references/enums/ESCH_PrimitiveEventType.md +77 -69
- package/skill/references/enums/ESCH_PrimitiveFillStyle.md +129 -113
- package/skill/references/enums/ESCH_PrimitiveLineType.md +77 -69
- package/skill/references/enums/ESCH_PrimitivePinShape.md +77 -69
- package/skill/references/enums/ESCH_PrimitivePinType.md +168 -146
- package/skill/references/enums/ESCH_PrimitiveTextAlignMode.md +142 -124
- package/skill/references/enums/ESCH_PrimitiveType.md +207 -179
- package/skill/references/enums/ESCH_SimulationNetlistType.md +38 -36
- package/skill/references/enums/ESCH_SpiceSimulationEnginePullEventType.md +51 -47
- package/skill/references/enums/ESCH_SpiceSimulationEnginePushEventType.md +77 -69
- package/skill/references/enums/ESYS_BottomPanelTab.md +94 -80
- package/skill/references/enums/ESYS_HeaderMenuEnvironment.md +181 -157
- package/skill/references/enums/ESYS_ImportProjectBoardOutlineSource.md +55 -51
- package/skill/references/enums/ESYS_ImportProjectImportOption.md +64 -58
- package/skill/references/enums/ESYS_ImportProjectSchematicObjectStyle.md +51 -47
- package/skill/references/enums/ESYS_ImportProjectViaSolderMaskExpansion.md +55 -51
- package/skill/references/enums/ESYS_JobState.md +95 -0
- package/skill/references/enums/ESYS_LeftPanelTab.md +94 -80
- package/skill/references/enums/ESYS_LogType.md +77 -102
- package/skill/references/enums/ESYS_NetlistType.md +129 -113
- package/skill/references/enums/ESYS_PanelPosition.md +69 -0
- package/skill/references/enums/ESYS_PanelTab.md +368 -0
- package/skill/references/enums/ESYS_RightPanelTab.md +237 -201
- package/skill/references/enums/ESYS_ShortcutKeyEffectiveEditorRange.md +220 -190
- package/skill/references/enums/ESYS_ShortcutKeyEffectiveEditorScene.md +103 -91
- package/skill/references/enums/ESYS_StartPageQuickStartItem.md +237 -205
- package/skill/references/enums/ESYS_Theme.md +51 -47
- package/skill/references/enums/ESYS_ToastMessageType.md +90 -80
- package/skill/references/enums/ESYS_Unit.md +116 -102
- package/skill/references/enums/ESYS_WindowEventType.md +64 -47
- package/skill/references/enums/ESYS_WindowOpenTarget.md +51 -47
- package/skill/references/enums/NetportDeviceName.md +146 -146
- package/skill/references/enums/SchToolBarDeviceName.md +278 -278
- package/skill/references/interfaces/BoardProps.md +169 -169
- package/skill/references/interfaces/BorderConfig.md +109 -0
- package/skill/references/interfaces/ButtonProps.md +196 -169
- package/skill/references/interfaces/CellClickInfo.md +142 -0
- package/skill/references/interfaces/CellCoord.md +88 -0
- package/skill/references/interfaces/CheckBoxProps.md +223 -196
- package/skill/references/interfaces/CheckChangeDetail.md +88 -0
- package/skill/references/interfaces/CheckboxEditConfig.md +159 -0
- package/skill/references/interfaces/ClipboardCellData.md +142 -0
- package/skill/references/interfaces/ClipboardConfig.md +115 -0
- package/skill/references/interfaces/ColorPickerProps.md +169 -0
- package/skill/references/interfaces/ColumnDef.md +605 -0
- package/skill/references/interfaces/ColumnEditTrigger.md +57 -0
- package/skill/references/interfaces/ColumnGroupDef.md +192 -0
- package/skill/references/interfaces/ColumnResizeConfig.md +142 -0
- package/skill/references/interfaces/ComponentPropsMap.md +517 -448
- package/skill/references/interfaces/CustomHeaderConfig.md +169 -0
- package/skill/references/interfaces/DialogProps.md +385 -385
- package/skill/references/interfaces/DragSortConfig.md +115 -0
- package/skill/references/interfaces/EditingConfig.md +196 -0
- package/skill/references/interfaces/FilteringConfig.md +250 -0
- package/skill/references/interfaces/FixedColumnConfig.md +88 -0
- package/skill/references/interfaces/FlexItemProps.md +116 -116
- package/skill/references/interfaces/FlexProps.md +224 -224
- package/skill/references/interfaces/GridItemProps.md +143 -143
- package/skill/references/interfaces/GridProps.md +143 -143
- package/skill/references/interfaces/IDMT_BoardItem.md +171 -171
- package/skill/references/interfaces/IDMT_BriefProjectItem.md +171 -171
- package/skill/references/interfaces/IDMT_EditorDocumentItem.md +169 -169
- package/skill/references/interfaces/IDMT_EditorSplitScreenItem.md +173 -173
- package/skill/references/interfaces/IDMT_EditorTabItem.md +169 -169
- package/skill/references/interfaces/IDMT_FolderItem.md +225 -225
- package/skill/references/interfaces/IDMT_IndicatorMarkerShape.md +393 -393
- package/skill/references/interfaces/IDMT_PanelItem.md +144 -144
- package/skill/references/interfaces/IDMT_PcbItem.md +171 -171
- package/skill/references/interfaces/IDMT_ProjectItem.md +143 -143
- package/skill/references/interfaces/IDMT_SchematicItem.md +225 -225
- package/skill/references/interfaces/IDMT_SchematicPageItem.md +198 -198
- package/skill/references/interfaces/IDMT_TeamItem.md +144 -144
- package/skill/references/interfaces/IDMT_WorkspaceItem.md +117 -117
- package/skill/references/interfaces/IDesignPortal.md +103 -103
- package/skill/references/interfaces/ILIB_3DModelItem.md +198 -198
- package/skill/references/interfaces/ILIB_3DModelSearchItem.md +277 -277
- package/skill/references/interfaces/ILIB_CbbItem.md +225 -225
- package/skill/references/interfaces/ILIB_CbbSearchItem.md +277 -277
- package/skill/references/interfaces/ILIB_ClassificationIndex.md +150 -150
- package/skill/references/interfaces/ILIB_ClassificationNode.md +98 -0
- package/skill/references/interfaces/ILIB_DeviceAssociationItem.md +210 -210
- package/skill/references/interfaces/ILIB_DeviceExtendPropertyItem.md +304 -304
- package/skill/references/interfaces/ILIB_DeviceItem.md +279 -279
- package/skill/references/interfaces/ILIB_DevicePropertiesForSearch.md +250 -250
- package/skill/references/interfaces/ILIB_DeviceSearchItem.md +521 -521
- package/skill/references/interfaces/ILIB_ExtendLibrary3DModelFunctions.md +64 -64
- package/skill/references/interfaces/ILIB_ExtendLibraryCbbFunctions.md +93 -99
- package/skill/references/interfaces/ILIB_ExtendLibraryClassificationIndex.md +150 -150
- package/skill/references/interfaces/ILIB_ExtendLibraryDeviceFunctions.md +143 -157
- package/skill/references/interfaces/ILIB_ExtendLibraryFootprintFunctions.md +63 -63
- package/skill/references/interfaces/ILIB_ExtendLibraryFunctions.md +123 -123
- package/skill/references/interfaces/ILIB_ExtendLibraryItem.md +97 -97
- package/skill/references/interfaces/ILIB_ExtendLibraryItemIndex.md +98 -98
- package/skill/references/interfaces/ILIB_ExtendLibrarySearchProperty.md +115 -115
- package/skill/references/interfaces/ILIB_ExtendLibrarySearchResult.md +169 -169
- package/skill/references/interfaces/ILIB_ExtendLibrarySearchResultDataLine.md +234 -234
- package/skill/references/interfaces/ILIB_ExtendLibrarySymbolFunctions.md +91 -105
- package/skill/references/interfaces/ILIB_ExtendLibraryUserIndex.md +96 -96
- package/skill/references/interfaces/ILIB_FootprintItem.md +256 -198
- package/skill/references/interfaces/ILIB_FootprintPropertiesForSearch.md +61 -61
- package/skill/references/interfaces/ILIB_FootprintSearchItem.md +277 -277
- package/skill/references/interfaces/ILIB_LibraryInfo.md +92 -92
- package/skill/references/interfaces/ILIB_LibraryItem.md +115 -115
- package/skill/references/interfaces/ILIB_PanelLibraryItem.md +198 -198
- package/skill/references/interfaces/ILIB_PanelLibrarySearchItem.md +277 -277
- package/skill/references/interfaces/ILIB_RegisterExtendLibraryProps.md +71 -0
- package/skill/references/interfaces/ILIB_SimulationModelItem.md +306 -306
- package/skill/references/interfaces/ILIB_SimulationModelSearchItem.md +304 -304
- package/skill/references/interfaces/ILIB_SymbolItem.md +306 -279
- package/skill/references/interfaces/ILIB_SymbolPropertiesForSearch.md +61 -61
- package/skill/references/interfaces/ILIB_SymbolSearchItem.md +304 -304
- package/skill/references/interfaces/IPCB_AutoLayoutResult.md +169 -169
- package/skill/references/interfaces/IPCB_AutoRoutingProps.md +220 -220
- package/skill/references/interfaces/IPCB_AutoRoutingResult.md +169 -169
- package/skill/references/interfaces/IPCB_BomPropertiesTableColumns.md +169 -169
- package/skill/references/interfaces/IPCB_DifferentialPairItem.md +115 -115
- package/skill/references/interfaces/IPCB_DiscretizeOptions.md +65 -65
- package/skill/references/interfaces/IPCB_DiscretizedPoint.md +88 -88
- package/skill/references/interfaces/IPCB_EqualLengthNetGroupItem.md +115 -115
- package/skill/references/interfaces/IPCB_LayerItem.md +277 -277
- package/skill/references/interfaces/IPCB_NetClassItem.md +115 -115
- package/skill/references/interfaces/IPCB_NetInfo.md +115 -115
- package/skill/references/interfaces/IPCB_PadPairGroupItem.md +88 -88
- package/skill/references/interfaces/IPCB_PadPairMinWireLengthItem.md +88 -88
- package/skill/references/interfaces/IPCB_PhysicalStackingConfiguration.md +115 -115
- package/skill/references/interfaces/IPCB_Primitive.md +218 -218
- package/skill/references/interfaces/IPCB_PrimitiveAPI.md +174 -175
- package/skill/references/interfaces/IPCB_PrimitivePadHeatWelding.md +151 -151
- package/skill/references/interfaces/IPCB_PrimitivePouredPourFill.md +142 -142
- package/skill/references/interfaces/IPCB_PrimitiveSolderMaskAndPasteMaskExpansion.md +154 -154
- package/skill/references/interfaces/IPCB_RayTracerBackgroundConfig.md +223 -0
- package/skill/references/interfaces/IPCB_RayTracerLightConfig.md +412 -0
- package/skill/references/interfaces/IPCB_RayTracerMaterialConfig.md +547 -0
- package/skill/references/interfaces/IPCB_RayTracerPcbMaterialConfig.md +196 -0
- package/skill/references/interfaces/IPCB_RayTracerRenderConfigurations.md +200 -0
- package/skill/references/interfaces/IPCB_RayTracerRendererConfig.md +196 -0
- package/skill/references/interfaces/IPCB_RayTracerSceneElement.md +115 -0
- package/skill/references/interfaces/IPCB_RayTracerSceneElementTransform.md +123 -0
- package/skill/references/interfaces/IPCB_RayTracerTexture.md +88 -0
- package/skill/references/interfaces/IPCB_SubstratePhysicalProperties.md +88 -88
- package/skill/references/interfaces/IRawNet.md +103 -103
- package/skill/references/interfaces/IRawPureSchematic.md +80 -80
- package/skill/references/interfaces/IRawSchematic.md +103 -103
- package/skill/references/interfaces/IRawWire.md +149 -149
- package/skill/references/interfaces/ISCH_DrcError.md +142 -142
- package/skill/references/interfaces/ISCH_DrcErrorPrimitive.md +142 -142
- package/skill/references/interfaces/ISCH_ExportPngResolution.md +94 -94
- package/skill/references/interfaces/ISCH_NetInfo.md +88 -88
- package/skill/references/interfaces/ISCH_Primitive.md +218 -219
- package/skill/references/interfaces/ISCH_PrimitiveAPI.md +174 -175
- package/skill/references/interfaces/ISCH_ProjectNetInfo.md +142 -142
- package/skill/references/interfaces/ISCH_WireInfo.md +169 -169
- package/skill/references/interfaces/ISYS_ComparisonResponse.md +115 -0
- package/skill/references/interfaces/ISYS_ExtensionExternalApiIndex.md +13 -0
- package/skill/references/interfaces/ISYS_ExtensionRegisteredExternalApis.md +13 -0
- package/skill/references/interfaces/ISYS_ExternalApiHelp.md +173 -0
- package/skill/references/interfaces/ISYS_ExternalApiRegistration.md +146 -0
- package/skill/references/interfaces/ISYS_FileSystemFileList.md +169 -169
- package/skill/references/interfaces/ISYS_HeaderMenuSub1MenuItem.md +205 -174
- package/skill/references/interfaces/ISYS_HeaderMenuSub2MenuItem.md +178 -147
- package/skill/references/interfaces/ISYS_HeaderMenuTopMenuItem.md +115 -115
- package/skill/references/interfaces/ISYS_HeaderMenus.md +408 -408
- package/skill/references/interfaces/ISYS_HelpAudienceEntry.md +92 -0
- package/skill/references/interfaces/ISYS_HelpClassSummary.md +205 -0
- package/skill/references/interfaces/ISYS_HelpData.md +92 -0
- package/skill/references/interfaces/ISYS_HelpMethodDetail.md +310 -0
- package/skill/references/interfaces/ISYS_JobHandle.md +65 -0
- package/skill/references/interfaces/ISYS_JobLogEntry.md +142 -0
- package/skill/references/interfaces/ISYS_JobStatus.md +176 -0
- package/skill/references/interfaces/ISYS_LogLine.md +115 -115
- package/skill/references/interfaces/ISYS_MathBBox.md +142 -142
- package/skill/references/interfaces/ISYS_MathPoint.md +88 -88
- package/skill/references/interfaces/ISYS_MathPolygonWithHoles.md +92 -92
- package/skill/references/interfaces/ISYS_MessageBusTask.md +115 -115
- package/skill/references/interfaces/ISYS_MultilingualLanguagesData.md +12 -12
- package/skill/references/interfaces/ISYS_RightClickMenuItem.md +174 -174
- package/skill/references/interfaces/ISYS_ShortcutKeyData.md +169 -169
- package/skill/references/interfaces/ISYS_ShortcutKeyDataWithCallFn.md +62 -62
- package/skill/references/interfaces/ISYS_ShortcutKeyDataWithUserDefinedShortcutKey.md +62 -62
- package/skill/references/interfaces/ISYS_WindowEventListenerRemovableObject.md +109 -109
- package/skill/references/interfaces/IconProps.md +88 -88
- package/skill/references/interfaces/ImageProps.md +115 -115
- package/skill/references/interfaces/InputEditConfig.md +182 -0
- package/skill/references/interfaces/InputProps.md +547 -520
- package/skill/references/interfaces/KeyboardConfig.md +61 -0
- package/skill/references/interfaces/ListChildren.md +223 -223
- package/skill/references/interfaces/ListProps.md +250 -223
- package/skill/references/interfaces/ModalProps.md +358 -358
- package/skill/references/interfaces/NumberEditConfig.md +234 -0
- package/skill/references/interfaces/RadioGroupProps.md +196 -196
- package/skill/references/interfaces/RadioItem.md +115 -115
- package/skill/references/interfaces/RichTableProps.md +1357 -0
- package/skill/references/interfaces/RowMetaConfig.md +142 -0
- package/skill/references/interfaces/ScrollerProps.md +169 -169
- package/skill/references/interfaces/SelectEditConfig.md +211 -0
- package/skill/references/interfaces/SelectListItem.md +142 -142
- package/skill/references/interfaces/SelectOption.md +142 -0
- package/skill/references/interfaces/SelectProps.md +169 -169
- package/skill/references/interfaces/SelectionConfig.md +358 -0
- package/skill/references/interfaces/SliderProps.md +142 -0
- package/skill/references/interfaces/SlotProps.md +88 -88
- package/skill/references/interfaces/SortState.md +88 -0
- package/skill/references/interfaces/SortingConfig.md +169 -0
- package/skill/references/interfaces/StyleProps.md +439 -385
- package/skill/references/interfaces/TextAreaProps.md +196 -196
- package/skill/references/interfaces/TextProps.md +169 -169
- package/skill/references/interfaces/TextareaEditConfig.md +182 -0
- package/skill/references/interfaces/ValidationRule.md +223 -0
- package/skill/references/interfaces/VirtualScrollConfig.md +115 -0
- package/skill/references/types/Align.md +9 -0
- package/skill/references/types/CellContentType.md +9 -0
- package/skill/references/types/ColumnDefOrGroup.md +12 -0
- package/skill/references/types/ColumnEditConfig.md +13 -0
- package/skill/references/types/ColumnType.md +9 -0
- package/skill/references/types/DataChangeType.md +9 -0
- package/skill/references/types/FilterMatchMode.md +9 -0
- package/skill/references/types/RichTableRow.md +12 -0
- package/skill/references/types/Serializable.md +10 -0
- package/skill/references/types/SerializablePrimitive.md +9 -0
- package/skill/references/types/SortOrder.md +9 -0
- package/skill/references/types/TPCB_LayerTypesOfInnerLayer.md +11 -11
- package/skill/references/types/TPCB_LayersInTheSelectable.md +42 -42
- package/skill/references/types/TPCB_LayersOfComponent.md +11 -11
- package/skill/references/types/TPCB_LayersOfCopper.md +15 -15
- package/skill/references/types/TPCB_LayersOfCustom.md +41 -41
- package/skill/references/types/TPCB_LayersOfDimension.md +16 -16
- package/skill/references/types/TPCB_LayersOfFill.md +28 -28
- package/skill/references/types/TPCB_LayersOfImage.md +22 -22
- package/skill/references/types/TPCB_LayersOfInner.md +41 -41
- package/skill/references/types/TPCB_LayersOfLine.md +25 -25
- package/skill/references/types/TPCB_LayersOfObject.md +12 -12
- package/skill/references/types/TPCB_LayersOfPad.md +11 -11
- package/skill/references/types/TPCB_LayersOfRegion.md +11 -11
- package/skill/references/types/TPCB_NumberOfCopperLayers.md +9 -9
- package/skill/references/types/TPCB_PolygonSourceArray.md +85 -83
- package/skill/references/types/TPCB_PrimitiveDimensionCoordinateSet.md +66 -66
- package/skill/references/types/TPCB_PrimitivePadHole.md +30 -30
- package/skill/references/types/TPCB_PrimitivePadShape.md +61 -61
- package/skill/references/types/TPCB_PrimitiveSpecialPadShape.md +19 -19
- package/skill/references/types/TSYS_ComparisonErrorCode.md +15 -0
- package/skill/references/types/TSYS_LanguageKeyValuePairs.md +13 -0
- package/skill/references/types/TSYS_MathPolygonGroup.md +15 -15
- package/skill/references/types/TSYS_MathPolygonInput.md +20 -20
- package/skill/references/types/TSYS_ShortcutKeys.md +96 -96
- package/skill/user-guide/using-extension.md +47 -47
- package/src/json-gen.test.js +430 -0
- package/skill/guide/ancillary-projects/pro-api-sdk.md +0 -1
- package/skill/references/interfaces/ISYS_PcbComparisonResponse.md +0 -115
- package/skill/references/types/ISYS_LanguageKeyValuePairs.md +0 -13
- package/skill/references/types/TSYS_PcbComparisonErrorCode.md +0 -10
|
@@ -1,1618 +1,1618 @@
|
|
|
1
|
-
# SYS\_MessageBus class
|
|
2
|
-
|
|
3
|
-
System / message bus class
|
|
4
|
-
|
|
5
|
-
## Signature
|
|
6
|
-
|
|
7
|
-
```typescript
|
|
8
|
-
class SYS_MessageBus
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
## Remarks
|
|
12
|
-
|
|
13
|
-
## Methods
|
|
14
|
-
|
|
15
|
-
<table><thead><tr><th>
|
|
16
|
-
|
|
17
|
-
Method
|
|
18
|
-
|
|
19
|
-
</th><th>
|
|
20
|
-
|
|
21
|
-
Modifiers
|
|
22
|
-
|
|
23
|
-
</th><th>
|
|
24
|
-
|
|
25
|
-
Description
|
|
26
|
-
|
|
27
|
-
</th></tr></thead>
|
|
28
|
-
<tbody><tr><td>
|
|
29
|
-
|
|
30
|
-
[createPrivateMessageBus()](./SYS_MessageBus.md)
|
|
31
|
-
|
|
32
|
-
</td><td>
|
|
33
|
-
|
|
34
|
-
</td><td>
|
|
35
|
-
|
|
36
|
-
Create Private message bus
|
|
37
|
-
|
|
38
|
-
</td></tr>
|
|
39
|
-
<tr><td>
|
|
40
|
-
|
|
41
|
-
[publish(topic, message)](./SYS_MessageBus.md)
|
|
42
|
-
|
|
43
|
-
</td><td>
|
|
44
|
-
|
|
45
|
-
</td><td>
|
|
46
|
-
|
|
47
|
-
Private message bus: publish a message
|
|
48
|
-
|
|
49
|
-
</td></tr>
|
|
50
|
-
<tr><td>
|
|
51
|
-
|
|
52
|
-
[publishPublic(topic, message)](./SYS_MessageBus.md)
|
|
53
|
-
|
|
54
|
-
</td><td>
|
|
55
|
-
|
|
56
|
-
</td><td>
|
|
57
|
-
|
|
58
|
-
Public message bus: publish a message
|
|
59
|
-
|
|
60
|
-
</td></tr>
|
|
61
|
-
<tr><td>
|
|
62
|
-
|
|
63
|
-
[pull(topic, callbackFn)](./SYS_MessageBus.md)
|
|
64
|
-
|
|
65
|
-
</td><td>
|
|
66
|
-
|
|
67
|
-
</td><td>
|
|
68
|
-
|
|
69
|
-
Private message bus: pull a message
|
|
70
|
-
|
|
71
|
-
</td></tr>
|
|
72
|
-
<tr><td>
|
|
73
|
-
|
|
74
|
-
[pullAsync(topic)](./SYS_MessageBus.md)
|
|
75
|
-
|
|
76
|
-
</td><td>
|
|
77
|
-
|
|
78
|
-
</td><td>
|
|
79
|
-
|
|
80
|
-
Private message bus: pull a message (Promise version)
|
|
81
|
-
|
|
82
|
-
</td></tr>
|
|
83
|
-
<tr><td>
|
|
84
|
-
|
|
85
|
-
[pullAsyncPublic(topic)](./SYS_MessageBus.md)
|
|
86
|
-
|
|
87
|
-
</td><td>
|
|
88
|
-
|
|
89
|
-
</td><td>
|
|
90
|
-
|
|
91
|
-
Public message bus: pull a message (Promise version)
|
|
92
|
-
|
|
93
|
-
</td></tr>
|
|
94
|
-
<tr><td>
|
|
95
|
-
|
|
96
|
-
[pullPublic(topic, callbackFn)](./SYS_MessageBus.md)
|
|
97
|
-
|
|
98
|
-
</td><td>
|
|
99
|
-
|
|
100
|
-
</td><td>
|
|
101
|
-
|
|
102
|
-
Public message bus: pull a message
|
|
103
|
-
|
|
104
|
-
</td></tr>
|
|
105
|
-
<tr><td>
|
|
106
|
-
|
|
107
|
-
[push(topic, message)](./SYS_MessageBus.md)
|
|
108
|
-
|
|
109
|
-
</td><td>
|
|
110
|
-
|
|
111
|
-
</td><td>
|
|
112
|
-
|
|
113
|
-
Private message bus: push a message
|
|
114
|
-
|
|
115
|
-
</td></tr>
|
|
116
|
-
<tr><td>
|
|
117
|
-
|
|
118
|
-
[pushPublic(topic, message)](./SYS_MessageBus.md)
|
|
119
|
-
|
|
120
|
-
</td><td>
|
|
121
|
-
|
|
122
|
-
</td><td>
|
|
123
|
-
|
|
124
|
-
Public message bus: push a message
|
|
125
|
-
|
|
126
|
-
</td></tr>
|
|
127
|
-
<tr><td>
|
|
128
|
-
|
|
129
|
-
[removePrivateMessageBus()](./SYS_MessageBus.md)
|
|
130
|
-
|
|
131
|
-
</td><td>
|
|
132
|
-
|
|
133
|
-
</td><td>
|
|
134
|
-
|
|
135
|
-
Remove Private message bus
|
|
136
|
-
|
|
137
|
-
</td></tr>
|
|
138
|
-
<tr><td>
|
|
139
|
-
|
|
140
|
-
[rpcCall(topic, message, timeout)](./SYS_MessageBus.md)
|
|
141
|
-
|
|
142
|
-
</td><td>
|
|
143
|
-
|
|
144
|
-
</td><td>
|
|
145
|
-
|
|
146
|
-
Private message bus: call RPC service
|
|
147
|
-
|
|
148
|
-
</td></tr>
|
|
149
|
-
<tr><td>
|
|
150
|
-
|
|
151
|
-
[rpcCallPublic(topic, message, timeout)](./SYS_MessageBus.md)
|
|
152
|
-
|
|
153
|
-
</td><td>
|
|
154
|
-
|
|
155
|
-
</td><td>
|
|
156
|
-
|
|
157
|
-
Public message bus: call RPC service
|
|
158
|
-
|
|
159
|
-
</td></tr>
|
|
160
|
-
<tr><td>
|
|
161
|
-
|
|
162
|
-
[rpcService(topic, callbackFn)](./SYS_MessageBus.md)
|
|
163
|
-
|
|
164
|
-
</td><td>
|
|
165
|
-
|
|
166
|
-
</td><td>
|
|
167
|
-
|
|
168
|
-
Private message bus: register RPC service
|
|
169
|
-
|
|
170
|
-
</td></tr>
|
|
171
|
-
<tr><td>
|
|
172
|
-
|
|
173
|
-
[rpcServicePublic(topic, callbackFn)](./SYS_MessageBus.md)
|
|
174
|
-
|
|
175
|
-
</td><td>
|
|
176
|
-
|
|
177
|
-
</td><td>
|
|
178
|
-
|
|
179
|
-
Public message bus: register RPC service
|
|
180
|
-
|
|
181
|
-
</td></tr>
|
|
182
|
-
<tr><td>
|
|
183
|
-
|
|
184
|
-
[subscribe(topic, callbackFn)](./SYS_MessageBus.md)
|
|
185
|
-
|
|
186
|
-
</td><td>
|
|
187
|
-
|
|
188
|
-
</td><td>
|
|
189
|
-
|
|
190
|
-
Private message bus: subscribe to a message
|
|
191
|
-
|
|
192
|
-
</td></tr>
|
|
193
|
-
<tr><td>
|
|
194
|
-
|
|
195
|
-
[subscribeOnce(topic, callbackFn)](./SYS_MessageBus.md)
|
|
196
|
-
|
|
197
|
-
</td><td>
|
|
198
|
-
|
|
199
|
-
</td><td>
|
|
200
|
-
|
|
201
|
-
Private message bus: subscribe to a message once
|
|
202
|
-
|
|
203
|
-
</td></tr>
|
|
204
|
-
<tr><td>
|
|
205
|
-
|
|
206
|
-
[subscribeOncePublic(topic, callbackFn)](./SYS_MessageBus.md)
|
|
207
|
-
|
|
208
|
-
</td><td>
|
|
209
|
-
|
|
210
|
-
</td><td>
|
|
211
|
-
|
|
212
|
-
Public message bus: subscribe to a message once
|
|
213
|
-
|
|
214
|
-
</td></tr>
|
|
215
|
-
<tr><td>
|
|
216
|
-
|
|
217
|
-
[subscribePublic(topic, callbackFn)](./SYS_MessageBus.md)
|
|
218
|
-
|
|
219
|
-
</td><td>
|
|
220
|
-
|
|
221
|
-
</td><td>
|
|
222
|
-
|
|
223
|
-
Public message bus: subscribe to a message
|
|
224
|
-
|
|
225
|
-
</td></tr>
|
|
226
|
-
</tbody></table>
|
|
227
|
-
|
|
228
|
-
---
|
|
229
|
-
|
|
230
|
-
## 方法详情
|
|
231
|
-
|
|
232
|
-
### createprivatemessagebus
|
|
233
|
-
|
|
234
|
-
# SYS\_MessageBus.createPrivateMessageBus() method
|
|
235
|
-
|
|
236
|
-
Create Private message bus
|
|
237
|
-
|
|
238
|
-
## Signature
|
|
239
|
-
|
|
240
|
-
```typescript
|
|
241
|
-
function createPrivateMessageBus(): void;
|
|
242
|
-
```
|
|
243
|
-
|
|
244
|
-
## Returns
|
|
245
|
-
|
|
246
|
-
void
|
|
247
|
-
|
|
248
|
-
## Remarks
|
|
249
|
-
|
|
250
|
-
Generally, there is no need to call this method. The private message bus is automatically created when listening or sending messages
|
|
251
|
-
|
|
252
|
-
## Example
|
|
253
|
-
|
|
254
|
-
```javascript
|
|
255
|
-
// 1. 手动创建私有消息总线(重复调用无副作用)
|
|
256
|
-
eda.sys_MessageBus.createPrivateMessageBus();
|
|
257
|
-
|
|
258
|
-
// 2. 订阅一个主题,验证总线已就绪
|
|
259
|
-
const task = eda.sys_MessageBus.subscribe('嘉立创示例_创建总线', (message) => {
|
|
260
|
-
console.log('订阅者收到:', message);
|
|
261
|
-
});
|
|
262
|
-
|
|
263
|
-
// 3. 发布消息,回调立即触发
|
|
264
|
-
eda.sys_MessageBus.publish('嘉立创示例_创建总线', '总线已创建并可用');
|
|
265
|
-
|
|
266
|
-
// 4. 取消订阅,恢复原状
|
|
267
|
-
task.cancel();
|
|
268
|
-
console.log('已取消订阅');
|
|
269
|
-
```
|
|
270
|
-
|
|
271
|
-
### publish
|
|
272
|
-
|
|
273
|
-
# SYS\_MessageBus.publish() method
|
|
274
|
-
|
|
275
|
-
Private message bus: publish a message
|
|
276
|
-
|
|
277
|
-
## Signature
|
|
278
|
-
|
|
279
|
-
```typescript
|
|
280
|
-
function publish(topic: string, message: any): void;
|
|
281
|
-
```
|
|
282
|
-
|
|
283
|
-
## Parameters
|
|
284
|
-
|
|
285
|
-
<table><thead><tr><th>
|
|
286
|
-
|
|
287
|
-
Parameter
|
|
288
|
-
|
|
289
|
-
</th><th>
|
|
290
|
-
|
|
291
|
-
Type
|
|
292
|
-
|
|
293
|
-
</th><th>
|
|
294
|
-
|
|
295
|
-
Description
|
|
296
|
-
|
|
297
|
-
</th></tr></thead>
|
|
298
|
-
<tbody><tr><td>
|
|
299
|
-
|
|
300
|
-
topic
|
|
301
|
-
|
|
302
|
-
</td><td>
|
|
303
|
-
|
|
304
|
-
string
|
|
305
|
-
|
|
306
|
-
</td><td>
|
|
307
|
-
|
|
308
|
-
Theme
|
|
309
|
-
|
|
310
|
-
</td></tr>
|
|
311
|
-
<tr><td>
|
|
312
|
-
|
|
313
|
-
message
|
|
314
|
-
|
|
315
|
-
</td><td>
|
|
316
|
-
|
|
317
|
-
any
|
|
318
|
-
|
|
319
|
-
</td><td>
|
|
320
|
-
|
|
321
|
-
Message
|
|
322
|
-
|
|
323
|
-
</td></tr>
|
|
324
|
-
</tbody></table>
|
|
325
|
-
|
|
326
|
-
## Returns
|
|
327
|
-
|
|
328
|
-
void
|
|
329
|
-
|
|
330
|
-
## Remarks
|
|
331
|
-
|
|
332
|
-
Broadcast the message to every Subscriber
|
|
333
|
-
|
|
334
|
-
## Example
|
|
335
|
-
|
|
336
|
-
```javascript
|
|
337
|
-
// 1. 两个不同模块订阅同一主题
|
|
338
|
-
const panelTask = eda.sys_MessageBus.subscribe('嘉立创示例_发布', (message) => {
|
|
339
|
-
console.log('面板模块收到:', message);
|
|
340
|
-
});
|
|
341
|
-
const cacheTask = eda.sys_MessageBus.subscribe('嘉立创示例_发布', (message) => {
|
|
342
|
-
console.log('缓存模块收到:', message);
|
|
343
|
-
});
|
|
344
|
-
|
|
345
|
-
// 2. 发布一条广播消息,两个订阅者都会收到
|
|
346
|
-
eda.sys_MessageBus.publish('嘉立创示例_发布', { source: '工程检查', result: '通过' });
|
|
347
|
-
|
|
348
|
-
// 3. 取消订阅,恢复原状
|
|
349
|
-
panelTask.cancel();
|
|
350
|
-
cacheTask.cancel();
|
|
351
|
-
console.log('已取消全部订阅');
|
|
352
|
-
```
|
|
353
|
-
|
|
354
|
-
### publishpublic
|
|
355
|
-
|
|
356
|
-
# SYS\_MessageBus.publishPublic() method
|
|
357
|
-
|
|
358
|
-
Public message bus: publish a message
|
|
359
|
-
|
|
360
|
-
## Signature
|
|
361
|
-
|
|
362
|
-
```typescript
|
|
363
|
-
function publishPublic(topic: string, message: any): void;
|
|
364
|
-
```
|
|
365
|
-
|
|
366
|
-
## Parameters
|
|
367
|
-
|
|
368
|
-
<table><thead><tr><th>
|
|
369
|
-
|
|
370
|
-
Parameter
|
|
371
|
-
|
|
372
|
-
</th><th>
|
|
373
|
-
|
|
374
|
-
Type
|
|
375
|
-
|
|
376
|
-
</th><th>
|
|
377
|
-
|
|
378
|
-
Description
|
|
379
|
-
|
|
380
|
-
</th></tr></thead>
|
|
381
|
-
<tbody><tr><td>
|
|
382
|
-
|
|
383
|
-
topic
|
|
384
|
-
|
|
385
|
-
</td><td>
|
|
386
|
-
|
|
387
|
-
string
|
|
388
|
-
|
|
389
|
-
</td><td>
|
|
390
|
-
|
|
391
|
-
Theme
|
|
392
|
-
|
|
393
|
-
</td></tr>
|
|
394
|
-
<tr><td>
|
|
395
|
-
|
|
396
|
-
message
|
|
397
|
-
|
|
398
|
-
</td><td>
|
|
399
|
-
|
|
400
|
-
any
|
|
401
|
-
|
|
402
|
-
</td><td>
|
|
403
|
-
|
|
404
|
-
Message
|
|
405
|
-
|
|
406
|
-
</td></tr>
|
|
407
|
-
</tbody></table>
|
|
408
|
-
|
|
409
|
-
## Returns
|
|
410
|
-
|
|
411
|
-
void
|
|
412
|
-
|
|
413
|
-
## Remarks
|
|
414
|
-
|
|
415
|
-
Broadcast the message to every Subscriber
|
|
416
|
-
|
|
417
|
-
## Example
|
|
418
|
-
|
|
419
|
-
```javascript
|
|
420
|
-
// 1. 两个公共订阅者 + 一个私有订阅者(用于对照隔离性)
|
|
421
|
-
const publicTaskA = eda.sys_MessageBus.subscribePublic('嘉立创示例_公共发布', (message) => {
|
|
422
|
-
console.log('公共订阅者 A 收到:', message);
|
|
423
|
-
});
|
|
424
|
-
const publicTaskB = eda.sys_MessageBus.subscribePublic('嘉立创示例_公共发布', (message) => {
|
|
425
|
-
console.log('公共订阅者 B 收到:', message);
|
|
426
|
-
});
|
|
427
|
-
const privateTask = eda.sys_MessageBus.subscribe('嘉立创示例_公共发布', (message) => {
|
|
428
|
-
console.log('私有订阅者收到:', message);
|
|
429
|
-
});
|
|
430
|
-
|
|
431
|
-
// 2. 在公共总线发布广播,只有公共订阅者会收到
|
|
432
|
-
eda.sys_MessageBus.publishPublic('嘉立创示例_公共发布', '工程已保存');
|
|
433
|
-
|
|
434
|
-
// 3. 取消订阅,恢复原状
|
|
435
|
-
publicTaskA.cancel();
|
|
436
|
-
publicTaskB.cancel();
|
|
437
|
-
privateTask.cancel();
|
|
438
|
-
console.log('已取消全部订阅');
|
|
439
|
-
```
|
|
440
|
-
|
|
441
|
-
### pull
|
|
442
|
-
|
|
443
|
-
# SYS\_MessageBus.pull() method
|
|
444
|
-
|
|
445
|
-
Private message bus: pull a message
|
|
446
|
-
|
|
447
|
-
## Signature
|
|
448
|
-
|
|
449
|
-
```typescript
|
|
450
|
-
function pull(topic: string, callbackFn: (message: any) => void): ISYS_MessageBusTask;
|
|
451
|
-
```
|
|
452
|
-
|
|
453
|
-
## Parameters
|
|
454
|
-
|
|
455
|
-
<table><thead><tr><th>
|
|
456
|
-
|
|
457
|
-
Parameter
|
|
458
|
-
|
|
459
|
-
</th><th>
|
|
460
|
-
|
|
461
|
-
Type
|
|
462
|
-
|
|
463
|
-
</th><th>
|
|
464
|
-
|
|
465
|
-
Description
|
|
466
|
-
|
|
467
|
-
</th></tr></thead>
|
|
468
|
-
<tbody><tr><td>
|
|
469
|
-
|
|
470
|
-
topic
|
|
471
|
-
|
|
472
|
-
</td><td>
|
|
473
|
-
|
|
474
|
-
string
|
|
475
|
-
|
|
476
|
-
</td><td>
|
|
477
|
-
|
|
478
|
-
Theme
|
|
479
|
-
|
|
480
|
-
</td></tr>
|
|
481
|
-
<tr><td>
|
|
482
|
-
|
|
483
|
-
callbackFn
|
|
484
|
-
|
|
485
|
-
</td><td>
|
|
486
|
-
|
|
487
|
-
(message: any) => void
|
|
488
|
-
|
|
489
|
-
</td><td>
|
|
490
|
-
|
|
491
|
-
Callback after a message is pulled
|
|
492
|
-
|
|
493
|
-
</td></tr>
|
|
494
|
-
</tbody></table>
|
|
495
|
-
|
|
496
|
-
## Returns
|
|
497
|
-
|
|
498
|
-
[ISYS\_MessageBusTask](../interfaces/ISYS_MessageBusTask.md)
|
|
499
|
-
|
|
500
|
-
Message bus task
|
|
501
|
-
|
|
502
|
-
## Remarks
|
|
503
|
-
|
|
504
|
-
Only one message can be pulled at a time
|
|
505
|
-
|
|
506
|
-
## Example
|
|
507
|
-
|
|
508
|
-
```javascript
|
|
509
|
-
// 1. 注册拉取回调(每次只能拉一个消息)
|
|
510
|
-
let count = 0;
|
|
511
|
-
const task = eda.sys_MessageBus.pull('嘉立创示例_拉取', (message) => {
|
|
512
|
-
count++;
|
|
513
|
-
console.log('第', count, '次拉到:', message);
|
|
514
|
-
});
|
|
515
|
-
|
|
516
|
-
// 2. 推送两条消息:只有第一条会被这个 Puller 收到
|
|
517
|
-
eda.sys_MessageBus.push('嘉立创示例_拉取', '任务甲');
|
|
518
|
-
eda.sys_MessageBus.push('嘉立创示例_拉取', '任务乙');
|
|
519
|
-
|
|
520
|
-
console.log('拉取次数:', count);
|
|
521
|
-
|
|
522
|
-
// 3. 取消任务(未消费完的排队消息一并放弃)
|
|
523
|
-
task.cancel();
|
|
524
|
-
console.log('已取消拉取任务');
|
|
525
|
-
```
|
|
526
|
-
|
|
527
|
-
### pullasync
|
|
528
|
-
|
|
529
|
-
# SYS\_MessageBus.pullAsync() method
|
|
530
|
-
|
|
531
|
-
Private message bus: pull a message (Promise version)
|
|
532
|
-
|
|
533
|
-
## Signature
|
|
534
|
-
|
|
535
|
-
```typescript
|
|
536
|
-
function pullAsync(topic: string): Promise<any>;
|
|
537
|
-
```
|
|
538
|
-
|
|
539
|
-
## Parameters
|
|
540
|
-
|
|
541
|
-
<table><thead><tr><th>
|
|
542
|
-
|
|
543
|
-
Parameter
|
|
544
|
-
|
|
545
|
-
</th><th>
|
|
546
|
-
|
|
547
|
-
Type
|
|
548
|
-
|
|
549
|
-
</th><th>
|
|
550
|
-
|
|
551
|
-
Description
|
|
552
|
-
|
|
553
|
-
</th></tr></thead>
|
|
554
|
-
<tbody><tr><td>
|
|
555
|
-
|
|
556
|
-
topic
|
|
557
|
-
|
|
558
|
-
</td><td>
|
|
559
|
-
|
|
560
|
-
string
|
|
561
|
-
|
|
562
|
-
</td><td>
|
|
563
|
-
|
|
564
|
-
Theme
|
|
565
|
-
|
|
566
|
-
</td></tr>
|
|
567
|
-
</tbody></table>
|
|
568
|
-
|
|
569
|
-
## Returns
|
|
570
|
-
|
|
571
|
-
Promise<any>
|
|
572
|
-
|
|
573
|
-
The pulled message
|
|
574
|
-
|
|
575
|
-
## Remarks
|
|
576
|
-
|
|
577
|
-
Only one message can be pulled at a time. You can use `await` to wait for the message to be pulled
|
|
578
|
-
|
|
579
|
-
## Example
|
|
580
|
-
|
|
581
|
-
```javascript
|
|
582
|
-
// 1. 先发起拉取(Promise 挂起等待消息)
|
|
583
|
-
const pending = eda.sys_MessageBus.pullAsync('嘉立创示例_异步拉取');
|
|
584
|
-
|
|
585
|
-
// 2. 推送消息,挂起的 Promise 随即满足
|
|
586
|
-
eda.sys_MessageBus.push('嘉立创示例_异步拉取', { task: '导出 BOM', done: true });
|
|
587
|
-
|
|
588
|
-
// 3. await 直接拿到拉到的消息
|
|
589
|
-
const message = await pending;
|
|
590
|
-
console.log('拉到的消息:', message);
|
|
591
|
-
```
|
|
592
|
-
|
|
593
|
-
### pullasyncpublic
|
|
594
|
-
|
|
595
|
-
# SYS\_MessageBus.pullAsyncPublic() method
|
|
596
|
-
|
|
597
|
-
Public message bus: pull a message (Promise version)
|
|
598
|
-
|
|
599
|
-
## Signature
|
|
600
|
-
|
|
601
|
-
```typescript
|
|
602
|
-
function pullAsyncPublic(topic: string): Promise<any>;
|
|
603
|
-
```
|
|
604
|
-
|
|
605
|
-
## Parameters
|
|
606
|
-
|
|
607
|
-
<table><thead><tr><th>
|
|
608
|
-
|
|
609
|
-
Parameter
|
|
610
|
-
|
|
611
|
-
</th><th>
|
|
612
|
-
|
|
613
|
-
Type
|
|
614
|
-
|
|
615
|
-
</th><th>
|
|
616
|
-
|
|
617
|
-
Description
|
|
618
|
-
|
|
619
|
-
</th></tr></thead>
|
|
620
|
-
<tbody><tr><td>
|
|
621
|
-
|
|
622
|
-
topic
|
|
623
|
-
|
|
624
|
-
</td><td>
|
|
625
|
-
|
|
626
|
-
string
|
|
627
|
-
|
|
628
|
-
</td><td>
|
|
629
|
-
|
|
630
|
-
Theme
|
|
631
|
-
|
|
632
|
-
</td></tr>
|
|
633
|
-
</tbody></table>
|
|
634
|
-
|
|
635
|
-
## Returns
|
|
636
|
-
|
|
637
|
-
Promise<any>
|
|
638
|
-
|
|
639
|
-
The pulled message
|
|
640
|
-
|
|
641
|
-
## Remarks
|
|
642
|
-
|
|
643
|
-
Only one message can be pulled at a time. You can use `await` to wait for the message to be pulled
|
|
644
|
-
|
|
645
|
-
## Example
|
|
646
|
-
|
|
647
|
-
```javascript
|
|
648
|
-
// 1. 在公共总线发起拉取(Promise 挂起等待消息)
|
|
649
|
-
const pending = eda.sys_MessageBus.pullAsyncPublic('嘉立创示例_公共异步拉取');
|
|
650
|
-
|
|
651
|
-
// 2. 用 pushPublic 投递消息(私有总线的 push 到不了这里)
|
|
652
|
-
eda.sys_MessageBus.pushPublic('嘉立创示例_公共异步拉取', '跨扩展结果已就绪');
|
|
653
|
-
|
|
654
|
-
// 3. await 直接拿到拉到的消息
|
|
655
|
-
const message = await pending;
|
|
656
|
-
console.log('拉到的公共消息:', message);
|
|
657
|
-
```
|
|
658
|
-
|
|
659
|
-
### pullpublic
|
|
660
|
-
|
|
661
|
-
# SYS\_MessageBus.pullPublic() method
|
|
662
|
-
|
|
663
|
-
Public message bus: pull a message
|
|
664
|
-
|
|
665
|
-
## Signature
|
|
666
|
-
|
|
667
|
-
```typescript
|
|
668
|
-
function pullPublic(topic: string, callbackFn: (message: any) => void): ISYS_MessageBusTask;
|
|
669
|
-
```
|
|
670
|
-
|
|
671
|
-
## Parameters
|
|
672
|
-
|
|
673
|
-
<table><thead><tr><th>
|
|
674
|
-
|
|
675
|
-
Parameter
|
|
676
|
-
|
|
677
|
-
</th><th>
|
|
678
|
-
|
|
679
|
-
Type
|
|
680
|
-
|
|
681
|
-
</th><th>
|
|
682
|
-
|
|
683
|
-
Description
|
|
684
|
-
|
|
685
|
-
</th></tr></thead>
|
|
686
|
-
<tbody><tr><td>
|
|
687
|
-
|
|
688
|
-
topic
|
|
689
|
-
|
|
690
|
-
</td><td>
|
|
691
|
-
|
|
692
|
-
string
|
|
693
|
-
|
|
694
|
-
</td><td>
|
|
695
|
-
|
|
696
|
-
Theme
|
|
697
|
-
|
|
698
|
-
</td></tr>
|
|
699
|
-
<tr><td>
|
|
700
|
-
|
|
701
|
-
callbackFn
|
|
702
|
-
|
|
703
|
-
</td><td>
|
|
704
|
-
|
|
705
|
-
(message: any) => void
|
|
706
|
-
|
|
707
|
-
</td><td>
|
|
708
|
-
|
|
709
|
-
Callback after a message is pulled
|
|
710
|
-
|
|
711
|
-
</td></tr>
|
|
712
|
-
</tbody></table>
|
|
713
|
-
|
|
714
|
-
## Returns
|
|
715
|
-
|
|
716
|
-
[ISYS\_MessageBusTask](../interfaces/ISYS_MessageBusTask.md)
|
|
717
|
-
|
|
718
|
-
Message bus task
|
|
719
|
-
|
|
720
|
-
## Remarks
|
|
721
|
-
|
|
722
|
-
Only one message can be pulled at a time
|
|
723
|
-
|
|
724
|
-
## Example
|
|
725
|
-
|
|
726
|
-
```javascript
|
|
727
|
-
// 1. 在公共总线注册拉取回调(一次性)
|
|
728
|
-
const task = eda.sys_MessageBus.pullPublic('嘉立创示例_公共拉取', (message) => {
|
|
729
|
-
console.log('公共总线拉到:', message);
|
|
730
|
-
});
|
|
731
|
-
|
|
732
|
-
// 2. 用 pushPublic 投递消息,回调立即触发
|
|
733
|
-
eda.sys_MessageBus.pushPublic('嘉立创示例_公共拉取', '公共任务甲');
|
|
734
|
-
|
|
735
|
-
// 3. 取消任务,恢复原状
|
|
736
|
-
task.cancel();
|
|
737
|
-
console.log('已取消公共拉取任务');
|
|
738
|
-
```
|
|
739
|
-
|
|
740
|
-
### push
|
|
741
|
-
|
|
742
|
-
# SYS\_MessageBus.push() method
|
|
743
|
-
|
|
744
|
-
Private message bus: push a message
|
|
745
|
-
|
|
746
|
-
## Signature
|
|
747
|
-
|
|
748
|
-
```typescript
|
|
749
|
-
function push(topic: string, message: any): void;
|
|
750
|
-
```
|
|
751
|
-
|
|
752
|
-
## Parameters
|
|
753
|
-
|
|
754
|
-
<table><thead><tr><th>
|
|
755
|
-
|
|
756
|
-
Parameter
|
|
757
|
-
|
|
758
|
-
</th><th>
|
|
759
|
-
|
|
760
|
-
Type
|
|
761
|
-
|
|
762
|
-
</th><th>
|
|
763
|
-
|
|
764
|
-
Description
|
|
765
|
-
|
|
766
|
-
</th></tr></thead>
|
|
767
|
-
<tbody><tr><td>
|
|
768
|
-
|
|
769
|
-
topic
|
|
770
|
-
|
|
771
|
-
</td><td>
|
|
772
|
-
|
|
773
|
-
string
|
|
774
|
-
|
|
775
|
-
</td><td>
|
|
776
|
-
|
|
777
|
-
Theme
|
|
778
|
-
|
|
779
|
-
</td></tr>
|
|
780
|
-
<tr><td>
|
|
781
|
-
|
|
782
|
-
message
|
|
783
|
-
|
|
784
|
-
</td><td>
|
|
785
|
-
|
|
786
|
-
any
|
|
787
|
-
|
|
788
|
-
</td><td>
|
|
789
|
-
|
|
790
|
-
Message
|
|
791
|
-
|
|
792
|
-
</td></tr>
|
|
793
|
-
</tbody></table>
|
|
794
|
-
|
|
795
|
-
## Returns
|
|
796
|
-
|
|
797
|
-
void
|
|
798
|
-
|
|
799
|
-
## Remarks
|
|
800
|
-
|
|
801
|
-
Each message can only be received by one Puller
|
|
802
|
-
|
|
803
|
-
## Example
|
|
804
|
-
|
|
805
|
-
```javascript
|
|
806
|
-
// 1. 先推送消息(此时还没有 Puller,消息排队保留)
|
|
807
|
-
eda.sys_MessageBus.push('嘉立创示例_推送', '先推后拉的消息');
|
|
808
|
-
|
|
809
|
-
// 2. 再注册拉取回调,排队的消息立即交付
|
|
810
|
-
const task = eda.sys_MessageBus.pull('嘉立创示例_推送', (message) => {
|
|
811
|
-
console.log('拉到排队消息:', message);
|
|
812
|
-
});
|
|
813
|
-
|
|
814
|
-
// 3. 常规顺序演示:先注册再推送
|
|
815
|
-
const task2 = eda.sys_MessageBus.pull('嘉立创示例_推送', (message) => {
|
|
816
|
-
console.log('拉到实时消息:', message);
|
|
817
|
-
});
|
|
818
|
-
eda.sys_MessageBus.push('嘉立创示例_推送', '先拉后推的消息');
|
|
819
|
-
|
|
820
|
-
// 4. 取消任务,恢复原状
|
|
821
|
-
task.cancel();
|
|
822
|
-
task2.cancel();
|
|
823
|
-
console.log('已取消拉取任务');
|
|
824
|
-
```
|
|
825
|
-
|
|
826
|
-
### pushpublic
|
|
827
|
-
|
|
828
|
-
# SYS\_MessageBus.pushPublic() method
|
|
829
|
-
|
|
830
|
-
Public message bus: push a message
|
|
831
|
-
|
|
832
|
-
## Signature
|
|
833
|
-
|
|
834
|
-
```typescript
|
|
835
|
-
function pushPublic(topic: string, message: any): void;
|
|
836
|
-
```
|
|
837
|
-
|
|
838
|
-
## Parameters
|
|
839
|
-
|
|
840
|
-
<table><thead><tr><th>
|
|
841
|
-
|
|
842
|
-
Parameter
|
|
843
|
-
|
|
844
|
-
</th><th>
|
|
845
|
-
|
|
846
|
-
Type
|
|
847
|
-
|
|
848
|
-
</th><th>
|
|
849
|
-
|
|
850
|
-
Description
|
|
851
|
-
|
|
852
|
-
</th></tr></thead>
|
|
853
|
-
<tbody><tr><td>
|
|
854
|
-
|
|
855
|
-
topic
|
|
856
|
-
|
|
857
|
-
</td><td>
|
|
858
|
-
|
|
859
|
-
string
|
|
860
|
-
|
|
861
|
-
</td><td>
|
|
862
|
-
|
|
863
|
-
Theme
|
|
864
|
-
|
|
865
|
-
</td></tr>
|
|
866
|
-
<tr><td>
|
|
867
|
-
|
|
868
|
-
message
|
|
869
|
-
|
|
870
|
-
</td><td>
|
|
871
|
-
|
|
872
|
-
any
|
|
873
|
-
|
|
874
|
-
</td><td>
|
|
875
|
-
|
|
876
|
-
Message
|
|
877
|
-
|
|
878
|
-
</td></tr>
|
|
879
|
-
</tbody></table>
|
|
880
|
-
|
|
881
|
-
## Returns
|
|
882
|
-
|
|
883
|
-
void
|
|
884
|
-
|
|
885
|
-
## Remarks
|
|
886
|
-
|
|
887
|
-
Each message can only be received by one Puller
|
|
888
|
-
|
|
889
|
-
## Example
|
|
890
|
-
|
|
891
|
-
```javascript
|
|
892
|
-
// 1. 在公共总线注册两个取件方(竞争关系)
|
|
893
|
-
let receivedByA = false;
|
|
894
|
-
const taskA = eda.sys_MessageBus.pullPublic('嘉立创示例_公共推送', () => {
|
|
895
|
-
receivedByA = true;
|
|
896
|
-
});
|
|
897
|
-
const taskB = eda.sys_MessageBus.pullPublic('嘉立创示例_公共推送', (message) => {
|
|
898
|
-
console.log('取件方 B 拉到:', message);
|
|
899
|
-
});
|
|
900
|
-
|
|
901
|
-
// 2. 推送一条消息:先注册的取件方 A 拿走,B 收不到
|
|
902
|
-
eda.sys_MessageBus.pushPublic('嘉立创示例_公共推送', '跨扩展任务');
|
|
903
|
-
|
|
904
|
-
console.log('取件方 A 是否收到:', receivedByA);
|
|
905
|
-
|
|
906
|
-
// 3. 取消任务,恢复原状
|
|
907
|
-
taskA.cancel();
|
|
908
|
-
taskB.cancel();
|
|
909
|
-
console.log('已取消公共拉取任务');
|
|
910
|
-
```
|
|
911
|
-
|
|
912
|
-
### removeprivatemessagebus
|
|
913
|
-
|
|
914
|
-
# SYS\_MessageBus.removePrivateMessageBus() method
|
|
915
|
-
|
|
916
|
-
Remove Private message bus
|
|
917
|
-
|
|
918
|
-
## Signature
|
|
919
|
-
|
|
920
|
-
```typescript
|
|
921
|
-
function removePrivateMessageBus(): void;
|
|
922
|
-
```
|
|
923
|
-
|
|
924
|
-
## Returns
|
|
925
|
-
|
|
926
|
-
void
|
|
927
|
-
|
|
928
|
-
## Remarks
|
|
929
|
-
|
|
930
|
-
Generally, there is no need to call this method unless you know what you are doing
|
|
931
|
-
|
|
932
|
-
## Example
|
|
933
|
-
|
|
934
|
-
```javascript
|
|
935
|
-
// 1. 订阅一个主题并验证能收到消息
|
|
936
|
-
let received = null;
|
|
937
|
-
eda.sys_MessageBus.subscribe('嘉立创示例_移除总线', (message) => {
|
|
938
|
-
received = message;
|
|
939
|
-
});
|
|
940
|
-
eda.sys_MessageBus.publish('嘉立创示例_移除总线', '移除前的消息');
|
|
941
|
-
console.log('移除前收到:', received);
|
|
942
|
-
|
|
943
|
-
// 2. 移除私有消息总线,原有订阅全部失效
|
|
944
|
-
eda.sys_MessageBus.removePrivateMessageBus();
|
|
945
|
-
eda.sys_MessageBus.publish('嘉立创示例_移除总线', '移除后的消息');
|
|
946
|
-
console.log('移除后订阅者是否还收到:', received);
|
|
947
|
-
|
|
948
|
-
// 3. 再次订阅,总线自动重建恢复正常
|
|
949
|
-
eda.sys_MessageBus.subscribe('嘉立创示例_移除总线', (message) => {
|
|
950
|
-
received = message;
|
|
951
|
-
});
|
|
952
|
-
eda.sys_MessageBus.publish('嘉立创示例_移除总线', '重建后的消息');
|
|
953
|
-
console.log('重建后收到:', received);
|
|
954
|
-
```
|
|
955
|
-
|
|
956
|
-
### rpccall
|
|
957
|
-
|
|
958
|
-
# SYS\_MessageBus.rpcCall() method
|
|
959
|
-
|
|
960
|
-
Private message bus: call RPC service
|
|
961
|
-
|
|
962
|
-
## Signature
|
|
963
|
-
|
|
964
|
-
```typescript
|
|
965
|
-
function rpcCall(topic: string, message?: any, timeout?: number): Promise<any>;
|
|
966
|
-
```
|
|
967
|
-
|
|
968
|
-
## Parameters
|
|
969
|
-
|
|
970
|
-
<table><thead><tr><th>
|
|
971
|
-
|
|
972
|
-
Parameter
|
|
973
|
-
|
|
974
|
-
</th><th>
|
|
975
|
-
|
|
976
|
-
Type
|
|
977
|
-
|
|
978
|
-
</th><th>
|
|
979
|
-
|
|
980
|
-
Description
|
|
981
|
-
|
|
982
|
-
</th></tr></thead>
|
|
983
|
-
<tbody><tr><td>
|
|
984
|
-
|
|
985
|
-
topic
|
|
986
|
-
|
|
987
|
-
</td><td>
|
|
988
|
-
|
|
989
|
-
string
|
|
990
|
-
|
|
991
|
-
</td><td>
|
|
992
|
-
|
|
993
|
-
Theme
|
|
994
|
-
|
|
995
|
-
</td></tr>
|
|
996
|
-
<tr><td>
|
|
997
|
-
|
|
998
|
-
message
|
|
999
|
-
|
|
1000
|
-
</td><td>
|
|
1001
|
-
|
|
1002
|
-
any
|
|
1003
|
-
|
|
1004
|
-
</td><td>
|
|
1005
|
-
|
|
1006
|
-
_(Optional)_ Message
|
|
1007
|
-
|
|
1008
|
-
</td></tr>
|
|
1009
|
-
<tr><td>
|
|
1010
|
-
|
|
1011
|
-
timeout
|
|
1012
|
-
|
|
1013
|
-
</td><td>
|
|
1014
|
-
|
|
1015
|
-
number
|
|
1016
|
-
|
|
1017
|
-
</td><td>
|
|
1018
|
-
|
|
1019
|
-
_(Optional)_ Timeout
|
|
1020
|
-
|
|
1021
|
-
</td></tr>
|
|
1022
|
-
</tbody></table>
|
|
1023
|
-
|
|
1024
|
-
## Returns
|
|
1025
|
-
|
|
1026
|
-
Promise<any>
|
|
1027
|
-
|
|
1028
|
-
RPC service return
|
|
1029
|
-
|
|
1030
|
-
## Example
|
|
1031
|
-
|
|
1032
|
-
```javascript
|
|
1033
|
-
// 1. 注册一个 DRC 检查服务(message 是单个参数,用对象打包请求字段)
|
|
1034
|
-
eda.sys_MessageBus.rpcService('嘉立创示例_RPC调用', (message) => {
|
|
1035
|
-
return `检查完成:${message.rule},发现 ${message.count} 处问题`;
|
|
1036
|
-
});
|
|
1037
|
-
|
|
1038
|
-
// 2. 发起 RPC 调用,await 直接拿到服务返回值
|
|
1039
|
-
const reply = await eda.sys_MessageBus.rpcCall('嘉立创示例_RPC调用', {
|
|
1040
|
-
rule: '间距约束',
|
|
1041
|
-
count: 2,
|
|
1042
|
-
});
|
|
1043
|
-
console.log('服务返回:', reply);
|
|
1044
|
-
```
|
|
1045
|
-
|
|
1046
|
-
### rpccallpublic
|
|
1047
|
-
|
|
1048
|
-
# SYS\_MessageBus.rpcCallPublic() method
|
|
1049
|
-
|
|
1050
|
-
Public message bus: call RPC service
|
|
1051
|
-
|
|
1052
|
-
## Signature
|
|
1053
|
-
|
|
1054
|
-
```typescript
|
|
1055
|
-
function rpcCallPublic(topic: string, message?: any, timeout?: number): Promise<any>;
|
|
1056
|
-
```
|
|
1057
|
-
|
|
1058
|
-
## Parameters
|
|
1059
|
-
|
|
1060
|
-
<table><thead><tr><th>
|
|
1061
|
-
|
|
1062
|
-
Parameter
|
|
1063
|
-
|
|
1064
|
-
</th><th>
|
|
1065
|
-
|
|
1066
|
-
Type
|
|
1067
|
-
|
|
1068
|
-
</th><th>
|
|
1069
|
-
|
|
1070
|
-
Description
|
|
1071
|
-
|
|
1072
|
-
</th></tr></thead>
|
|
1073
|
-
<tbody><tr><td>
|
|
1074
|
-
|
|
1075
|
-
topic
|
|
1076
|
-
|
|
1077
|
-
</td><td>
|
|
1078
|
-
|
|
1079
|
-
string
|
|
1080
|
-
|
|
1081
|
-
</td><td>
|
|
1082
|
-
|
|
1083
|
-
Theme
|
|
1084
|
-
|
|
1085
|
-
</td></tr>
|
|
1086
|
-
<tr><td>
|
|
1087
|
-
|
|
1088
|
-
message
|
|
1089
|
-
|
|
1090
|
-
</td><td>
|
|
1091
|
-
|
|
1092
|
-
any
|
|
1093
|
-
|
|
1094
|
-
</td><td>
|
|
1095
|
-
|
|
1096
|
-
_(Optional)_ Message
|
|
1097
|
-
|
|
1098
|
-
</td></tr>
|
|
1099
|
-
<tr><td>
|
|
1100
|
-
|
|
1101
|
-
timeout
|
|
1102
|
-
|
|
1103
|
-
</td><td>
|
|
1104
|
-
|
|
1105
|
-
number
|
|
1106
|
-
|
|
1107
|
-
</td><td>
|
|
1108
|
-
|
|
1109
|
-
_(Optional)_ Timeout
|
|
1110
|
-
|
|
1111
|
-
</td></tr>
|
|
1112
|
-
</tbody></table>
|
|
1113
|
-
|
|
1114
|
-
## Returns
|
|
1115
|
-
|
|
1116
|
-
Promise<any>
|
|
1117
|
-
|
|
1118
|
-
RPC service return
|
|
1119
|
-
|
|
1120
|
-
## Example
|
|
1121
|
-
|
|
1122
|
-
```javascript
|
|
1123
|
-
// 1. 在公共总线注册一个库查询服务
|
|
1124
|
-
eda.sys_MessageBus.rpcServicePublic('嘉立创示例_公共RPC调用', (message) => {
|
|
1125
|
-
return { name: message, stock: 1200 };
|
|
1126
|
-
});
|
|
1127
|
-
|
|
1128
|
-
// 2. 调用公共 RPC 服务,await 拿到返回值
|
|
1129
|
-
const reply = await eda.sys_MessageBus.rpcCallPublic('嘉立创示例_公共RPC调用', '0402 电阻');
|
|
1130
|
-
console.log('查询结果:', reply.name, '库存', reply.stock);
|
|
1131
|
-
```
|
|
1132
|
-
|
|
1133
|
-
### rpcservice
|
|
1134
|
-
|
|
1135
|
-
# SYS\_MessageBus.rpcService() method
|
|
1136
|
-
|
|
1137
|
-
Private message bus: register RPC service
|
|
1138
|
-
|
|
1139
|
-
## Signature
|
|
1140
|
-
|
|
1141
|
-
```typescript
|
|
1142
|
-
function rpcService(topic: string, callbackFn: (...args: Array<any>) => any | Promise<any>): void;
|
|
1143
|
-
```
|
|
1144
|
-
|
|
1145
|
-
## Parameters
|
|
1146
|
-
|
|
1147
|
-
<table><thead><tr><th>
|
|
1148
|
-
|
|
1149
|
-
Parameter
|
|
1150
|
-
|
|
1151
|
-
</th><th>
|
|
1152
|
-
|
|
1153
|
-
Type
|
|
1154
|
-
|
|
1155
|
-
</th><th>
|
|
1156
|
-
|
|
1157
|
-
Description
|
|
1158
|
-
|
|
1159
|
-
</th></tr></thead>
|
|
1160
|
-
<tbody><tr><td>
|
|
1161
|
-
|
|
1162
|
-
topic
|
|
1163
|
-
|
|
1164
|
-
</td><td>
|
|
1165
|
-
|
|
1166
|
-
string
|
|
1167
|
-
|
|
1168
|
-
</td><td>
|
|
1169
|
-
|
|
1170
|
-
Theme
|
|
1171
|
-
|
|
1172
|
-
</td></tr>
|
|
1173
|
-
<tr><td>
|
|
1174
|
-
|
|
1175
|
-
callbackFn
|
|
1176
|
-
|
|
1177
|
-
</td><td>
|
|
1178
|
-
|
|
1179
|
-
(...args: Array<any>) => any \| Promise<any>
|
|
1180
|
-
|
|
1181
|
-
</td><td>
|
|
1182
|
-
|
|
1183
|
-
Callback after receiving the message
|
|
1184
|
-
|
|
1185
|
-
</td></tr>
|
|
1186
|
-
</tbody></table>
|
|
1187
|
-
|
|
1188
|
-
## Returns
|
|
1189
|
-
|
|
1190
|
-
void
|
|
1191
|
-
|
|
1192
|
-
## Example
|
|
1193
|
-
|
|
1194
|
-
```javascript
|
|
1195
|
-
// 1. 注册同步服务:直接返回计算结果
|
|
1196
|
-
eda.sys_MessageBus.rpcService('嘉立创示例_RPC服务_同步', (message) => {
|
|
1197
|
-
return `同步响应:${message}`;
|
|
1198
|
-
});
|
|
1199
|
-
|
|
1200
|
-
// 2. 注册异步服务:返回 Promise,处理完才响应
|
|
1201
|
-
eda.sys_MessageBus.rpcService('嘉立创示例_RPC服务_异步', async (message) => {
|
|
1202
|
-
await new Promise(resolve => setTimeout(resolve, 200));
|
|
1203
|
-
return `异步响应:${message}`;
|
|
1204
|
-
});
|
|
1205
|
-
|
|
1206
|
-
// 3. 分别调用两种服务验证
|
|
1207
|
-
console.log(await eda.sys_MessageBus.rpcCall('嘉立创示例_RPC服务_同步', '参数甲'));
|
|
1208
|
-
console.log(await eda.sys_MessageBus.rpcCall('嘉立创示例_RPC服务_异步', '参数乙'));
|
|
1209
|
-
```
|
|
1210
|
-
|
|
1211
|
-
### rpcservicepublic
|
|
1212
|
-
|
|
1213
|
-
# SYS\_MessageBus.rpcServicePublic() method
|
|
1214
|
-
|
|
1215
|
-
Public message bus: register RPC service
|
|
1216
|
-
|
|
1217
|
-
## Signature
|
|
1218
|
-
|
|
1219
|
-
```typescript
|
|
1220
|
-
function rpcServicePublic(
|
|
1221
|
-
topic: string,
|
|
1222
|
-
callbackFn: (...args: Array<any>) => any | Promise<any>,
|
|
1223
|
-
): void;
|
|
1224
|
-
```
|
|
1225
|
-
|
|
1226
|
-
## Parameters
|
|
1227
|
-
|
|
1228
|
-
<table><thead><tr><th>
|
|
1229
|
-
|
|
1230
|
-
Parameter
|
|
1231
|
-
|
|
1232
|
-
</th><th>
|
|
1233
|
-
|
|
1234
|
-
Type
|
|
1235
|
-
|
|
1236
|
-
</th><th>
|
|
1237
|
-
|
|
1238
|
-
Description
|
|
1239
|
-
|
|
1240
|
-
</th></tr></thead>
|
|
1241
|
-
<tbody><tr><td>
|
|
1242
|
-
|
|
1243
|
-
topic
|
|
1244
|
-
|
|
1245
|
-
</td><td>
|
|
1246
|
-
|
|
1247
|
-
string
|
|
1248
|
-
|
|
1249
|
-
</td><td>
|
|
1250
|
-
|
|
1251
|
-
Theme
|
|
1252
|
-
|
|
1253
|
-
</td></tr>
|
|
1254
|
-
<tr><td>
|
|
1255
|
-
|
|
1256
|
-
callbackFn
|
|
1257
|
-
|
|
1258
|
-
</td><td>
|
|
1259
|
-
|
|
1260
|
-
(...args: Array<any>) => any \| Promise<any>
|
|
1261
|
-
|
|
1262
|
-
</td><td>
|
|
1263
|
-
|
|
1264
|
-
Callback after receiving the message
|
|
1265
|
-
|
|
1266
|
-
</td></tr>
|
|
1267
|
-
</tbody></table>
|
|
1268
|
-
|
|
1269
|
-
## Returns
|
|
1270
|
-
|
|
1271
|
-
void
|
|
1272
|
-
|
|
1273
|
-
## Example
|
|
1274
|
-
|
|
1275
|
-
```javascript
|
|
1276
|
-
// 1. 在公共总线注册一个工程信息服务
|
|
1277
|
-
eda.sys_MessageBus.rpcServicePublic('嘉立创示例_公共RPC服务', (message) => {
|
|
1278
|
-
return `当前工程《示例工程》的${message}已就绪`;
|
|
1279
|
-
});
|
|
1280
|
-
|
|
1281
|
-
// 2. 用 rpcCallPublic 调用自己注册的公共服务(跨扩展调用同理)
|
|
1282
|
-
const reply = await eda.sys_MessageBus.rpcCallPublic('嘉立创示例_公共RPC服务', '原理图数据');
|
|
1283
|
-
console.log('公共服务返回:', reply);
|
|
1284
|
-
```
|
|
1285
|
-
|
|
1286
|
-
### subscribe
|
|
1287
|
-
|
|
1288
|
-
# SYS\_MessageBus.subscribe() method
|
|
1289
|
-
|
|
1290
|
-
Private message bus: subscribe to a message
|
|
1291
|
-
|
|
1292
|
-
## Signature
|
|
1293
|
-
|
|
1294
|
-
```typescript
|
|
1295
|
-
function subscribe(topic: string, callbackFn: (message: any) => void): ISYS_MessageBusTask;
|
|
1296
|
-
```
|
|
1297
|
-
|
|
1298
|
-
## Parameters
|
|
1299
|
-
|
|
1300
|
-
<table><thead><tr><th>
|
|
1301
|
-
|
|
1302
|
-
Parameter
|
|
1303
|
-
|
|
1304
|
-
</th><th>
|
|
1305
|
-
|
|
1306
|
-
Type
|
|
1307
|
-
|
|
1308
|
-
</th><th>
|
|
1309
|
-
|
|
1310
|
-
Description
|
|
1311
|
-
|
|
1312
|
-
</th></tr></thead>
|
|
1313
|
-
<tbody><tr><td>
|
|
1314
|
-
|
|
1315
|
-
topic
|
|
1316
|
-
|
|
1317
|
-
</td><td>
|
|
1318
|
-
|
|
1319
|
-
string
|
|
1320
|
-
|
|
1321
|
-
</td><td>
|
|
1322
|
-
|
|
1323
|
-
Theme
|
|
1324
|
-
|
|
1325
|
-
</td></tr>
|
|
1326
|
-
<tr><td>
|
|
1327
|
-
|
|
1328
|
-
callbackFn
|
|
1329
|
-
|
|
1330
|
-
</td><td>
|
|
1331
|
-
|
|
1332
|
-
(message: any) => void
|
|
1333
|
-
|
|
1334
|
-
</td><td>
|
|
1335
|
-
|
|
1336
|
-
Callback after receiving the message
|
|
1337
|
-
|
|
1338
|
-
</td></tr>
|
|
1339
|
-
</tbody></table>
|
|
1340
|
-
|
|
1341
|
-
## Returns
|
|
1342
|
-
|
|
1343
|
-
[ISYS\_MessageBusTask](../interfaces/ISYS_MessageBusTask.md)
|
|
1344
|
-
|
|
1345
|
-
Message bus task
|
|
1346
|
-
|
|
1347
|
-
## Remarks
|
|
1348
|
-
|
|
1349
|
-
Persistent subscription message
|
|
1350
|
-
|
|
1351
|
-
## Example
|
|
1352
|
-
|
|
1353
|
-
```javascript
|
|
1354
|
-
// 1. 持久订阅主题
|
|
1355
|
-
const received = [];
|
|
1356
|
-
const task = eda.sys_MessageBus.subscribe('嘉立创示例_订阅', (message) => {
|
|
1357
|
-
received.push(message);
|
|
1358
|
-
});
|
|
1359
|
-
|
|
1360
|
-
// 2. 连续发布多条消息,每条都能收到
|
|
1361
|
-
eda.sys_MessageBus.publish('嘉立创示例_订阅', '第一条');
|
|
1362
|
-
eda.sys_MessageBus.publish('嘉立创示例_订阅', '第二条');
|
|
1363
|
-
console.log('已收到:', received.join('、'));
|
|
1364
|
-
|
|
1365
|
-
// 3. cancel 之后不再接收
|
|
1366
|
-
task.cancel();
|
|
1367
|
-
eda.sys_MessageBus.publish('嘉立创示例_订阅', '取消后的消息');
|
|
1368
|
-
console.log('cancel 后仍停留在:', received.join('、'));
|
|
1369
|
-
```
|
|
1370
|
-
|
|
1371
|
-
### subscribeonce
|
|
1372
|
-
|
|
1373
|
-
# SYS\_MessageBus.subscribeOnce() method
|
|
1374
|
-
|
|
1375
|
-
Private message bus: subscribe to a message once
|
|
1376
|
-
|
|
1377
|
-
## Signature
|
|
1378
|
-
|
|
1379
|
-
```typescript
|
|
1380
|
-
function subscribeOnce(topic: string, callbackFn: (message: any) => void): ISYS_MessageBusTask;
|
|
1381
|
-
```
|
|
1382
|
-
|
|
1383
|
-
## Parameters
|
|
1384
|
-
|
|
1385
|
-
<table><thead><tr><th>
|
|
1386
|
-
|
|
1387
|
-
Parameter
|
|
1388
|
-
|
|
1389
|
-
</th><th>
|
|
1390
|
-
|
|
1391
|
-
Type
|
|
1392
|
-
|
|
1393
|
-
</th><th>
|
|
1394
|
-
|
|
1395
|
-
Description
|
|
1396
|
-
|
|
1397
|
-
</th></tr></thead>
|
|
1398
|
-
<tbody><tr><td>
|
|
1399
|
-
|
|
1400
|
-
topic
|
|
1401
|
-
|
|
1402
|
-
</td><td>
|
|
1403
|
-
|
|
1404
|
-
string
|
|
1405
|
-
|
|
1406
|
-
</td><td>
|
|
1407
|
-
|
|
1408
|
-
Theme
|
|
1409
|
-
|
|
1410
|
-
</td></tr>
|
|
1411
|
-
<tr><td>
|
|
1412
|
-
|
|
1413
|
-
callbackFn
|
|
1414
|
-
|
|
1415
|
-
</td><td>
|
|
1416
|
-
|
|
1417
|
-
(message: any) => void
|
|
1418
|
-
|
|
1419
|
-
</td><td>
|
|
1420
|
-
|
|
1421
|
-
Callback after receiving the message
|
|
1422
|
-
|
|
1423
|
-
</td></tr>
|
|
1424
|
-
</tbody></table>
|
|
1425
|
-
|
|
1426
|
-
## Returns
|
|
1427
|
-
|
|
1428
|
-
[ISYS\_MessageBusTask](../interfaces/ISYS_MessageBusTask.md)
|
|
1429
|
-
|
|
1430
|
-
Message bus task
|
|
1431
|
-
|
|
1432
|
-
## Example
|
|
1433
|
-
|
|
1434
|
-
```javascript
|
|
1435
|
-
// 1. 注册单次订阅
|
|
1436
|
-
let received = null;
|
|
1437
|
-
const task = eda.sys_MessageBus.subscribeOnce('嘉立创示例_单次订阅', (message) => {
|
|
1438
|
-
received = message;
|
|
1439
|
-
});
|
|
1440
|
-
|
|
1441
|
-
// 2. 发布两条消息:只有第一条触发回调
|
|
1442
|
-
eda.sys_MessageBus.publish('嘉立创示例_单次订阅', '首次触发');
|
|
1443
|
-
eda.sys_MessageBus.publish('嘉立创示例_单次订阅', '第二次发布');
|
|
1444
|
-
console.log('实际收到:', received);
|
|
1445
|
-
|
|
1446
|
-
// 3. 消息未到时也可以主动 cancel 放弃等待
|
|
1447
|
-
task.cancel();
|
|
1448
|
-
console.log('已清理单次订阅任务');
|
|
1449
|
-
```
|
|
1450
|
-
|
|
1451
|
-
### subscribeoncepublic
|
|
1452
|
-
|
|
1453
|
-
# SYS\_MessageBus.subscribeOncePublic() method
|
|
1454
|
-
|
|
1455
|
-
Public message bus: subscribe to a message once
|
|
1456
|
-
|
|
1457
|
-
## Signature
|
|
1458
|
-
|
|
1459
|
-
```typescript
|
|
1460
|
-
function subscribeOncePublic(
|
|
1461
|
-
topic: string,
|
|
1462
|
-
callbackFn: (message: any) => void,
|
|
1463
|
-
): ISYS_MessageBusTask;
|
|
1464
|
-
```
|
|
1465
|
-
|
|
1466
|
-
## Parameters
|
|
1467
|
-
|
|
1468
|
-
<table><thead><tr><th>
|
|
1469
|
-
|
|
1470
|
-
Parameter
|
|
1471
|
-
|
|
1472
|
-
</th><th>
|
|
1473
|
-
|
|
1474
|
-
Type
|
|
1475
|
-
|
|
1476
|
-
</th><th>
|
|
1477
|
-
|
|
1478
|
-
Description
|
|
1479
|
-
|
|
1480
|
-
</th></tr></thead>
|
|
1481
|
-
<tbody><tr><td>
|
|
1482
|
-
|
|
1483
|
-
topic
|
|
1484
|
-
|
|
1485
|
-
</td><td>
|
|
1486
|
-
|
|
1487
|
-
string
|
|
1488
|
-
|
|
1489
|
-
</td><td>
|
|
1490
|
-
|
|
1491
|
-
Theme
|
|
1492
|
-
|
|
1493
|
-
</td></tr>
|
|
1494
|
-
<tr><td>
|
|
1495
|
-
|
|
1496
|
-
callbackFn
|
|
1497
|
-
|
|
1498
|
-
</td><td>
|
|
1499
|
-
|
|
1500
|
-
(message: any) => void
|
|
1501
|
-
|
|
1502
|
-
</td><td>
|
|
1503
|
-
|
|
1504
|
-
Callback after receiving the message
|
|
1505
|
-
|
|
1506
|
-
</td></tr>
|
|
1507
|
-
</tbody></table>
|
|
1508
|
-
|
|
1509
|
-
## Returns
|
|
1510
|
-
|
|
1511
|
-
[ISYS\_MessageBusTask](../interfaces/ISYS_MessageBusTask.md)
|
|
1512
|
-
|
|
1513
|
-
Message bus task
|
|
1514
|
-
|
|
1515
|
-
## Example
|
|
1516
|
-
|
|
1517
|
-
```javascript
|
|
1518
|
-
// 1. 在公共总线注册单次订阅
|
|
1519
|
-
let received = null;
|
|
1520
|
-
eda.sys_MessageBus.subscribeOncePublic('嘉立创示例_公共单次订阅', (message) => {
|
|
1521
|
-
received = message;
|
|
1522
|
-
});
|
|
1523
|
-
|
|
1524
|
-
// 2. 连续两条公共广播:只有第一条触发
|
|
1525
|
-
eda.sys_MessageBus.publishPublic('嘉立创示例_公共单次订阅', '首次广播');
|
|
1526
|
-
eda.sys_MessageBus.publishPublic('嘉立创示例_公共单次订阅', '第二次广播');
|
|
1527
|
-
console.log('实际收到:', received);
|
|
1528
|
-
|
|
1529
|
-
// 3. 私有总线的 publish 与公共订阅互不相通(隔离验证)
|
|
1530
|
-
eda.sys_MessageBus.publish('嘉立创示例_公共单次订阅', '私有消息');
|
|
1531
|
-
console.log('私有消息到达后仍停留在:', received);
|
|
1532
|
-
```
|
|
1533
|
-
|
|
1534
|
-
### subscribepublic
|
|
1535
|
-
|
|
1536
|
-
# SYS\_MessageBus.subscribePublic() method
|
|
1537
|
-
|
|
1538
|
-
Public message bus: subscribe to a message
|
|
1539
|
-
|
|
1540
|
-
## Signature
|
|
1541
|
-
|
|
1542
|
-
```typescript
|
|
1543
|
-
function subscribePublic(topic: string, callbackFn: (message: any) => void): ISYS_MessageBusTask;
|
|
1544
|
-
```
|
|
1545
|
-
|
|
1546
|
-
## Parameters
|
|
1547
|
-
|
|
1548
|
-
<table><thead><tr><th>
|
|
1549
|
-
|
|
1550
|
-
Parameter
|
|
1551
|
-
|
|
1552
|
-
</th><th>
|
|
1553
|
-
|
|
1554
|
-
Type
|
|
1555
|
-
|
|
1556
|
-
</th><th>
|
|
1557
|
-
|
|
1558
|
-
Description
|
|
1559
|
-
|
|
1560
|
-
</th></tr></thead>
|
|
1561
|
-
<tbody><tr><td>
|
|
1562
|
-
|
|
1563
|
-
topic
|
|
1564
|
-
|
|
1565
|
-
</td><td>
|
|
1566
|
-
|
|
1567
|
-
string
|
|
1568
|
-
|
|
1569
|
-
</td><td>
|
|
1570
|
-
|
|
1571
|
-
Theme
|
|
1572
|
-
|
|
1573
|
-
</td></tr>
|
|
1574
|
-
<tr><td>
|
|
1575
|
-
|
|
1576
|
-
callbackFn
|
|
1577
|
-
|
|
1578
|
-
</td><td>
|
|
1579
|
-
|
|
1580
|
-
(message: any) => void
|
|
1581
|
-
|
|
1582
|
-
</td><td>
|
|
1583
|
-
|
|
1584
|
-
Callback after receiving the message
|
|
1585
|
-
|
|
1586
|
-
</td></tr>
|
|
1587
|
-
</tbody></table>
|
|
1588
|
-
|
|
1589
|
-
## Returns
|
|
1590
|
-
|
|
1591
|
-
[ISYS\_MessageBusTask](../interfaces/ISYS_MessageBusTask.md)
|
|
1592
|
-
|
|
1593
|
-
Message bus task
|
|
1594
|
-
|
|
1595
|
-
## Remarks
|
|
1596
|
-
|
|
1597
|
-
Persistent subscription message
|
|
1598
|
-
|
|
1599
|
-
## Example
|
|
1600
|
-
|
|
1601
|
-
```javascript
|
|
1602
|
-
// 1. 在公共总线持久订阅主题
|
|
1603
|
-
const received = [];
|
|
1604
|
-
const task = eda.sys_MessageBus.subscribePublic('嘉立创示例_公共订阅', (message) => {
|
|
1605
|
-
received.push(message);
|
|
1606
|
-
});
|
|
1607
|
-
|
|
1608
|
-
// 2. 公共广播两条都能收到;私有 publish 不会到达
|
|
1609
|
-
eda.sys_MessageBus.publishPublic('嘉立创示例_公共订阅', '公共甲');
|
|
1610
|
-
eda.sys_MessageBus.publishPublic('嘉立创示例_公共订阅', '公共乙');
|
|
1611
|
-
eda.sys_MessageBus.publish('嘉立创示例_公共订阅', '私有丙');
|
|
1612
|
-
console.log('已收到:', received.join('、'));
|
|
1613
|
-
|
|
1614
|
-
// 3. cancel 之后不再接收
|
|
1615
|
-
task.cancel();
|
|
1616
|
-
eda.sys_MessageBus.publishPublic('嘉立创示例_公共订阅', '取消后广播');
|
|
1617
|
-
console.log('cancel 后仍停留在:', received.join('、'));
|
|
1618
|
-
```
|
|
1
|
+
# SYS\_MessageBus class
|
|
2
|
+
|
|
3
|
+
System / message bus class
|
|
4
|
+
|
|
5
|
+
## Signature
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
class SYS_MessageBus
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Remarks
|
|
12
|
+
|
|
13
|
+
## Methods
|
|
14
|
+
|
|
15
|
+
<table><thead><tr><th>
|
|
16
|
+
|
|
17
|
+
Method
|
|
18
|
+
|
|
19
|
+
</th><th>
|
|
20
|
+
|
|
21
|
+
Modifiers
|
|
22
|
+
|
|
23
|
+
</th><th>
|
|
24
|
+
|
|
25
|
+
Description
|
|
26
|
+
|
|
27
|
+
</th></tr></thead>
|
|
28
|
+
<tbody><tr><td>
|
|
29
|
+
|
|
30
|
+
[createPrivateMessageBus()](./SYS_MessageBus.md)
|
|
31
|
+
|
|
32
|
+
</td><td>
|
|
33
|
+
|
|
34
|
+
</td><td>
|
|
35
|
+
|
|
36
|
+
Create Private message bus
|
|
37
|
+
|
|
38
|
+
</td></tr>
|
|
39
|
+
<tr><td>
|
|
40
|
+
|
|
41
|
+
[publish(topic, message)](./SYS_MessageBus.md)
|
|
42
|
+
|
|
43
|
+
</td><td>
|
|
44
|
+
|
|
45
|
+
</td><td>
|
|
46
|
+
|
|
47
|
+
Private message bus: publish a message
|
|
48
|
+
|
|
49
|
+
</td></tr>
|
|
50
|
+
<tr><td>
|
|
51
|
+
|
|
52
|
+
[publishPublic(topic, message)](./SYS_MessageBus.md)
|
|
53
|
+
|
|
54
|
+
</td><td>
|
|
55
|
+
|
|
56
|
+
</td><td>
|
|
57
|
+
|
|
58
|
+
Public message bus: publish a message
|
|
59
|
+
|
|
60
|
+
</td></tr>
|
|
61
|
+
<tr><td>
|
|
62
|
+
|
|
63
|
+
[pull(topic, callbackFn)](./SYS_MessageBus.md)
|
|
64
|
+
|
|
65
|
+
</td><td>
|
|
66
|
+
|
|
67
|
+
</td><td>
|
|
68
|
+
|
|
69
|
+
Private message bus: pull a message
|
|
70
|
+
|
|
71
|
+
</td></tr>
|
|
72
|
+
<tr><td>
|
|
73
|
+
|
|
74
|
+
[pullAsync(topic)](./SYS_MessageBus.md)
|
|
75
|
+
|
|
76
|
+
</td><td>
|
|
77
|
+
|
|
78
|
+
</td><td>
|
|
79
|
+
|
|
80
|
+
Private message bus: pull a message (Promise version)
|
|
81
|
+
|
|
82
|
+
</td></tr>
|
|
83
|
+
<tr><td>
|
|
84
|
+
|
|
85
|
+
[pullAsyncPublic(topic)](./SYS_MessageBus.md)
|
|
86
|
+
|
|
87
|
+
</td><td>
|
|
88
|
+
|
|
89
|
+
</td><td>
|
|
90
|
+
|
|
91
|
+
Public message bus: pull a message (Promise version)
|
|
92
|
+
|
|
93
|
+
</td></tr>
|
|
94
|
+
<tr><td>
|
|
95
|
+
|
|
96
|
+
[pullPublic(topic, callbackFn)](./SYS_MessageBus.md)
|
|
97
|
+
|
|
98
|
+
</td><td>
|
|
99
|
+
|
|
100
|
+
</td><td>
|
|
101
|
+
|
|
102
|
+
Public message bus: pull a message
|
|
103
|
+
|
|
104
|
+
</td></tr>
|
|
105
|
+
<tr><td>
|
|
106
|
+
|
|
107
|
+
[push(topic, message)](./SYS_MessageBus.md)
|
|
108
|
+
|
|
109
|
+
</td><td>
|
|
110
|
+
|
|
111
|
+
</td><td>
|
|
112
|
+
|
|
113
|
+
Private message bus: push a message
|
|
114
|
+
|
|
115
|
+
</td></tr>
|
|
116
|
+
<tr><td>
|
|
117
|
+
|
|
118
|
+
[pushPublic(topic, message)](./SYS_MessageBus.md)
|
|
119
|
+
|
|
120
|
+
</td><td>
|
|
121
|
+
|
|
122
|
+
</td><td>
|
|
123
|
+
|
|
124
|
+
Public message bus: push a message
|
|
125
|
+
|
|
126
|
+
</td></tr>
|
|
127
|
+
<tr><td>
|
|
128
|
+
|
|
129
|
+
[removePrivateMessageBus()](./SYS_MessageBus.md)
|
|
130
|
+
|
|
131
|
+
</td><td>
|
|
132
|
+
|
|
133
|
+
</td><td>
|
|
134
|
+
|
|
135
|
+
Remove Private message bus
|
|
136
|
+
|
|
137
|
+
</td></tr>
|
|
138
|
+
<tr><td>
|
|
139
|
+
|
|
140
|
+
[rpcCall(topic, message, timeout)](./SYS_MessageBus.md)
|
|
141
|
+
|
|
142
|
+
</td><td>
|
|
143
|
+
|
|
144
|
+
</td><td>
|
|
145
|
+
|
|
146
|
+
Private message bus: call RPC service
|
|
147
|
+
|
|
148
|
+
</td></tr>
|
|
149
|
+
<tr><td>
|
|
150
|
+
|
|
151
|
+
[rpcCallPublic(topic, message, timeout)](./SYS_MessageBus.md)
|
|
152
|
+
|
|
153
|
+
</td><td>
|
|
154
|
+
|
|
155
|
+
</td><td>
|
|
156
|
+
|
|
157
|
+
Public message bus: call RPC service
|
|
158
|
+
|
|
159
|
+
</td></tr>
|
|
160
|
+
<tr><td>
|
|
161
|
+
|
|
162
|
+
[rpcService(topic, callbackFn)](./SYS_MessageBus.md)
|
|
163
|
+
|
|
164
|
+
</td><td>
|
|
165
|
+
|
|
166
|
+
</td><td>
|
|
167
|
+
|
|
168
|
+
Private message bus: register RPC service
|
|
169
|
+
|
|
170
|
+
</td></tr>
|
|
171
|
+
<tr><td>
|
|
172
|
+
|
|
173
|
+
[rpcServicePublic(topic, callbackFn)](./SYS_MessageBus.md)
|
|
174
|
+
|
|
175
|
+
</td><td>
|
|
176
|
+
|
|
177
|
+
</td><td>
|
|
178
|
+
|
|
179
|
+
Public message bus: register RPC service
|
|
180
|
+
|
|
181
|
+
</td></tr>
|
|
182
|
+
<tr><td>
|
|
183
|
+
|
|
184
|
+
[subscribe(topic, callbackFn)](./SYS_MessageBus.md)
|
|
185
|
+
|
|
186
|
+
</td><td>
|
|
187
|
+
|
|
188
|
+
</td><td>
|
|
189
|
+
|
|
190
|
+
Private message bus: subscribe to a message
|
|
191
|
+
|
|
192
|
+
</td></tr>
|
|
193
|
+
<tr><td>
|
|
194
|
+
|
|
195
|
+
[subscribeOnce(topic, callbackFn)](./SYS_MessageBus.md)
|
|
196
|
+
|
|
197
|
+
</td><td>
|
|
198
|
+
|
|
199
|
+
</td><td>
|
|
200
|
+
|
|
201
|
+
Private message bus: subscribe to a message once
|
|
202
|
+
|
|
203
|
+
</td></tr>
|
|
204
|
+
<tr><td>
|
|
205
|
+
|
|
206
|
+
[subscribeOncePublic(topic, callbackFn)](./SYS_MessageBus.md)
|
|
207
|
+
|
|
208
|
+
</td><td>
|
|
209
|
+
|
|
210
|
+
</td><td>
|
|
211
|
+
|
|
212
|
+
Public message bus: subscribe to a message once
|
|
213
|
+
|
|
214
|
+
</td></tr>
|
|
215
|
+
<tr><td>
|
|
216
|
+
|
|
217
|
+
[subscribePublic(topic, callbackFn)](./SYS_MessageBus.md)
|
|
218
|
+
|
|
219
|
+
</td><td>
|
|
220
|
+
|
|
221
|
+
</td><td>
|
|
222
|
+
|
|
223
|
+
Public message bus: subscribe to a message
|
|
224
|
+
|
|
225
|
+
</td></tr>
|
|
226
|
+
</tbody></table>
|
|
227
|
+
|
|
228
|
+
---
|
|
229
|
+
|
|
230
|
+
## 方法详情
|
|
231
|
+
|
|
232
|
+
### createprivatemessagebus
|
|
233
|
+
|
|
234
|
+
# SYS\_MessageBus.createPrivateMessageBus() method
|
|
235
|
+
|
|
236
|
+
Create Private message bus
|
|
237
|
+
|
|
238
|
+
## Signature
|
|
239
|
+
|
|
240
|
+
```typescript
|
|
241
|
+
function createPrivateMessageBus(): void;
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
## Returns
|
|
245
|
+
|
|
246
|
+
void
|
|
247
|
+
|
|
248
|
+
## Remarks
|
|
249
|
+
|
|
250
|
+
Generally, there is no need to call this method. The private message bus is automatically created when listening or sending messages
|
|
251
|
+
|
|
252
|
+
## Example
|
|
253
|
+
|
|
254
|
+
```javascript
|
|
255
|
+
// 1. 手动创建私有消息总线(重复调用无副作用)
|
|
256
|
+
eda.sys_MessageBus.createPrivateMessageBus();
|
|
257
|
+
|
|
258
|
+
// 2. 订阅一个主题,验证总线已就绪
|
|
259
|
+
const task = eda.sys_MessageBus.subscribe('嘉立创示例_创建总线', (message) => {
|
|
260
|
+
console.log('订阅者收到:', message);
|
|
261
|
+
});
|
|
262
|
+
|
|
263
|
+
// 3. 发布消息,回调立即触发
|
|
264
|
+
eda.sys_MessageBus.publish('嘉立创示例_创建总线', '总线已创建并可用');
|
|
265
|
+
|
|
266
|
+
// 4. 取消订阅,恢复原状
|
|
267
|
+
task.cancel();
|
|
268
|
+
console.log('已取消订阅');
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
### publish
|
|
272
|
+
|
|
273
|
+
# SYS\_MessageBus.publish() method
|
|
274
|
+
|
|
275
|
+
Private message bus: publish a message
|
|
276
|
+
|
|
277
|
+
## Signature
|
|
278
|
+
|
|
279
|
+
```typescript
|
|
280
|
+
function publish(topic: string, message: any): void;
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
## Parameters
|
|
284
|
+
|
|
285
|
+
<table><thead><tr><th>
|
|
286
|
+
|
|
287
|
+
Parameter
|
|
288
|
+
|
|
289
|
+
</th><th>
|
|
290
|
+
|
|
291
|
+
Type
|
|
292
|
+
|
|
293
|
+
</th><th>
|
|
294
|
+
|
|
295
|
+
Description
|
|
296
|
+
|
|
297
|
+
</th></tr></thead>
|
|
298
|
+
<tbody><tr><td>
|
|
299
|
+
|
|
300
|
+
topic
|
|
301
|
+
|
|
302
|
+
</td><td>
|
|
303
|
+
|
|
304
|
+
string
|
|
305
|
+
|
|
306
|
+
</td><td>
|
|
307
|
+
|
|
308
|
+
Theme
|
|
309
|
+
|
|
310
|
+
</td></tr>
|
|
311
|
+
<tr><td>
|
|
312
|
+
|
|
313
|
+
message
|
|
314
|
+
|
|
315
|
+
</td><td>
|
|
316
|
+
|
|
317
|
+
any
|
|
318
|
+
|
|
319
|
+
</td><td>
|
|
320
|
+
|
|
321
|
+
Message
|
|
322
|
+
|
|
323
|
+
</td></tr>
|
|
324
|
+
</tbody></table>
|
|
325
|
+
|
|
326
|
+
## Returns
|
|
327
|
+
|
|
328
|
+
void
|
|
329
|
+
|
|
330
|
+
## Remarks
|
|
331
|
+
|
|
332
|
+
Broadcast the message to every Subscriber
|
|
333
|
+
|
|
334
|
+
## Example
|
|
335
|
+
|
|
336
|
+
```javascript
|
|
337
|
+
// 1. 两个不同模块订阅同一主题
|
|
338
|
+
const panelTask = eda.sys_MessageBus.subscribe('嘉立创示例_发布', (message) => {
|
|
339
|
+
console.log('面板模块收到:', message);
|
|
340
|
+
});
|
|
341
|
+
const cacheTask = eda.sys_MessageBus.subscribe('嘉立创示例_发布', (message) => {
|
|
342
|
+
console.log('缓存模块收到:', message);
|
|
343
|
+
});
|
|
344
|
+
|
|
345
|
+
// 2. 发布一条广播消息,两个订阅者都会收到
|
|
346
|
+
eda.sys_MessageBus.publish('嘉立创示例_发布', { source: '工程检查', result: '通过' });
|
|
347
|
+
|
|
348
|
+
// 3. 取消订阅,恢复原状
|
|
349
|
+
panelTask.cancel();
|
|
350
|
+
cacheTask.cancel();
|
|
351
|
+
console.log('已取消全部订阅');
|
|
352
|
+
```
|
|
353
|
+
|
|
354
|
+
### publishpublic
|
|
355
|
+
|
|
356
|
+
# SYS\_MessageBus.publishPublic() method
|
|
357
|
+
|
|
358
|
+
Public message bus: publish a message
|
|
359
|
+
|
|
360
|
+
## Signature
|
|
361
|
+
|
|
362
|
+
```typescript
|
|
363
|
+
function publishPublic(topic: string, message: any): void;
|
|
364
|
+
```
|
|
365
|
+
|
|
366
|
+
## Parameters
|
|
367
|
+
|
|
368
|
+
<table><thead><tr><th>
|
|
369
|
+
|
|
370
|
+
Parameter
|
|
371
|
+
|
|
372
|
+
</th><th>
|
|
373
|
+
|
|
374
|
+
Type
|
|
375
|
+
|
|
376
|
+
</th><th>
|
|
377
|
+
|
|
378
|
+
Description
|
|
379
|
+
|
|
380
|
+
</th></tr></thead>
|
|
381
|
+
<tbody><tr><td>
|
|
382
|
+
|
|
383
|
+
topic
|
|
384
|
+
|
|
385
|
+
</td><td>
|
|
386
|
+
|
|
387
|
+
string
|
|
388
|
+
|
|
389
|
+
</td><td>
|
|
390
|
+
|
|
391
|
+
Theme
|
|
392
|
+
|
|
393
|
+
</td></tr>
|
|
394
|
+
<tr><td>
|
|
395
|
+
|
|
396
|
+
message
|
|
397
|
+
|
|
398
|
+
</td><td>
|
|
399
|
+
|
|
400
|
+
any
|
|
401
|
+
|
|
402
|
+
</td><td>
|
|
403
|
+
|
|
404
|
+
Message
|
|
405
|
+
|
|
406
|
+
</td></tr>
|
|
407
|
+
</tbody></table>
|
|
408
|
+
|
|
409
|
+
## Returns
|
|
410
|
+
|
|
411
|
+
void
|
|
412
|
+
|
|
413
|
+
## Remarks
|
|
414
|
+
|
|
415
|
+
Broadcast the message to every Subscriber
|
|
416
|
+
|
|
417
|
+
## Example
|
|
418
|
+
|
|
419
|
+
```javascript
|
|
420
|
+
// 1. 两个公共订阅者 + 一个私有订阅者(用于对照隔离性)
|
|
421
|
+
const publicTaskA = eda.sys_MessageBus.subscribePublic('嘉立创示例_公共发布', (message) => {
|
|
422
|
+
console.log('公共订阅者 A 收到:', message);
|
|
423
|
+
});
|
|
424
|
+
const publicTaskB = eda.sys_MessageBus.subscribePublic('嘉立创示例_公共发布', (message) => {
|
|
425
|
+
console.log('公共订阅者 B 收到:', message);
|
|
426
|
+
});
|
|
427
|
+
const privateTask = eda.sys_MessageBus.subscribe('嘉立创示例_公共发布', (message) => {
|
|
428
|
+
console.log('私有订阅者收到:', message);
|
|
429
|
+
});
|
|
430
|
+
|
|
431
|
+
// 2. 在公共总线发布广播,只有公共订阅者会收到
|
|
432
|
+
eda.sys_MessageBus.publishPublic('嘉立创示例_公共发布', '工程已保存');
|
|
433
|
+
|
|
434
|
+
// 3. 取消订阅,恢复原状
|
|
435
|
+
publicTaskA.cancel();
|
|
436
|
+
publicTaskB.cancel();
|
|
437
|
+
privateTask.cancel();
|
|
438
|
+
console.log('已取消全部订阅');
|
|
439
|
+
```
|
|
440
|
+
|
|
441
|
+
### pull
|
|
442
|
+
|
|
443
|
+
# SYS\_MessageBus.pull() method
|
|
444
|
+
|
|
445
|
+
Private message bus: pull a message
|
|
446
|
+
|
|
447
|
+
## Signature
|
|
448
|
+
|
|
449
|
+
```typescript
|
|
450
|
+
function pull(topic: string, callbackFn: (message: any) => void): ISYS_MessageBusTask;
|
|
451
|
+
```
|
|
452
|
+
|
|
453
|
+
## Parameters
|
|
454
|
+
|
|
455
|
+
<table><thead><tr><th>
|
|
456
|
+
|
|
457
|
+
Parameter
|
|
458
|
+
|
|
459
|
+
</th><th>
|
|
460
|
+
|
|
461
|
+
Type
|
|
462
|
+
|
|
463
|
+
</th><th>
|
|
464
|
+
|
|
465
|
+
Description
|
|
466
|
+
|
|
467
|
+
</th></tr></thead>
|
|
468
|
+
<tbody><tr><td>
|
|
469
|
+
|
|
470
|
+
topic
|
|
471
|
+
|
|
472
|
+
</td><td>
|
|
473
|
+
|
|
474
|
+
string
|
|
475
|
+
|
|
476
|
+
</td><td>
|
|
477
|
+
|
|
478
|
+
Theme
|
|
479
|
+
|
|
480
|
+
</td></tr>
|
|
481
|
+
<tr><td>
|
|
482
|
+
|
|
483
|
+
callbackFn
|
|
484
|
+
|
|
485
|
+
</td><td>
|
|
486
|
+
|
|
487
|
+
(message: any) => void
|
|
488
|
+
|
|
489
|
+
</td><td>
|
|
490
|
+
|
|
491
|
+
Callback after a message is pulled
|
|
492
|
+
|
|
493
|
+
</td></tr>
|
|
494
|
+
</tbody></table>
|
|
495
|
+
|
|
496
|
+
## Returns
|
|
497
|
+
|
|
498
|
+
[ISYS\_MessageBusTask](../interfaces/ISYS_MessageBusTask.md)
|
|
499
|
+
|
|
500
|
+
Message bus task
|
|
501
|
+
|
|
502
|
+
## Remarks
|
|
503
|
+
|
|
504
|
+
Only one message can be pulled at a time
|
|
505
|
+
|
|
506
|
+
## Example
|
|
507
|
+
|
|
508
|
+
```javascript
|
|
509
|
+
// 1. 注册拉取回调(每次只能拉一个消息)
|
|
510
|
+
let count = 0;
|
|
511
|
+
const task = eda.sys_MessageBus.pull('嘉立创示例_拉取', (message) => {
|
|
512
|
+
count++;
|
|
513
|
+
console.log('第', count, '次拉到:', message);
|
|
514
|
+
});
|
|
515
|
+
|
|
516
|
+
// 2. 推送两条消息:只有第一条会被这个 Puller 收到
|
|
517
|
+
eda.sys_MessageBus.push('嘉立创示例_拉取', '任务甲');
|
|
518
|
+
eda.sys_MessageBus.push('嘉立创示例_拉取', '任务乙');
|
|
519
|
+
|
|
520
|
+
console.log('拉取次数:', count);
|
|
521
|
+
|
|
522
|
+
// 3. 取消任务(未消费完的排队消息一并放弃)
|
|
523
|
+
task.cancel();
|
|
524
|
+
console.log('已取消拉取任务');
|
|
525
|
+
```
|
|
526
|
+
|
|
527
|
+
### pullasync
|
|
528
|
+
|
|
529
|
+
# SYS\_MessageBus.pullAsync() method
|
|
530
|
+
|
|
531
|
+
Private message bus: pull a message (Promise version)
|
|
532
|
+
|
|
533
|
+
## Signature
|
|
534
|
+
|
|
535
|
+
```typescript
|
|
536
|
+
function pullAsync(topic: string): Promise<any>;
|
|
537
|
+
```
|
|
538
|
+
|
|
539
|
+
## Parameters
|
|
540
|
+
|
|
541
|
+
<table><thead><tr><th>
|
|
542
|
+
|
|
543
|
+
Parameter
|
|
544
|
+
|
|
545
|
+
</th><th>
|
|
546
|
+
|
|
547
|
+
Type
|
|
548
|
+
|
|
549
|
+
</th><th>
|
|
550
|
+
|
|
551
|
+
Description
|
|
552
|
+
|
|
553
|
+
</th></tr></thead>
|
|
554
|
+
<tbody><tr><td>
|
|
555
|
+
|
|
556
|
+
topic
|
|
557
|
+
|
|
558
|
+
</td><td>
|
|
559
|
+
|
|
560
|
+
string
|
|
561
|
+
|
|
562
|
+
</td><td>
|
|
563
|
+
|
|
564
|
+
Theme
|
|
565
|
+
|
|
566
|
+
</td></tr>
|
|
567
|
+
</tbody></table>
|
|
568
|
+
|
|
569
|
+
## Returns
|
|
570
|
+
|
|
571
|
+
Promise<any>
|
|
572
|
+
|
|
573
|
+
The pulled message
|
|
574
|
+
|
|
575
|
+
## Remarks
|
|
576
|
+
|
|
577
|
+
Only one message can be pulled at a time. You can use `await` to wait for the message to be pulled
|
|
578
|
+
|
|
579
|
+
## Example
|
|
580
|
+
|
|
581
|
+
```javascript
|
|
582
|
+
// 1. 先发起拉取(Promise 挂起等待消息)
|
|
583
|
+
const pending = eda.sys_MessageBus.pullAsync('嘉立创示例_异步拉取');
|
|
584
|
+
|
|
585
|
+
// 2. 推送消息,挂起的 Promise 随即满足
|
|
586
|
+
eda.sys_MessageBus.push('嘉立创示例_异步拉取', { task: '导出 BOM', done: true });
|
|
587
|
+
|
|
588
|
+
// 3. await 直接拿到拉到的消息
|
|
589
|
+
const message = await pending;
|
|
590
|
+
console.log('拉到的消息:', message);
|
|
591
|
+
```
|
|
592
|
+
|
|
593
|
+
### pullasyncpublic
|
|
594
|
+
|
|
595
|
+
# SYS\_MessageBus.pullAsyncPublic() method
|
|
596
|
+
|
|
597
|
+
Public message bus: pull a message (Promise version)
|
|
598
|
+
|
|
599
|
+
## Signature
|
|
600
|
+
|
|
601
|
+
```typescript
|
|
602
|
+
function pullAsyncPublic(topic: string): Promise<any>;
|
|
603
|
+
```
|
|
604
|
+
|
|
605
|
+
## Parameters
|
|
606
|
+
|
|
607
|
+
<table><thead><tr><th>
|
|
608
|
+
|
|
609
|
+
Parameter
|
|
610
|
+
|
|
611
|
+
</th><th>
|
|
612
|
+
|
|
613
|
+
Type
|
|
614
|
+
|
|
615
|
+
</th><th>
|
|
616
|
+
|
|
617
|
+
Description
|
|
618
|
+
|
|
619
|
+
</th></tr></thead>
|
|
620
|
+
<tbody><tr><td>
|
|
621
|
+
|
|
622
|
+
topic
|
|
623
|
+
|
|
624
|
+
</td><td>
|
|
625
|
+
|
|
626
|
+
string
|
|
627
|
+
|
|
628
|
+
</td><td>
|
|
629
|
+
|
|
630
|
+
Theme
|
|
631
|
+
|
|
632
|
+
</td></tr>
|
|
633
|
+
</tbody></table>
|
|
634
|
+
|
|
635
|
+
## Returns
|
|
636
|
+
|
|
637
|
+
Promise<any>
|
|
638
|
+
|
|
639
|
+
The pulled message
|
|
640
|
+
|
|
641
|
+
## Remarks
|
|
642
|
+
|
|
643
|
+
Only one message can be pulled at a time. You can use `await` to wait for the message to be pulled
|
|
644
|
+
|
|
645
|
+
## Example
|
|
646
|
+
|
|
647
|
+
```javascript
|
|
648
|
+
// 1. 在公共总线发起拉取(Promise 挂起等待消息)
|
|
649
|
+
const pending = eda.sys_MessageBus.pullAsyncPublic('嘉立创示例_公共异步拉取');
|
|
650
|
+
|
|
651
|
+
// 2. 用 pushPublic 投递消息(私有总线的 push 到不了这里)
|
|
652
|
+
eda.sys_MessageBus.pushPublic('嘉立创示例_公共异步拉取', '跨扩展结果已就绪');
|
|
653
|
+
|
|
654
|
+
// 3. await 直接拿到拉到的消息
|
|
655
|
+
const message = await pending;
|
|
656
|
+
console.log('拉到的公共消息:', message);
|
|
657
|
+
```
|
|
658
|
+
|
|
659
|
+
### pullpublic
|
|
660
|
+
|
|
661
|
+
# SYS\_MessageBus.pullPublic() method
|
|
662
|
+
|
|
663
|
+
Public message bus: pull a message
|
|
664
|
+
|
|
665
|
+
## Signature
|
|
666
|
+
|
|
667
|
+
```typescript
|
|
668
|
+
function pullPublic(topic: string, callbackFn: (message: any) => void): ISYS_MessageBusTask;
|
|
669
|
+
```
|
|
670
|
+
|
|
671
|
+
## Parameters
|
|
672
|
+
|
|
673
|
+
<table><thead><tr><th>
|
|
674
|
+
|
|
675
|
+
Parameter
|
|
676
|
+
|
|
677
|
+
</th><th>
|
|
678
|
+
|
|
679
|
+
Type
|
|
680
|
+
|
|
681
|
+
</th><th>
|
|
682
|
+
|
|
683
|
+
Description
|
|
684
|
+
|
|
685
|
+
</th></tr></thead>
|
|
686
|
+
<tbody><tr><td>
|
|
687
|
+
|
|
688
|
+
topic
|
|
689
|
+
|
|
690
|
+
</td><td>
|
|
691
|
+
|
|
692
|
+
string
|
|
693
|
+
|
|
694
|
+
</td><td>
|
|
695
|
+
|
|
696
|
+
Theme
|
|
697
|
+
|
|
698
|
+
</td></tr>
|
|
699
|
+
<tr><td>
|
|
700
|
+
|
|
701
|
+
callbackFn
|
|
702
|
+
|
|
703
|
+
</td><td>
|
|
704
|
+
|
|
705
|
+
(message: any) => void
|
|
706
|
+
|
|
707
|
+
</td><td>
|
|
708
|
+
|
|
709
|
+
Callback after a message is pulled
|
|
710
|
+
|
|
711
|
+
</td></tr>
|
|
712
|
+
</tbody></table>
|
|
713
|
+
|
|
714
|
+
## Returns
|
|
715
|
+
|
|
716
|
+
[ISYS\_MessageBusTask](../interfaces/ISYS_MessageBusTask.md)
|
|
717
|
+
|
|
718
|
+
Message bus task
|
|
719
|
+
|
|
720
|
+
## Remarks
|
|
721
|
+
|
|
722
|
+
Only one message can be pulled at a time
|
|
723
|
+
|
|
724
|
+
## Example
|
|
725
|
+
|
|
726
|
+
```javascript
|
|
727
|
+
// 1. 在公共总线注册拉取回调(一次性)
|
|
728
|
+
const task = eda.sys_MessageBus.pullPublic('嘉立创示例_公共拉取', (message) => {
|
|
729
|
+
console.log('公共总线拉到:', message);
|
|
730
|
+
});
|
|
731
|
+
|
|
732
|
+
// 2. 用 pushPublic 投递消息,回调立即触发
|
|
733
|
+
eda.sys_MessageBus.pushPublic('嘉立创示例_公共拉取', '公共任务甲');
|
|
734
|
+
|
|
735
|
+
// 3. 取消任务,恢复原状
|
|
736
|
+
task.cancel();
|
|
737
|
+
console.log('已取消公共拉取任务');
|
|
738
|
+
```
|
|
739
|
+
|
|
740
|
+
### push
|
|
741
|
+
|
|
742
|
+
# SYS\_MessageBus.push() method
|
|
743
|
+
|
|
744
|
+
Private message bus: push a message
|
|
745
|
+
|
|
746
|
+
## Signature
|
|
747
|
+
|
|
748
|
+
```typescript
|
|
749
|
+
function push(topic: string, message: any): void;
|
|
750
|
+
```
|
|
751
|
+
|
|
752
|
+
## Parameters
|
|
753
|
+
|
|
754
|
+
<table><thead><tr><th>
|
|
755
|
+
|
|
756
|
+
Parameter
|
|
757
|
+
|
|
758
|
+
</th><th>
|
|
759
|
+
|
|
760
|
+
Type
|
|
761
|
+
|
|
762
|
+
</th><th>
|
|
763
|
+
|
|
764
|
+
Description
|
|
765
|
+
|
|
766
|
+
</th></tr></thead>
|
|
767
|
+
<tbody><tr><td>
|
|
768
|
+
|
|
769
|
+
topic
|
|
770
|
+
|
|
771
|
+
</td><td>
|
|
772
|
+
|
|
773
|
+
string
|
|
774
|
+
|
|
775
|
+
</td><td>
|
|
776
|
+
|
|
777
|
+
Theme
|
|
778
|
+
|
|
779
|
+
</td></tr>
|
|
780
|
+
<tr><td>
|
|
781
|
+
|
|
782
|
+
message
|
|
783
|
+
|
|
784
|
+
</td><td>
|
|
785
|
+
|
|
786
|
+
any
|
|
787
|
+
|
|
788
|
+
</td><td>
|
|
789
|
+
|
|
790
|
+
Message
|
|
791
|
+
|
|
792
|
+
</td></tr>
|
|
793
|
+
</tbody></table>
|
|
794
|
+
|
|
795
|
+
## Returns
|
|
796
|
+
|
|
797
|
+
void
|
|
798
|
+
|
|
799
|
+
## Remarks
|
|
800
|
+
|
|
801
|
+
Each message can only be received by one Puller
|
|
802
|
+
|
|
803
|
+
## Example
|
|
804
|
+
|
|
805
|
+
```javascript
|
|
806
|
+
// 1. 先推送消息(此时还没有 Puller,消息排队保留)
|
|
807
|
+
eda.sys_MessageBus.push('嘉立创示例_推送', '先推后拉的消息');
|
|
808
|
+
|
|
809
|
+
// 2. 再注册拉取回调,排队的消息立即交付
|
|
810
|
+
const task = eda.sys_MessageBus.pull('嘉立创示例_推送', (message) => {
|
|
811
|
+
console.log('拉到排队消息:', message);
|
|
812
|
+
});
|
|
813
|
+
|
|
814
|
+
// 3. 常规顺序演示:先注册再推送
|
|
815
|
+
const task2 = eda.sys_MessageBus.pull('嘉立创示例_推送', (message) => {
|
|
816
|
+
console.log('拉到实时消息:', message);
|
|
817
|
+
});
|
|
818
|
+
eda.sys_MessageBus.push('嘉立创示例_推送', '先拉后推的消息');
|
|
819
|
+
|
|
820
|
+
// 4. 取消任务,恢复原状
|
|
821
|
+
task.cancel();
|
|
822
|
+
task2.cancel();
|
|
823
|
+
console.log('已取消拉取任务');
|
|
824
|
+
```
|
|
825
|
+
|
|
826
|
+
### pushpublic
|
|
827
|
+
|
|
828
|
+
# SYS\_MessageBus.pushPublic() method
|
|
829
|
+
|
|
830
|
+
Public message bus: push a message
|
|
831
|
+
|
|
832
|
+
## Signature
|
|
833
|
+
|
|
834
|
+
```typescript
|
|
835
|
+
function pushPublic(topic: string, message: any): void;
|
|
836
|
+
```
|
|
837
|
+
|
|
838
|
+
## Parameters
|
|
839
|
+
|
|
840
|
+
<table><thead><tr><th>
|
|
841
|
+
|
|
842
|
+
Parameter
|
|
843
|
+
|
|
844
|
+
</th><th>
|
|
845
|
+
|
|
846
|
+
Type
|
|
847
|
+
|
|
848
|
+
</th><th>
|
|
849
|
+
|
|
850
|
+
Description
|
|
851
|
+
|
|
852
|
+
</th></tr></thead>
|
|
853
|
+
<tbody><tr><td>
|
|
854
|
+
|
|
855
|
+
topic
|
|
856
|
+
|
|
857
|
+
</td><td>
|
|
858
|
+
|
|
859
|
+
string
|
|
860
|
+
|
|
861
|
+
</td><td>
|
|
862
|
+
|
|
863
|
+
Theme
|
|
864
|
+
|
|
865
|
+
</td></tr>
|
|
866
|
+
<tr><td>
|
|
867
|
+
|
|
868
|
+
message
|
|
869
|
+
|
|
870
|
+
</td><td>
|
|
871
|
+
|
|
872
|
+
any
|
|
873
|
+
|
|
874
|
+
</td><td>
|
|
875
|
+
|
|
876
|
+
Message
|
|
877
|
+
|
|
878
|
+
</td></tr>
|
|
879
|
+
</tbody></table>
|
|
880
|
+
|
|
881
|
+
## Returns
|
|
882
|
+
|
|
883
|
+
void
|
|
884
|
+
|
|
885
|
+
## Remarks
|
|
886
|
+
|
|
887
|
+
Each message can only be received by one Puller
|
|
888
|
+
|
|
889
|
+
## Example
|
|
890
|
+
|
|
891
|
+
```javascript
|
|
892
|
+
// 1. 在公共总线注册两个取件方(竞争关系)
|
|
893
|
+
let receivedByA = false;
|
|
894
|
+
const taskA = eda.sys_MessageBus.pullPublic('嘉立创示例_公共推送', () => {
|
|
895
|
+
receivedByA = true;
|
|
896
|
+
});
|
|
897
|
+
const taskB = eda.sys_MessageBus.pullPublic('嘉立创示例_公共推送', (message) => {
|
|
898
|
+
console.log('取件方 B 拉到:', message);
|
|
899
|
+
});
|
|
900
|
+
|
|
901
|
+
// 2. 推送一条消息:先注册的取件方 A 拿走,B 收不到
|
|
902
|
+
eda.sys_MessageBus.pushPublic('嘉立创示例_公共推送', '跨扩展任务');
|
|
903
|
+
|
|
904
|
+
console.log('取件方 A 是否收到:', receivedByA);
|
|
905
|
+
|
|
906
|
+
// 3. 取消任务,恢复原状
|
|
907
|
+
taskA.cancel();
|
|
908
|
+
taskB.cancel();
|
|
909
|
+
console.log('已取消公共拉取任务');
|
|
910
|
+
```
|
|
911
|
+
|
|
912
|
+
### removeprivatemessagebus
|
|
913
|
+
|
|
914
|
+
# SYS\_MessageBus.removePrivateMessageBus() method
|
|
915
|
+
|
|
916
|
+
Remove Private message bus
|
|
917
|
+
|
|
918
|
+
## Signature
|
|
919
|
+
|
|
920
|
+
```typescript
|
|
921
|
+
function removePrivateMessageBus(): void;
|
|
922
|
+
```
|
|
923
|
+
|
|
924
|
+
## Returns
|
|
925
|
+
|
|
926
|
+
void
|
|
927
|
+
|
|
928
|
+
## Remarks
|
|
929
|
+
|
|
930
|
+
Generally, there is no need to call this method unless you know what you are doing
|
|
931
|
+
|
|
932
|
+
## Example
|
|
933
|
+
|
|
934
|
+
```javascript
|
|
935
|
+
// 1. 订阅一个主题并验证能收到消息
|
|
936
|
+
let received = null;
|
|
937
|
+
eda.sys_MessageBus.subscribe('嘉立创示例_移除总线', (message) => {
|
|
938
|
+
received = message;
|
|
939
|
+
});
|
|
940
|
+
eda.sys_MessageBus.publish('嘉立创示例_移除总线', '移除前的消息');
|
|
941
|
+
console.log('移除前收到:', received);
|
|
942
|
+
|
|
943
|
+
// 2. 移除私有消息总线,原有订阅全部失效
|
|
944
|
+
eda.sys_MessageBus.removePrivateMessageBus();
|
|
945
|
+
eda.sys_MessageBus.publish('嘉立创示例_移除总线', '移除后的消息');
|
|
946
|
+
console.log('移除后订阅者是否还收到:', received);
|
|
947
|
+
|
|
948
|
+
// 3. 再次订阅,总线自动重建恢复正常
|
|
949
|
+
eda.sys_MessageBus.subscribe('嘉立创示例_移除总线', (message) => {
|
|
950
|
+
received = message;
|
|
951
|
+
});
|
|
952
|
+
eda.sys_MessageBus.publish('嘉立创示例_移除总线', '重建后的消息');
|
|
953
|
+
console.log('重建后收到:', received);
|
|
954
|
+
```
|
|
955
|
+
|
|
956
|
+
### rpccall
|
|
957
|
+
|
|
958
|
+
# SYS\_MessageBus.rpcCall() method
|
|
959
|
+
|
|
960
|
+
Private message bus: call RPC service
|
|
961
|
+
|
|
962
|
+
## Signature
|
|
963
|
+
|
|
964
|
+
```typescript
|
|
965
|
+
function rpcCall(topic: string, message?: any, timeout?: number): Promise<any>;
|
|
966
|
+
```
|
|
967
|
+
|
|
968
|
+
## Parameters
|
|
969
|
+
|
|
970
|
+
<table><thead><tr><th>
|
|
971
|
+
|
|
972
|
+
Parameter
|
|
973
|
+
|
|
974
|
+
</th><th>
|
|
975
|
+
|
|
976
|
+
Type
|
|
977
|
+
|
|
978
|
+
</th><th>
|
|
979
|
+
|
|
980
|
+
Description
|
|
981
|
+
|
|
982
|
+
</th></tr></thead>
|
|
983
|
+
<tbody><tr><td>
|
|
984
|
+
|
|
985
|
+
topic
|
|
986
|
+
|
|
987
|
+
</td><td>
|
|
988
|
+
|
|
989
|
+
string
|
|
990
|
+
|
|
991
|
+
</td><td>
|
|
992
|
+
|
|
993
|
+
Theme
|
|
994
|
+
|
|
995
|
+
</td></tr>
|
|
996
|
+
<tr><td>
|
|
997
|
+
|
|
998
|
+
message
|
|
999
|
+
|
|
1000
|
+
</td><td>
|
|
1001
|
+
|
|
1002
|
+
any
|
|
1003
|
+
|
|
1004
|
+
</td><td>
|
|
1005
|
+
|
|
1006
|
+
_(Optional)_ Message
|
|
1007
|
+
|
|
1008
|
+
</td></tr>
|
|
1009
|
+
<tr><td>
|
|
1010
|
+
|
|
1011
|
+
timeout
|
|
1012
|
+
|
|
1013
|
+
</td><td>
|
|
1014
|
+
|
|
1015
|
+
number
|
|
1016
|
+
|
|
1017
|
+
</td><td>
|
|
1018
|
+
|
|
1019
|
+
_(Optional)_ Timeout
|
|
1020
|
+
|
|
1021
|
+
</td></tr>
|
|
1022
|
+
</tbody></table>
|
|
1023
|
+
|
|
1024
|
+
## Returns
|
|
1025
|
+
|
|
1026
|
+
Promise<any>
|
|
1027
|
+
|
|
1028
|
+
RPC service return
|
|
1029
|
+
|
|
1030
|
+
## Example
|
|
1031
|
+
|
|
1032
|
+
```javascript
|
|
1033
|
+
// 1. 注册一个 DRC 检查服务(message 是单个参数,用对象打包请求字段)
|
|
1034
|
+
eda.sys_MessageBus.rpcService('嘉立创示例_RPC调用', (message) => {
|
|
1035
|
+
return `检查完成:${message.rule},发现 ${message.count} 处问题`;
|
|
1036
|
+
});
|
|
1037
|
+
|
|
1038
|
+
// 2. 发起 RPC 调用,await 直接拿到服务返回值
|
|
1039
|
+
const reply = await eda.sys_MessageBus.rpcCall('嘉立创示例_RPC调用', {
|
|
1040
|
+
rule: '间距约束',
|
|
1041
|
+
count: 2,
|
|
1042
|
+
});
|
|
1043
|
+
console.log('服务返回:', reply);
|
|
1044
|
+
```
|
|
1045
|
+
|
|
1046
|
+
### rpccallpublic
|
|
1047
|
+
|
|
1048
|
+
# SYS\_MessageBus.rpcCallPublic() method
|
|
1049
|
+
|
|
1050
|
+
Public message bus: call RPC service
|
|
1051
|
+
|
|
1052
|
+
## Signature
|
|
1053
|
+
|
|
1054
|
+
```typescript
|
|
1055
|
+
function rpcCallPublic(topic: string, message?: any, timeout?: number): Promise<any>;
|
|
1056
|
+
```
|
|
1057
|
+
|
|
1058
|
+
## Parameters
|
|
1059
|
+
|
|
1060
|
+
<table><thead><tr><th>
|
|
1061
|
+
|
|
1062
|
+
Parameter
|
|
1063
|
+
|
|
1064
|
+
</th><th>
|
|
1065
|
+
|
|
1066
|
+
Type
|
|
1067
|
+
|
|
1068
|
+
</th><th>
|
|
1069
|
+
|
|
1070
|
+
Description
|
|
1071
|
+
|
|
1072
|
+
</th></tr></thead>
|
|
1073
|
+
<tbody><tr><td>
|
|
1074
|
+
|
|
1075
|
+
topic
|
|
1076
|
+
|
|
1077
|
+
</td><td>
|
|
1078
|
+
|
|
1079
|
+
string
|
|
1080
|
+
|
|
1081
|
+
</td><td>
|
|
1082
|
+
|
|
1083
|
+
Theme
|
|
1084
|
+
|
|
1085
|
+
</td></tr>
|
|
1086
|
+
<tr><td>
|
|
1087
|
+
|
|
1088
|
+
message
|
|
1089
|
+
|
|
1090
|
+
</td><td>
|
|
1091
|
+
|
|
1092
|
+
any
|
|
1093
|
+
|
|
1094
|
+
</td><td>
|
|
1095
|
+
|
|
1096
|
+
_(Optional)_ Message
|
|
1097
|
+
|
|
1098
|
+
</td></tr>
|
|
1099
|
+
<tr><td>
|
|
1100
|
+
|
|
1101
|
+
timeout
|
|
1102
|
+
|
|
1103
|
+
</td><td>
|
|
1104
|
+
|
|
1105
|
+
number
|
|
1106
|
+
|
|
1107
|
+
</td><td>
|
|
1108
|
+
|
|
1109
|
+
_(Optional)_ Timeout
|
|
1110
|
+
|
|
1111
|
+
</td></tr>
|
|
1112
|
+
</tbody></table>
|
|
1113
|
+
|
|
1114
|
+
## Returns
|
|
1115
|
+
|
|
1116
|
+
Promise<any>
|
|
1117
|
+
|
|
1118
|
+
RPC service return
|
|
1119
|
+
|
|
1120
|
+
## Example
|
|
1121
|
+
|
|
1122
|
+
```javascript
|
|
1123
|
+
// 1. 在公共总线注册一个库查询服务
|
|
1124
|
+
eda.sys_MessageBus.rpcServicePublic('嘉立创示例_公共RPC调用', (message) => {
|
|
1125
|
+
return { name: message, stock: 1200 };
|
|
1126
|
+
});
|
|
1127
|
+
|
|
1128
|
+
// 2. 调用公共 RPC 服务,await 拿到返回值
|
|
1129
|
+
const reply = await eda.sys_MessageBus.rpcCallPublic('嘉立创示例_公共RPC调用', '0402 电阻');
|
|
1130
|
+
console.log('查询结果:', reply.name, '库存', reply.stock);
|
|
1131
|
+
```
|
|
1132
|
+
|
|
1133
|
+
### rpcservice
|
|
1134
|
+
|
|
1135
|
+
# SYS\_MessageBus.rpcService() method
|
|
1136
|
+
|
|
1137
|
+
Private message bus: register RPC service
|
|
1138
|
+
|
|
1139
|
+
## Signature
|
|
1140
|
+
|
|
1141
|
+
```typescript
|
|
1142
|
+
function rpcService(topic: string, callbackFn: (...args: Array<any>) => any | Promise<any>): void;
|
|
1143
|
+
```
|
|
1144
|
+
|
|
1145
|
+
## Parameters
|
|
1146
|
+
|
|
1147
|
+
<table><thead><tr><th>
|
|
1148
|
+
|
|
1149
|
+
Parameter
|
|
1150
|
+
|
|
1151
|
+
</th><th>
|
|
1152
|
+
|
|
1153
|
+
Type
|
|
1154
|
+
|
|
1155
|
+
</th><th>
|
|
1156
|
+
|
|
1157
|
+
Description
|
|
1158
|
+
|
|
1159
|
+
</th></tr></thead>
|
|
1160
|
+
<tbody><tr><td>
|
|
1161
|
+
|
|
1162
|
+
topic
|
|
1163
|
+
|
|
1164
|
+
</td><td>
|
|
1165
|
+
|
|
1166
|
+
string
|
|
1167
|
+
|
|
1168
|
+
</td><td>
|
|
1169
|
+
|
|
1170
|
+
Theme
|
|
1171
|
+
|
|
1172
|
+
</td></tr>
|
|
1173
|
+
<tr><td>
|
|
1174
|
+
|
|
1175
|
+
callbackFn
|
|
1176
|
+
|
|
1177
|
+
</td><td>
|
|
1178
|
+
|
|
1179
|
+
(...args: Array<any>) => any \| Promise<any>
|
|
1180
|
+
|
|
1181
|
+
</td><td>
|
|
1182
|
+
|
|
1183
|
+
Callback after receiving the message
|
|
1184
|
+
|
|
1185
|
+
</td></tr>
|
|
1186
|
+
</tbody></table>
|
|
1187
|
+
|
|
1188
|
+
## Returns
|
|
1189
|
+
|
|
1190
|
+
void
|
|
1191
|
+
|
|
1192
|
+
## Example
|
|
1193
|
+
|
|
1194
|
+
```javascript
|
|
1195
|
+
// 1. 注册同步服务:直接返回计算结果
|
|
1196
|
+
eda.sys_MessageBus.rpcService('嘉立创示例_RPC服务_同步', (message) => {
|
|
1197
|
+
return `同步响应:${message}`;
|
|
1198
|
+
});
|
|
1199
|
+
|
|
1200
|
+
// 2. 注册异步服务:返回 Promise,处理完才响应
|
|
1201
|
+
eda.sys_MessageBus.rpcService('嘉立创示例_RPC服务_异步', async (message) => {
|
|
1202
|
+
await new Promise(resolve => setTimeout(resolve, 200));
|
|
1203
|
+
return `异步响应:${message}`;
|
|
1204
|
+
});
|
|
1205
|
+
|
|
1206
|
+
// 3. 分别调用两种服务验证
|
|
1207
|
+
console.log(await eda.sys_MessageBus.rpcCall('嘉立创示例_RPC服务_同步', '参数甲'));
|
|
1208
|
+
console.log(await eda.sys_MessageBus.rpcCall('嘉立创示例_RPC服务_异步', '参数乙'));
|
|
1209
|
+
```
|
|
1210
|
+
|
|
1211
|
+
### rpcservicepublic
|
|
1212
|
+
|
|
1213
|
+
# SYS\_MessageBus.rpcServicePublic() method
|
|
1214
|
+
|
|
1215
|
+
Public message bus: register RPC service
|
|
1216
|
+
|
|
1217
|
+
## Signature
|
|
1218
|
+
|
|
1219
|
+
```typescript
|
|
1220
|
+
function rpcServicePublic(
|
|
1221
|
+
topic: string,
|
|
1222
|
+
callbackFn: (...args: Array<any>) => any | Promise<any>,
|
|
1223
|
+
): void;
|
|
1224
|
+
```
|
|
1225
|
+
|
|
1226
|
+
## Parameters
|
|
1227
|
+
|
|
1228
|
+
<table><thead><tr><th>
|
|
1229
|
+
|
|
1230
|
+
Parameter
|
|
1231
|
+
|
|
1232
|
+
</th><th>
|
|
1233
|
+
|
|
1234
|
+
Type
|
|
1235
|
+
|
|
1236
|
+
</th><th>
|
|
1237
|
+
|
|
1238
|
+
Description
|
|
1239
|
+
|
|
1240
|
+
</th></tr></thead>
|
|
1241
|
+
<tbody><tr><td>
|
|
1242
|
+
|
|
1243
|
+
topic
|
|
1244
|
+
|
|
1245
|
+
</td><td>
|
|
1246
|
+
|
|
1247
|
+
string
|
|
1248
|
+
|
|
1249
|
+
</td><td>
|
|
1250
|
+
|
|
1251
|
+
Theme
|
|
1252
|
+
|
|
1253
|
+
</td></tr>
|
|
1254
|
+
<tr><td>
|
|
1255
|
+
|
|
1256
|
+
callbackFn
|
|
1257
|
+
|
|
1258
|
+
</td><td>
|
|
1259
|
+
|
|
1260
|
+
(...args: Array<any>) => any \| Promise<any>
|
|
1261
|
+
|
|
1262
|
+
</td><td>
|
|
1263
|
+
|
|
1264
|
+
Callback after receiving the message
|
|
1265
|
+
|
|
1266
|
+
</td></tr>
|
|
1267
|
+
</tbody></table>
|
|
1268
|
+
|
|
1269
|
+
## Returns
|
|
1270
|
+
|
|
1271
|
+
void
|
|
1272
|
+
|
|
1273
|
+
## Example
|
|
1274
|
+
|
|
1275
|
+
```javascript
|
|
1276
|
+
// 1. 在公共总线注册一个工程信息服务
|
|
1277
|
+
eda.sys_MessageBus.rpcServicePublic('嘉立创示例_公共RPC服务', (message) => {
|
|
1278
|
+
return `当前工程《示例工程》的${message}已就绪`;
|
|
1279
|
+
});
|
|
1280
|
+
|
|
1281
|
+
// 2. 用 rpcCallPublic 调用自己注册的公共服务(跨扩展调用同理)
|
|
1282
|
+
const reply = await eda.sys_MessageBus.rpcCallPublic('嘉立创示例_公共RPC服务', '原理图数据');
|
|
1283
|
+
console.log('公共服务返回:', reply);
|
|
1284
|
+
```
|
|
1285
|
+
|
|
1286
|
+
### subscribe
|
|
1287
|
+
|
|
1288
|
+
# SYS\_MessageBus.subscribe() method
|
|
1289
|
+
|
|
1290
|
+
Private message bus: subscribe to a message
|
|
1291
|
+
|
|
1292
|
+
## Signature
|
|
1293
|
+
|
|
1294
|
+
```typescript
|
|
1295
|
+
function subscribe(topic: string, callbackFn: (message: any) => void): ISYS_MessageBusTask;
|
|
1296
|
+
```
|
|
1297
|
+
|
|
1298
|
+
## Parameters
|
|
1299
|
+
|
|
1300
|
+
<table><thead><tr><th>
|
|
1301
|
+
|
|
1302
|
+
Parameter
|
|
1303
|
+
|
|
1304
|
+
</th><th>
|
|
1305
|
+
|
|
1306
|
+
Type
|
|
1307
|
+
|
|
1308
|
+
</th><th>
|
|
1309
|
+
|
|
1310
|
+
Description
|
|
1311
|
+
|
|
1312
|
+
</th></tr></thead>
|
|
1313
|
+
<tbody><tr><td>
|
|
1314
|
+
|
|
1315
|
+
topic
|
|
1316
|
+
|
|
1317
|
+
</td><td>
|
|
1318
|
+
|
|
1319
|
+
string
|
|
1320
|
+
|
|
1321
|
+
</td><td>
|
|
1322
|
+
|
|
1323
|
+
Theme
|
|
1324
|
+
|
|
1325
|
+
</td></tr>
|
|
1326
|
+
<tr><td>
|
|
1327
|
+
|
|
1328
|
+
callbackFn
|
|
1329
|
+
|
|
1330
|
+
</td><td>
|
|
1331
|
+
|
|
1332
|
+
(message: any) => void
|
|
1333
|
+
|
|
1334
|
+
</td><td>
|
|
1335
|
+
|
|
1336
|
+
Callback after receiving the message
|
|
1337
|
+
|
|
1338
|
+
</td></tr>
|
|
1339
|
+
</tbody></table>
|
|
1340
|
+
|
|
1341
|
+
## Returns
|
|
1342
|
+
|
|
1343
|
+
[ISYS\_MessageBusTask](../interfaces/ISYS_MessageBusTask.md)
|
|
1344
|
+
|
|
1345
|
+
Message bus task
|
|
1346
|
+
|
|
1347
|
+
## Remarks
|
|
1348
|
+
|
|
1349
|
+
Persistent subscription message
|
|
1350
|
+
|
|
1351
|
+
## Example
|
|
1352
|
+
|
|
1353
|
+
```javascript
|
|
1354
|
+
// 1. 持久订阅主题
|
|
1355
|
+
const received = [];
|
|
1356
|
+
const task = eda.sys_MessageBus.subscribe('嘉立创示例_订阅', (message) => {
|
|
1357
|
+
received.push(message);
|
|
1358
|
+
});
|
|
1359
|
+
|
|
1360
|
+
// 2. 连续发布多条消息,每条都能收到
|
|
1361
|
+
eda.sys_MessageBus.publish('嘉立创示例_订阅', '第一条');
|
|
1362
|
+
eda.sys_MessageBus.publish('嘉立创示例_订阅', '第二条');
|
|
1363
|
+
console.log('已收到:', received.join('、'));
|
|
1364
|
+
|
|
1365
|
+
// 3. cancel 之后不再接收
|
|
1366
|
+
task.cancel();
|
|
1367
|
+
eda.sys_MessageBus.publish('嘉立创示例_订阅', '取消后的消息');
|
|
1368
|
+
console.log('cancel 后仍停留在:', received.join('、'));
|
|
1369
|
+
```
|
|
1370
|
+
|
|
1371
|
+
### subscribeonce
|
|
1372
|
+
|
|
1373
|
+
# SYS\_MessageBus.subscribeOnce() method
|
|
1374
|
+
|
|
1375
|
+
Private message bus: subscribe to a message once
|
|
1376
|
+
|
|
1377
|
+
## Signature
|
|
1378
|
+
|
|
1379
|
+
```typescript
|
|
1380
|
+
function subscribeOnce(topic: string, callbackFn: (message: any) => void): ISYS_MessageBusTask;
|
|
1381
|
+
```
|
|
1382
|
+
|
|
1383
|
+
## Parameters
|
|
1384
|
+
|
|
1385
|
+
<table><thead><tr><th>
|
|
1386
|
+
|
|
1387
|
+
Parameter
|
|
1388
|
+
|
|
1389
|
+
</th><th>
|
|
1390
|
+
|
|
1391
|
+
Type
|
|
1392
|
+
|
|
1393
|
+
</th><th>
|
|
1394
|
+
|
|
1395
|
+
Description
|
|
1396
|
+
|
|
1397
|
+
</th></tr></thead>
|
|
1398
|
+
<tbody><tr><td>
|
|
1399
|
+
|
|
1400
|
+
topic
|
|
1401
|
+
|
|
1402
|
+
</td><td>
|
|
1403
|
+
|
|
1404
|
+
string
|
|
1405
|
+
|
|
1406
|
+
</td><td>
|
|
1407
|
+
|
|
1408
|
+
Theme
|
|
1409
|
+
|
|
1410
|
+
</td></tr>
|
|
1411
|
+
<tr><td>
|
|
1412
|
+
|
|
1413
|
+
callbackFn
|
|
1414
|
+
|
|
1415
|
+
</td><td>
|
|
1416
|
+
|
|
1417
|
+
(message: any) => void
|
|
1418
|
+
|
|
1419
|
+
</td><td>
|
|
1420
|
+
|
|
1421
|
+
Callback after receiving the message
|
|
1422
|
+
|
|
1423
|
+
</td></tr>
|
|
1424
|
+
</tbody></table>
|
|
1425
|
+
|
|
1426
|
+
## Returns
|
|
1427
|
+
|
|
1428
|
+
[ISYS\_MessageBusTask](../interfaces/ISYS_MessageBusTask.md)
|
|
1429
|
+
|
|
1430
|
+
Message bus task
|
|
1431
|
+
|
|
1432
|
+
## Example
|
|
1433
|
+
|
|
1434
|
+
```javascript
|
|
1435
|
+
// 1. 注册单次订阅
|
|
1436
|
+
let received = null;
|
|
1437
|
+
const task = eda.sys_MessageBus.subscribeOnce('嘉立创示例_单次订阅', (message) => {
|
|
1438
|
+
received = message;
|
|
1439
|
+
});
|
|
1440
|
+
|
|
1441
|
+
// 2. 发布两条消息:只有第一条触发回调
|
|
1442
|
+
eda.sys_MessageBus.publish('嘉立创示例_单次订阅', '首次触发');
|
|
1443
|
+
eda.sys_MessageBus.publish('嘉立创示例_单次订阅', '第二次发布');
|
|
1444
|
+
console.log('实际收到:', received);
|
|
1445
|
+
|
|
1446
|
+
// 3. 消息未到时也可以主动 cancel 放弃等待
|
|
1447
|
+
task.cancel();
|
|
1448
|
+
console.log('已清理单次订阅任务');
|
|
1449
|
+
```
|
|
1450
|
+
|
|
1451
|
+
### subscribeoncepublic
|
|
1452
|
+
|
|
1453
|
+
# SYS\_MessageBus.subscribeOncePublic() method
|
|
1454
|
+
|
|
1455
|
+
Public message bus: subscribe to a message once
|
|
1456
|
+
|
|
1457
|
+
## Signature
|
|
1458
|
+
|
|
1459
|
+
```typescript
|
|
1460
|
+
function subscribeOncePublic(
|
|
1461
|
+
topic: string,
|
|
1462
|
+
callbackFn: (message: any) => void,
|
|
1463
|
+
): ISYS_MessageBusTask;
|
|
1464
|
+
```
|
|
1465
|
+
|
|
1466
|
+
## Parameters
|
|
1467
|
+
|
|
1468
|
+
<table><thead><tr><th>
|
|
1469
|
+
|
|
1470
|
+
Parameter
|
|
1471
|
+
|
|
1472
|
+
</th><th>
|
|
1473
|
+
|
|
1474
|
+
Type
|
|
1475
|
+
|
|
1476
|
+
</th><th>
|
|
1477
|
+
|
|
1478
|
+
Description
|
|
1479
|
+
|
|
1480
|
+
</th></tr></thead>
|
|
1481
|
+
<tbody><tr><td>
|
|
1482
|
+
|
|
1483
|
+
topic
|
|
1484
|
+
|
|
1485
|
+
</td><td>
|
|
1486
|
+
|
|
1487
|
+
string
|
|
1488
|
+
|
|
1489
|
+
</td><td>
|
|
1490
|
+
|
|
1491
|
+
Theme
|
|
1492
|
+
|
|
1493
|
+
</td></tr>
|
|
1494
|
+
<tr><td>
|
|
1495
|
+
|
|
1496
|
+
callbackFn
|
|
1497
|
+
|
|
1498
|
+
</td><td>
|
|
1499
|
+
|
|
1500
|
+
(message: any) => void
|
|
1501
|
+
|
|
1502
|
+
</td><td>
|
|
1503
|
+
|
|
1504
|
+
Callback after receiving the message
|
|
1505
|
+
|
|
1506
|
+
</td></tr>
|
|
1507
|
+
</tbody></table>
|
|
1508
|
+
|
|
1509
|
+
## Returns
|
|
1510
|
+
|
|
1511
|
+
[ISYS\_MessageBusTask](../interfaces/ISYS_MessageBusTask.md)
|
|
1512
|
+
|
|
1513
|
+
Message bus task
|
|
1514
|
+
|
|
1515
|
+
## Example
|
|
1516
|
+
|
|
1517
|
+
```javascript
|
|
1518
|
+
// 1. 在公共总线注册单次订阅
|
|
1519
|
+
let received = null;
|
|
1520
|
+
eda.sys_MessageBus.subscribeOncePublic('嘉立创示例_公共单次订阅', (message) => {
|
|
1521
|
+
received = message;
|
|
1522
|
+
});
|
|
1523
|
+
|
|
1524
|
+
// 2. 连续两条公共广播:只有第一条触发
|
|
1525
|
+
eda.sys_MessageBus.publishPublic('嘉立创示例_公共单次订阅', '首次广播');
|
|
1526
|
+
eda.sys_MessageBus.publishPublic('嘉立创示例_公共单次订阅', '第二次广播');
|
|
1527
|
+
console.log('实际收到:', received);
|
|
1528
|
+
|
|
1529
|
+
// 3. 私有总线的 publish 与公共订阅互不相通(隔离验证)
|
|
1530
|
+
eda.sys_MessageBus.publish('嘉立创示例_公共单次订阅', '私有消息');
|
|
1531
|
+
console.log('私有消息到达后仍停留在:', received);
|
|
1532
|
+
```
|
|
1533
|
+
|
|
1534
|
+
### subscribepublic
|
|
1535
|
+
|
|
1536
|
+
# SYS\_MessageBus.subscribePublic() method
|
|
1537
|
+
|
|
1538
|
+
Public message bus: subscribe to a message
|
|
1539
|
+
|
|
1540
|
+
## Signature
|
|
1541
|
+
|
|
1542
|
+
```typescript
|
|
1543
|
+
function subscribePublic(topic: string, callbackFn: (message: any) => void): ISYS_MessageBusTask;
|
|
1544
|
+
```
|
|
1545
|
+
|
|
1546
|
+
## Parameters
|
|
1547
|
+
|
|
1548
|
+
<table><thead><tr><th>
|
|
1549
|
+
|
|
1550
|
+
Parameter
|
|
1551
|
+
|
|
1552
|
+
</th><th>
|
|
1553
|
+
|
|
1554
|
+
Type
|
|
1555
|
+
|
|
1556
|
+
</th><th>
|
|
1557
|
+
|
|
1558
|
+
Description
|
|
1559
|
+
|
|
1560
|
+
</th></tr></thead>
|
|
1561
|
+
<tbody><tr><td>
|
|
1562
|
+
|
|
1563
|
+
topic
|
|
1564
|
+
|
|
1565
|
+
</td><td>
|
|
1566
|
+
|
|
1567
|
+
string
|
|
1568
|
+
|
|
1569
|
+
</td><td>
|
|
1570
|
+
|
|
1571
|
+
Theme
|
|
1572
|
+
|
|
1573
|
+
</td></tr>
|
|
1574
|
+
<tr><td>
|
|
1575
|
+
|
|
1576
|
+
callbackFn
|
|
1577
|
+
|
|
1578
|
+
</td><td>
|
|
1579
|
+
|
|
1580
|
+
(message: any) => void
|
|
1581
|
+
|
|
1582
|
+
</td><td>
|
|
1583
|
+
|
|
1584
|
+
Callback after receiving the message
|
|
1585
|
+
|
|
1586
|
+
</td></tr>
|
|
1587
|
+
</tbody></table>
|
|
1588
|
+
|
|
1589
|
+
## Returns
|
|
1590
|
+
|
|
1591
|
+
[ISYS\_MessageBusTask](../interfaces/ISYS_MessageBusTask.md)
|
|
1592
|
+
|
|
1593
|
+
Message bus task
|
|
1594
|
+
|
|
1595
|
+
## Remarks
|
|
1596
|
+
|
|
1597
|
+
Persistent subscription message
|
|
1598
|
+
|
|
1599
|
+
## Example
|
|
1600
|
+
|
|
1601
|
+
```javascript
|
|
1602
|
+
// 1. 在公共总线持久订阅主题
|
|
1603
|
+
const received = [];
|
|
1604
|
+
const task = eda.sys_MessageBus.subscribePublic('嘉立创示例_公共订阅', (message) => {
|
|
1605
|
+
received.push(message);
|
|
1606
|
+
});
|
|
1607
|
+
|
|
1608
|
+
// 2. 公共广播两条都能收到;私有 publish 不会到达
|
|
1609
|
+
eda.sys_MessageBus.publishPublic('嘉立创示例_公共订阅', '公共甲');
|
|
1610
|
+
eda.sys_MessageBus.publishPublic('嘉立创示例_公共订阅', '公共乙');
|
|
1611
|
+
eda.sys_MessageBus.publish('嘉立创示例_公共订阅', '私有丙');
|
|
1612
|
+
console.log('已收到:', received.join('、'));
|
|
1613
|
+
|
|
1614
|
+
// 3. cancel 之后不再接收
|
|
1615
|
+
task.cancel();
|
|
1616
|
+
eda.sys_MessageBus.publishPublic('嘉立创示例_公共订阅', '取消后广播');
|
|
1617
|
+
console.log('cancel 后仍停留在:', received.join('、'));
|
|
1618
|
+
```
|