メインコンテンツ

smartConnect

R2026b

ポート名またはカスタム ポリシーを使用してモデル内の選択したコンポーネントを自動接続する

R2025a 以降

    説明

    [connectors,diag] = smartConnect(arch) は、ポート名を使用してアーキテクチャ モデル内の選択したコンポーネントを自動接続します。

    例

    [connectors,diag] = smartConnect(arch,Policy=policy) は、カスタム ポリシーを使用してアーキテクチャ モデル内の選択したコンポーネントを自動接続します。

    例

    すべて折りたたむ

    この例では、smartConnect 関数を使用して、既定のポート名の一致によって mSmartConnect.slx アーキテクチャ モデル内のコンポーネントを接続する方法を示します。

    model = systemcomposer.loadModel("mSmartConnect");
    conns = smartConnect(model.Architecture)
    conns = 1×6 Connector array with properties:
        SourcePort
        DestinationPort
        SourceElement
        DestinationElement
        Name
        Parent
        Ports
        Model
        SimulinkHandle
        SimulinkModelHandle
        UUID
        ExternalUID
    
    

    この例では、mPortNameAmbiguous.slx アーキテクチャ モデルで、診断の警告につながるコンポーネントを接続する方法を示します。

    model = systemcomposer.loadModel('mPortNameAmbiguous');
    [conns,diag] = smartConnect(model.Architecture);
    diag
    diag = 
      MSLException with properties:
    
           handles: {[0×1 double]}
        identifier: 'systemcomposer_operations:EditorOperationsImpl:ConnectorCreationFailed'
           message: 'Unable to create connector.'
             cause: {3×1 cell}
             stack: [8×1 struct]
        Correction: []
    
    
    diag.cause{1}
    ans = 
      MSLException with properties:
    
           handles: {[0×1 double]}
        identifier: 'systemcomposer_operations:EditorOperationsImpl:CreateConnectorPortInterfaceMismatch'
           message: 'Unable to connect input port 'mPortNameAmbiguous/Y/p5'. Multiple output ports with same name are available, but their interfaces do not match.'
             cause: {}
             stack: [8×1 struct]
        Correction: []
    
    
    diag.cause{2}
    ans = 
      MSLException with properties:
    
           handles: {[0×1 double]}
        identifier: 'systemcomposer_operations:EditorOperationsImpl:CreateConnectorPortInterfaceMismatch'
           message: 'Unable to connect input port 'mPortNameAmbiguous/Z/p2'. Multiple output ports with same name are available, but their interfaces do not match.'
             cause: {}
             stack: [8×1 struct]
        Correction: []
    
    
    diag.cause{3}
    ans = 
      MSLException with properties:
    
           handles: {[0×1 double]}
        identifier: 'systemcomposer_operations:EditorOperationsImpl:CreateConnectorPortInterfaceMismatch'
           message: 'Unable to connect input port 'mPortNameAmbiguous/Y/p1'. Multiple output ports with same name are available, but their interfaces do not match.'
             cause: {}
             stack: [8×1 struct]
        Correction: []
    
    

    入力引数

    すべて折りたたむ

    アーキテクチャ。systemcomposer.arch.Architecture オブジェクトとして指定します。

    カスタム接続ポリシー。systemcomposer.arch.SmartConnectPolicy オブジェクトとして指定します。カスタム ポリシーの作成の詳細については、Automatically Connect Ports Using Custom Policyを参照してください。

    出力引数

    すべて折りたたむ

    コネクタ。systemcomposer.arch.Connector オブジェクトまたは systemcomposer.arch.PhysicalConnector オブジェクトの配列として返されます。

    診断。MException オブジェクトとして返されます。詳細については、MSLException オブジェクトを使用した Simulink のエラー処理を参照してください。

    詳細

    すべて折りたたむ

    バージョン履歴

    R2025a で導入