MATLAB Answers

Is possible to configure the "Data source" of a parameter in Data Dictionary to another file?

조회 수: 7(최근 30일)
Song Decn
Song Decn 29 May 2017
답변: Donn Shull 7 Aug 2017
Hi, I want to put all commom parameters of my different models into a single shared data dictionary. I can see there is a option "Data Source" with "xxxx.sldd" for each parameter, but I can't specify a specific file except the file which holds the parameter.
So is this possible? Thx.

  댓글 수: 0

댓글을 달려면 로그인하십시오.

답변(1개)

Donn Shull
Donn Shull 7 Aug 2017
You can not change the 'Data Source' for an item directly. Here is an example of how to achieve that result using reference dictionaries. In this example VehicleDictionary.sldd is a container dictionary with with no data items of its own. TransmissionDictionary.sldd, EngineDictionary.sldd, and CommonDictionary.sldd are 'DataSource' dictionaries for VehicleDictionary.sldd. TransmissionDictionary.sldd and EngineDictionary.sldd both contain VehicleSpeed. In this example the Engine Version of Vehicle Speed is copied to the CommonDictionary.sldd and then VehicleSpeed is deleted from the Engind and Transmission dictionaries. The effectively changes the VehicleSpeed 'Data Source' to CommonDictionary.sldd.
% first create the individual data dictionaries
vehicleSldd = Simulink.data.dictionary.create('VehicleDictionary.sldd');
transmissionSldd = Simulink.data.dictionary.create('TransmissionDictionary.sldd');
engineSldd = Simulink.data.dictionary.create('EngineDictionary.sldd');
commonSldd = Simulink.data.dictionary.create('CommonDictionary.sldd');
% add some data to the transmission dictionary
transDataSection = transmissionSldd.getSection('Global');
transDataSection.addEntry('VehicleSpeed', Simulink.Signal);
transDataSection.addEntry('FirstSecondShiftPoint', Simulink.Parameter);
% add some data to the engine dictionary with a duplication from transmission
engDataSection = engineSldd.getSection('Global');
engDataSection.addEntry('VehicleSpeed', Simulink.Signal);
engDataSection.addEntry('MassAirFlow', Simulink.Signal);
% create the composite dictionary
vehicleSldd.addDataSource('TransmissionDictionary.sldd');
vehicleSldd.addDataSource('EngineDictionary.sldd');
vehicleSldd.addDataSource('CommonDictionary.sldd');
% show the referenced dictionaries
vehicleSldd.DataSources
ans =
3×1 cell array
'CommonDictionary.sldd'
'EngineDictionary.sldd'
'TransmissionDictionary.sldd'
% show the design items including the duplications
vehicleSldd.listEntry;
Section Name Status DataSource LastModified LastModifiedBy Class
Design Data FirstSecondShiftPoint new TransmissionDictionary.sldd 2017-08-07 13:52 Donn Simulink.Parameter
Design Data MassAirFlow new EngineDictionary.sldd 2017-08-07 13:55 Donn Simulink.Signal
Design Data VehicleSpeed new TransmissionDictionary.sldd 2017-08-07 13:52 Donn Simulink.Signal
Design Data VehicleSpeed new EngineDictionary.sldd 2017-08-07 13:55 Donn Simulink.Signal
% copy the engine VehicleSpeed to the common dictionary
commonDataSection = commonSldd.getSection('Global');
commonDataSection.addEntry('VehicleSpeed', engDataSection.getEntry('VehicleSpeed').getValue);
% show the design items including the duplications
vehicleSldd.listEntry;
Section Name Status DataSource LastModified LastModifiedBy Class
Design Data FirstSecondShiftPoint new TransmissionDictionary.sldd 2017-08-07 13:52 Donn Simulink.Parameter
Design Data MassAirFlow new EngineDictionary.sldd 2017-08-07 13:55 Donn Simulink.Signal
Design Data VehicleSpeed new TransmissionDictionary.sldd 2017-08-07 13:52 Donn Simulink.Signal
Design Data VehicleSpeed new EngineDictionary.sldd 2017-08-07 13:55 Donn Simulink.Signal
Design Data VehicleSpeed new CommonDictionary.sldd 2017-08-07 14:01 Donn Simulink.Signal
% remove vehicle speed from the engine and transmission dictionaries
engDataSection.deleteEntry('VehicleSpeed');
transDataSection.deleteEntry('VehicleSpeed');
% show the design items including the duplications
vehicleSldd.listEntry;
Section Name Status DataSource LastModified LastModifiedBy Class
Design Data FirstSecondShiftPoint new TransmissionDictionary.sldd 2017-08-07 13:52 Donn Simulink.Parameter
Design Data MassAirFlow new EngineDictionary.sldd 2017-08-07 13:55 Donn Simulink.Signal
Design Data VehicleSpeed new CommonDictionary.sldd 2017-08-07 14:01 Donn Simulink.Signal

  댓글 수: 0

댓글을 달려면 로그인하십시오.

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!