主要内容

本页采用了机器翻译。点击此处可查看最新英文版本。

systemcomposer.query.Constraint

查询约束

    说明

    Constraint 对象表示所有 System Composer™ 查询约束。

    对象函数

    AnyComponent创建查询以选择模型中的所有组件
    IsStereotypeDerivedFrom创建查询,从限定名称中选择构造型
    HasStereotype创建查询,根据指定的子约束条件选择具有构造型的架构元素
    HasPort创建查询,根据指定的子约束条件选择带端口的架构元素
    HasConnector创建查询,根据指定的子约束条件选择带有连接器的架构元素
    HasInterface创建查询,根据指定的子约束条件选择端口上有接口的架构元素
    HasInterfaceElement创建查询,以便根据指定的子约束条件,在接口上选择带有接口元素的架构元素
    IsInRange创建查询以选择属性值范围
    Property创建查询,为对象属性或元素构造型属性选择未计算值
    PropertyValue创建查询,从对象或构造型属性中选择属性,然后计算属性值

    示例

    全部折叠

    使用查询在 System Composer 模型中查找组件。

    导入包含所有 System Composer 查询的命名空间。

    import systemcomposer.query.*

    打开模型。

    openProject("scKeylessEntrySystem");
    model = systemcomposer.loadModel("KeylessEntryArchitecture");

    查找系统中的所有软件组件。

    con1 = HasStereotype(Property("Name") == "SoftwareComponent");
    [compPaths,compObjs] = model.find(con1)
    compPaths = 5×1 cell
        {'KeylessEntryArchitecture/Door Lock//Unlock System/Door Lock Controller' }
        {'KeylessEntryArchitecture/Sound System/Sound Controller'                 }
        {'KeylessEntryArchitecture/Engine Control System/Keyless Start Controller'}
        {'KeylessEntryArchitecture/Lighting System/Lighting Controller'           }
        {'KeylessEntryArchitecture/FOB Locater System/FOB Locater Module'         }
    
    
    compObjs=1×5 Component array with properties:
        IsAdapterComponent
        Architecture
        ReferenceName
        Name
        Parent
        Ports
        OwnedPorts
        OwnedArchitecture
        Parameters
        Position
        Model
        SimulinkHandle
        SimulinkModelHandle
        UUID
        ExternalUID
    
    

    在搜索中包括引用模型。

    softwareComps = model.find(con1,IncludeReferenceModels=true)
    softwareComps = 9×1 cell
        {'KeylessEntryArchitecture/Door Lock//Unlock System/Door Lock Controller'                                 }
        {'KeylessEntryArchitecture/Sound System/Sound Controller'                                                 }
        {'KeylessEntryArchitecture/Engine Control System/Keyless Start Controller'                                }
        {'KeylessEntryArchitecture/Lighting System/Lighting Controller'                                           }
        {'KeylessEntryArchitecture/FOB Locater System/FOB Locater Module'                                         }
        {'KeylessEntryArchitecture/Door Lock//Unlock System/Front Driver Door Lock Sensor/Detect Door Lock Status'}
        {'KeylessEntryArchitecture/Door Lock//Unlock System/Rear Driver Door Lock Sensor/Detect Door Lock Status' }
        {'KeylessEntryArchitecture/Door Lock//Unlock System/Front Pass Door Lock Sensor/Detect Door Lock Status'  }
        {'KeylessEntryArchitecture/Door Lock//Unlock System/Rear Pass Door Lock Sensor/Detect Door Lock Status'   }
    
    

    查找系统中的所有基本组件。

    con2 = HasStereotype(IsStereotypeDerivedFrom("AutoProfile.BaseComponent"));
    baseComps = model.find(con2)
    baseComps = 18×1 cell
        {'KeylessEntryArchitecture/Door Lock//Unlock System/Door Lock Controller'           }
        {'KeylessEntryArchitecture/Sound System/Sound Controller'                           }
        {'KeylessEntryArchitecture/Engine Control System/Keyless Start Controller'          }
        {'KeylessEntryArchitecture/Lighting System/Lighting Controller'                     }
        {'KeylessEntryArchitecture/FOB Locater System/FOB Locater Module'                   }
        {'KeylessEntryArchitecture/Door Lock//Unlock System/Front Pass Door Lock Sensor'    }
        {'KeylessEntryArchitecture/FOB Locater System/Front Receiver'                       }
        {'KeylessEntryArchitecture/Sound System/Dashboard Speaker'                          }
        {'KeylessEntryArchitecture/Door Lock//Unlock System/Rear Pass Door Lock Sensor'     }
        {'KeylessEntryArchitecture/Door Lock//Unlock System/Front Driver Door Lock Actuator'}
        {'KeylessEntryArchitecture/Door Lock//Unlock System/Front Pass Door Lock Actuator'  }
        {'KeylessEntryArchitecture/Door Lock//Unlock System/Rear Driver Door Lock Sensor'   }
        {'KeylessEntryArchitecture/Door Lock//Unlock System/Rear Driver Door Lock Actuator' }
        {'KeylessEntryArchitecture/FOB Locater System/Rear Receiver'                        }
        {'KeylessEntryArchitecture/FOB Locater System/Center Receiver'                      }
        {'KeylessEntryArchitecture/Door Lock//Unlock System/Front Driver Door Lock Sensor'  }
        {'KeylessEntryArchitecture/Door Lock//Unlock System/Rear Pass Door Lock Actuator'   }
        {'KeylessEntryArchitecture/Engine Control System/Start//Stop Button'                }
    
    

    查找使用接口 KeyFOBPosition 的所有组件。

    con3 = HasPort(HasInterface(Property("Name") == "KeyFOBPosition"));
    con3_a = HasPort(Property("InterfaceName") == "KeyFOBPosition");
    keyFOBPosComps = model.find(con3)
    keyFOBPosComps = 10×1 cell
        {'KeylessEntryArchitecture/Door Lock//Unlock System/Door Lock Controller' }
        {'KeylessEntryArchitecture/Sound System/Sound Controller'                 }
        {'KeylessEntryArchitecture/Engine Control System/Keyless Start Controller'}
        {'KeylessEntryArchitecture/Lighting System/Lighting Controller'           }
        {'KeylessEntryArchitecture/FOB Locater System/FOB Locater Module'         }
        {'KeylessEntryArchitecture/FOB Locater System'                            }
        {'KeylessEntryArchitecture/Door Lock//Unlock System'                      }
        {'KeylessEntryArchitecture/Lighting System'                               }
        {'KeylessEntryArchitecture/Engine Control System'                         }
        {'KeylessEntryArchitecture/Sound System'                                  }
    
    

    查找 WCET 小于或等于 5 ms 的所有组件。

    con4 = PropertyValue("AutoProfile.SoftwareComponent.WCET") <= 5;
    model.find(con4)
    ans = 1×1 cell array
        {'KeylessEntryArchitecture/Sound System/Sound Controller'}
    
    

    您可以为自动单位转换指定单位。

    con5 = PropertyValue("AutoProfile.SoftwareComponent.WCET") <= Value(5,'ms');
    query1Comps = model.find(con5)
    query1Comps = 3×1 cell
        {'KeylessEntryArchitecture/Sound System/Sound Controller'        }
        {'KeylessEntryArchitecture/Lighting System/Lighting Controller'  }
        {'KeylessEntryArchitecture/FOB Locater System/FOB Locater Module'}
    
    

    查找所有 WCET 大于 1 ms 或成本大于 10 USD 的组件。

    con6 = PropertyValue("AutoProfile.SoftwareComponent.WCET") > Value(1,'ms') | PropertyValue("AutoProfile.Base.Cost") > Value(10,'USD');
    query2Comps = model.find(con6)
    query2Comps = 2×1 cell
        {'KeylessEntryArchitecture/Door Lock//Unlock System/Door Lock Controller' }
        {'KeylessEntryArchitecture/Engine Control System/Keyless Start Controller'}
    
    

    详细信息

    全部展开

    版本历史记录

    在 R2019b 中推出