Configure Measurement Service Interface for Persistent Data for States and Data Stores - MATLAB & Simulink (original) (raw)

Configuring a measurement service interface for persistent data results in state and data store data stored in nonvolatile memory that is managed externally by a memory management service in the target environment. The configuration described in this section supports synchronous or asynchronous memory. For more information about nonvolatile memory interface configuration options, see Nonvolatile Memory Interfaces.

To configure a measurement service interface used with nonvolatile memory, the service configuration must enable the persistent data option and specify a storage class that does not initialize the data. Measurement service interfaces and storage classes are defined in a shared Embedded Coder Dictionary. Use the Code Mappings editor to configure the measurement service interface for specific states and data stores.

Configure Measurement Service Interfaces for Persistent Data for States and Data Stores by Using the Code Mappings Editor

In this example, the component model references the shared coder dictionary ComponentServiceCoderDictionary that is configured to support persistent memory. To configure the model to use this service interface, use theCode Mappings editor.

Open the component model,ComponentServiceWithPersistency.

openExample('ComponentServiceWithPersistency');

Screenshot of component model

In this model, the Unit Delay block within theAccumulator Function-Call Subsystem, and the Discrete-Time Integrator block within the Integrator Function-Call Subsystem each have a state. Per a requirement for the system, the state of the unit delay and discrete-time integrator must be stored in persistent memory.

Verify that the component model references the shared coder dictionary,ComponentServiceCoderDictionary.sldd.

In the Model Configuration Parameters dialog box, verify that the Shared coder dictionary parameter is set toComponentServiceCoderDictionary.sldd. Shared coder dictionaries define service interfaces of the component model. For this shared dictionary, measurement service interfaces include Not measured (the default),MeasurementService, and PermanentRAM, a measurement service interface configured to use persistent data.

Embedded Coder Dictionary showing measurement service interfaces.

Open the Embedded Coder app.

To configure the block states to use a measurement service interface for persistent data other than the default defined by the shared coder dictionary, use the Code Mappings editor.

To open the Code Mappings editor, in the C Code tab, click > .

On the Signals/States tab, set the Measurement Service of the two block states toPermanentRAM.

Measurement service for Discrete-Time Integrator and Unit Delay blocks state configured to 'PermanentRAM' in Code Mappings editor

In the dialog box that appears if you click the pencil icon or in the Property Inspector, you can specify the identifier that the code generator uses to represent the state or data store in the generated code.

If using nonvolatile memory is not a requirement, you could configure the block states to use the measurement service interface Not measured, which does not preserve state variables in the generated code, orMeasurementService, which does preserve the state variables. Alternatively, you could create a new measurement service interface in the dictionary, and reference an existing or new storage class in the new measurement service interface definition.

For more information, see Define Service Interfaces, Storage Classes, Memory Sections, and Function Templates for Software Architecture.

Configure Measurement Service Interfaces for Persistent Memory for States and Data Stores Programmatically

To configure the measurement service interface of a state or data store using persistent memory programmatically, access the code mapping properties of the component model using thecoder.mapping.api.get function.

Open the model.

openExample('ComponentServiceWithPersistency');

Get the code mappings for the model by using thecoder.mapping.api.get function.

cm = coder.mapping.api.get('ComponentServiceWithPersistency');

In this model, the Unit Delay block within theAccumulator Function-Call Subsystem, and the Discrete-Time Integrator block within the Integrator Function-Call Subsystem each have an associated state. Get the current measurement service interface configuration by using the getState function.

getState(cm, ... 'ComponentServiceWithPersistency'/Integrator/Discrete-Time Integrator',... 'MeasurementService')

The block state is configured to use the measurement service interface PermanentRAM defined in the shared coder dictionary.

To specify that a state or data store does not require a measurement service interface, set the measurement service interface to 'Not measured'.

setState(cm,... 'ComponentDeploymentFcn/Integrator/Discrete-Time Integrator',... 'MeasurementService', 'Not measured')

See Also

getState | setState | getDataStore | setDataStore

Topics