MATLAB: How to programmatically add an AUTOSAR Event or Runnable

addanautosarautosar.api.getautosarpropertiesEmbedded Codereventprogrammaticallyrunnablesimulink

I am using the bottom-up workflow working with AUTOSAR and my model. I know how to add an AUTOSAR runnable using the Configure AUTOSAR Interface UI, but I would like to do this using the Command Line instead. Is this possible?

Best Answer

Yes, the workflow is set around the 'autosar.api.getAUTOSARProperties' function. This method allows you to access all the features from the command line. Please refer to the link below for detailed documentation:
Basically, in order to add an event, you can use the following workflow:
  1. Open the model.
  2. Use the API to get the AUTOSAR Properties.
  3. Add a runnable.
  4. Add an event.
(It is possible to skip step 3, and add the event to an already-existing runnable)
This workflow is explained below with the help of the example model 'autosar_swc':
>> myModel = 'autosar_swc';
>> open_system(myModel);
>> autosar.api.create(myModel , 'default');
>> myProps= autosar.api.getAUTOSARProperties(myModel );
>> add(myProps,[myModel '/Behavior/'],'Runnables','myRunnable');
>> add(myProps,[myModel '/Behavior/'],'Events','testEvent','Category', 'TimingEvent','StartOnEvent','autosar_swc/Behavior/myRunnable');
After that, just use Ctrl+Shift+C, and click on the dictionary button to see the added event, as seen in the screenshot below: