Borrar filtros
Borrar filtros

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

1 visualización (últimos 30 días)
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.

Respuestas (1)

Donn Shull
Donn Shull el 7 de Ag. de 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

Categorías

Más información sobre 信号 en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!