How to programmaticaly set storage class (2020a) in Data Store Memory ?

9 Ansichten (letzte 30 Tage)
Jean Matthieu
Jean Matthieu am 3 Aug. 2021
Kommentiert: Fangjun Jiang am 3 Aug. 2021
Hi, I use Matlab 2020a.
I have hundreds of Data Store Memory Block that i generate on the Simulink model from an external file (Excel).
I've got a custom package ('mypackage') and a custom storage class within this package ('DataStore').
It works when i do it manualy.
What i want to do is setting by command line the package 'mypackage' with my storage class 'DataStore' into my data store memory block. It works when i do it manualy. To do that, i tried:
1) set(DSM_Block, 'StateSignalObject', mypackage.Signal)
--> It gives back:
"Invalid input for argument 1 (rhs1):
Value must be 'matlab.mixin.SetGet'.
Error in Simulink.DataObject/set"
2) a=get(DSM_Block_with_good_package, 'StateSignalObject')
set(DSM_Block, 'StateSignalObject', a)
--> It gives back:
"Invalid input for argument 1 (rhs1):
Value must be 'matlab.mixin.SetGet'.
Error in Simulink.DataObject/set"
And if i only write "set(DSM_Block,'StateStorageClass', 'DataStore');",
--> it gives back
"Invalid setting in DataStoreMemory block 'My_Bus' for parameter 'StateStorageClass'
Caused by:
'DataStore' is not a valid storage class"
Can you please help me ?

Antworten (1)

Fangjun Jiang
Fangjun Jiang am 3 Aug. 2021
if "DSM_Block" is a block handle, you can use get/set
if "DSM_Block" is a block path, use set_param/get_param
  2 Kommentare
Jean Matthieu
Jean Matthieu am 3 Aug. 2021
That's exactly what i do, but as the question's decriptor says, it doesn't work. It specificaly does not work with 'StateSignalObject' because of the errors mentionned in the description.
Fangjun Jiang
Fangjun Jiang am 3 Aug. 2021
I tried it in R2020a. It seemed that way. It might have some dependency but hard to experiment.
I usually do it in a different way. You have hundres of DSM blocks. Each must have a unique data store name (the default is "A", for example). You need to create a signal object in base workspace or data dictionary
A=mpt.Signal and then set whatever property/value pair.
In the block, check "Data store name must resolve to Simulink signal object" option
command line is set_param(BlockPath,'StateMustResolveToSignalObject','On')
This way, the properties that you want to set are all linked to that sigal object.
This is a better way to manage the DSM blocks.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Programmatic Model Editing finden Sie in Help Center und File Exchange

Produkte


Version

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by