Video length is 7:43

Manage Projects Using Automation and Source Control | New Ways to Work in Simulink, Part 8

From the series: New Ways to Work in Simulink

Manage project development and collaborate with your team by automating tasks, processes, and file management. You’ll learn how to componentize projects, organize files, analyze their dependencies, compare changes, and perform common operations through automation and integration with source control.

Published: 30 Aug 2020

In this video, let's talk about new capabilities for you to manage projects. Projects allow you to manage complexity by helping you organize, manage, and share your code and models with a single environment and interface that works with both Matlab and Simulink. So let's go around this hexagon.

You can create a new project from the Matlab tool strip and also from the Simulink Start page. It's easy for you to create a new blank project or a project from an existing folder or get a subversion repository. But if you have an existing folder locally, you can wrap it in a project with just a few clicks, and your files will be automatically added for you.

You may be thinking, why would I want to do that? Well, let's see a few reasons. When you work in projects, you don't have to worry about setting up the environment before you open or run your models. You simply open the project, and the Matlab path is automatically set, startup and shutdown scripts that you specify run automatically so all your data and utilities are loaded, the tool checks for shadowed models.

You can also configure the project to set model templates and team preferences like certain utilities. And you get shortcuts in the Project tab to Common Tasks. It can be for the top level model, scripts, data, documentation, and so on. If you're sharing your work with others, these shortcuts make things easy to find for everyone.

Another advantage of having all your files in a project is you can run batch operations on them. That means that if you make a change or check a task in multiple files, you don't have to do it one by one. You simply write some Matlab code and run custom tasks on multiple files at the same time.

Some examples include running the Matlab Code Checker on all m and mlx files or positioning all Simulink models so that they fit on the computer screen. All you do is go to Custom Tasks, select all the files you want to operate on, and specify the function you want to run on all those files. So that's another way that projects help you be more efficient.

Now let's talk about automation. You don't have to write Matlab code to add and remove folders and files from the Matlab path. You simply specify that once in the Project settings, and you don't worry about it again. Things are there for you when you open the project. And the path is cleaned up when you close a project.

If you have worked on the wrong file before, because maybe you had two models with the same name and you didn't realize that you picked the wrong one, then projects can help you avoid that because it runs this check when you start the project. And it gives you warnings when you have shadow files. Working on the wrong file can be costly, so we definitely want to help you avoid that.

Another costly issue is loosing work because of unsaved changes. Maybe you have dozens of files open, then you close Matlab. You quickly click through all the prompts, and then the next day you realized that you didn't save the changes for the one file that mattered.

If this hasn't happened to you, good. Don't wait for it to happen. Projects help you see all the files with unsaved changes. And you see them grouped by project, and that also includes project references. That way, you can easily save or discard changes for individual files or for everything in your project.

Perhaps one of the most helpful capabilities in projects is the ability to visualize and understand all the dependencies between files and the impact of changes that you make, especially if you're working with hundreds of files. So if you have a large project like this one, you can do a dependency analysis. And when that is done, what you see is the relationship and dependencies for all the files in your project. So it gives you an idea of that model structure.

It shows you a list of required products. And it also reports issues with missing files and things like that. When you make changes to a file like renaming it, then the tool shows you all the other files that depend on that one file that you're changing. And it helps you update them with just one click. So you can make the changes and move on.

The opposite would be to not use projects, then change a file without knowing that you're affecting other files. And then when you run something, you have to manually jump between four different models to fix the issue. This gives you a way to mistake proof the file rename process and be more efficient.

This is very useful if you're working with library links, model references, subsystem references, and model callbacks. Here is the rename process in action. If I rename this file, it gives me the warning that I'm affecting other files. And it shows me all those dependencies. And I have the option to rename and update all of those files with just one click.

Projects also help you with renaming buses and bus elements. You've probably run into this. You change the signal name in a bus, and then you break 10 different models and model references. And then once again, you're jumping between 10 different files updating the bus manually. So projects are one way to avoid that and just do it automatically.

When you make all these changes we've been talking about, you may need to maintain historical snapshots of all your artifacts and easily return to a previous state. That's what source control allows you to do. Projects give you source control integration, so you can track changes that are being made to your code and models, as well as who was responsible for those changes.

This makes it easier for multiple people to work on the same code base. Projects have interfaces to both git and subversion. And here, you can see an example of a project with a git status indicator in the File view. And you can pull, push, and fetch files, as well as commit changes directly from the tool strip.

By doing version control with projects, you simplify the comparison and merge workflow. You have a three-way merge available to you. And that's great to identify differences between model elements, state flowcharts, and Matlab function blocks. And you can use Model Comparison also to review and merge changes in models, also to show the changes in the original models and to filter and save comparison results.

In addition to source control integration, projects give you a way to componentize your development with project references. That means you can have projects that work with other projects. And the goal is to help you componentized the development. So you can explore the full project reference hierarchy and the associated files directly from your project. You can view all references in a hierarchy. And you can view all the files and modifications for a specific reference.

Finally, projects help you with the upgrade process. So it's easier to update all the models in your project to the latest release. You don't have to go through the manual process of upgrading one model at a time. The project automatically runs code compatibility checks for Matlab and Simulink files. It applies fixes automatically if you choose to, of course. And it generates a report for you. That is projects for working in Matlab and Simulink. See you in the next video.