主要内容

異なるフォルダ,間で複数のモデルのクロ,ンをプログラムで検出

この例では,プログラムを使用して,異なるフォルダーに配置された複数のモデルのクローンを検出する方法を説明します。クロン検出APIの詳細にいては,プログラムによるサブシステムクロ,ンの検出と置換を参照してください。

この例では,クローン検出APIを使用し,フォルダー内に存在する6つの仿真软件®金宝appモデル内のクローンを特定する方法を示します。クロ,ンの置換はこのワ,クフロ,例を使用しても実行できません。プログラムにより複数のモデルのクロ,ンを置換するには,プログラムにより複数のモデルのクロ,ン検出と置換をル,プで実行を参照してください。

1.Matlab®コマンドラ▪▪ンで,次のように入力します。

addpath(fullfile(docroot,'toolbox','金宝appsimulink','examples')) ex_clone_detection_A ex_clone_detection_B ex_clone_detection_C ex_clone_detection_D ex_clone_detection_E ex_clone_detection_F

書き込み可能なフォルダ,にモデルを保存します。

2.金宝appSimulink.CloneDetection.Settingsクラスを使用してオブジェクトを作成します。

cloneDetectionSettings = 金宝appSimulink.CloneDetection.Settings();

3.cloneDetectionSettingsオブジェクトにモデルを含むフォルダ,のパスを追加します。

cloneDetectionSettings。文件夹= {“D: \模型”
cloneDetectionSettings =带有属性的设置:IgnoreSignalName: 0 IgnoreBlockProperty: 0 ExcludeModelReferences: 0 ExcludeLibraryLinks: 0 ParamDifferenceThreshold: 50 ReplaceExactClonesWithSubsystemReference: 0 Libraries: {} Folders: {'D:\models'} DetectClonesAcrossModel: 0 ExcludeInactiveRegions: 0 FindClonesRecursivelyInFolders: 1

4.クロンを検出するには,cloneDetectionSettingsオブジェクトを使用して関数金宝appSimulink.CloneDetection.findClonesを実行します。

克隆结果= simulink 金宝app. clonedetection . find克隆(cloneDetectionSettings)
克隆结果:[1×1 struct] ExceptionLog: {}

cloneResultsは2のプロパティ克隆ExceptionLogをも金宝appSimulink.CloneDetection.Resultsクラスのオブジェクトです。

5.克隆。总结フィ,ルドを表示します。

cloneResults.Clones.Summary
ans = struct with fields: CloneGroups: 4 similar克隆:18 exact克隆:8克隆:26 PotentialReusePercentage: [1×1 struct]

この例では,モデルには,サブシステムのパターンが一致する4つの異なるクローングループ(18個の類似クローン,8個の厳密クローン,および26個のサブシステムクローン)があります。

5.最初のクロ,ングル,プの詳細を表示します。

cloneResults.Clones.CloneGroups (1)
ans = struct with fields:名称:'精确克隆组1'摘要:[1×1 struct] CloneList: {5×1 cell}

6.最初のクロ,ングル,プの概要を表示します。

cloneResults.Clones.CloneGroups (1) .Summary
ans = struct with fields: ParameterDifferences: [1×1 struct]克隆:5 BlocksPerClone: 5 CloneType: 'Exact' BlockDifference: 0

7.最初のクロ,ングル,プのクロ,ンリストを表示します。

cloneResults.Clones.CloneGroups (1) .CloneList
ans = 5×1单元阵列{'ex_clone_detection_A/子系统'}{'ex_clone_detection_B/子系统'}{'ex_clone_detection_C/子系统'}{'ex_clone_detection_D/子系统'}{'ex_clone_detection_F/子系统'}

同様に,上記の手順を使用して他のクロ,ングル,プの結果を確認できます。

関連するトピック